From 2ab9bef5873ca9d226ddf31fc65b96fe20fa72d5 Mon Sep 17 00:00:00 2001 From: zhou jiangwei Date: Tue, 11 Aug 2009 14:17:28 +0100 Subject: [PATCH] [cogl] Fix the GLES 2.0 backend Update the GLES 2.0 backend to the new COGL API after the breakage introduced by the journal. Signed-off-by: Emmanuele Bassi --- clutter/cogl/common/cogl-primitives.c | 5 +++-- clutter/cogl/gles/cogl-context.h | 5 ++++- clutter/cogl/gles/cogl-gles2-wrapper.h | 5 +++++ clutter/cogl/gles/cogl-primitives.c | 10 +++++----- clutter/cogl/gles/cogl-texture-private.h | 3 +++ 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/clutter/cogl/common/cogl-primitives.c b/clutter/cogl/common/cogl-primitives.c index 0133b36cf..ec48e73e7 100644 --- a/clutter/cogl/common/cogl-primitives.c +++ b/clutter/cogl/common/cogl-primitives.c @@ -88,6 +88,7 @@ typedef void (*CoglJournalBatchCallback) (CoglJournalEntry *start, void *data); typedef gboolean (*CoglJournalBatchTest) (CoglJournalEntry *entry0, CoglJournalEntry *entry1); +typedef CoglVertexBufferIndices CoglJournalIndices; typedef struct _CoglJournalFlushState { @@ -212,8 +213,8 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, int indices_offset = (state->vertex_offset / 4) * 6; GE (glDrawElements (GL_TRIANGLES, 6 * batch_len, - indices->type, - indices_offset * state->indices_type_size)); + state->indices->type, + (GLvoid*)(indices_offset * state->indices_type_size))); } else { diff --git a/clutter/cogl/gles/cogl-context.h b/clutter/cogl/gles/cogl-context.h index f2d7b0654..f5fe05e49 100644 --- a/clutter/cogl/gles/cogl-context.h +++ b/clutter/cogl/gles/cogl-context.h @@ -28,7 +28,7 @@ #include "cogl-clip-stack.h" #include "cogl-matrix-stack.h" #include "cogl-current-matrix.h" - +#include "cogl-material-private.h" #include "cogl-gles2-wrapper.h" typedef struct @@ -61,6 +61,7 @@ typedef struct /* Client-side matrix stack or NULL if none */ CoglMatrixMode matrix_mode; CoglMatrixStack *modelview_stack; + CoglMatrixStack *projection_stack; /* Cache of inverse projection matrix */ float inverse_projection[16]; @@ -81,10 +82,12 @@ typedef struct GArray *journal; GArray *logged_vertices; GArray *polygon_vertices; + GLuint journal_vbo; /* Some simple caching, to minimize state changes... */ CoglHandle current_material; gulong current_material_flags; + CoglMaterialFlushOptions current_material_flush_options; GArray *current_layers; guint n_texcoord_arrays_enabled; diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h index 5d232f922..e6c6a4c16 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.h +++ b/clutter/cogl/gles/cogl-gles2-wrapper.h @@ -229,6 +229,11 @@ struct _CoglGles2WrapperShader #define GL_MODELVIEW 0x1700 #define GL_PROJECTION 0x1701 +#ifdef COGL_ENABLE_DEBUG +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#endif + #define GL_VERTEX_ARRAY 0x8074 #define GL_TEXTURE_COORD_ARRAY 0x8078 #define GL_COLOR_ARRAY 0x8076 diff --git a/clutter/cogl/gles/cogl-primitives.c b/clutter/cogl/gles/cogl-primitives.c index d8dee0ba6..65705a4c1 100644 --- a/clutter/cogl/gles/cogl-primitives.c +++ b/clutter/cogl/gles/cogl-primitives.c @@ -76,17 +76,17 @@ _cogl_path_stroke_nodes () { guint path_start = 0; gulong enable_flags = COGL_ENABLE_VERTEX_ARRAY; + CoglMaterialFlushOptions options; _COGL_GET_CONTEXT (ctx, NO_RETVAL); enable_flags |= _cogl_material_get_cogl_enable_flags (ctx->source_material); cogl_enable (enable_flags); - _cogl_material_flush_gl_state (ctx->source_material, - COGL_MATERIAL_FLUSH_DISABLE_MASK, - (guint32)~0, /* disable all texture layers */ - NULL); - _cogl_current_matrix_state_flush (); + options.flags = COGL_MATERIAL_FLUSH_DISABLE_MASK; + options.disable_layers = (guint32)~0; + _cogl_material_flush_gl_state (ctx->source_material,&options); + _cogl_flush_matrix_stacks(); while (path_start < ctx->path_nodes->len) { diff --git a/clutter/cogl/gles/cogl-texture-private.h b/clutter/cogl/gles/cogl-texture-private.h index 365a47921..ad74ad121 100644 --- a/clutter/cogl/gles/cogl-texture-private.h +++ b/clutter/cogl/gles/cogl-texture-private.h @@ -25,6 +25,7 @@ #define __COGL_TEXTURE_H #include "cogl-bitmap-private.h" +#include "cogl-material-private.h" #include "cogl-handle.h" typedef struct _CoglTexture CoglTexture; @@ -103,6 +104,8 @@ typedef struct _CoglJournalEntry gint n_layers; guint32 fallback_mask; GLuint layer0_override_texture; + CoglMatrix model_view; + CoglMaterialFlushOptions flush_options; } CoglJournalEntry; CoglTexture*