diff --git a/clutter/cogl/common/cogl-primitives.c b/clutter/cogl/common/cogl-primitives.c index ec48e73e7..bbda733e4 100644 --- a/clutter/cogl/common/cogl-primitives.c +++ b/clutter/cogl/common/cogl-primitives.c @@ -495,19 +495,19 @@ compare_entry_strides (CoglJournalEntry *entry0, CoglJournalEntry *entry1) return FALSE; } -static void +static GLuint upload_vertices_to_vbo (GArray *vertices, CoglJournalFlushState *state) { size_t needed_vbo_len; + GLuint journal_vbo; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + _COGL_GET_CONTEXT (ctx, 0); needed_vbo_len = vertices->len * sizeof (GLfloat); - g_assert (ctx->journal_vbo == 0); g_assert (needed_vbo_len); - GE (glGenBuffers (1, &ctx->journal_vbo)); - GE (glBindBuffer (GL_ARRAY_BUFFER, ctx->journal_vbo)); + GE (glGenBuffers (1, &journal_vbo)); + GE (glBindBuffer (GL_ARRAY_BUFFER, journal_vbo)); GE (glBufferData (GL_ARRAY_BUFFER, needed_vbo_len, vertices->data, @@ -516,6 +516,8 @@ upload_vertices_to_vbo (GArray *vertices, CoglJournalFlushState *state) /* As we flush the journal entries in batches we walk forward through the * above VBO starting at offset 0... */ state->vbo_offset = 0; + + return journal_vbo; } /* XXX NB: When _cogl_journal_flush() returns all state relating @@ -527,6 +529,7 @@ _cogl_journal_flush (void) { CoglJournalFlushState state; int i; + GLuint journal_vbo; gboolean vbo_fallback = (cogl_get_features () & COGL_FEATURE_VBOS) ? FALSE : TRUE; @@ -541,7 +544,7 @@ _cogl_journal_flush (void) /* Load all the vertex data we have accumulated so far into a single VBO * to minimize memory management costs within the GL driver. */ if (!vbo_fallback) - upload_vertices_to_vbo (ctx->logged_vertices, &state); + journal_vbo = upload_vertices_to_vbo (ctx->logged_vertices, &state); else state.vbo_offset = (char *)ctx->logged_vertices->data; @@ -598,10 +601,7 @@ _cogl_journal_flush (void) } if (!vbo_fallback) - { - GE (glDeleteBuffers (1, &ctx->journal_vbo)); - ctx->journal_vbo = 0; - } + GE (glDeleteBuffers (1, &journal_vbo)); g_array_set_size (ctx->journal, 0); g_array_set_size (ctx->logged_vertices, 0); diff --git a/clutter/cogl/gl/cogl-context.c b/clutter/cogl/gl/cogl-context.c index 745069ce8..0fe366ba7 100644 --- a/clutter/cogl/gl/cogl-context.c +++ b/clutter/cogl/gl/cogl-context.c @@ -69,8 +69,6 @@ cogl_create_context () _context->journal = g_array_new (FALSE, FALSE, sizeof (CoglJournalEntry)); _context->logged_vertices = g_array_new (FALSE, FALSE, sizeof (GLfloat)); - _context->journal_vbo = 0; - _context->journal_vbo_len = 0; _context->current_material = NULL; _context->current_material_flags = 0; diff --git a/clutter/cogl/gl/cogl-context.h b/clutter/cogl/gl/cogl-context.h index b0a72eaf4..d1a79c6ee 100644 --- a/clutter/cogl/gl/cogl-context.h +++ b/clutter/cogl/gl/cogl-context.h @@ -80,8 +80,6 @@ typedef struct * can batch things together. */ GArray *journal; GArray *logged_vertices; - GLuint journal_vbo; - size_t journal_vbo_len; /* Some simple caching, to minimize state changes... */ CoglHandle current_material; diff --git a/clutter/cogl/gles/cogl-context.h b/clutter/cogl/gles/cogl-context.h index f5fe05e49..683c8ce8f 100644 --- a/clutter/cogl/gles/cogl-context.h +++ b/clutter/cogl/gles/cogl-context.h @@ -82,7 +82,6 @@ typedef struct GArray *journal; GArray *logged_vertices; GArray *polygon_vertices; - GLuint journal_vbo; /* Some simple caching, to minimize state changes... */ CoglHandle current_material;