Commit Graph

64 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
Günther Brammer 23d34f75ec Remove some dead graphics code 2016-02-06 23:46:58 +01:00
Günther Brammer 934b519bb4 Update the SDL port to SDL2
SDL2 is a much closer match to the other platform code, and
allows the creation of OpenGL 3 core contexts, which is
now required.
2016-02-06 16:48:21 +01:00
Günther Brammer 59e5a327b2 gtk: Add support for microsoft windows 2016-02-06 16:47:44 +01:00
Günther Brammer 487277b58d WGL: Stop caching the window handle in the GL context 2016-02-06 15:54:47 +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
Nicolas Hake 506d116c42 WGL: Wrap the temporary context for OpenGL extension detection in a class
Unlike GLX, the OpenGL function pointers are context-dependant. Because we
need an extension function to create the context we're going to use, we
first need to create a temporary context. Since this is independent of the
library used to fetch the function pointers, decouple it from glewInit().
2016-01-29 18:37:32 +01:00
Günther Brammer 83cf09db1a GL: Replace CStdGLCtx::Reinitialize with parameter to Clear() 2016-01-29 16:52:36 +01:00
Günther Brammer 34a720ca54 win32: Remove unused CreateContext function taking a HWND 2016-01-23 22:02:52 +01:00
Günther Brammer 93f12150c4 CMake: Remove obsolete USE_X11 option and add USE_WIN32_WINDOWS
USE_WIN32_WINDOWS was previously defined in PlatformAbstraction.h. Move it
to CMakeLists.txt and config.h like its peers. Replace USE_X11 with USE_GTK
or GDK_WINDOWING_X11 as appropriate.
2016-01-23 20:36:34 +01: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 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 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
Nicolas Hake 73c26114cb C4Draw: Remove C4Draw::IsOpenGL()
Nobody was interested in testing whether the renderer was GL or something
else, so the function is superfluous.
2015-12-27 01:54:06 +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 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 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 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 c58e474f76 win32/GL: Reuse the same rendering context for everything
Some resources can't be shared across different rendering contexts while
others can. Additionally, the standard GLEW library does not support
multiple rendering contexts (that's what GLEX MX is for), even though it
might work on some (or even most) cards. WGL supports reuse of a
rendering context across multiple windows as long as the pixel formats
are the same.
2015-03-26 15:51:01 +01:00
Nicolas Hake b2f742f997 gl: Check glew for GL_KHR_debug support
Debian wheezy's glew doesn't support GL_KHR_debug yet, so make sure
we're only using it if we can.
2015-03-25 23:15:45 +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 eed1c43b8a GL: Correctly encode error strings
gluErrorString returns latin-1 encoded strings. Our code expects to
receive UTF-8 encoded strings everywhere, so make sure that the strings
are converted before passing them on.
2015-02-16 15:39:05 +01:00
Günther Brammer 5bcedb5bbf Remove some redundant #includes 2015-01-25 18:53:48 +01:00
Sven Eberhardt 1c994ad3c7 Windows: Do not deselect GL context when losing focus (#1208).
Fixes engine intialization when tabbing out.
2015-01-11 17:01:27 +01:00
Armin Burgmeier 1c68526440 Remove unused function C4DrawGL::EnsureAnyContext() 2015-01-04 13:36:29 +01:00
Armin Burgmeier 8686441d45 Make mesh shaders use the C4Shader slice machinery 2014-12-22 22:56:30 +01:00
Armin Burgmeier 5054322b6d Enable lighting shaders for particle rendering 2014-11-25 11:42:17 -05:00
Armin Burgmeier 192dddec6f Use the new shader system for rendering sprites
This now also avoids the use of conditionals in shaders by using different
shaders instead.
2014-11-24 14:51:08 -05:00
Armin Burgmeier 137abb89df Implement normal maps for sprite graphics 2014-11-07 15:29:09 -05:00
Armin Burgmeier 73e4f5a89c Remove some unused code in C4Draw 2014-11-04 11:24:55 -05:00
Armin Burgmeier a1bafb937f Implement DrawQuadDw with PerformMultiTris
This simplifies the code further.
2014-11-04 11:02:40 -05:00
Armin Burgmeier fe7897539a Remove unused code 2014-11-02 16:57:28 -05:00
Armin Burgmeier 233e5e7c13 Remove CStdGL::BlitLandscape
This code is only used for the low-resolution landscape that is hardly in use
anymore. The code was mostly a duplicate of the standard C4Surface blit
function, CStdGL::PerformBlt, with some added code for blitting material
textures with higher resolution. However, that code was not enabled anymore
by the classic landscape renderer either, so it seems safe to remove it.

The landscape is now simply drawn by C4Draw::Blit.
2014-11-02 11:15:06 -05:00
Armin Burgmeier 2b2bc56e77 Remove unused PerformBlt function 2014-11-01 22:28:03 -04:00
Armin Burgmeier b58fde88aa Add option to draw overlay with PerformMultiTris
This allows drawing images with overlay in a single rendering pass.
2014-11-01 22:28:03 -04:00