Make backface culling be part of the legacy state

This adds an internal function to set the backface culling state on a
pipeline. This includes properties to set the culling mode (front,
back or both) and also to set which face is considered the front
(COGL_WINDING_CLOCKWISE or COGL_WINDING_COUNTER_CLOCKWISE). The actual
front face flushed to GL depends on whether we are rendering to an
offscreen buffer or not. This means that when changing between on- and
off- screen framebuffers it now checks whether the last flushed
pipeline has backface culling enabled and forces a reflush of the cull
face state if so.

The backface culling is now set on a pipeline as part of the legacy
state. This is important because some code in Cogl assumes it can
flush a temporary pipeline to revert to a known state, but previously
this wouldn't disable backface culling so things such as flushing the
clip stack could get confused.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts
2011-09-15 11:25:39 +01:00
committed by Robert Bragg
parent 879ce7301a
commit dbff3a357e
12 changed files with 258 additions and 103 deletions

View File

@ -39,6 +39,7 @@
#include "cogl-clip-stack.h"
#include "cogl-journal-private.h"
#include "cogl-winsys-private.h"
#include "cogl-pipeline-state-private.h"
#ifndef GL_FRAMEBUFFER
#define GL_FRAMEBUFFER 0x8D40
@ -1143,16 +1144,32 @@ notify_buffers_changed (CoglFramebuffer *old_draw_buffer,
_cogl_clip_stack_dirty ();
/* If the two draw framebuffers have a different color mask then we
need to ensure the logic ops are reflushed the next time
something is drawn */
if (old_draw_buffer && new_draw_buffer &&
cogl_framebuffer_get_color_mask (old_draw_buffer) !=
cogl_framebuffer_get_color_mask (new_draw_buffer))
if (old_draw_buffer && new_draw_buffer)
{
ctx->current_pipeline_changes_since_flush |=
COGL_PIPELINE_STATE_LOGIC_OPS;
ctx->current_pipeline_age--;
/* If the two draw framebuffers have a different color mask then
we need to ensure the logic ops are reflushed the next time
something is drawn */
if (cogl_framebuffer_get_color_mask (old_draw_buffer) !=
cogl_framebuffer_get_color_mask (new_draw_buffer))
{
ctx->current_pipeline_changes_since_flush |=
COGL_PIPELINE_STATE_LOGIC_OPS;
ctx->current_pipeline_age--;
}
/* If we're switching from onscreen to offscreen and the last
flush pipeline is using backface culling then we also need to
reflush the cull face state because the winding order of the
front face is flipped for offscreen buffers */
if (old_draw_buffer->type != new_draw_buffer->type &&
ctx->current_pipeline &&
_cogl_pipeline_get_cull_face_mode (ctx->current_pipeline) !=
COGL_PIPELINE_CULL_FACE_MODE_NONE)
{
ctx->current_pipeline_changes_since_flush |=
COGL_PIPELINE_STATE_CULL_FACE;
ctx->current_pipeline_age--;
}
}
/* XXX: