Public Group

# gluPerspective

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

## 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 on other sites
You may want to try posting this in the OpenGL board if you still aren't getting responses here.

Matt Hughson

##### Share on other sites
Quote:
 Original post by matthughsonYou 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 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

##### Share on other sites
Quote:
Original post by Promit
Quote:
 Original post by matthughsonYou 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

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 11
• 13
• 87
• 11
• 10
• ### Forum Statistics

• Total Topics
632973
• Total Posts
3009617
• ### Who's Online (See full list)

There are no registered users currently online

×