Commit Graph

107 Commits (eabca223f5e7c237f5d3bb88183d38a41cb9bced)

Author SHA1 Message Date
Nicolas Hake eabca223f5 Update all copyright notices for 2016 2016-04-03 20:24:42 +02:00
Nicolas Hake 493c276126 Rewrite header inclusions to #include "path/to/file.h" style 2016-04-03 20:24:42 +02:00
Nicolas Hake 33b8d404a5 GL: Add "frameCounter" uniform
Add the current frame counter as a uniform variable to the shaders, so
people can use it to do time-based animation.
2016-03-31 01:44:44 +02:00
Nicolas Hake 4fdafbc78a Move StdColors.h ref from C4Surface.h to files that actually need it
C4Surface.h doesn't require anything from StdColors.h, so there's no
reason to reference the latter there.
2016-02-08 02:13:18 +01:00
Günther Brammer 23d34f75ec Remove some dead graphics code 2016-02-06 23:46:58 +01:00
Günther Brammer d0fb24adda Merge epoxy preparation branch
Various changes to make the commit switching to epoxy smaller.
2016-02-02 03:35:13 +01:00
Nicolas Hake e9cf0f6fdc Stop pretending we support 16 bit color
The GTK and OS X platforms already ignored the requested bit depth and
always used 32 bit. Windows and SDL would set a 16 bit color depth for
the screen, but still did all of the rendering short of the final
present in 32 bit.
2016-02-02 00:00:23 +01:00
Günther Brammer a1a6e36cde GL: Deduplicate the check for glObjectLabel 2016-01-29 18:37:32 +01:00
Günther Brammer fd534c430e GL: Move notification about debug context to common code 2016-01-29 16:55:36 +01:00
Günther Brammer 34a720ca54 win32: Remove unused CreateContext function taking a HWND 2016-01-23 22:02:52 +01:00
Armin Burgmeier 1349962ac3 Fix release build 2016-01-17 13:36:26 -08:00
Armin Burgmeier b459cb35f1 Remove the OpenGL version check
As long as we can create a core profile context we are good anyway.
And if we don't, we'll get an error during context construction.
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 bc8db0589e Make the mesh material properties uniform variables
Instead of relying on the obsolete glMaterial 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 fabb4cbdbf Implement a mechanism that allows using VAOs across contexts
Basically add another layer of indirection around accessing VAOs. The problem
is that VAOs are not shared between OpenGL contexts. This mechanism allows to
treat them mostly as if they were shared if they are only accessed through
the API defined in CStdGL.

