PDA

View Full Version : a Z-buffer problem



white skies
02-18-2006, 07:09 AM
Hello :)
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 :)

shelll
02-18-2006, 08:40 AM
looks like you don't have any z-buffer or you did not enable depth test. post your context creation code.

white skies
02-19-2006, 08:49 AM
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 :)

shelll
02-20-2006, 02:10 AM
show us your pixelformatdescriptor settings

white skies
02-20-2006, 06:58 AM
Originally posted by shelll:
show us your pixelformatdescriptor settingsI use wxWindows so i don't really deal with this stuff.
The wxWindows sets the windows and the openGL itself... :(

shelll
02-20-2006, 07:26 AM
is there any initialization function in wxWidgets for ogl control? if so, show that one please.

white skies
02-25-2006, 08:17 AM
Ok, I believe i now have a 32-bit z-buffer, but still i have this problem...

gemelli_d
02-27-2006, 12:44 AM
maybe backface culling and wrong faces orientation ?