Jump to content
  • Advertisement
Sign in to follow this  
mike74

gluPerspective

This topic is 4787 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does gluPerspective make any weird changes to the OpenGL matrices besides adding perspective? Basically, I was just doing: glLoadIdentity(); Now, I'm doing: glLoadIdentity(); gluPerspective(90, yadda, yadda, yadda); When I did a glTranslatef(0, 0, -10) call initially and placed a point, it would be at (0, 0, -10). However, now with gluPerspective in place, the point is now at (0, 0, 10) after a glTranslatef(0, 0, -10). What's up with that? Mike C. http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by matthughson
You may want to try posting this in the OpenGL board if you still aren't getting responses here.

Matt Hughson


Three and a half hours after posting, a bit hasty no?

Anyway, mike74, the perspective matrix affects how your points move. I can think of a couple things:
1) Maybe something is important in the "yadda"s.
2) You should call gluPerspective with the matrix mode set to projection, then switch back to modelview, like so:

glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( ... );
glMatrixMode( GL_MODELVIEW );

If you try to apply the perspective without doing that, it will affect the model view matrix in weird ways and generally not do the right things.

Share this post


Link to post
Share on other sites
What I think the conflict is that the gluPerspective() function places a matrix onto the stack. Well, a matrix at its most basic changes between coordinate systems. For example, a glTranslatef(5.0f, 5.0f, 5.0f) will place the point {5.0f, 5.0f, 5.0f} at the origin.

The matrix created by gluPerspective not only adds perspective to the scene, it also changes the coordinate system. In this case, it switched around the z axis. The z values increase as they go forward from the origin (0, 0, 0), and decrease as they go backwards from the origin.

Z AXIS
<-----------|----------->
-4 -3 -2 -1 0 1 2 3 4

Hopefully that solves your problem.

Share this post


Link to post
Share on other sites
Quote:
Original post by Promit
Quote:
Original post by matthughson
You may want to try posting this in the OpenGL board if you still aren't getting responses here.

Matt Hughson


Three and a half hours after posting, a bit hasty no?


It's never too early to help someone out [wink].

Matt Hughson

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!