summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/draw/draw_twoside.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-07-13 14:22:46 -0600
committerBrian <[email protected]>2007-07-13 14:22:46 -0600
commitdc313b578386dc07f4916fba98da061af3ab18e5 (patch)
tree28dc7a6218e61a152136555e3f32d017c1762b2d /src/mesa/pipe/draw/draw_twoside.c
parent2bf4a500de24347476ce96cdd48d68ddeecbb019 (diff)
Fix more polygon winding, culling confusion.
If the determinant of the triangle is positive, its winding is CCW (right-handed coord system).
Diffstat (limited to 'src/mesa/pipe/draw/draw_twoside.c')
-rw-r--r--src/mesa/pipe/draw/draw_twoside.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c
index e86123e84db..9f26335fb65 100644
--- a/src/mesa/pipe/draw/draw_twoside.c
+++ b/src/mesa/pipe/draw/draw_twoside.c
@@ -35,8 +35,7 @@
struct twoside_stage {
struct draw_stage stage;
-
- GLfloat facing;
+ GLfloat sign; /**< +1 or -1 */
const GLuint *lookup;
};
@@ -51,7 +50,12 @@ static void twoside_begin( struct draw_stage *stage )
{
struct twoside_stage *twoside = twoside_stage(stage);
- twoside->facing = (stage->draw->setup.front_winding == PIPE_WINDING_CW) ? 1 : -1;
+ /*
+ * We'll multiply the primitive's determinant by this sign to determine
+ * if the triangle is back-facing (negative).
+ * sign = 1 for CCW, -1 for CW
+ */
+ twoside->sign = (stage->draw->setup.front_winding == PIPE_WINDING_CCW) ? 1 : -1;
stage->next->begin( stage->next );
}
@@ -94,7 +98,7 @@ static void twoside_tri( struct draw_stage *stage,
{
struct twoside_stage *twoside = twoside_stage(stage);
- if (header->det * twoside->facing < 0) {
+ if (header->det * twoside->sign < 0.0) {
/* this is a back-facing triangle */
struct prim_header tmp;