glViewport(0, w, h, 0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 1, 0, 1, -100000.0, 100000.0);
glMatrixMode(GL_MODELVIEW);
If I comment the ortho part and I render this mesh with a perspective projection it looks perfect. The problem is with the orthographic one.
I don't have the exact source code with me right now. I'll try to bring it on later.
Thanks in advance.
[Edited by - owl on June 18, 2008 9:40:10 AM]
Rendering a (cal3D) 3D mesh in glOrtho: faces get front/back messed up. FIXED
Started by owl, Jun 17 2008 02:22 PM
3 replies to this topic
#1 Banned - Reputation: 356
Posted 17 June 2008 - 02:22 PM
Hi,
I'm trying to render a 3D mesh within an orthographic projection and the mesh faces are not being rendered in the proper way, the ones behind appear mixed/screwed up with the ones on the front.
This gets more obvious when you rotate the mesh.
With or without enabling GL_DEPTH_TEST I'm getting the same result.
The mesh is being rendered as a vertex array with glDrawElements (as they do in the CAL3D examples)
I'm setting glOrtho as usual. Light0 is on and set up, blending is on, texturing is off.
I set it like this:
Sponsor:
#3 Members - Reputation: 1789
Posted 17 June 2008 - 08:25 PM
In addition to zimerman's answer: If you compare your set-up using glOrtho with your set-up using glFrustum, then you'll see a significant difference in the value of zNear. You've set zNear to -100000.0 for glOrtho, i.e. a value far behind the camera. Then, of course, scene stuff located behind the camera becomes visible, too. It is questionable whether this is really "as usual" for glOrtho. However, for glFrustum you use a relatively small zNear in front of the camera, didn't you? So set zNear for glOrtho to, e.g., 0 and you'll benefit from a doubled z-buffer resolution as well. Then think about the 100000 for zFar, as zimerman has suggested.






