[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:
@ -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 */
|
||||
|
@ -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) );
|
||||
|
@ -173,29 +173,26 @@ cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
from a non-screen buffer */
|
||||
GE( glGetIntegerv (GL_VIEWPORT, ctx->drv.viewport_store) );
|
||||
|
||||
_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 */
|
||||
GE( glViewport (0, 0, 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( glBindFramebuffer (GL_FRAMEBUFFER, fbo->gl_handle) );
|
||||
@ -229,11 +226,9 @@ cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
ctx->drv.viewport_store[2],
|
||||
ctx->drv.viewport_store[3]) );
|
||||
|
||||
_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 */
|
||||
|
@ -167,7 +167,7 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
|
||||
GE( glColorMask (FALSE, FALSE, FALSE, FALSE) );
|
||||
GE( glDepthMask (FALSE) );
|
||||
|
||||
_cogl_current_matrix_state_flush ();
|
||||
_cogl_matrix_stack_flush_to_gl (ctx->modelview_stack, COGL_MATRIX_MODELVIEW);
|
||||
while (path_start < path_size)
|
||||
{
|
||||
GE( glVertexPointer (2, GL_FLOAT, sizeof (CoglPathNode),
|
||||
@ -204,27 +204,17 @@ _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_rectangle (-1.0, -1.0, 1.0, 1.0);
|
||||
cogl_rectangle (-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) );
|
||||
|
Reference in New Issue
Block a user