[cogl] Removes the cogl-current-matrix abstraction

The indirection through this API isn't necessary since we no longer
arbitrate between the OpenGL matrix API and Cogl's client side API.  Also it
doesn't help to maintain an OpenGL style matrix mode API for internal use
since it's awkward to keep restoring the MODELVIEW mode and easy enough to
directly work with the matrix stacks of interest.

This replaces use of the _cogl_current_matrix API with direct use of the
_cogl_matrix_stack API.  All the unused cogl_current_matrix API is removed
and the matrix utility code left in cogl-current-matrix.c was moved to
cogl.c.
This commit is contained in:
Robert Bragg
2009-10-13 23:09:42 +01:00
parent 01887460f6
commit eed2479556
15 changed files with 270 additions and 227 deletions

View File

@ -202,29 +202,25 @@ cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
from a non-screen buffer */
GE( glPushAttrib (GL_VIEWPORT_BIT) );
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->projection_stack);
_cogl_matrix_stack_load_identity (ctx->projection_stack);
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->modelview_stack);
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
}
else
{
/* Override viewport and matrix setup if redirecting
from another offscreen buffer */
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_identity ();
_cogl_matrix_stack_load_identity (ctx->projection_stack);
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_identity ();
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
}
/* Setup new viewport and matrices */
cogl_viewport (fbo->width, fbo->height);
_cogl_current_matrix_translate (-1.0f, -1.0f, 0.0f);
_cogl_current_matrix_scale (2.0f / fbo->width, 2.0f / fbo->height, 1.0f);
_cogl_matrix_stack_translate (ctx->modelview_stack, -1.0f, -1.0f, 0.0f);
_cogl_matrix_stack_scale (ctx->modelview_stack, 2.0f / fbo->width, 2.0f / fbo->height, 1.0f);
/* Bind offscreen framebuffer object */
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo->gl_handle) );
@ -249,11 +245,9 @@ cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
from an offscreen buffer */
GE( glPopAttrib () );
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_pop ();
_cogl_matrix_stack_pop (ctx->projection_stack);
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_pop ();
_cogl_matrix_stack_pop (ctx->modelview_stack);
}
/* Bind window framebuffer object */

View File

@ -216,29 +216,19 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
/* Decrement all of the bits twice so that only pixels where the
value is 3 will remain */
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->projection_stack);
_cogl_matrix_stack_load_identity (ctx->projection_stack);
/* Cogl generally assumes the modelview matrix is current, so since
* cogl_rectangle will be flushing GL state and emitting geometry
* to OpenGL it will be confused if we leave the projection matrix
* active... */
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
_cogl_matrix_stack_push (ctx->modelview_stack);
_cogl_matrix_stack_load_identity (ctx->modelview_stack);
_cogl_flush_matrix_stacks ();
glRectf (-1.0, -1.0, 1.0, 1.0);
glRectf (-1.0, -1.0, 1.0, 1.0);
_cogl_current_matrix_pop ();
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_pop ();
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_matrix_stack_pop (ctx->modelview_stack);
_cogl_matrix_stack_pop (ctx->projection_stack);
}
GE( glStencilMask (~(GLuint) 0) );