From 9e1cd15b48f4e6a9bb6928bf1218e7bea2b1b1ed Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 9 Sep 2010 12:15:59 +0100 Subject: [PATCH] cogl-vertex-buffer: Flush the framebuffer state first Flushing the framebuffer state can cause some drawing to occur if the framebuffer has a clip stack which needs the stencil buffer. This was causing the array pointers set up by enable_state_for_drawing_buffer to get mangled so it would crash when it hits glDrawArrays. This patch moves the framebuffer state flush to before it sets up the array pointers. http://bugzilla.clutter-project.org/show_bug.cgi?id=2297 --- clutter/cogl/cogl/cogl-vertex-buffer.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/clutter/cogl/cogl/cogl-vertex-buffer.c b/clutter/cogl/cogl/cogl-vertex-buffer.c index d91ddc09c..24e210409 100644 --- a/clutter/cogl/cogl/cogl-vertex-buffer.c +++ b/clutter/cogl/cogl/cogl-vertex-buffer.c @@ -1540,6 +1540,14 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer) _cogl_bitmask_clear_all (&ctx->temp_bitmask); + /* NB: _cogl_framebuffer_flush_state may disrupt various state (such + * as the material state) when flushing the clip stack, so should + * always be done first when preparing to draw. We need to do this + * before setting up the array pointers because setting up the clip + * stack can cause some drawing which would change the array + * pointers. */ + _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); + for (tmp = buffer->submitted_vbos; tmp != NULL; tmp = tmp->next) { CoglVertexBufferVBO *cogl_vbo = tmp->data; @@ -1729,11 +1737,6 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer) /* Disable any tex coord arrays that we didn't use */ _cogl_disable_other_texcoord_arrays (&ctx->temp_bitmask); - /* NB: _cogl_framebuffer_flush_state may disrupt various state (such - * as the material state) when flushing the clip stack, so should - * always be done first when preparing to draw. */ - _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); - options.fallback_layers = fallback_layers; if (G_UNLIKELY (options.flags))