Hi! I’m developing a gl4java application, but I have problems with a function of this library. My intention is to save on a file (.jpg, .png …) the actual view of OpenGL buffer. For this, I use the function glReadPixels, but this returns to me all 0, it is to say, the function glReadPixels returns to me all pixels whit a 0 value. This is a bug of the gl4java or I do a bad use of this function? If I use the function badly, how I do it?
The GL context must be the current context for the currently executing thread when you call that method. Otherwise it returns white.
Cas
The GLContext is the currently context, the code is:
IntBuffer buff = ByteBuffer.allocateDirect(1024 * 768 * 4).order(ByteOrder.nativeOrder()).asIntBuffer();
byte buffh[] = new byte[512000];
gl.glReadPixels(0, 0, 1024, 768, GL_BGRA, GL_BYTE, buffh);
int i=0;
for (i=0;i<buffh.length;i++) {
System.out.println(buffh[i]);
}
I call all gl4java functions with gl. … Do you have an example about this?