gluPerspective

Started by
3 comments, last by matthughson 18 years, 9 months ago
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/
Mike C.http://www.coolgroups.com/zoomer/http://www.coolgroups.com/ez/
Advertisement
You may want to try posting this in the OpenGL board if you still aren't getting responses here.

Matt Hughson
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]
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.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
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.
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

__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]

This topic is closed to new replies.

Advertisement