Maintain the Cogl assumption that the modelview matrix is normally current
authorRobert Bragg <robert@linux.intel.com>
Thu, 12 Mar 2009 14:16:48 +0000 (14:16 +0000)
committerRobert Bragg <robert@linux.intel.com>
Thu, 12 Mar 2009 18:55:41 +0000 (18:55 +0000)
_cogl_add_path_to_stencil_buffer and _cogl_add_stencil_clip were leaving
the projection matrix current when calling cogl_rectangle which was
upsetting _cogl_current_matrix_state_flush.

clutter/cogl/gl/cogl-primitives.c
clutter/cogl/gl/cogl.c
clutter/cogl/gles/cogl-primitives.c
clutter/cogl/gles/cogl.c

index 07e728b..8195a3d 100644 (file)
@@ -198,18 +198,28 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
       GE( glStencilOp (GL_DECR, GL_DECR, GL_DECR) );
       /* 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_set_current_matrix (COGL_MATRIX_PROJECTION);
+      /* 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_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_MODELVIEW);
+      _cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
       _cogl_current_matrix_pop ();
+
+      _cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
     }
 
   GE( glStencilMask (~(GLuint) 0) );
index 88ffb97..ba92cba 100644 (file)
@@ -479,15 +479,27 @@ _cogl_add_stencil_clip (float x_offset,
         only pixels where both the original stencil buffer and the
         rectangle are set will be valid */
       GE( glStencilOp (GL_DECR, GL_DECR, GL_DECR) );
+
+      _cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
       _cogl_current_matrix_push ();
       _cogl_current_matrix_identity ();
-      _cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
+
+      /* 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_rectangle (-1.0, -1.0, 1.0, 1.0);
+
       _cogl_current_matrix_pop ();
-      _cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
+
+      _cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
       _cogl_current_matrix_pop ();
+
+      _cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
     }
 
   /* Restore the stencil mode */
index d1ba143..ae91aa0 100644 (file)
@@ -204,18 +204,28 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
       GE( glStencilOp (GL_DECR, GL_DECR, GL_DECR) );
       /* 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_set_current_matrix (COGL_MATRIX_PROJECTION);
+      /* 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_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_MODELVIEW);
+      _cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
       _cogl_current_matrix_pop ();
+
+      _cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
     }
 
   GE( glStencilMask (~(GLuint) 0) );
index ca669e4..47e84c5 100644 (file)
@@ -421,15 +421,27 @@ _cogl_add_stencil_clip (float x_offset,
         only pixels where both the original stencil buffer and the
         rectangle are set will be valid */
       GE( glStencilOp (GL_DECR, GL_DECR, GL_DECR) );
+
+      _cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
       _cogl_current_matrix_push ();
       _cogl_current_matrix_identity ();
-      _cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
+
+      /* 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_rectangle (-1.0, -1.0, 1.0, 1.0);
+
       _cogl_current_matrix_pop ();
-      _cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
+
+      _cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
       _cogl_current_matrix_pop ();
+
+      _cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
     }
 
   /* Restore the stencil mode */