The cost of glGetFloatv with Mesa is still representing a majority of our
time in OpenGL for some applications, and the last thing left using this is
the current-matrix API when getting the projection matrix.
This adds a matrix stack for the projection matrix, so all getting, setting
and modification of the projection matrix is now managed by Cogl and it's only
when we come to draw that we flush changes to the matrix to OpenGL.
This also brings us closer to being able to drop internal use of the
deprecated OpenGL matrix functions, re: commit 54159f5a1d
Previously we only used the Cogl matrix stack API for indirect contexts, but
it's too costly to keep on requesting modelview matrices from GL (for
logging in the journal) even for direct rendering.
I also experimented with a patch for mesa to improve performance and
discussed this with upstream, but we agreed to consider the GL matrix API
essentially deprecated. (For reference the GLES 2 and GL 3 specs have
removed the matrix APIs)
This adds cogl_matrix api for multiplying matrices either by a perspective
or ortho projective transform. The internal matrix stack and current-matrix
APIs also have corresponding support added.
New public API:
cogl_matrix_perspective
cogl_matrix_ortho
cogl_ortho
cogl_set_modelview_matrix
cogl_set_projection_matrix
Adds missing notices, and ensures all the notices are consistent. The Cogl
blurb also now reads:
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
Adds glFrustum wrappers (GLES only accepts floats not doubles, and GLES2
needs to use our internal cogl_wrap_glFrustumf)
Adds GL_TEXTURE_MATRIX getter code in cogl_wrap_glGetFloatv
Adds a GL_TEXTURE_MATRIX define for GLES2
Its not intended that users should use these with any other matrix mode, and
internally we now have the _cogl_current_matrix API if we need to play with
other modes.
If we later add internal flags to CoglMatrix then this code wouldn't
initialize those flags. The ways it's now done adds a redundant copy, but
if that turns out to be something worth optimizing we can look again at
using a cast but adding another way for initializing internal flags.
This is useful because sometimes we need to get the current matrix, which
is too expensive when indirect rendering.
In addition, this virtualization makes it easier to clean up the API in
the future.