aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_triangle.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-08-27 16:50:03 -0600
committerBrian Paul <[email protected]>2009-08-27 16:50:03 -0600
commit8f4d66c5f893b49eb3973aa3b31a856314c045c7 (patch)
treefbb405382c03fbd4af45a664af6509f244e3d8d3 /src/mesa/swrast/s_triangle.c
parent43a064e06dd0d3f7ff7ae23f19248e312c0b03b1 (diff)
swrast: fix incorrect tri culling in selection/feedback mode.
See bug 16866.
Diffstat (limited to 'src/mesa/swrast/s_triangle.c')
-rw-r--r--src/mesa/swrast/s_triangle.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 9260e35066f..1d2fed71691 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -44,8 +44,9 @@
#include "s_triangle.h"
-/*
- * Just used for feedback mode.
+/**
+ * Test if a triangle should be culled. Used for feedback and selection mode.
+ * \return GL_TRUE if the triangle is to be culled, GL_FALSE otherwise.
*/
GLboolean
_swrast_culltriangle( GLcontext *ctx,
@@ -53,16 +54,17 @@ _swrast_culltriangle( GLcontext *ctx,
const SWvertex *v1,
const SWvertex *v2 )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLfloat ex = v1->attrib[FRAG_ATTRIB_WPOS][0] - v0->attrib[FRAG_ATTRIB_WPOS][0];
GLfloat ey = v1->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1];
GLfloat fx = v2->attrib[FRAG_ATTRIB_WPOS][0] - v0->attrib[FRAG_ATTRIB_WPOS][0];
GLfloat fy = v2->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1];
GLfloat c = ex*fy-ey*fx;
- if (c * SWRAST_CONTEXT(ctx)->_BackfaceCullSign > 0)
- return 0;
+ if (c * swrast->_BackfaceSign * swrast->_BackfaceCullSign < 0.0F)
+ return GL_FALSE;
- return 1;
+ return GL_TRUE;
}