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
This commit is contained in:
Neil Roberts 2010-09-09 12:15:59 +01:00
parent 0e325404aa
commit 9e1cd15b48

View File

@ -1540,6 +1540,14 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
_cogl_bitmask_clear_all (&ctx->temp_bitmask); _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) for (tmp = buffer->submitted_vbos; tmp != NULL; tmp = tmp->next)
{ {
CoglVertexBufferVBO *cogl_vbo = tmp->data; 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 */ /* Disable any tex coord arrays that we didn't use */
_cogl_disable_other_texcoord_arrays (&ctx->temp_bitmask); _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; options.fallback_layers = fallback_layers;
if (G_UNLIKELY (options.flags)) if (G_UNLIKELY (options.flags))