Front/Back Faces selection (CullFace)

Hi
I have to draw the backfaces of a cube. But I’ve some problem of comprehension with the different parameters.

If I define:
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
and the draw a polygone with glPolygonMode(GL_FRONT_AND_BACK,GL_FILL) (or GL_LINE), only the back faces appear.
It’s exactly what I want BUT glCullFace(GL_BACK) should mean that the back faces will be culled…

And if do not use glCullFace and glEnable and simply draw a polygon using glPolygonMode(GL_BACK,GL_FILL), I then obtain Front faces. But if I execute glPolygonMode(GL_BACK,GL_LINE) it will then draw the back faces AND the front lines (edges).

WHY??? Do you have any good explanation because it’s really not clear…
Thanks
Best regards

Originally posted by Lapinot:
[b]Hi
I have to draw the backfaces of a cube. But I’ve some problem of comprehension with the different parameters.

If I define:
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
and the draw a polygone with glPolygonMode(GL_FRONT_AND_BACK,GL_FILL) (or GL_LINE), only the back faces appear.
It’s exactly what I want BUT glCullFace(GL_BACK) should mean that the back faces will be culled…

And if do not use glCullFace and glEnable and simply draw a polygon using glPolygonMode(GL_BACK,GL_FILL), I then obtain Front faces. But if I execute glPolygonMode(GL_BACK,GL_LINE) it will then draw the back faces AND the front lines (edges).

WHY??? Do you have any good explanation because it’s really not clear…
Thanks
Best regards[/b]
Its actually quite simple.
First u enable culling by glEnable(GL_CULL_FACE)
Then
u tell which face to cull by calling glFrontFace(GL_CW) //for clockwise vertex order for GL_CCW for Counterclockwise order. en you tell how the faces should appear by glolygonMode(GL_FRONT, GL_FILL) etc see if you are specifying the vertex order correctly and it works out ok.
Thanx
MMM

Ok. The problem is that i want to draw a cube, using triangle strip. It mean, it is not possible to define the cube having always the same order with the vertex indices (CW or CCW).

And why can we define twice our choice of the back/front face (in polygonMode AND in cullFace)?

Originally posted by Lapinot:
[b]Ok. The problem is that i want to draw a cube, using triangle strip. It mean, it is not possible to define the cube having always the same order with the vertex indices (CW or CCW).

And why can we define twice our choice of the back/front face (in polygonMode AND in cullFace)?[/b]
The first part of your question is e if i could provide you the code here of making cube by tri strip.
As for why opengl provides a culling function and then a polygonmode function well its by design i presume b/c ideally a face chosen for culling must not be visible at all so why provide the polygon mode for it? This is for the gurus to answer. This is what i can tell you. As for the first part I will try to help you out with it asap.Perhaps you can send me a pm and i will email you the code.
Thanx
MMM

Originally posted by Lapinot:
[b]Ok. The problem is that i want to draw a cube, using triangle strip. It mean, it is not possible to define the cube having always the same order with the vertex indices (CW or CCW).

[/b]
I’m wrong. Only the FIRST triangle define the orientation (CCW or CW). It mean, it’s possible to use triangle strip, without problem of back/front face.