From c83ad109db36a07342a0e4575036cf8410c5f1d4 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 21 May 2009 14:56:38 +0100 Subject: [PATCH 1/3] Make backface culling work with vertex buffers Backface culling is enabled as part of cogl_enable so the different rendering functions in Cogl need to explicitly opt-in to have backface culling enabled. Cogl vertex buffers should allow backface culling so they should check whether it is enabled and then set the appropriate cogl_enable flag. --- cogl.h.in | 6 +++--- common/cogl-vertex-buffer.c | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cogl.h.in b/cogl.h.in index b3b0584b0..bd3698312 100644 --- a/cogl.h.in +++ b/cogl.h.in @@ -325,9 +325,9 @@ void cogl_enable_depth_test (gboolean setting); * * Sets whether textures positioned so that their backface is showing * should be hidden. This can be used to efficiently draw two-sided - * textures or fully closed cubes without enabling depth testing. Only - * calls to cogl_texture_rectangle() and cogl_texture_polygon() are - * affected. Backface culling is disabled by default. + * textures or fully closed cubes without enabling depth testing. This + * only affects calls to the cogl_rectangle* family of functions and + * cogl_vertex_buffer_draw*. Backface culling is disabled by default. */ void cogl_enable_backface_culling (gboolean setting); diff --git a/common/cogl-vertex-buffer.c b/common/cogl-vertex-buffer.c index b7e004a49..28c9df46b 100644 --- a/common/cogl-vertex-buffer.c +++ b/common/cogl-vertex-buffer.c @@ -1647,6 +1647,9 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer) enable_flags |= cogl_material_get_cogl_enable_flags (ctx->source_material); + if (ctx->enable_backface_culling) + enable_flags |= COGL_ENABLE_BACKFACE_CULLING; + cogl_enable (enable_flags); } From 2e6bb11201eb900a889474e95999c38e171b584d Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 21 May 2009 15:04:38 +0100 Subject: [PATCH 2/3] [build] The cogl GE macro wasn't passing an int according to the format string This patch simply updates the arguments passed to g_warning inline with the given format string. --- common/cogl-internal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/cogl-internal.h b/common/cogl-internal.h index f148c35b6..980e2a886 100644 --- a/common/cogl-internal.h +++ b/common/cogl-internal.h @@ -62,6 +62,7 @@ const gchar *cogl_gl_error_to_string (GLenum error_code); { \ g_warning ("%s: GL error (%d): %s\n", \ G_STRLOC, \ + __err, \ cogl_gl_error_to_string (__err)); \ } } G_STMT_END From c73d3404483c67b2d15eac17ef95cb9cabadf29f Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 22 May 2009 11:41:02 +0100 Subject: [PATCH 3/3] [cogl-vertex-buffer] Ensure the clip state before rendering Before any rendering is done by Cogl it needs to ensure the clip stack is set up correctly by calling cogl_clip_ensure. This was not being done for the Cogl vertex buffer so it would still use the clip from the previous render. --- common/cogl-vertex-buffer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/cogl-vertex-buffer.c b/common/cogl-vertex-buffer.c index 28c9df46b..f6fa6ba89 100644 --- a/common/cogl-vertex-buffer.c +++ b/common/cogl-vertex-buffer.c @@ -1726,6 +1726,8 @@ cogl_vertex_buffer_draw (CoglHandle handle, if (!cogl_is_vertex_buffer (handle)) return; + cogl_clip_ensure (); + buffer = _cogl_vertex_buffer_pointer_from_handle (handle); enable_state_for_drawing_buffer (buffer); @@ -1754,6 +1756,8 @@ cogl_vertex_buffer_draw_elements (CoglHandle handle, if (!cogl_is_vertex_buffer (handle)) return; + cogl_clip_ensure (); + buffer = _cogl_vertex_buffer_pointer_from_handle (handle); enable_state_for_drawing_buffer (buffer);