Not understanding Culling ????

Im new to openGL and I do have the redbook as my reference but I feel like Im missing something in regards to rendering polygons.

I created a model of a cube from which I boolean diff’d a sphere which had a slightly larger diameter than the width of the cube. This left me with a nice interior volume to the cube and nifty hole on each face of the cube. I saved this as a raw triangle file and used this to load vertices into my openGL tutorial program.

My problem is that this model does not render solid and I have toyed with every permutation of Culling and not-culling I can imagine…

Here are a few images from my app

Cube in line mode with front or back face culling enabled (both give the same result)
http://digitalhound.biz/cube1.JPG

Now 2 views with Culling disabled…
http://digitalhound.biz/cube2.JPG
http://digitalhound.biz/cube3.JPG

What is going on here???
Is this some artifact of how Im exporting the model???

Basic code:
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPolygonMode(Gl.GL_FRONT,Gl.GL_FLAT);
Gl.glPolygonMode(Gl.GL_BACK,Gl.GL_FLAT);
//Gl.glCullFace(Gl.GL_FRONT);
//Gl.glEnable(Gl.GL_CULL_FACE);
Gl.glLoadIdentity();
Gl.glTranslatef(0,0,0);
Gl.glOrtho(Xmin2,Xmax2,Ymin2,Ymax2,Zmax2,Zmin2);

Thanks for any pointers you can give…

Edit:
You need to draw solid with back face culling on.

An optical illusion makes the results appear the same but they are not. You also may have some issues with zbuffering, it looks like you don’t have zbuffering on, or that it lacks precision.

you can also mess around with glCullFace(GL_FRONT)
or glCullFace(GL_BACK)

there is also you’re ‘winding’ which describes if the vertices to your polygon are defined in a clockwise or counter clockwise fashion (set this using: glFrontFace(GL_CCW or GL_CW)). OpenGL uses this information to determine whether your polygon is front facing or back facing by calculating a determinant.

anyway, enough about culling.
your problem seems to be depth testing.

try this:
in your initialization:
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);

then in your render ‘OR’ in GL_DEPTH_BUFFER_BIT
into your glClear() call (glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | …)

cheers.

edit: looks like dorbie got to you as I was writting this :slight_smile:

Aeluned your solution worked like a champ!!!
Your help has been much appreciated!

Thanks
mccainz