This is accomplished by caching all existing VAOs per context. If a VAO is
being accessed, it is checked whether that VAO exists in the currently
selected context. If yes, return it, otherwise create a new VAO and return it,
together with a flag that indicates that the VAO needs to be initialized.
2016-01-17 11:37:17 -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
Armin Burgmeier 988fe15e29 Use VBOs to draw sprite graphics
I don't expect much of a performance benefit from this, but it works toward
removal of legacy OpenGL usage. Note that we are already using VBOs for
meshes, so this does not require any functionality that we don't require
already.
2016-01-01 22:26:41 -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 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
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 a1f7a7c0e8 Fix conversion of C4BltTransform to StdMeshMatrix (#1508)
This was introduced by a9967e7.
2015-12-20 09:55:41 -08:00
Armin Burgmeier 10f98d1e3b Fix Windows build (hopefully) 2015-12-20 09:48:17 -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
Armin Burgmeier 12ae83cfe4 Re-initialize shaders after changing anti-alias setting (#1286) 2015-10-31 21:12:45 -06:00
Peter Wortmann beef0369e7 Fix OC_SKY definition
Lost in the merge...
2015-10-04 14:24:49 +01:00
Armin Burgmeier fb68624686 Try to compile vertex shader before trying work-around (#1368)
It looks like sometimes graphics drivers don't report the correct number for
maximum uniforms, since the workaround was enabled even though Newton
confirmed disabling the workaround worked just fine on his GPU. Therefore,
don't listen to what the graphics driver is saying but just try to compile the
shader, and fall back to the workaround if the compilation fails.
2015-10-03 14:45:54 -04:00
Armin Burgmeier 745683c860 Small shader preprocessor fixes 2015-10-03 11:18:47 -04:00
Peter Wortmann cf4ed1b0b7 Shiny materials, shader reorganisation
This implements the proposal made in the forum for "shiny" materials -
material can now determine the angle at which the most light is reflected.
Shiny materials might set this lower to approximate a "reflection" effect,
and increase the "spottiness" at the same time. To compensate for the
lack of brightness without light, "emittance" can be used.

Not sure this is the most elegant way to model this - the "proper" way
here would be to have emittance, shading and specular as three separate
light parameters instead of molding one into the other and using the third
to compensate.

Furthermore, this reorganises shaders in a major way: We reduce the
number of shader files down to three, pushing a number of possible
configurations into preprocessor. I believe this should be easier to
understand, which for the moment trumps theoretical extensibility
benefits.
2015-10-03 15:32:39 +01:00
Sven Eberhardt bdad81d2d1 Show "gl: Create context" messages on first context only.
They would clutter the log whenever you switched tools, created viewports, etc.
2015-09-18 09:50:06 -04:00
Armin Burgmeier 061305c0c7 Don't enable textures in C4ShaderCall::AllocTexUnit
This was only necessary with the fixed function pipeline, but not when
using shaders.
2015-09-16 21:45:30 -04:00
Armin Burgmeier 20eb0615ee Custom shader for drawing sky
Add a C4ShaderCall parameter to tho most important drawing functions, and
make C4DrawGL's CreateSpriteShader public with additional parameters to
specify additional defines and shader slices. C4Sky uses this to compile its
own shader with OC_SKY defined.
2015-09-12 18:15:34 -04:00
Armin Burgmeier 80791ec5ec Add a low-level PerformMultiBlt function to C4Draw
This allows drawing with custom sprite shaders. Plan is to make the sky draw
with a separate shader.
2015-09-10 20:45:42 -04:00
Armin Burgmeier f3da8525d0 Prefix most shader defines with "OC_" 2015-09-10 19:45:43 -04:00
Armin Burgmeier db29160fea Revert "revert workaround made for #1368, doesn't work on (certain) Intel chipsets. Instead, limit the maximum bone count to 64 so to meet the limit of 1024 uniform components by certain graphics cards (#1285)"
This reverts commit f57bfa089c.

This was committed by mistake. Fixes #1375.
2015-09-03 20:38:53 -04:00
Tobias Zwick f57bfa089c revert workaround made for #1368, doesn't work on (certain) Intel chipsets. Instead, limit the maximum bone count to 64 so to meet the limit of 1024 uniform components by certain graphics cards (#1285) 2015-08-31 19:28:00 +02:00
Peter Wortmann 30857e835e Shader gamma implementation
In comparison to the old system, this is a downgrade - instead of being
able to set a full color mapping by gamma ramp, we now get just a value
per colour channel.

Upside is that we do not need to play around with the global gamma ramps
any more, which was arguably the wrong way to do it.

This commit will likely break everything that has been using gamma so far.
2015-08-31 17:35:08 +01:00
Armin Burgmeier a172245c1e Illuminate materials with no backface culling from both sides
This might need adaptions in some materials, but is probably the right thing
to do.
2015-07-20 22:11:19 -04:00
Nicolas Hake 0db5950c8d GL: Test for GL_KHR_debug before enabling GL_DEBUG_OUTPUT
The GLEW headers of Ubuntu 12.04 LTS don't know about GL_KHR_debug yet,
so we have to test for it before using its enum. Additionally, drivers
without support for GL_KHR_debug would emit INVALID_ENUM, so we test for
driver support too.
2015-05-28 22:56:48 +02:00
Fabian Pietsch 0f65ab4b35 GL: Avoid endless recursion via OpenGLDebugProc
When an error's log output is represented graphically the graphics
operation can lead to another error (or the same error again), which
will be logged graphically again and so forth, until stack overflow.
So log to the log file only.
2015-05-28 21:34:15 +02:00
Fabian Pietsch 8ef6d65520 GLX: More debug output, to be able to trace the code paths taken 2015-05-28 21:34:14 +02:00
Fabian Pietsch 72366a56b7 GLX: Get debug callback to work even when the driver violates the specs
According to Isilkor, the initial state of DEBUG_OUTPUT should be TRUE
on a debug context. This was not the case on my system (Mesa 10.3.2).
2015-05-28 21:34:12 +02:00
Nicolas Hake 5562b09dc4 Remove a lot of disabled legacy code, round 2
Maybe at some point we'll be rid of all the commented-out code that
nobody has looked at in years.
2015-03-25 20:02:53 +01:00
Nicolas Hake d6f219a3df Use 3x4 bones on low MAX_VTX_UNIFORM_COMPS (#1285)
4x3 matrices use the same number of uniform components as 4x4 ones.
If we're short on uniform components, don't transpose the transformation
matrix before sending it to the shader, and transpose it in the shader
itself instead, saving 4 components per bone.
2015-03-18 23:38:20 +01:00
Nicolas Hake d2563fe345 Do skinning in hardware
Instead of transforming all vertices on the CPU every time an animation
progresses, we now only recalculate the skeleton, leaving the heavy
lifting for the GPU. This also means we no longer have to push all
vertices onto the bus every frame, because the mesh isn't changing and
can therefore be stored in a GL_STATIC_DRAW VBO when it's first loaded.
The downside of this approach is that there's only a limited number of
uniforms and vertex attributes we can pass to the shader. At the moment
these limits are a maximum of 128 bones per skeleton, and no vertex can
be influenced by more than 8 bones at once. So far this is no problem,
as the most complex skeleton in the base game uses less than 64 bones
and no more than 6 bone weights per vertex.
2015-02-27 21:51:58 +01:00
Nicolas Hake 75c2b8e61c GL: Dump list of supported extensions with --debug-opengl
glGetString(GL_EXTENSIONS) is deprecated starting with OpenGL 3.0.
Instead, you're now supposed to retrieve the list of extensions one by
one with glGetStringi.
2015-02-22 15:52:38 +01:00