gluPerspective
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/
You may want to try posting this in the OpenGL board if you still aren't getting responses here.
Matt Hughson
Matt Hughson
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.
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.
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 PromitQuote: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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement