Commit Graph

406 Commits (objectmenu)

Author SHA1 Message Date
Maikel de Vries 4bcdfc451e block construction sites based on Exclusive and not on planes (#1534)
This makes more sense, exclusive object block all other construction sites, irrespective of their planes.
2016-01-30 14:46:14 +01:00
Sven Eberhardt 80b8879805 Fix SolidMask DensityProvider to return C4M_Vehicle, not C4M_Solid.
Fixes attached movement of objects with increased contact density.
2016-01-28 22:00:41 -05:00
Sven Eberhardt 36489145b6 Fix automatic engine detection of melee-like scenarios to allow team selection. 2016-01-24 22:13:21 -05:00
Sven Eberhardt 451ea87ab9 Fix another FoW crash 2016-01-24 17:23:20 -05:00
Sven Eberhardt 42d8885877 Fix crash in FoW rendering #1643 2016-01-24 14:44:00 -05:00
Günther Brammer d0d27d25f1 Merge script branch 2016-01-24 12:25:52 +01:00
Sven Eberhardt e94c0e38fc Add scenario core field "Mode" (in [Game]) to allow setting game mode independent of goal objects.
To be used by the league so you can properly host race scenarios in the open melee league.
2016-01-23 21:19:22 -05:00
Sven Eberhardt df6d349166 Add safety to light object creation. 2016-01-23 21:09:12 -05:00
Günther Brammer a5f797f96b Move miscellaneous global functions from C4Effect.cpp to their users 2016-01-24 02:09:14 +01:00
Günther Brammer fd61ac7ebe Remove unused IsRenderTarget and MaxTextureSize C4Surface options
They were always false and 0.
2016-01-17 11:37:17 -08:00
Armin Burgmeier d7d24ca36a Enable OGL core profile for linux 2016-01-17 11:37:17 -08:00
Armin Burgmeier e13cda4bd0 Use an IBO for the particle system
glDrawElements needs an IBO when using a core profile. The particle
system's IBO is actually quite static since it's always a triangle
strip with 2 triangles followed by a PRI. Therefore, this reduces the
amount of data we have to send to the GPU compared to the previous
solution.

Also, remove the workaround when glPrimitiveRestartIndex is not
available since it is always available with OpenGL 3.1 and when using
a core profile we are guaranteed to have OpenGL 3.1 anyway.
2016-01-17 11:37:17 -08:00
Armin Burgmeier 686a32764c Use an IBO to render the FoW 2016-01-17 11:37:17 -08:00
Armin Burgmeier aef7538aa1 Switch shader code to OpenGL 3 style 2016-01-17 11:37:17 -08:00
Armin Burgmeier 2c2c3f98c8 Switch framebuffer API to OpenGL core API 2016-01-17 11:37:17 -08:00
Armin Burgmeier 5de1bc70a9 Remove a stray glClientActiveTexture call 2016-01-17 11:37:17 -08:00
Armin Burgmeier 28aa1d1812 For each VBO, use a VAO to render it
For OpenGL 3.2 core compatibility, and to reduce the number of state
changes during rendering.
2016-01-17 11:37:17 -08:00
Armin Burgmeier fa9f4c6356 Replace GL_GENERATE_MIPMAP flag by glGenerateMipmap call
The former is not available in a OpenGL 3 core profile, but glGenerateMipmap
is available since OpenGL 3.0, and so is always available when we have a
core profile.
2016-01-17 11:37:17 -08:00
Armin Burgmeier bb8b933417 Revert "Revert "Replace 3D texture in landscape shader by a 2D texture array""
This reverts commit 4a02d3c77b.

This was merged into master even though I only wanted it in stable-7.0.
Oh well, let's just revert it again.
2016-01-17 11:37:17 -08:00
Sven Eberhardt 4eddeba9aa Fix crash when drawing zero-sized viewports (may happen during editor viewport initialization) 2016-01-15 08:53:00 -05:00
Sven Eberhardt cd63c06aaf Fix crash when starting tabbed out. 2016-01-14 22:25:45 -05:00
Günther Brammer 9b7b4bf30a Remove unused variable in C4Landscape::DrawBrush
This was forgotten in 47e422f452.
2016-01-11 01:50:34 +01:00
David Dormagen 1c35bdf8e3 particles: fix high severity OpenGL API error
glObjectLabel would result in invalid VBOs if called on a not-instantiated object. glGenBuffers does apparently only reserve the name and not create the buffer itself.
For me the landscape and some objects were drawn completely black.

More information: http://stackoverflow.com/questions/26614130/opengl-debug-extension-with-globjectlabel
Found via --debug-opengl
which lead to
gl: high severity API error: GL_INVALID_VALUE error generated. ObjectLabel: unknown buffer object <name>
2016-01-10 23:31:17 +01:00
Clonkonaut 962b178663 Merge remote-tracking branch 'remotes/origin/revert-opengl-2.1' 2016-01-10 17:27:56 +01:00
Sven Eberhardt 8552b3a8f9 Change return value of InsertMaterial when inserting outside landscape bounds #1509
Fixes clogged pump when pumping outside map.
2016-01-08 01:05:22 -04:00
David Dormagen e3553ca0cd particles: replaced "TODO" comment
This was actually part of a larger performance boosting commit, which turned out to not actually boost performance. But I want to retain the comment change even when I won't push the larger commit.
Having a "todo" comment is just misleading.

For an explanation of why that's needed, see http://stackoverflow.com/questions/21652546/what-is-the-role-of-glbindvertexarrays-vs-glbindbuffer-and-what-is-their-relatio
2016-01-07 09:55:35 +01:00
Armin Burgmeier 5ecb393c71 Fix FoW flicker when resizing the FoW texture
We do this by copying the contents of the old texture when resizing it.
2016-01-05 20:23:15 -08:00
Armin Burgmeier 4a02d3c77b Revert "Replace 3D texture in landscape shader by a 2D texture array"
This reverts commit 790219ac7e.

This commit broke support for Mac OS X since Apple only supports OpenGL 3.0
with a core profile, not a compatibility profile. Revert this commit
temporarily for the 7.0 release, until we port all OpenGL usage to the core
profile with 8.0.

This fixes #1495.
2016-01-04 18:27:44 -08:00
Armin Burgmeier d72b8cc385 Use generic vertex attributes for FoW rendering 2016-01-02 19:11:41 -08:00
Armin Burgmeier 96c8b51eac Use generic vertex attributes for landscape rendering 2016-01-02 17:20:24 -08:00
Armin Burgmeier 95774e0e8f Use generic vertex attributes for sprites, meshes, particles 2016-01-02 13:10:03 -08:00
David Dormagen a0dddce691 C4FoWDrawLightTextureStrategy: do not crash when nothing to draw
This would crash for me when starting a game in developer's mode. Not sure if this is the best place for the fix. Maybe there is some other underlying issue. ck?
2016-01-02 13:03:44 +01:00
Armin Burgmeier b80a7ebb01 Use VBOs to render the FoW texture
In doing so, refactor the way C4FoWDrawStrategy works slightly. Get rid of
immediate mode OpenGL, and instead populate a vertex array and an index array
as vertices are added to the draw strategy. Then render everything as
triangles.

The actual rendering is then performed in C4DrawStrategy::End(). It passes
the accumulated vertices to the GL. Also get rid of the notion of multiple
passes in C4DrawStrategy. Instead, C4DrawStrategy::End() can simply just draw
the bunch of vertices multiple times. This allows us to do the vertex
generation and GPU upload only once, instead of repeating it for every pass.
2016-01-01 22:28:22 -08:00
Armin Burgmeier f582ea9f24 fow: persist draw strategies between light renderings
This allows the strategy to keep some state between invocations. I want to
use this in order to store a VBO in the draw strategy, and to avoid having
to re-create the VBO for every rendering.
2016-01-01 22:28:22 -08:00
Armin Burgmeier ecdcf5ac92 fow: Use a VBO to blit the framebuffer 2016-01-01 22:28:22 -08:00
Armin Burgmeier 1f4dbcc260 Particle system: make sure to always use a VBO
We are already using VBOs for meshes, so we can rely on them being available.
VBOs are shared between contexts, so #1195 is not an issue, either. However,
keep the workaround in place for the VAO, which is not shared between
contexts.
2016-01-01 22:28:22 -08:00
Armin Burgmeier b407558d7a Use a VBO to render the landscape 2016-01-01 22:28:22 -08:00
Armin Burgmeier c0844c10ff Add support for generic attributes to C4Shader
Replace the hardcoded VAI_ constants with that. The VAI constants are now
moved to C4DrawGL as C4SSA_ constants, similar to the C4SSU ones. This allows
to introduce other attributes to replace vertex positions, normals, colors
and texture coordinates with attributes in later commits. This, in turn, is
needed because the built-in attributes are no longer available in the OpenGL
core profile.

Also, while at it, cleanup C4Shader a bit. Use std::vector<> instead of
maintaining an own array of uniform names. Delete the vertex and fragment
objects after the full shader program has been linked. Make sure that
C4Shader::Init keeps the old program in place if the new one cannot be
compiled or linked.
2015-12-31 22:28:23 -08:00
Armin Burgmeier c043795552 Fix memory leak in FoW surfaces
Surfaces are initially created in locked state, and only when unlocked the
memory buffer with the surface data is uploaded to the GPU. The FoW code
however never unlocks the surface but instead operates on the OpenGL texture
directly. To fix this, introduce a new flag for C4Surface to create it in an
unlocked state.

This is not a memory leak in the traditional sense as a pointer to the buffer
is still available and is being freed when the surface is being destructed
at the end of the game. However, during the game there might be several
megabytes allocated that are never used.

I'm not really sold by this Lock/Unlock mechanism. Instead, there should
simply be a function to obtain the current texture data, and a function to
upload new texture data. That's for another time though...
2015-12-31 18:40:38 -08:00
Armin Burgmeier 8766f5123b Remove other usages of built-in GL matrices
Primarily for the FoW rendering, which now also uses (simple) shaders
without ftransform() everywhere. This also removes all GLU calls.
2015-12-31 17:30:21 -08:00
Nicolas Hake 90293d019d C4FoWRegion: Make more private
Code outside of C4FoWRegion should not care about the internals of the
class. Therefore, we remove direct access to the backing surface (and
secondary buffer surface) and replace it instead with accessors that
return those few values that are required by outside code.
2015-12-28 21:45:21 +01:00
Nicolas Hake 5a9baeddbf C4FoWRegion: Turn some owned pointers into std::unique_ptr 2015-12-28 21:45:19 +01:00
Nicolas Hake 46abecded7 C4FoWRegion: Merge Clear() into dtor 2015-12-28 21:45:15 +01:00
Nicolas Hake b36a9ec5b5 C4Draw: Remove C4Draw::IsShaderific()
In a surprising touch, using shaders to affect pretty much every pixel
that gets drawn on screen means there is little reason for code to ask
the renderer if it knows about shaders.
2015-12-27 01:54:41 +01:00
Armin Burgmeier a487457563 Add a 4x4 matrix class (StdProjectionMatrix)
This makes it easier to convert the projection and modelview matrices
to GLSL uniforms.
2015-12-24 23:01:52 -08:00
Armin Burgmeier 43e50f9320 Drop usage of gluErrorString
There are only a couple of error values worth considering, so we can just
write out own function for it. Disable error checking in C4FoWRegion.cpp as
well, since we have the --debug-opengl flag now.

This should allow us to get rid of the GLU dependency soon.
2015-12-24 16:26:52 -08:00
Armin Burgmeier eab0f2850a Clear Relight markers in C4Landscape::Clear (#1510)
Otherwise, when starting the next scenario, random spots would be initially
re-lighted. That's not necessarily a problem, but unnecessary work, and it
triggered the assertion in C4FowAmbient::UpdateFromLandscape if the relight
was scheduled for a region that's outside of the landscape boundaries of the
second scenario.
2015-12-21 19:35:43 -08:00
Armin Burgmeier a9967e7b16 Avoid built-in GL matrices for sprite rendering
Instead, compute the projection, modelview and normal matrices explictly
and upload them as shader uniforms. This is one step towards using the
OpenGL 3 core profile.
2015-12-19 22:37:36 -08:00
Armin Burgmeier 609840fda0 Fix internalFormat parameter of glTexImage* calls 2015-12-19 17:20:11 -08:00
David Dormagen dcfb986e34 moved sounds into subfolders
This completes http://forum.openclonk.org/topic_show.pl?tid=3215
2015-12-13 22:14:55 +01:00