Archived

This topic is now archived and is closed to further replies.

racer_x

Why do my objects vanish when far into the screen?

Recommended Posts

Hi. I''m getting started with OpenGL and I''m writing a program that for now simply displays a few objects. A problem I''m having is that objects simply disappear after they are into the screen a certain amount. They are clearly visible, then the textures start to get jagged around each edge and then the thing just gets sucked into the blackness of the background. I would think it would need to be MUCH further back before it disappears. There is definitely something wrong because this doesn''t happen with NeHe''s tutorial''s. Can someone figure this out? Thanks! -E

Share this post


Link to post
Share on other sites
Are you using Translatef, Rotatef, and/or Scalef? When you set them on one object they may be affecting others. Maybe try using glPushMatrix() and glPopMatrix().Double check them. Also, you may want to increase you clipping area.


-----------------------------
"There are ones that say they can and there are those who actually do."

"...u can not learn programming in a class, you have to learn it on your own."



Edited by - cMADsc on February 6, 2002 11:22:06 PM

Share this post


Link to post
Share on other sites
just realise though, that the depth buffer has only so much accuracy, and that accuracy has to be scaled accross the entire scene, so when you increase you far clip plane, you reduce the over-all accuracy of the depth buffer, and you can get very ugly artifacts where objects ''fight'' for pixels...
eg,
have you ever noticed decals flickering in a game before? this is an example of this...

Share this post


Link to post
Share on other sites
Gah I wish people would just be nice to other people without resorting to unnecessary comments. Some people learn stuff by copy-pasting tutorials. Just because you didn''t, you shouldn''t bash other people trying to learn what is afterall no an easy thing.



Gyzmo
==============================
"Well is the world standard" - The Alchemist
"Not in Canada!" - jonnyfish

Share this post


Link to post
Share on other sites
Siaspete, if you knew how much time I've spent researching OpenGL on the Internet you'd take back what you said. I have a million bookmarks for all kinds of API sites.

ANYWAY. I was looking into the clipping plane as a possibility, but I never call glFrustum (I'm positive) and I don't remember calling glPerspective, but I don't have the code in front of me now. The annoying this is that the NeHe tutorials don't do this (I've tried sending an object far far away into the background and it is still crisp and visible) and my project is based around an early NeHe tutorial.

I suspect it is a depth buffer issue because of the horrible jagged edges that appear when it is far away, but it shouldn't be happening because it's not that far away!

Thanks for your replies so far. Any other suggestions? I'm going to try to fix it tonight.
-E

Edited by - racer_x on February 7, 2002 12:05:38 PM

Share this post


Link to post
Share on other sites
It''s ''gluPerspective'', not ''glPerspective''. You probably have it right in your code, but if you ever try to code a gl program without any doc''s, your going to be wondering why it doesn''t work.

If you didn''t call it, you probably have a slightly stretched isometric view. I''m not sure what the default clipping volume is, so you really should call ''gluPerspective'' or a related function to make sure it is what you think it is.

The depth buffer is setup so that the closer you are, the more accuracy it is, i.e., the first half of possible depths are in the first quarter of the volume.

If you really need alot of accuracy in a huge volume, you could just use a huge value for the back clipping plane, turn off depth testing, and sort the polygons farthest first. You''d have to do that if they were transparent, anyway.

Some people draw a black quad to clear the screen. If you''re one of these people, don''t be. It could be you''re problem if you are.

Good luck with OpenGL.

Share this post


Link to post
Share on other sites
Okay, you guys rock. Here''s the story:

I was basing my entire project around the NeHe tutorial #5, which if you look at his site is basically just a stupid triangle or something. Therefore the gluPerspective was set to clip near at 0.1f and far at 100.0f!!! So I changed it to 2.0f and 1000.0f and now it looks about 769.5 times better.

thanks guys!
-E

Share this post


Link to post
Share on other sites