Seethrough models problem.

Hi,

I have a small OBJ importer application written with QT 2010.04 and a basic window for displaying and rotating the imported
model. The problem is that the models are partly see-through. This might be due to culling settings
or so, but cannot figure out the solution. See the screenshots for reference.

Here is what i have enabled in OpenGL, might contain some useless stuff as well, since tried lots of stuff:

glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);

glEnable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable( GL_NORMALIZE );
glMatrixMode( GL_MODELVIEW );

glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);

glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);

GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 50.0 };
GLfloat light_position[] = { 50.0, 50.0, 50.0, 0.0 };

GLfloat global_ambient[] = { 0.5f, 0.5f, 0.5f, 1.0f };
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);

glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);

Painting code:

void GLWidget::paintGL()
{
glPushAttrib(GL_ALL_ATTRIB_BITS);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslated(0.0, 0.0, -10.0);
glScalef(0.1, 0.1, 0.1);
    glRotated(xRot / 16.0, 1.0, 0.0, 0.0);
    glRotated(yRot / 16.0, 0.0, 1.0, 0.0);
    glRotated(zRot / 16.0, 0.0, 0.0, 1.0);

glCallList(object);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopAttrib();
drawLegend();
swapBuffers();

}

http://img695.imageshack.us/img695/6973/cowshot.png
(that is the backside of the cow model, the best view to see the problem, sorry:))

Help appreciated.

try calling glCullFace(GL_BACK); after glEnable(GL_CULL_FACE);
to specified backface culling

If you still only see the back face of the model , may be the vertex order of model are not store in counter clockwise format (OpenGL’s default) try changing glFrontFace(GL_CCW) to glFrontFace(GL_CW).

Most of the modeling package has an option to specified handed of the export mesh make sure you set them to right hand (counter clock wise as front face) before exporting

I tried those all, but this was after all a depth buffer problem, i had not set up near or far planes at all, the call to

glDepthRange(0,1);

was missing, and

glEnable(GL_DEPTH_TEST);

was only present in my initializeGL -function.