summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2011-11-15 14:05:06 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2011-11-15 14:05:06 +0800
commit03e1be4c2b59646481a624e199bdffc3b194bc62 (patch)
tree98872b4423c0e8f76c7a364dc0835e34cf5e425e
parent19717777ff07e41fc26f5a97d17e82a8f24b3ff3 (diff)
parent39ca3e51dfaa652ae4a0d936fff32a5edaca6c5f (diff)
downloadcogl-03e1be4c2b59646481a624e199bdffc3b194bc62.tar.gz
Merge branch 'master' into msvc-support
-rw-r--r--cogl/cogl-context.c6
-rw-r--r--cogl/cogl-framebuffer.c20
-rw-r--r--cogl/cogl-onscreen.c3
-rw-r--r--cogl/cogl-pipeline-private.h14
-rw-r--r--cogl/cogl-pipeline-state-private.h8
-rw-r--r--cogl/cogl-pipeline-state.c60
-rw-r--r--cogl/cogl-pipeline-state.h91
-rw-r--r--cogl/cogl-pipeline.c8
-rw-r--r--cogl/cogl-types.h15
-rw-r--r--cogl/cogl-util.h1
-rw-r--r--doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt5
-rw-r--r--tests/conform/test-backface-culling.c181
12 files changed, 270 insertions, 142 deletions
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index da41a820..b8296ece 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -408,12 +408,6 @@ _cogl_context_free (CoglContext *context)
winsys->context_deinit (context);
- if (context->window_buffer)
- {
- cogl_object_unref (context->window_buffer);
- context->window_buffer = NULL;
- }
-
_cogl_free_framebuffer_stack (context->framebuffer_stack);
if (context->current_path)
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 3144c952..6d99e339 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -1132,7 +1132,7 @@ notify_buffers_changed (CoglFramebuffer *old_draw_buffer,
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_get_cull_face_mode (ctx->current_pipeline) !=
COGL_PIPELINE_CULL_FACE_MODE_NONE)
{
ctx->current_pipeline_changes_since_flush |=
@@ -1141,18 +1141,16 @@ notify_buffers_changed (CoglFramebuffer *old_draw_buffer,
}
}
- /* XXX:
- * To support the deprecated cogl_set_draw_buffer API we keep track
- * of the last onscreen framebuffer that was set so that it can
- * be restored if the COGL_WINDOW_BUFFER enum is used. */
+ /* XXX: To support the deprecated cogl_set_draw_buffer API we keep
+ * track of the last onscreen framebuffer that was set so that it
+ * can be restored if the COGL_WINDOW_BUFFER enum is used. A
+ * reference isn't taken to the framebuffer because otherwise we
+ * would have a circular reference between the context and the
+ * framebuffer. Instead the pointer is set to NULL in
+ * _cogl_onscreen_free as a kind of a cheap weak reference */
if (new_draw_buffer &&
new_draw_buffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN)
- {
- cogl_object_ref (new_draw_buffer);
- if (ctx->window_buffer)
- cogl_object_unref (ctx->window_buffer);
- ctx->window_buffer = new_draw_buffer;
- }
+ ctx->window_buffer = new_draw_buffer;
}
/* Set the current framebuffer without checking if it's already the
diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c
index f95f96c7..f9439930 100644
--- a/cogl/cogl-onscreen.c
+++ b/cogl/cogl-onscreen.c
@@ -112,6 +112,9 @@ _cogl_onscreen_free (CoglOnscreen *onscreen)
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer);
+ if (framebuffer->context->window_buffer == onscreen)
+ framebuffer->context->window_buffer = NULL;
+
winsys->onscreen_deinit (onscreen);
_COGL_RETURN_IF_FAIL (onscreen->winsys == NULL);
diff --git a/cogl/cogl-pipeline-private.h b/cogl/cogl-pipeline-private.h
index 57f3503e..4d045364 100644
--- a/cogl/cogl-pipeline-private.h
+++ b/cogl/cogl-pipeline-private.h
@@ -298,20 +298,6 @@ typedef enum _CoglPipelineBlendEnable
COGL_PIPELINE_BLEND_ENABLE_AUTOMATIC
} CoglPipelineBlendEnable;
-typedef enum
-{
- COGL_PIPELINE_CULL_FACE_MODE_NONE,
- COGL_PIPELINE_CULL_FACE_MODE_FRONT,
- COGL_PIPELINE_CULL_FACE_MODE_BACK,
- COGL_PIPELINE_CULL_FACE_MODE_BOTH
-} CoglPipelineCullFaceMode;
-
-typedef enum
-{
- COGL_WINDING_CLOCKWISE,
- COGL_WINDING_COUNTER_CLOCKWISE
-} CoglWinding;
-
typedef struct
{
/* Determines how this pipeline is blended with other primitives */
diff --git a/cogl/cogl-pipeline-state-private.h b/cogl/cogl-pipeline-state-private.h
index dd00f005..d93771bc 100644
--- a/cogl/cogl-pipeline-state-private.h
+++ b/cogl/cogl-pipeline-state-private.h
@@ -35,14 +35,6 @@ void
_cogl_pipeline_set_fog_state (CoglPipeline *pipeline,
const CoglPipelineFogState *fog_state);
-void
-_cogl_pipeline_set_cull_face_state (CoglPipeline *pipeline,
- const CoglPipelineCullFaceState *
- cull_face_state);
-
-CoglPipelineCullFaceMode
-_cogl_pipeline_get_cull_face_mode (CoglPipeline *pipeline);
-
gboolean
_cogl_pipeline_color_equal (CoglPipeline *authority0,
CoglPipeline *authority1);
diff --git a/cogl/cogl-pipeline-state.c b/cogl/cogl-pipeline-state.c
index 78102d86..db662f4f 100644
--- a/cogl/cogl-pipeline-state.c
+++ b/cogl/cogl-pipeline-state.c
@@ -1177,22 +1177,20 @@ _cogl_pipeline_set_fog_state (CoglPipeline *pipeline,
}
void
-_cogl_pipeline_set_cull_face_state (CoglPipeline *pipeline,
- const CoglPipelineCullFaceState *
- cull_face_state)
+cogl_pipeline_set_cull_face_mode (CoglPipeline *pipeline,
+ CoglPipelineCullFaceMode cull_face_mode)
{
CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE;
CoglPipeline *authority;
- CoglPipelineCullFaceState *current_cull_face_state;
+ CoglPipelineCullFaceState *cull_face_state;
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
- current_cull_face_state = &authority->big_state->cull_face_state;
+ cull_face_state = &authority->big_state->cull_face_state;
- if (current_cull_face_state->mode == cull_face_state->mode &&
- current_cull_face_state->front_winding == cull_face_state->front_winding)
+ if (cull_face_state->mode == cull_face_mode)
return;
/* - Flush journal primitives referencing the current state.
@@ -1202,14 +1200,44 @@ _cogl_pipeline_set_cull_face_state (CoglPipeline *pipeline,
*/
_cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE);
- pipeline->big_state->cull_face_state = *cull_face_state;
+ pipeline->big_state->cull_face_state.mode = cull_face_mode;
+
+ _cogl_pipeline_update_authority (pipeline, authority, state,
+ _cogl_pipeline_cull_face_state_equal);
+}
+
+void
+cogl_pipeline_set_front_face_winding (CoglPipeline *pipeline,
+ CoglWinding front_winding)
+{
+ CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE;
+ CoglPipeline *authority;
+ CoglPipelineCullFaceState *cull_face_state;
+
+ _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
+
+ authority = _cogl_pipeline_get_authority (pipeline, state);
+
+ cull_face_state = &authority->big_state->cull_face_state;
+
+ if (cull_face_state->front_winding == front_winding)
+ return;
+
+ /* - Flush journal primitives referencing the current state.
+ * - Make sure the pipeline has no dependants so it may be modified.
+ * - If the pipeline isn't currently an authority for the state being
+ * changed, then initialize that state from the current authority.
+ */
+ _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE);
+
+ pipeline->big_state->cull_face_state.front_winding = front_winding;
_cogl_pipeline_update_authority (pipeline, authority, state,
_cogl_pipeline_cull_face_state_equal);
}
CoglPipelineCullFaceMode
-_cogl_pipeline_get_cull_face_mode (CoglPipeline *pipeline)
+cogl_pipeline_get_cull_face_mode (CoglPipeline *pipeline)
{
CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE;
CoglPipeline *authority;
@@ -1222,6 +1250,20 @@ _cogl_pipeline_get_cull_face_mode (CoglPipeline *pipeline)
return authority->big_state->cull_face_state.mode;
}
+CoglWinding
+cogl_pipeline_get_front_face_winding (CoglPipeline *pipeline)
+{
+ CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE;
+ CoglPipeline *authority;
+
+ _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline),
+ COGL_PIPELINE_CULL_FACE_MODE_NONE);
+
+ authority = _cogl_pipeline_get_authority (pipeline, state);
+
+ return authority->big_state->cull_face_state.front_winding;
+}
+
float
cogl_pipeline_get_point_size (CoglPipeline *pipeline)
{
diff --git a/cogl/cogl-pipeline-state.h b/cogl/cogl-pipeline-state.h
index 7015b00c..5dfd21a1 100644
--- a/cogl/cogl-pipeline-state.h
+++ b/cogl/cogl-pipeline-state.h
@@ -686,6 +686,97 @@ void
cogl_pipeline_get_depth_state (CoglPipeline *pipeline,
CoglDepthState *state_out);
+/**
+ * CoglPipelineCullFaceMode:
+ * @COGL_PIPELINE_CULL_FACE_MODE_NONE: Neither face will be
+ * called. This is the default.
+ * @COGL_PIPELINE_CULL_FACE_MODE_FRONT: Front faces will be called.
+ * @COGL_PIPELINE_CULL_FACE_MODE_BACK: Back faces will be called.
+ * @COGL_PIPELINE_CULL_FACE_MODE_BOTH: All faces will be called.
+ *
+ * Specifies which faces should be called. This can be set on a
+ * pipeline using cogl_pipeline_set_cull_face_mode().
+ */
+typedef enum
+{
+ COGL_PIPELINE_CULL_FACE_MODE_NONE,
+ COGL_PIPELINE_CULL_FACE_MODE_FRONT,
+ COGL_PIPELINE_CULL_FACE_MODE_BACK,
+ COGL_PIPELINE_CULL_FACE_MODE_BOTH
+} CoglPipelineCullFaceMode;
+
+/**
+ * cogl_pipeline_set_cull_face_mode:
+ * @pipeline: A #CoglPipeline
+ * @cull_face_mode: The new mode to set
+ *
+ * Sets which faces will be culled when drawing. Face culling can be
+ * used to increase efficiency by avoiding drawing faces that would
+ * get overridden. For example, if a model has gaps so that it is
+ * impossible to see the inside then faces which are facing away from
+ * the screen will never be seen so there is no point in drawing
+ * them. This can be acheived by setting the cull face mode to
+ * %COGL_PIPELINE_CULL_FACE_MODE_BACK.
+ *
+ * Face culling relies on the primitives being drawn with a specific
+ * order to represent which faces are facing inside and outside the
+ * model. This order can be specified by calling
+ * cogl_pipeline_set_front_face_winding().
+ *
+ * Status: Unstable
+ * Since: 2.0
+ */
+void
+cogl_pipeline_set_cull_face_mode (CoglPipeline *pipeline,
+ CoglPipelineCullFaceMode cull_face_mode);
+
+/**
+ * cogl_pipeline_get_cull_face_mode:
+ *
+ * Return value: the cull face mode that was previously set with
+ * cogl_pipeline_set_cull_face_mode().
+ *
+ * Status: Unstable
+ * Since: 2.0
+ */
+CoglPipelineCullFaceMode
+cogl_pipeline_get_cull_face_mode (CoglPipeline *pipeline);
+
+/**
+ * cogl_pipeline_set_front_face_winding:
+ *
+ * The order of the vertices within a primitive specifies whether it
+ * is considered to be front or back facing. This function specifies
+ * which order is considered to be the front
+ * faces. %COGL_WINDING_COUNTER_CLOCKWISE sets the front faces to
+ * primitives with vertices in a counter-clockwise order and
+ * %COGL_WINDING_CLOCKWISE sets them to be clockwise. The default is
+ * %COGL_WINDING_COUNTER_CLOCKWISE.
+ *
+ * Status: Unstable
+ * Since: 2.0
+ */
+void
+cogl_pipeline_set_front_face_winding (CoglPipeline *pipeline,
+ CoglWinding front_winding);
+
+/**
+ * cogl_pipeline_set_front_face_winding:
+ *
+ * The order of the vertices within a primitive specifies whether it
+ * is considered to be front or back facing. This function specifies
+ * which order is considered to be the front
+ * faces. %COGL_WINDING_COUNTER_CLOCKWISE sets the front faces to
+ * primitives with vertices in a counter-clockwise order and
+ * %COGL_WINDING_CLOCKWISE sets them to be clockwise. The default is
+ * %COGL_WINDING_COUNTER_CLOCKWISE.
+ *
+ * Status: Unstable
+ * Since: 2.0
+ */
+CoglWinding
+cogl_pipeline_get_front_face_winding (CoglPipeline *pipeline);
+
#endif /* COGL_ENABLE_EXPERIMENTAL_API */
G_END_DECLS
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 60e96eb2..907f692c 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -2460,12 +2460,8 @@ _cogl_pipeline_apply_legacy_state (CoglPipeline *pipeline)
_cogl_pipeline_set_fog_state (pipeline, &ctx->legacy_fog_state);
if (ctx->legacy_backface_culling_enabled)
- {
- CoglPipelineCullFaceState state;
- state.mode = COGL_PIPELINE_CULL_FACE_MODE_BACK;
- state.front_winding = COGL_WINDING_COUNTER_CLOCKWISE;
- _cogl_pipeline_set_cull_face_state (pipeline, &state);
- }
+ cogl_pipeline_set_cull_face_mode (pipeline,
+ COGL_PIPELINE_CULL_FACE_MODE_BACK);
}
void
diff --git a/cogl/cogl-types.h b/cogl/cogl-types.h
index c93bde84..b8edb695 100644
--- a/cogl/cogl-types.h
+++ b/cogl/cogl-types.h
@@ -702,6 +702,21 @@ typedef enum
COGL_COLOR_MASK_ALL = (COGL_COLOR_MASK_RED | COGL_COLOR_MASK_GREEN | COGL_COLOR_MASK_BLUE | COGL_COLOR_MASK_ALPHA)
} CoglColorMask;
+/**
+ * CoglWinding:
+ * @COGL_WINDING_CLOCKWISE: Vertices are in a clockwise order
+ * @COGL_WINDING_COUNTER_CLOCKWISE: Vertices are in a counter-clockwise order
+ *
+ * Enum used to represent the two directions of rotation. This can be
+ * used to set the front face for culling by calling
+ * cogl_pipeline_set_front_face_winding().
+ */
+typedef enum
+{
+ COGL_WINDING_CLOCKWISE,
+ COGL_WINDING_COUNTER_CLOCKWISE
+} CoglWinding;
+
G_END_DECLS
#endif /* __COGL_TYPES_H__ */
diff --git a/cogl/cogl-util.h b/cogl/cogl-util.h
index f90da617..68fd9150 100644
--- a/cogl/cogl-util.h
+++ b/cogl/cogl-util.h
@@ -26,6 +26,7 @@
#include <glib.h>
#include <math.h>
+#include "cogl-defines.h"
#ifndef COGL_HAS_GLIB_SUPPORT
#include <stdio.h>
diff --git a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
index f8a1185a..0073408e 100644
--- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
+++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
@@ -570,6 +570,11 @@ cogl_pipeline_get_point_size
cogl_pipeline_get_color_mask
cogl_pipeline_set_color_mask
+CoglPipelineCullFaceMode
+cogl_pipeline_set_cull_face_mode
+CoglWinding
+cogl_pipeline_set_front_face_winding
+
cogl_pipeline_set_layer_texture
cogl_pipeline_get_layer_texture
CoglMaterialFilter
diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c
index 4beff1eb..fc7caa45 100644
--- a/tests/conform/test-backface-culling.c
+++ b/tests/conform/test-backface-culling.c
@@ -10,10 +10,10 @@
/* Amount of pixels to skip off the top, bottom, left and right of the
texture when reading back the stage */
-#define TEST_INSET 4
+#define TEST_INSET 2
/* Size to actually render the texture at */
-#define TEXTURE_RENDER_SIZE 32
+#define TEXTURE_RENDER_SIZE 8
typedef struct _TestState
{
@@ -24,49 +24,29 @@ typedef struct _TestState
int width, height;
} TestState;
-static gboolean
+static void
validate_part (int xnum, int ynum, gboolean shown)
{
- guchar *pixels, *p;
- gboolean ret = TRUE;
-
- pixels = g_malloc0 ((TEXTURE_RENDER_SIZE - TEST_INSET * 2)
- * (TEXTURE_RENDER_SIZE - TEST_INSET * 2) * 4);
-
- /* Read the appropriate part but skip out a few pixels around the
- edges */
- cogl_read_pixels (xnum * TEXTURE_RENDER_SIZE + TEST_INSET,
- ynum * TEXTURE_RENDER_SIZE + TEST_INSET,
- TEXTURE_RENDER_SIZE - TEST_INSET * 2,
- TEXTURE_RENDER_SIZE - TEST_INSET * 2,
- COGL_READ_PIXELS_COLOR_BUFFER,
- COGL_PIXEL_FORMAT_RGBA_8888_PRE,
- pixels);
-
- /* Make sure every pixel is the appropriate color */
- for (p = pixels;
- p < pixels + ((TEXTURE_RENDER_SIZE - TEST_INSET * 2)
- * (TEXTURE_RENDER_SIZE - TEST_INSET * 2));
- p += 4)
- {
- if (p[0] != (shown ? 255 : 0))
- ret = FALSE;
- if (p[1] != 0)
- ret = FALSE;
- if (p[2] != 0)
- ret = FALSE;
- }
+ test_utils_check_region (xnum * TEXTURE_RENDER_SIZE + TEST_INSET,
+ ynum * TEXTURE_RENDER_SIZE + TEST_INSET,
+ TEXTURE_RENDER_SIZE - TEST_INSET * 2,
+ TEXTURE_RENDER_SIZE - TEST_INSET * 2,
+ shown ? 0xff0000ff : 0x000000ff);
+}
- g_free (pixels);
+/* We draw everything 16 times. The draw number is used as a bitmask
+ to test all of the combinations of enabling legacy state, both
+ winding orders and all four culling modes */
- return ret;
-}
+#define USE_LEGACY_STATE(draw_num) (((draw_num) & 0x01) >> 0)
+#define FRONT_WINDING(draw_num) (((draw_num) & 0x02) >> 1)
+#define CULL_FACE_MODE(draw_num) (((draw_num) & 0x0c) >> 2)
static void
paint_test_backface_culling (TestState *state)
{
- int i;
- CoglPipeline *pipeline = cogl_pipeline_new ();
+ int draw_num;
+ CoglPipeline *base_pipeline = cogl_pipeline_new ();
CoglColor clear_color;
cogl_ortho (0, state->width, /* left, right */
@@ -76,25 +56,30 @@ paint_test_backface_culling (TestState *state)
cogl_color_init_from_4ub (&clear_color, 0x00, 0x00, 0x00, 0xff);
cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR | COGL_BUFFER_BIT_STENCIL);
- cogl_pipeline_set_layer_texture (pipeline, 0, state->texture);
+ cogl_pipeline_set_layer_texture (base_pipeline, 0, state->texture);
- cogl_pipeline_set_layer_filters (pipeline, 0,
+ cogl_pipeline_set_layer_filters (base_pipeline, 0,
COGL_PIPELINE_FILTER_NEAREST,
COGL_PIPELINE_FILTER_NEAREST);
- cogl_set_backface_culling_enabled (TRUE);
-
- cogl_push_matrix ();
-
- /* Render the scene twice - once with backface culling enabled and
- once without. The second time is translated so that it is below
- the first */
- for (i = 0; i < 2; i++)
+ /* Render the scene sixteen times to test all of the combinations of
+ cull face mode, legacy state and winding orders */
+ for (draw_num = 0; draw_num < 16; draw_num++)
{
float x1 = 0, x2, y1 = 0, y2 = (float)(TEXTURE_RENDER_SIZE);
CoglTextureVertex verts[4];
+ CoglPipeline *pipeline;
+
+ cogl_push_matrix ();
+ cogl_translate (0, TEXTURE_RENDER_SIZE * draw_num, 0);
- cogl_set_source (pipeline);
+ pipeline = cogl_pipeline_copy (base_pipeline);
+
+ cogl_set_backface_culling_enabled (USE_LEGACY_STATE (draw_num));
+ cogl_pipeline_set_front_face_winding (pipeline, FRONT_WINDING (draw_num));
+ cogl_pipeline_set_cull_face_mode (pipeline, CULL_FACE_MODE (draw_num));
+
+ cogl_push_source (pipeline);
memset (verts, 0, sizeof (verts));
@@ -152,51 +137,71 @@ paint_test_backface_culling (TestState *state)
x1 = x2;
x2 = x1 + (float)(TEXTURE_RENDER_SIZE);
- /* Draw a regular rectangle (this should always show) */
- cogl_set_source_color4f (1.0, 0, 0, 1.0);
- cogl_rectangle (x1, y1, x2, y2);
+ cogl_pop_matrix ();
- /* The second time round draw beneath the first with backface
- culling disabled */
- cogl_translate (0, TEXTURE_RENDER_SIZE, 0);
- cogl_set_backface_culling_enabled (FALSE);
+ cogl_pop_source ();
+ cogl_object_unref (pipeline);
}
- cogl_object_unref (pipeline);
-
- cogl_pop_matrix ();
+ cogl_object_unref (base_pipeline);
}
static void
validate_result (int y_offset)
{
- /* Front-facing texture */
- g_assert (validate_part (0, y_offset + 0, TRUE));
- /* Front-facing texture with flipped tex coords */
- g_assert (validate_part (1, y_offset + 0, TRUE));
- /* Back-facing texture */
- g_assert (validate_part (2, y_offset + 0, FALSE));
- /* Front-facing texture polygon */
- g_assert (validate_part (3, y_offset + 0, TRUE));
- /* Back-facing texture polygon */
- g_assert (validate_part (4, y_offset + 0, FALSE));
- /* Regular rectangle */
- g_assert (validate_part (5, y_offset + 0, TRUE));
-
- /* Backface culling disabled - everything should be shown */
-
- /* Front-facing texture */
- g_assert (validate_part (0, y_offset + 1, TRUE));
- /* Front-facing texture with flipped tex coords */
- g_assert (validate_part (1, y_offset + 1, TRUE));
- /* Back-facing texture */
- g_assert (validate_part (2, y_offset + 1, TRUE));
- /* Front-facing texture polygon */
- g_assert (validate_part (3, y_offset + 1, TRUE));
- /* Back-facing texture polygon */
- g_assert (validate_part (4, y_offset + 1, TRUE));
- /* Regular rectangle */
- g_assert (validate_part (5, y_offset + 1, TRUE));
+ int draw_num;
+
+ for (draw_num = 0; draw_num < 16; draw_num++)
+ {
+ gboolean cull_front, cull_back;
+ CoglPipelineCullFaceMode cull_mode;
+
+ if (USE_LEGACY_STATE (draw_num))
+ cull_mode = COGL_PIPELINE_CULL_FACE_MODE_BACK;
+ else
+ cull_mode = CULL_FACE_MODE (draw_num);
+
+ switch (cull_mode)
+ {
+ case COGL_PIPELINE_CULL_FACE_MODE_NONE:
+ cull_front = FALSE;
+ cull_back = FALSE;
+ break;
+
+ case COGL_PIPELINE_CULL_FACE_MODE_FRONT:
+ cull_front = TRUE;
+ cull_back = FALSE;
+ break;
+
+ case COGL_PIPELINE_CULL_FACE_MODE_BACK:
+ cull_front = FALSE;
+ cull_back = TRUE;
+ break;
+
+ case COGL_PIPELINE_CULL_FACE_MODE_BOTH:
+ cull_front = TRUE;
+ cull_back = TRUE;
+ break;
+ }
+
+ if (FRONT_WINDING (draw_num) == COGL_WINDING_CLOCKWISE)
+ {
+ gboolean tmp = cull_front;
+ cull_front = cull_back;
+ cull_back = tmp;
+ }
+
+ /* Front-facing texture */
+ validate_part (0, y_offset + draw_num, !cull_front);
+ /* Front-facing texture with flipped tex coords */
+ validate_part (1, y_offset + draw_num, !cull_front);
+ /* Back-facing texture */
+ validate_part (2, y_offset + draw_num, !cull_back);
+ /* Front-facing texture polygon */
+ validate_part (3, y_offset + draw_num, !cull_front);
+ /* Back-facing texture polygon */
+ validate_part (4, y_offset + draw_num, !cull_back);
+ }
}
static void
@@ -235,12 +240,12 @@ paint (TestState *state)
/* Incase we want feedback of what was drawn offscreen we draw it
* to the stage... */
cogl_set_source_texture (state->offscreen_tex);
- cogl_rectangle (0, TEXTURE_RENDER_SIZE * 2,
+ cogl_rectangle (0, TEXTURE_RENDER_SIZE * 16,
stage_viewport[2],
- stage_viewport[3] + TEXTURE_RENDER_SIZE * 2);
+ stage_viewport[3] + TEXTURE_RENDER_SIZE * 16);
validate_result (0);
- validate_result (2);
+ validate_result (16);
}
static CoglHandle