PDA

View Full Version : how to hide back faces of a cube



jyoung77
03-25-2002, 03:43 PM
Hi,

I can always see the hidden (i.e. the back) faces of my cube. Could I make the back faces invisible? My GL_DEPTH_TEST is turned on. Thanks for your information.

Tony

blood.angel
03-25-2002, 04:06 PM
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);

jyoung77
03-25-2002, 04:32 PM
Hi,

I tried different combinations: glDisable(GL_CULL_FACE), glEnable(GL_CULL_FACE), and when enabled, tried glCullFace(GL_BACK), glCullFace(GL_FRONT). They all produce different views, but none of them can hide the back faces. Should I make the faces non-transparent somehow? Please help. Thanks.

Tony

dorbie
03-25-2002, 05:11 PM
You need to ensure that the faces have a consistent winding w.r.t. the inside vs the outside of the cube.

If you have a mix of clockwise & counterclockwise winding w.r.t. the cube inside vs outside then seemingly random faces will be culled.


[This message has been edited by dorbie (edited 03-25-2002).]

blood.angel
03-26-2002, 11:20 AM
Yeah, order your points on the cube in either a clockwise or anticlockwise manner (ie when you call them to be drawn)

Then use

glFrontFace(GL_CCW); //or GL_CW for clockwise ordered points

To tell the program which are the front face sides to the squares of the cubes.