I am going through the OpenGL guide on the OpenGL homesite and I am having issues with projection perspectives. I am able to use glOrtho() and get things to look like they should. However, I am now trying to add perspective to my view. So I’ve replaced glOrtho() with glFrustum and I’m not getting what I think I should get.
I use:
gl.glFrustum(-(double)getWidth()/2, (double)getWidth()/2, -(double)getHeight()/2, (double)getHeight()/2, 2000.0, 20.0);
and I get almost what I want, but it behaves incorrectly. I am working in fullscreen mode and the view is centering the origin correctly. However, the perspective is reversed with objects getting larger the further back they are instead getting larger the closer they are. I suspect it has to do with my near value being large and my far value being small, which is the opposite of how I think it should be. If I reverse them, though, I get a really wierd result where my objects stretch immensely like looking at them through a fun house mirror.
I guess my question is, how does glFrustrum work? Am I missing a key component? I do enable GL_DEPTH_TEST and I clear the depth buffer at the start of every display call.