glReadPixels()

Hi

Looking in GL.java we see:

public void glReadPixels(int x, int y, int width, int height, int format, int type, java.nio.Buffer pixels);

public void glReadPixels(int x, int y, int width, int height, int format, int type, long pixels_buffer_offset);

How are we to use these versions of glReadPixels()?

Specifically, I’m trying to convert the example at:

http://nehe.gamedev.net/data/articles/article.asp?article=13

with the C call:

glReadPixels(X, -Y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, @winZ );

which sets the z-value winZ by arg reference.

Graham

Hi,

most of the time when C use a pointer for OpenGl, Java use a buffer. I don’t know whish binding you are using but it should look like something like :

FloatBuffer winZ= BufferUtils.createFloatBuffer(1);

GL11.glReadPixels(X, -Y, 1, 1, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, winZ );

The second version of the call is when using pixel buffer objects.

Cas :slight_smile: