Results 1 to 4 of 4

Thread: explain please

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2002
    Location
    Port Dickson, Negeri Sembilan, Malaysia
    Posts
    13

    explain please

    hi, can anyone explain the sub-program below pls:

    void reshape (int w, int h)
    {
    glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    gluPerspective(65.0, (GLfloat) w/(GLfloat) h, 2.0, 20.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef (0.0, 0.0, -5.0);
    }

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: explain please

    Hi !

    // Define the viewport, origin will be in
    // the lower left corner and the viewport
    // will use up all of the window, we tell
    // OpenGL to use all of the window area to
    // render output into.
    glViewport (0, 0, w, h);

    // Select projection matrix mode, all matrix
    // operations will modify the projection
    // matrix
    glMatrixMode (GL_PROJECTION);

    // Load the projection matrix with an
    // identity or unit matrix, this is a matrix
    // that does not do anything at all, like
    // 1234*1 will still be 1234
    glLoadIdentity ();

    // We want a perspective projection with a
    // view angle of 65 degrees, a smaller
    // angler will "zoom" in because a smaller
    // area will be displayed in the viewport.
    // We set the aspect ratio to w/h, this
    // will make sure the a quad that has the
    // same width as height will look square.
    // The 2.0 is the near clipping plane,
    // anything that is closer to the viewer
    // then 2.0 will be clipped away, same thing
    // with 20.0 but this is the far clipping
    // plane, anything beyond that point is
    // clipped.
    gluPerspective(65.0, (GLfloat) w/(GLfloat) h, 2.0, 20.0);

    // Switch to modeview matrix mode.
    glMatrixMode(GL_MODELVIEW);

    // Load it with an identity matrix.
    glLoadIdentity();

    // Translate the coordinate system 5
    // points along the Z axis.
    glTranslatef (0.0, 0.0, -5.0);

    Thats it, remember that you cannot move the camera in OpenGL, the camera is always at
    0,0,0 looking down the Z axis, so to move things you have to transform the objects instead.

    If you have a peek at the FAQ on this website I think you will be able to find lots of useful stuff.

    Mikael

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2002
    Location
    Port Dickson, Negeri Sembilan, Malaysia
    Posts
    13

    Re: explain please

    what is the different between (GLsizei)w and (GLfloat)w ?

    by the way, how can i combine two cubes and make it into one straight line?

    thanks

    [This message has been edited by always1 (edited 07-16-2002).]

  4. #4
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: explain please

    Hi !

    the (GLsizei) does not do much, you don't need it, it's a typecast fron one interger type to another, but the (GLfloat) is needed to get a floating point result.

    100 / 75 = 1
    (GLfloat) 100 / (GLfloat) 75 = 1.3333333

    That's the reason for it.

    I am not sure what you mean with the cubes ?

    Mikael

Similar Threads

  1. Can anyone explain glPolygonOffset?
    By billy in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-12-2002, 01:38 AM
  2. would you like to explain it for me ?
    By victorswan in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 02-11-2002, 11:51 PM
  3. would you like to explain it for me ?
    By victorswan in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-09-2002, 11:17 AM
  4. please explain for me
    By victorswan in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-19-2001, 03:10 AM
  5. ase explain
    By odysseykre in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 01-30-2001, 01:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean