Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: gluPerspective is "centered" on lower left corner. i want it in the center

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2013
    Posts
    9

    gluPerspective is "centered" on lower left corner. i want it in the center

    i'm using opengl 4 on windows 8.

    When i call gluPerspective, the focus or center of the view seems to be in the corner rather than the center. this is depicted in the following link to an image:

    ://i*imgdiode*com/0wu5E0*png
    (add http in front and replace all * with . to get it working)

    On the left side is how a wireframe cube would look if i used gluPerspective. The view is centered on the lower left corner.

    On the right side is how i want the cube to look. The view is centered on the center, and all edges of the cube are visible.

    how can i do this?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    Please supply some code

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2013
    Posts
    9
    my post was denied for some reason involving urls and forbidden words
    instead, here is a link to my code and explanation. link was modified in the same way as the image was as descriped in the first post. thank you

    ://pastebin*com/3VBCwYKA

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    gluPerspective in GL_MODELVIEW


    gluPerspective should not be used with the view-model matrix. It defines the projection. The view-model matrix defines the position of the cameras and objects in the world. You uses gluLookAt to position the camera.
    You might want to look at
    http://www.songho.ca/opengl/gl_transform.html

  5. #5
    Junior Member Newbie
    Join Date
    Dec 2013
    Posts
    9
    i understand. however, i cannot get gluPerspective to work in GL_PROJECTION. (the resulting display is the same as if i left the gluPerspective line out completely. do you have any idea why this might be the case?

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    That doesn't make any sense but have a read of http://www.opengl.org/archives/resou...al/viewing.htm it might help solve your problem

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    Also make sure window.clear and world.draw aren't changing anything

  8. #8
    Junior Member Newbie
    Join Date
    Dec 2013
    Posts
    9
    i've got it working with this now:

    Code :
    def display():   
        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
        glShadeModel(GL_SMOOTH)
        glLoadIdentity()
     
    def reshape():
        glShadeModel( GL_FLAT )
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluPerspective(120., window.width / float(window.height), .1, 1000.)
        glMatrixMode(GL_MODELVIEW)
        glTranslatef(0.,0.,-100.))

    thanks!

Posting Permissions

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