depth problem

Started by
11 comments, last by Goober King 19 years, 2 months ago
Quote:Original post by chowe6685
Looks like your far clip plane is too close. What do I mean by this?
Opengl uses 6 planes to define the viewing volume - in the case of gluPerspective it happens to be a frustum. Four of the planes form the borders of your screen. The exact position of these planes is set by the call to gluPerspective. It is possible to set them more precisely with glFrustum - but for many applications gluPerspective is more than sufficient. The last two planes are the near and far plane - their distance from your screen is set by the last two parameters to gluPerspective. In your case they are at depths .1 and 500, which means that only objects within this depth range will be drawn. The screenshot you posted shows that the back of the metal box thing is going outside the clip volume and thus not being drawn. The solution is simply to change the 500 to some larger value like 1000 or 1500.
A word of caution. The depth buffer is scaled according to the distance between the near and far planes. Pushing the far plane out to far or pulling the near plane in too close can cause depth buffer inaccuracies especially in distant objects. The way you have things set you will have no problems - but as you start adjusting the near and far clip planes be aware that you want them as close as possible. In particular the near plane should be as far as you can tolorate - .5 is more than fine but don't pull it closer unless you have to.
I hope that this helps


Well I've tried using 1000, 100, 50, 2000 and nothing changes. I've changed the viewing angle from 15-180 with no visible changes. 180 should have made it all very squishy. The gluPerspective function dosn't seem to be doing anything. It cannot return an error so I can't check to see if it fails. I've also tried fiddling with glFrstrm but that also didn't seem to affect anything, but in all fairness, I'm not sure how to be sure I'm using it correctly.
------------------------------------------------------------- neglected projects Lore and The KeepersRandom artwork
Advertisement
Quote:Original post by Goober King
Well I've tried using 1000, 100, 50, 2000 and nothing changes. I've changed the viewing angle from 15-180 with no visible changes. 180 should have made it all very squishy. The gluPerspective function dosn't seem to be doing anything. It cannot return an error so I can't check to see if it fails. I've also tried fiddling with glFrstrm but that also didn't seem to affect anything, but in all fairness, I'm not sure how to be sure I'm using it correctly.



If changing those parameters didn't do anything noticeable, you are most likely resetting the projection matrix elsewhere in your program, making that call to gluPerspective()/glFrustum() meaningless. Check the rest of your code for any place where you switch to the projection matrix and make sure you aren't altering it.
Quote:Original post by Kalidor
Quote:Original post by Goober King
Well I've tried using 1000, 100, 50, 2000 and nothing changes. I've changed the viewing angle from 15-180 with no visible changes. 180 should have made it all very squishy. The gluPerspective function dosn't seem to be doing anything. It cannot return an error so I can't check to see if it fails. I've also tried fiddling with glFrstrm but that also didn't seem to affect anything, but in all fairness, I'm not sure how to be sure I'm using it correctly.



If changing those parameters didn't do anything noticeable, you are most likely resetting the projection matrix elsewhere in your program, making that call to gluPerspective()/glFrustum() meaningless. Check the rest of your code for any place where you switch to the projection matrix and make sure you aren't altering it.


Well you may be right. For whatever reason I cannot figure out, makeing the calls outside of the OpenGL init function works. Right now it sets it when it starts up the Title screen instead. I would really rather not put it there but until I figure out what is causing the problem I may be stuck. Where ever it goes its working now. That was enough to get me to a solution so koodos and all.
------------------------------------------------------------- neglected projects Lore and The KeepersRandom artwork

This topic is closed to new replies.

Advertisement