Login  Register

Re: Seeking Help with OpenGL Depth Buffer Issue

Posted by jmaasing on Oct 15, 2014; 10:49am
URL: https://forum.jogamp.org/Seeking-Help-with-OpenGL-Depth-Buffer-Issue-tp4033219p4033359.html

xghost wrote
projMatrix = MathUtils.createPerspectiveMatrix(60.0f, aspectRatio, 0.0f, 100.0f);   // from
projMatrix = MathUtils.createPerspectiveMatrix(60.0f, aspectRatio, 0.01f, 100.0f);  // to

For me, I think the most frustrating thing overall is that OpenGL, instead of raising an appropriate error when it receives an invalid value (say, GL_INVALID_VALUE?? gasp!), it merrily chooses to continue, but behaving in whatever way it deems to be more difficult to debug.

-x
Just so you know, setting small values on the near clip plane is usually avoided due to precision issues, this is a good explanation: http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

OpenGL often do raise an error (depending on driver ofc) when you break the spec. Sometimes you must remember to ask OpenGL about the status of the previosu operation and the way I usually do it is to use JOGL-classes and constructs like these
drawable.setGL(new TraceGL4(new DebugGL4(gl.getGL4()), System.out));
Although in this case I doubt it would have warned you about writing a very high depth value. There is nothing afaik in the spec. preventing you from writing strange values in this case and that's why it becomes so hard to track down.