Hello-
I’m trying to use the glDrawPixels method with the beta 2 version of JOGL, but I’m getting the following exception:
java.lang.IndexOutOfBoundsException: Required 1000800 remaining bytes in buffer, only had 0
at com.sun.gluegen.runtime.BufferFactory.rangeCheckBytes(BufferFactory.java:274)
at com.sun.opengl.impl.GLImpl.glDrawPixels(GLImpl.java:3648)
1000800 is exactly 4 times what I’m allocating (which is image width * image height * 3). My code looks like this:
int width = ...
int height = ...
IntBuffer buffer = IntBuffer.allocate(3 * width * height);
for (int h=0; h<height; h++)
for (int w=0; w<width; w++) {
buffer.put(...); // R
buffer.put(...); // G
buffer.put(...); // B
}
gl2.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl2.glRasterPos2d(0, 0);
gl2.glViewport(0, 0, width, height);
gl2.glDrawBuffer(GL.GL_FRONT);
gl2.glDrawPixels(width, height, GL.GL_RGB, GL.GL_INT, buffer); // EXCEPTION HERE
gl2.glFinish();
Am I misunderstanding how arrays are transferred between OpenGL and Java? This seemed to be the reverse of other -working- code I have that uses glReadPixels.
Thanks for any clues or pointers you can provide.
Cheers,
Uwe