summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-12-04 14:06:01 -0700
committerBrian <brian.paul@tungstengraphics.com>2007-12-04 14:07:15 -0700
commit385bddbde04ca3ec2a159e8c8a50d9009da25b63 (patch)
tree723f6b6c3940d828667f3215e5244e28e048a8ff
parentc13542626729a6fe3e4dfbc71f3569119255b668 (diff)
fix span->facing computation and gl_FrontFacing initialization
-rw-r--r--src/mesa/swrast/s_fragprog.c2
-rw-r--r--src/mesa/swrast/s_tritemp.h10
2 files changed, 5 insertions, 7 deletions
diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c
index 324afb9c761..89114ebc9d6 100644
--- a/src/mesa/swrast/s_fragprog.c
+++ b/src/mesa/swrast/s_fragprog.c
@@ -118,7 +118,7 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine,
if (ctx->Shader.CurrentProgram) {
/* Store front/back facing value in register FOGC.Y */
- machine->Attribs[FRAG_ATTRIB_FOGC][col][1] = (GLfloat) span->facing;
+ machine->Attribs[FRAG_ATTRIB_FOGC][col][1] = 1.0 - span->facing;
}
machine->CurElement = col;
diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
index ae30fe5e597..891eaf6787a 100644
--- a/src/mesa/swrast/s_tritemp.h
+++ b/src/mesa/swrast/s_tritemp.h
@@ -172,7 +172,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
EdgeT eMaj, eTop, eBot;
GLfloat oneOverArea;
const SWvertex *vMin, *vMid, *vMax; /* Y(vMin)<=Y(vMid)<=Y(vMax) */
- GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceCullSign;
+ GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceSign;
#if !TRIANGLE_WALK_DOUBLE
const GLint snapMask = ~((FIXED_ONE / (1 << SUB_PIXEL_BITS)) - 1); /* for x/y coord snapping */
#endif
@@ -292,18 +292,16 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
#else
const GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
#endif
- /* Do backface culling */
-
- if (area * bf < 0.0)
+ if (IS_INF_OR_NAN(area) || area == 0.0F)
return;
- if (IS_INF_OR_NAN(area) || area == 0.0F)
+ if (area * bf * swrast->_BackfaceCullSign < 0.0)
return;
oneOverArea = 1.0F / area;
/* 0 = front, 1 = back */
- span.facing = oneOverArea * swrast->_BackfaceSign > 0.0F;
+ span.facing = oneOverArea * bf > 0.0F;
}
/* Edge setup. For a triangle strip these could be reused... */