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.
This commit is contained in:
Neil Roberts 2009-05-21 14:56:38 +01:00
parent 4f5a5f38f7
commit f13c3ee309
2 changed files with 6 additions and 3 deletions

View File

@ -325,9 +325,9 @@ void cogl_enable_depth_test (gboolean setting);
* *
* Sets whether textures positioned so that their backface is showing * Sets whether textures positioned so that their backface is showing
* should be hidden. This can be used to efficiently draw two-sided * should be hidden. This can be used to efficiently draw two-sided
* textures or fully closed cubes without enabling depth testing. Only * textures or fully closed cubes without enabling depth testing. This
* calls to cogl_texture_rectangle() and cogl_texture_polygon() are * only affects calls to the cogl_rectangle* family of functions and
* affected. Backface culling is disabled by default. * cogl_vertex_buffer_draw*. Backface culling is disabled by default.
*/ */
void cogl_enable_backface_culling (gboolean setting); void cogl_enable_backface_culling (gboolean setting);

View File

@ -1647,6 +1647,9 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
enable_flags |= cogl_material_get_cogl_enable_flags (ctx->source_material); 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); cogl_enable (enable_flags);
} }