Hey people,
I have a problem with my renderer where i want to depth test on my md5 mesh so you can´t see through it, but when i do set glEnable(GL_DEPTH_TEST), the model just disappears and i have searched around the internet and i have found people having the same problem and i tried the solutions offerd but nothing has helped.
I set glDisable(GL_DEPTH_TEST);, glDepthFunc(GL_LEQUAL); and glClearDepth(1.0f); for the default GL state (when first initialized) and before rendering the mesh, i set glClear(GL_DEPTH_BUFFER_BIT); and glEnable(GL_DEPTH_TEST);.
I do request 24 bit depth buffer from the context and i use gluPerspective(45.0f, glConfig.screenWidth/glConfig.screenHeight, 3.0f, 0.0f);, now i just toyed around with zFar and zNear so thats why its 3 and 0.
Does anyone have any clue to what im doing wrong or missing here?.
Here is where i don´t use depth test
http://img408.imageshack.us/img408/5843/namnlsc.jpg
And here is where i use depth test
http://img809.imageshack.us/img809/5461/namnls2y.jpg
- Thanks
GL_DEPTH_TEST problem, help!
You have the planes in the wrong order. The second last parameter is the near plane and the last is the far plane. The far plane must be greater than the near plane, and 0 is not greater than 3.
Furthermore, even if you correct your code and swap them (which I assume is what you intended), the near plane must be a positive value.
Furthermore, even if you correct your code and swap them (which I assume is what you intended), the near plane must be a positive value.
Quote:Original post by Brother Bob
You have the planes in the wrong order. The second last parameter is the near plane and the last is the far plane. The far plane must be greater than the near plane, and 0 is not greater than 3.
Furthermore, even if you correct your code and swap them (which I assume is what you intended), the near plane must be a positive value.
Okey so i did swap them to 0.1f and 3.0f but then it wont draw at all with depth test on :s. It seems that setting zFar to 1000.0f makes it draw but depth test is still failing (it only draws the skeleton).
Reduce your code to an absolute minimum working program by removing things that don't affect the problem, and post it here. More often than not, this process of isolating the problem actually helps you find it.
Quote:Original post by Brother Bob
Reduce your code to an absolute minimum working program by removing things that don't affect the problem, and post it here. More often than not, this process of isolating the problem actually helps you find it.
Yeah, i was thinking that too, my renderer is kinda messy so im going to rewrite it and go by "trail and error" testing and see what the problem is.
Try pushing the model away a bit. I find that helps when working in perspective.
glTranslatef(0.0f, 0.0f, -10.0f);
glTranslatef(0.0f, 0.0f, -10.0f);
Quote:Okey so i did swap them to 0.1f and 3.0f but then it wont draw at all with depth test on :s. It seems that setting zFar to 1000.0f makes it draw but depth test is still failing (it only draws the skeleton).This is because the geometry was getting clipped against the far plane. Usually, you want to make the distance between the planes large for testing, and reduce them for better precision.
I agree that the issue is probably something that could be fixed by some housekeeping, but it would also be nice to have some code to look at here.
-G
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement