Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: gluPerspective Question

  1. #1
    Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    265

    gluPerspective Question

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

    Thank You.

    - VC6-OGL

  2. #2
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Los Angeles, CA
    Posts
    208

    Re: gluPerspective Question

    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.

  3. #3
    Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    265

    Re: gluPerspective Question

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

    Code :
    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).]

  4. #4
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    Re: gluPerspective Question

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

  5. #5
    Senior Member OpenGL Pro cass's Avatar
    Join Date
    Feb 2000
    Location
    Austin, TX, USA
    Posts
    1,058

    Re: gluPerspective Question

    gluPerspective belongs in the PROJECTION matrix.

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

    Thanks -
    Cass
    Cass Everitt -- cass@xyzw.us

  6. #6
    Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    265

    Re: gluPerspective Question

    Thanx,

    I figured out what I was missing.

    - VC6-OGL

  7. #7
    Junior Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    124

    Re: gluPerspective Question

    Originally posted by cass:

    gluPerspective belongs in the PROJECTION matrix.

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

    Thanks -
    Cass
    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.

  8. #8
    Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    265

    Re: gluPerspective Question

    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

  9. #9
    Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    265

    Re: gluPerspective Question

    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).]

  10. #10
    Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    265

    Re: gluPerspective Question

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •