Re: Depth buffer not working on Win7-64b?
Posted by markm on Nov 18, 2010; 10:28pm
URL: https://forum.jogamp.org/Depth-buffer-not-working-on-Win7-64b-tp1737435p1927086.html
...for those whose only option is an Intel graphics chip, the following might be useful:
After having this exact problem on my rather old laptop, it turned out that the GLCapabilities object I was using to create my GLCanvas was asking for a 24-bit depth buffer:
GLProfile profile = GLProfile.get(GLProfile.GL2);
GLCapabilities capabilities = new GLCapabilities(profile);
System.out.println("caps: " + capabilities.getDepthBits()); // Returns 24
Now I'm assuming that my graphics chip can't fulfil this request, because later when I come to query the actual depth buffer size, it's zero...
public void init(GLAutoDrawable drawable) {
...
GL2 gl2 = drawable.getGL().getGL2();
IntBuffer buff = IntBuffer.allocate(1);
gl2.glGetIntegerv(GL2.GL_DEPTH_BITS,buff);
System.out.println("Depth buffer: " + buff.get(0)); // Prints 0; oops, our depth buffer looks a little shallow...
...
}
I was able to work around this on my system by changing the depth requested by the GLCapabilities:
capabilities.setDepthBits(16); // Gears now render correctly!
I'm not yet sure as to the ideal way to incorporate this workaround in my code; it'd be nice if I could find out in advance the best non-zero depth buffer value to ask for. But for the moment this seems to work. Hope it's useful to someone.