gluPerspective Question

Is there a way to update gluPerspective by using LoadIdentity or anything else?

Thank You.

  • VC6-OGL

gluPerspective effectively makes a matrix from the argument list and then calls glMultMatrix with it. In other words, gluPerspective is not a matrix, it just modifies the active matrix.

I am trying to create a camera scene by changing the gluPerspective, for example:

void reshape( int w, int h ) {
h = h < 1 ? 1 : h;
n = 1.0;

glMatrixMode( GL_PROJECTION );
glLoadIdentity();
    
glViewport( 0, 0, w, h );

ratio = n * w / h;
gluPerspective( 75.0, ratio, 1.0, 1000.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}

So far n = 1, but if I change n from 1 to 2, the perspective view does not update. Why?

  • VC6-OGL

[This message has been edited by VC6-OGL (edited 01-01-2003).]

[This message has been edited by VC6-OGL (edited 01-01-2003).]

[This message has been edited by VC6-OGL (edited 01-01-2003).]

[This message has been edited by VC6-OGL (edited 01-01-2003).]

[This message has been edited by VC6-OGL (edited 01-01-2003).]

gluPerspective( 75.0, ratio, 1.0, 1000.0 );
belongs in the modelview not projection

gluPerspective belongs in the PROJECTION matrix.

From your description it looks like changing n should have an obvious effect.

Thanks -
Cass

Thanx,

I figured out what I was missing.

  • VC6-OGL

Originally posted by cass:
[b]
gluPerspective belongs in the PROJECTION matrix.

From your description it looks like changing n should have an obvious effect.

Thanks -
Cass[/b]

Come on Cass you know that gluPerspective is completely valid for any matrix mode. Imagine the scene geometry (or texture coords for that matter) taking on perspective !!! Ahhh my head hurts trying to picture that. ( :

Devulon

The only reason I made this post is because I haven’t posted anything in a while. Currently occupied with a massive 3dStudio Max Exporter.

My Program works just fine if I define gluPerspective in PROJECTION Matrix Mode. What really needs to go in the MODELVIEW Matrix Mode is glTranslatef or gluLookAt, which I have defined in my Display function for camera motion.

  • VC6-OGL

Now, what I forgot to do before was, glLoadIdentity was not set in my function using ‘n’, so I could not change Perspective view, but changing float n from 1 to 2 was successful, but it never changed the view as ‘n’ requested. After using glLoadIdentity, I set n to equal 2 and my Perspective changed. So, using gluPerspective in PROJECTION Matrix Mode does not change the fact of using gluPerspective in MODELVIEW or any other Matrix Mode.

Thank you, Cass.

  • VC6-OGL

[This message has been edited by VC6-OGL (edited 01-02-2003).]

One more thing, my screen blanks out defining gluPerspective in MODELVIEW Matrix Mode before or after glLoadIdentity, including glOrtho or almost anything besides glTranslatef or gluLookAt.

  • VC6-OGL

Originally posted by Devulon:
[b] Come on Cass you know that gluPerspective is completely valid for any matrix mode. Imagine the scene geometry (or texture coords for that matter) taking on perspective !!! Ahhh my head hurts trying to picture that. ( :

Devulon
[/b]

Certainly gluPerspective is completely valid for any matrix stack. It’s used regularly in the texture matrix for projective texture mapping, for example.

What I wanted to make clear is that it’s fine (and almost certainly most common) to have gluPerspective in the PROJECTION matrix.

Thanks -
Cass

Devulon, you may want to check out the Red Book to refer to the examples. Most of them seem to use glOrtho or gluPerspective in the PROJECTION Matrix Mode. Red Book

Chapter 3: Viewing

  • VC6-OGL