This topic is now archived and is closed to further replies.

problem in finding front face of polygon

This topic is 5501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, how can i determine, which is the front face and back face of a polygon.because i m using glCullFace() and the cube i m making is also showing the back side of the cube.i have also seen in this forum that glDepthFunc can also solve this problem.but can any one tell me which one is better(glDepthFunc or glCullFace). and also tell me which one is better where. thanx

Share this post

Link to post
Share on other sites
Whether a face is the front or the back face is determined by the way the vertices present themselve when you look at the face, as specified by glFrontFace() (clockwise with GL_CW, counterclockwise with GL_CCW, which is the default)

Thus, by default

Front Back
0 0
1 2 2 1

glCullFace() controls whether the front faces ( GL_FRONT ), the back faces ( GL_BACK ), or both ( GL_FRONT_AND_BACK ) will be culled. Culling front faces doesn''t change the fact that the remaining are back-facing - whichm means they use back face material properties and things like that.

glDepthFunc() controls depth-testing. i.e. what to do with faces with are behind other faces. It holds no direct relation with their orientation - especially with non closed-manifold meshes.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share this post

Link to post
Share on other sites
yes i understood what u said but it is still not working correctly
if u look at the code below u will see that i have drawn the quad in clock wise direction so that the upper part of the quad will cull but it is still culling the lower part of the quad whats the problem here.please help me i m new to opengl.

void DrawScene(void)









Share this post

Link to post
Share on other sites

by default, opengl defines the winding of a front facing polygon to be counter-clockwise. This means that if the points are defined in a counter-clockwise order, they are facing the front.

To define the winding you want to use, call

glFrontFace(GLenum mode);

mode can be 2 values:

GL_CCW (counter-clockwise winding) (default)
GL_CW (clockwise winding) (what you want)

the 2 calls you made:

enable back face culling, and cull the back faces. Stick glFrontFace(GL_CW); after those 2 and see how it goes

hope this helps, have fun!

Share this post

Link to post
Share on other sites