I’m totally new to OpenGL, and am confused about how to do perspective. Right now I have a module that draws texture mapped squares using Ortho projection:
When I used her setting, I just get a black screen. And also even if I can experiment around with x and ys, I also need to detect mouse clicks, which don’t work anymore.
I have a slight feeling you might be looking in the wrong direction ( try looking towards -ve Z).
Also, what are the Z co-ordinates of the objects you are drawing? If they are less than 1.0, they will be clipped by the front plane. Try placing your initial camera position (look-at point) right in front of one of your objects (same x and y) and slightly back from it (-z).
The commented out glFrustrum works the same as the gluPerspective. Seems like what I specify for near and far doesn’t matter as long as the eyez for gluLookAt is set to be the same as near.
I’m slowing understanding how these work. One thing I’m confused is the z coordinates. So many sites online say that for glFrustrum, (left, bottom, -zNear) and (right, top, -zNear) are mapped to the lower-left and upper-right corners of the window. So in my case, the z-coordinate right on the window is -2.0? And then gluLookAt sets the zEye at +2.0. Is this +2.0 relative to the window or to z=0.0?
Also, does the same thing work for gluPerspective? I mean, is the surface of the window at z = -near?