diff options
author | Robert Bragg <robert@linux.intel.com> | 2009-10-14 10:53:48 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2009-10-20 12:32:50 +0100 |
commit | 01887460f6051cb107b3a03934eee411ac382a3f (patch) | |
tree | 6af98ba8bc31d08da256b5e5a846d7b06389c1e3 /cogl/cogl-matrix-stack.c | |
parent | 43f8032a7f658245edee77133f3cc970aa6820ed (diff) | |
download | cogl-01887460f6051cb107b3a03934eee411ac382a3f.tar.gz |
[matrix-stack] Adds ctx->flushed_matrix_mode to cache the gl matrix mode
This cache of the gl matrix mode lets us avoid repeat calls to glMatrixMode
in _cogl_matrix_stack_flush_to_gl when we have lots of sequential modelview
matrix modifications.
Diffstat (limited to 'cogl/cogl-matrix-stack.c')
-rw-r--r-- | cogl/cogl-matrix-stack.c | 30 |
1 files changed, 18 insertions, 12 deletions
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 |