From 4609770bb9faa4dc74ddd0f25e099ff46b91e258 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Mon, 24 Jan 2011 17:32:06 +0000 Subject: [PATCH] cogl-clip-stack: Fix flushing multiple stencil rectangles When flushing a clip stack that contains more than one rectangle which needs to use the stencil buffer the code takes a different path so that it can combine the new rectangle with the existing contents of the stencil buffer. However it was not correctly flushing the modelview and projection matrices so that rectangle would be in the wrong place. --- clutter/cogl/cogl/cogl-clip-stack.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/clutter/cogl/cogl/cogl-clip-stack.c b/clutter/cogl/cogl/cogl-clip-stack.c index 082d62358..ef0313be3 100644 --- a/clutter/cogl/cogl/cogl-clip-stack.c +++ b/clutter/cogl/cogl/cogl-clip-stack.c @@ -203,6 +203,14 @@ add_stencil_clip_rectangle (float x_1, /* temporarily swap in our special stenciling pipeline */ cogl_push_source (ctx->stencil_pipeline); + /* This can be called from the journal code which doesn't flush + the matrix stacks between calls so we need to ensure they're + flushed now */ + _cogl_matrix_stack_flush_to_gl (modelview_stack, + COGL_MATRIX_MODELVIEW); + _cogl_matrix_stack_flush_to_gl (projection_stack, + COGL_MATRIX_PROJECTION); + if (first) { GE( glEnable (GL_STENCIL_TEST) ); @@ -215,14 +223,6 @@ add_stencil_clip_rectangle (float x_1, GE( glStencilFunc (GL_NEVER, 0x1, 0x1) ); GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) ); - /* This can be called from the journal code which doesn't flush - the matrix stacks between calls so we need to ensure they're - flushed now */ - _cogl_matrix_stack_flush_to_gl (modelview_stack, - COGL_MATRIX_MODELVIEW); - _cogl_matrix_stack_flush_to_gl (projection_stack, - COGL_MATRIX_PROJECTION); - _cogl_rectangle_immediate (x_1, y_1, x_2, y_2); } else