View Full Version : glOrtho and Clipping Planes

11-09-2006, 01:10 PM
First of all, thanks to everyone for all the help I have been getting. It is great to be able to come to a forum and have questions resolved (even though they are probably easy for all the experts).

I am trying to fit an image in a OpenGL window and it appears to be getting "clipped" when I rotate it. I am using glOrtho() because it seemed to be the easiest to start with. The image I am "drawing" is a series of Triangular polygons that are very large in number (~58,000). A small snippet of the code I am using follows (using the Java OpenGL bindings JOGL):

public void reshapeGLAutoDrawable drawable, int x, int y, int width, int height) {
GL gl = drawable.getGL();
gl.glViewport(0, 0, width, height);
gl.glOrtho(-50, 50, -50, 50, -50, 50);

}// End of reshape()

The Image looks great, just when I rotate it the ends are visibly "clipped" at certain points. I am sure this is probably a simple problem that maybe just needs some "tweeking" but I just wanted to make sure it wasn't something obvious in my code first. ANY help/hints would be great.

Thanks in advance.

11-09-2006, 01:15 PM
Never mind,

I just found the problem (it was some stupidity on my part). I just shifted the near and far parameters to increase in magnitude. However, since I chose glOrtho in the first place just for simplicity - can anyone suggest a better function? The desire is for a more realistic rendering, not necessarily the one provided by glOrtho.


11-10-2006, 01:45 AM
The desire is for a more realistic rendering, not necessarily the one provided by glOrtho.What do you mean by 'more realistic'?
If you want 3D rendering, then you should use glFrustum and enable depth test.

11-10-2006, 10:21 AM
I guess I am looking for something that can allow me to zoom in and out on an image in the most efficient way.

11-10-2006, 02:16 PM
Am I right, that greater magnitude between near and far means more artifact on the rendered scene?

11-11-2006, 08:01 AM
Simplest way to zoom is to use gluPerspective and change the field of view parameter.
With glOrtho you can "zoom" only by changing the left, right, bottom, and top parameters.

Yes, the smaller the ratio zFar/zNear the better the depth buffer precision (while using the same number of depth bits).

11-11-2006, 10:14 AM
Thanks to everyone for all the input. I will certainly give the gluPerspective a try.