Removed unneeded member variables, removed wrong assertions and wrong
documentation (most of the state they were fobidding is actually valid).
Retrieving shader log with full length, properly printing non-error
messages to debug output.
Each shader must now be compiled explicitly using compile(), which is
slightly better for the user as it is possible to check compile status
instead of having it weirdly hidden inside attachShader(). link() now
also returns linking status.
OpenGL includes are ~35k lines together and it is a waste of
compilation time to include them even if they are not needed at all
(e.g. whole SceneGraph and Physics libraries). Saves ~10s of compilation
time (6:46 before, now 6:35).
Remaining unspecified components are set to 0, 0, 1, according to spec.
Also cleaned up and simplified the internals, added debug output
operators for attribute component count and types and tested the whole
thing.
The stride was computed always for resulting GLSL type (e.g. vec4) even
if the data were of anoother type (e.g. std::uint8_t[4]). The code is
exceptionally ugly now, time to wrap it with unit tests.
Also explicitly calling use() on default (non-DSA) setUniform()
implementation. Because of that, it is now possible to conveniently call
use() at the end, instead of at the beginning of uniform setting chain,
for example:
// before
shader->use();
shader->setTransformation(transformation)
->setProjection(projection)
->setColor(color);
// now
shader->setTransformation(transformation)
->setProjection(projection)
->setColor(color)
->use();
Note that you still have to explicitly call use(), because if DSA is
available, no use() is called explicitly on any setUniform(). If DSA is
not available, use() is called on first setUniform() and subsequent
calls have no negative performance impacts.
Magnum.h now doesn't include anything except OpenGL headers, thus
changes in Math library don't trigger recompilation of everything, but
only of things really depending on it.
Math constants moved to separate file for similar reasons, de-inlined
some functions to remove the need for some #includes.
Desktop OpenGL and OpenGL ES 2 support can be switched using CMake
TARGET_GLES option. All functionality not supported in ES is marked in
documentation.
If targetting OpenGL ES, GLES2/gl2.h is included instead of GLEW.
Mesh class now uses VAOs only in desktop OpenGL, in ES the buffers are
bound on each draw call.
Preferred workflow is to specify attribute location explicitly in the
shader. The functions remains here as some old Intel systems don't
support the required extension ARB_explicit_attrib_location (and it's
not in GL 3.0 either). Also updated and fixed the documentation.
Function bindAttribute() was renamed to bindAttributeLocation() to be
consistent with bindFragmentDataLocation().
PhongShader now uses explicit attribute location.
The class is now created always on the stack, so the user doesn't have
to delete it explicitly. It's now possible to write less verbose
shader code, instead of three lines before:
Shader* s = Shader::fromFile(Shader::Fragment, "Shader.frag");
attachShader(s);
// ...
delete s;
It's now only one:
attachShader(Shader::fromFile(Shader::Fragment, "Shader.frag"));
Removed another old overdone code, the attributes are now bound
directly, without saving the data to some temporary location and then
binding everything at once in link().