From 3d79cfaba1a09c0e0ce3e1933478977af77da8f2 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. --- common/cogl-current-matrix.c | 15 +++++++++++++++ common/cogl-current-matrix.h | 1 + common/cogl-matrix-stack.c | 7 +++++++ common/cogl-matrix-stack.h | 1 + 4 files changed, 24 insertions(+) diff --git a/common/cogl-current-matrix.c b/common/cogl-current-matrix.c index 6d069bc66..7c3bc57a3 100644 --- a/common/cogl-current-matrix.c +++ b/common/cogl-current-matrix.c @@ -354,6 +354,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) { diff --git a/common/cogl-current-matrix.h b/common/cogl-current-matrix.h index d1b1bdec7..876c72bbb 100644 --- a/common/cogl-current-matrix.h +++ b/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/common/cogl-matrix-stack.c b/common/cogl-matrix-stack.c index 6ba909840..e395ee1c6 100644 --- a/common/cogl-matrix-stack.c +++ b/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/common/cogl-matrix-stack.h b/common/cogl-matrix-stack.h index a766f4bbc..c2d0048f5 100644 --- a/common/cogl-matrix-stack.h +++ b/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 */