LWJGL Forum

Programming => OpenGL => Topic started by: Jens v.P. on December 17, 2007, 17:11:13

Title: reading depth buffer returns only 0
Post by: Jens v.P. on December 17, 2007, 17:11:13
Hi,

I'm trying to read the depth buffer, but it isn't working -- the result contains only 0 floats.
This is my code (abridged):


// init
final GLData data = new GLData();
data.doubleBuffer = true;
data.depthSize = 1; // Add this line to force a depth buffer
final GLCanvas canvas = new Draw3DCanvas(i_composite, SWT.NONE, data);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthRange(0.0, 1.0);
// later on
.. render some stuff ..
.. create buffer .. actualBufferSize contains the size of the screen (with unpack alignment)
GL11.glReadPixels(0, 0, actualBufferSize.width, actualBufferSize.height,
        GL11.GL_DEPTH_COMPONENT,
        GL11.GL_FLOAT, bufferDepth);

getCanvas().swapBuffers();


I'm also reading the color buffer the very same way, and it is working. What am I doing wrong, here?
Is it my system (MacBook Pro with Leopard)?
Title: Re: reading depth buffer returns only 0
Post by: Fool Running on December 17, 2007, 19:43:20
Are you using JOGL and LWJGL at the same time? I'm surprised that works at all. How are you able to use LWJGL without creating a display?
Title: Re: reading depth buffer returns only 0
Post by: Jens v.P. on December 18, 2007, 17:03:10
I'm using LWJGL with Eclipse. The canvas is an org.eclipse.swt.opengl.GLCanvas. A small example can be found at
http://www.eclipse.org/swt/opengl/ (http://www.eclipse.org/swt/opengl/) (Snippet 195).