PDA

View Full Version : can not get right perspective view of model



steven25000
08-10-2011, 01:07 PM
Hi everyone,
I'm new here and I met a problem of implementation of correct perspective view of a mesh.
I am using realbasic, so the code may look a little different.

Here's how I did

glMatrixMode(GL_PROJCTION)
glLoadIdentity()

if perspectiveSwitch=true then
glFrustum(-1.0,1.0,-1.0,1.0,99.0,1000.0)
else
glOrtho(-1.0,1.0,-1.0,1.0,0.01,1000.0)
end

glMatrixMode(GL_MODELVIEW)
glLoadIdentity()

glClearColor(1.0,1.0,1.0,1.0)
glClearDepth(1.0)

glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LEQUAL)
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
glEnable(GL_POLYGON_SMOOTH)
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST)

draw_mesh()

When I change between the perspective view and the orthogonal view, I just don't see any change.

Where did I make the mistakes?

Thanks for your help.

Regards,
Steven

Ehsan_Liverpool
08-11-2011, 12:04 AM
Wouldnt it be better to not change your frustum/ortho and use the camera to change your view? you could use the gluLookAt command and change where your camera is positioned.

steven25000
08-11-2011, 11:07 AM
Thanks Ehsan_Liverpool, I found the bug.
I shift the model too far away from the viewer, so the perpective effect is not that obvious, when I move it towards the viewer, it looks much better.