a Z-buffer problem

Hello :slight_smile:
I seem to have a problem with the Z-buffer:
http://img394.imageshack.us/img394/5418/zwrong8cd.jpg
As you can see, The part circled in green - should not be seen - it intersect the front face.
I have no idea why it happens…
This is how i draw the outline:

glColor3f(1.0,0.0,0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0, 1.0);
WireframeDraw(GL_POLYGON);
glDisable(GL_POLYGON_OFFSET_FILL);
glColor3f(1.0,1.0,1.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
WireframeDraw(GL_POLYGON);

and this is how i initialize the openGL:

int w,h;
GetClientSize(&w, &h);
glClearColor(0,0,0,0);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);	
glLoadIdentity();
float ratio = (float)((float)w/(float)h);
gluPerspective(60 ,ratio, 1, 150); 
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDepthFunc(GL_LEQUAL);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

can anybody tell me what’s wrong?
thanks :slight_smile:

looks like you don’t have any z-buffer or you did not enable depth test. post your context creation code.

Originally posted by shelll:
looks like you don’t have any z-buffer or you did not enable depth test. post your context creation code.
What do you mean by " don’t have any z-buffer"?
How can i fix it?
And i DID enable the depth test :slight_smile:

show us your pixelformatdescriptor settings

Originally posted by shelll:
show us your pixelformatdescriptor settings
I use wxWindows so i don’t really deal with this stuff.
The wxWindows sets the windows and the openGL itself… :frowning:

is there any initialization function in wxWidgets for ogl control? if so, show that one please.

Ok, I believe i now have a 32-bit z-buffer, but still i have this problem…

maybe backface culling and wrong faces orientation ?