From 8790306629f8186bba7998b5567c2a45aafb87d9 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Sun, 6 Sep 2009 21:47:46 +0100 Subject: [PATCH] [test-backface-culling] Check that inverted tex coords don't affect culling The additional check draws another front facing rectangle but this time with the texture coords flipped on the x axis. The code that handles sliced textures in cogl-primitives.c makes some suspicious changes to the geometry when the texture coords are inverted. --- tests/conform/test-backface-culling.c | 28 +++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c index 5d8b7ba62..56cb8c45a 100644 --- a/tests/conform/test-backface-culling.c +++ b/tests/conform/test-backface-culling.c @@ -74,27 +74,31 @@ validate_result (TestState *state) { /* Front-facing texture */ g_assert (validate_part (0, 0, TRUE)); + /* Front-facing texture with flipped tex coords */ + g_assert (validate_part (1, 0, TRUE)); /* Back-facing texture */ - g_assert (validate_part (1, 0, FALSE)); + g_assert (validate_part (2, 0, FALSE)); /* Front-facing texture polygon */ - g_assert (validate_part (2, 0, TRUE)); + g_assert (validate_part (3, 0, TRUE)); /* Back-facing texture polygon */ - g_assert (validate_part (3, 0, FALSE)); + g_assert (validate_part (4, 0, FALSE)); /* Regular rectangle */ - g_assert (validate_part (4, 0, TRUE)); + g_assert (validate_part (5, 0, TRUE)); /* Backface culling disabled - everything should be shown */ /* Front-facing texture */ g_assert (validate_part (0, 1, TRUE)); - /* Back-facing texture */ + /* Front-facing texture with flipped tex coords */ g_assert (validate_part (1, 1, TRUE)); - /* Front-facing texture polygon */ + /* Back-facing texture */ g_assert (validate_part (2, 1, TRUE)); - /* Back-facing texture polygon */ + /* Front-facing texture polygon */ g_assert (validate_part (3, 1, TRUE)); - /* Regular rectangle */ + /* Back-facing texture polygon */ g_assert (validate_part (4, 1, TRUE)); + /* Regular rectangle */ + g_assert (validate_part (5, 1, TRUE)); /* Comment this out if you want visual feedback of what this test * paints. @@ -138,6 +142,14 @@ on_paint (ClutterActor *actor, TestState *state) x1 = x2; x2 = x1 + (float)(TEXTURE_RENDER_SIZE); + /* Draw a front-facing texture with flipped texcoords */ + cogl_material_set_layer (material, 0, state->texture); + cogl_rectangle_with_texture_coords (x1, y1, x2, y2, + 1.0, 0.0, 0.0, 1.0); + + x1 = x2; + x2 = x1 + (float)(TEXTURE_RENDER_SIZE); + /* Draw a back-facing texture */ cogl_material_set_layer (material, 0, state->texture); cogl_rectangle (x2, y1, x1, y2);