The order in which you indicate vertices determine the clock-wise or anti-clock-wise orientation of that geometry (such as a triangle or a square etc). As you follow that winding see how a right-hand-screw will advance. The direction of the advance will tell you which surface is facing outwards and which surface is facing inwards.
satya - Sat Aug 18 2012 11:14:35 GMT-0400 (Eastern Daylight Time)
opengl winding images
satya - Sat Aug 18 2012 11:16:05 GMT-0400 (Eastern Daylight Time)
It is quite instructional to see the image links above!!
It is quite instructional to see the image links above!!
satya - Sat Aug 18 2012 11:21:27 GMT-0400 (Eastern Daylight Time)
Take a look at this from glprogramming guide
satya - Sat Aug 18 2012 11:22:00 GMT-0400 (Eastern Daylight Time)
The direction of the arrows are winding in anti-clock wise direction
The direction of the arrows are winding in anti-clock wise direction
satya - Sat Aug 18 2012 11:24:12 GMT-0400 (Eastern Daylight Time)
If you were to rotate an RHS screw then the screw will come out of the page
So the face that from which the curling arrow comes out is the front face. the direction in which the screw advances as you loosen it in counter clock wise direction indicates the front of the surface. If you look at that surface from the other side then the screw will be moving away from the surface and that is the back side.
satya - Sat Aug 18 2012 11:25:34 GMT-0400 (Eastern Daylight Time)
As you specify the 6 faces of a cube with a number of vertices and triangles
You can form a mental picture for each face and see how a screw will advance and which vertices need to come first to provide that anti-clock-wise rotation.
satya - Sat Aug 18 2012 11:26:18 GMT-0400 (Eastern Daylight Time)
Typically OpenGL can hide back facing surfaces which is called CULLING
Typically OpenGL can hide back facing surfaces which is called CULLING
Search for: Typically OpenGL can hide back facing surfaces which is called CULLING
satya - Sat Aug 18 2012 11:29:05 GMT-0400 (Eastern Daylight Time)
Here is a link to read more on this aspect
satya - Sat Aug 18 2012 11:30:46 GMT-0400 (Eastern Daylight Time)
Here is an interesting gl function: glPolygonMode
//paint front facing
//Use a surface
glPolygonMode(GL_FRONT, GL_FILL);
//paint back facing
//Only use outlines. don't fill the triangle
//just the perimeter
glPolygonMode(GL_BACK, GL_LINE);
satya - Sat Aug 18 2012 11:31:35 GMT-0400 (Eastern Daylight Time)
Possible values
GL_FRONT_AND_BACK,
GL_FRONT, or
GL_BACK
GL_POINT,
GL_LINE, or
GL_FILL
satya - Sat Aug 18 2012 11:32:40 GMT-0400 (Eastern Daylight Time)
The later 3 you can use for interesting effects
For example to draw a cube that is filled with color but also has distinct edges, you may want to draw it twice, first as a fill and then again as a line!!
satya - Mon Aug 20 2012 09:52:18 GMT-0400 (Eastern Daylight Time)
Read this article on depth and hiding hidden surfaces
satya - Mon Aug 20 2012 09:52:55 GMT-0400 (Eastern Daylight Time)
Here is how to hide hidden surfaces quite easily
// Enable depth test
glEnable(GL_DEPTH_TEST);
// Accept fragment Or Draw a pixel
// if it closer to the camera than the former one
glDepthFunc(GL_LESS);