From 27fff12a6a880241002cec3705da7af9905a20bf Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 17 Jun 2009 02:08:31 +0100 Subject: [PATCH] [cogl matrix] Adds ability to dirty state cached by the client matrix apis 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 | 15 +++++++++++++++ clutter/cogl/common/cogl-current-matrix.h | 1 + clutter/cogl/common/cogl-matrix-stack.c | 7 +++++++ clutter/cogl/common/cogl-matrix-stack.h | 1 + 4 files changed, 24 insertions(+) diff --git a/clutter/cogl/common/cogl-current-matrix.c b/clutter/cogl/common/cogl-current-matrix.c index 6d069bc..7c3bc57 100644 --- a/clutter/cogl/common/cogl-current-matrix.c +++ b/clutter/cogl/common/cogl-current-matrix.c @@ -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); diff --git a/clutter/cogl/common/cogl-current-matrix.h b/clutter/cogl/common/cogl-current-matrix.h index d1b1bde..876c72b 100644 --- a/clutter/cogl/common/cogl-current-matrix.h +++ b/clutter/cogl/common/cogl-current-matrix.h @@ -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 */ diff --git a/clutter/cogl/common/cogl-matrix-stack.c b/clutter/cogl/common/cogl-matrix-stack.c index 6ba9098..e395ee1 100644 --- a/clutter/cogl/common/cogl-matrix-stack.c +++ b/clutter/cogl/common/cogl-matrix-stack.c @@ -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; +} + diff --git a/clutter/cogl/common/cogl-matrix-stack.h b/clutter/cogl/common/cogl-matrix-stack.h index a766f4b..c2d0048 100644 --- a/clutter/cogl/common/cogl-matrix-stack.h +++ b/clutter/cogl/common/cogl-matrix-stack.h @@ -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 */ -- 2.7.4