summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cogl/cogl-context.c1
-rw-r--r--cogl/cogl-context.h1
-rw-r--r--cogl/cogl-matrix-stack.c30
3 files changed, 20 insertions, 12 deletions
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index cb93fdcd..248fbc07 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -65,6 +65,7 @@ cogl_create_context (void)
_context->indirect = gl_is_indirect;
+ _context->flushed_matrix_mode = COGL_MATRIX_MODELVIEW;
_context->texture_units = NULL;
_context->default_material = cogl_material_new ();
diff --git a/cogl/cogl-context.h b/cogl/cogl-context.h
index 33d8948b..1ee36d1f 100644
--- a/cogl/cogl-context.h
+++ b/cogl/cogl-context.h
@@ -59,6 +59,7 @@ typedef struct
gboolean indirect;
CoglMatrixMode matrix_mode;
+ CoglMatrixMode flushed_matrix_mode;
CoglMatrixStack *projection_stack;
CoglMatrixStack *modelview_stack;
diff --git a/cogl/cogl-matrix-stack.c b/cogl/cogl-matrix-stack.c
index 8b7576d4..b1f21c94 100644
--- a/cogl/cogl-matrix-stack.c
+++ b/cogl/cogl-matrix-stack.c
@@ -385,26 +385,32 @@ _cogl_matrix_stack_flush_to_gl (CoglMatrixStack *stack,
CoglMatrixMode mode)
{
CoglMatrixState *state;
- GLenum gl_mode;
+
+ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
state = _cogl_matrix_stack_top (stack);
if (stack->flushed_state == state)
return;
- switch (mode)
+ if (ctx->flushed_matrix_mode != mode)
{
- case COGL_MATRIX_MODELVIEW:
- gl_mode = GL_MODELVIEW;
- break;
- case COGL_MATRIX_PROJECTION:
- gl_mode = GL_PROJECTION;
- break;
- case COGL_MATRIX_TEXTURE:
- gl_mode = GL_TEXTURE;
- break;
+ GLenum gl_mode;
+ switch (mode)
+ {
+ case COGL_MATRIX_MODELVIEW:
+ gl_mode = GL_MODELVIEW;
+ break;
+ case COGL_MATRIX_PROJECTION:
+ gl_mode = GL_PROJECTION;
+ break;
+ case COGL_MATRIX_TEXTURE:
+ gl_mode = GL_TEXTURE;
+ break;
+ }
+ GE (glMatrixMode (gl_mode));
+ ctx->flushed_matrix_mode = mode;
}
- GE (glMatrixMode (gl_mode));
/* In theory it might help the GL implementation if we used our
* local analysis of the matrix and called Translate/Scale rather