PDA

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



kolkon
12-16-2013, 05:20 PM
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?

tonyo_au
12-16-2013, 11:17 PM
Please supply some code

kolkon
12-17-2013, 03:28 PM
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

tonyo_au
12-17-2013, 04:26 PM
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

kolkon
12-17-2013, 04:36 PM
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?

tonyo_au
12-17-2013, 04:41 PM
That doesn't make any sense but have a read of http://www.opengl.org/archives/resources/faq/technical/viewing.htm it might help solve your problem

tonyo_au
12-17-2013, 04:44 PM
Also make sure window.clear and world.draw aren't changing anything

kolkon
12-18-2013, 07:43 PM
i've got it working with this now:


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!