1. Debug/Feedback Backface Culling

Hi all,
I just entered openGL.
And already run into problems .
For geometric calculations, I need information about triangles that are culled.
I tried program the culling myself but it somehow does not match with the culling of opengl.
See image: http://img268.imageshack.us/img268/7...ingproblem.jpg (this is the inner side of a head. i asked opengl to cull the front faces away)
OpenGL and my calculations are not the same. I colored the triangles according to my culling test, and basically, all triangles should be red but some are not). So I was wondering how I can debug/reproduce openGL's calculations. From the outcome, I think openGL's results are correct.
In the code, there is a
gluLookAt(x, y, z,
x + lx,y + ly,z + lz,
0.0f,1.0f,0.0f);
I then used the lx,ly, lz vector and multiplied it with the computed normal vector of my triangles (or the vertices, that i pushed into openGL during drawing).
What might be wrong?
The culling operation itself is not so hard, so I wonder what might be the error. Maybe I cannot use lx,ly,lz as a view vector?
Would be super if someone could help, it is for a freeware tool!
KR,
Ben

2. Re: Debug/Feedback Backface Culling

Multiply the triangle's vertices by the final model-view-projection matrix ( = projection * model_view) . To find if a triangle should be culled, find the cross-product of two of its edges. If z is negative (or positive, I don't remember), then the triangle is culled. That's the way gpus decide whether to cull, afaik.

3. Re: Debug/Feedback Backface Culling

Hi Ilian,
i implemented your suggestion and it seems that you were correct. Applying the transformation to the vertexes resulted in equivalent culling. I think I need more knowledge of the mathematical fundamentals. Appearently,the perspective transformations do not leave the triangle orientation invariant. Which I thought it must, as the matrices seemed linear/affine transformations.
Either way, thanks a lot.
I now have a point for doing research.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•