[cogl matrix] Adds ability to dirty state cached by the client matrix apis
authorRobert Bragg <robert@linux.intel.com>
Wed, 17 Jun 2009 01:08:31 +0000 (02:08 +0100)
committerRobert Bragg <robert@linux.intel.com>
Mon, 29 Jun 2009 22:49:06 +0000 (23:49 +0100)
To be able to load matrices to GL manually within Cogl we need a way to
dirty the state cached by the client matrix stack API.

clutter/cogl/common/cogl-current-matrix.c
clutter/cogl/common/cogl-current-matrix.h
clutter/cogl/common/cogl-matrix-stack.c
clutter/cogl/common/cogl-matrix-stack.h

index 6d069bc..7c3bc57 100644 (file)
@@ -355,6 +355,21 @@ _cogl_current_matrix_state_flush (void)
 }
 
 void
+_cogl_current_matrix_state_dirty (void)
+{
+  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+  if (ctx->matrix_mode != COGL_MATRIX_MODELVIEW)
+    {
+      g_warning ("matrix state must be dirtied in MODELVIEW mode");
+      return;
+    }
+
+  if (ctx->modelview_stack)
+    _cogl_matrix_stack_dirty (ctx->modelview_stack);
+}
+
+void
 cogl_push_matrix (void)
 {
   _cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
index d1b1bde..876c72b 100644 (file)
@@ -88,5 +88,6 @@ void _cogl_get_matrix                    (CoglMatrixMode    mode,
 void _cogl_current_matrix_state_init     (void);
 void _cogl_current_matrix_state_destroy  (void);
 void _cogl_current_matrix_state_flush    (void);
+void _cogl_current_matrix_state_dirty    (void);
 
 #endif /* __COGL_CURRENT_MATRIX_H */
index 6ba9098..e395ee1 100644 (file)
@@ -360,3 +360,10 @@ _cogl_matrix_stack_flush_to_gl (CoglMatrixStack *stack,
   if (gl_mode != GL_MODELVIEW)
     GE (glMatrixMode (GL_MODELVIEW));
 }
+
+void
+_cogl_matrix_stack_dirty (CoglMatrixStack *stack)
+{
+  stack->flushed_state = NULL;
+}
+
index a766f4b..c2d0048 100644 (file)
@@ -76,5 +76,6 @@ void             _cogl_matrix_stack_set           (CoglMatrixStack  *stack,
                                                    const CoglMatrix *matrix);
 void             _cogl_matrix_stack_flush_to_gl   (CoglMatrixStack  *stack,
                                                    GLenum            gl_mode);
+void             _cogl_matrix_stack_dirty         (CoglMatrixStack  *stack);
 
 #endif /* __COGL_MATRIX_STACK_H */