[Help] glBindBuffer + GL_PIXEL_PACK_BUFFER + glReadPixels

Started by gui0rafa, March 14, 2013, 05:04:17

Previous topic - Next topic


Hello guys,

I'm trying to implement the examples from OpenGL SuperBible 5th, and a particularly one is giving me a headache. The blur example, the book uses a PBO method.

The step-by-step is almost like:

It creates a Buffer, bind this buffer to GL_PIXEL_PACK_BUFFER and then try to glReadPixels to the PBO.

But I'm receiving this exception:
org.lwjgl.opengl.OpenGLException: Cannot use Buffers when Pixel Pack Buffer Object is enabled

Why i cannot readpixels to a PBO?

Sorry if some concepts I understood wrongly, I'm just start to study opengl


Hi, Pixel Pack Buffer Object refers to ARBPixelPackBufferObject extension which should be available on your setup if this error appears. For this reason, you must use the ARBPixelBufferObject.gl*ARB() functions in order to handle your PBO buffer in place of the orginal GL15 buffer functions.

You may share out a bit of your code (use Paste Bin if it is long) for help.


OpenGL functions that read from or write to a buffer usually have 2 forms:

a) When an OpenGL buffer object IS NOT bound to the corresponding target (e.g. PIXEL_PACK_BUFFER in your case), data is read from or written to client memory, i.e. a java.nio Buffer.

b) When an OpenGL buffer object IS bound, data is read from or written to the corresponding buffer object's memory store (which the driver allocates and manages). In this case, you should not use the version of the function that accepts a java.nio Buffer and use the one that accepts a long offset instead.

Since this is a common bug in user code, LWJGL checks for the above invariants and throws the exception you're seeing. Please note that in both cases the OpenGL driver receives a pointer value, which is interpreted as a memory address in the first case and as an offset (from the buffer object start) in the second. That's why this bug usually leads to a JVM crash without the check.


Thank you very much guys!

It worked perfectly, with the overloaded version, saddly my graphic card doesn't supports ARB PBO (or I couldn't activate it).