You did not properly create a real pixel buffer object. All you did was creating a name for one. You must call glBufferData()
to create an actual data store. Use NULL
as the data pointer to create an unitizialized buffer.
LWJGL Using PBO for reading pixels fail
-
23-06-2023 - |
Question
I'm trying to read from the framebuffer Asynchronously but glReadPixels() generates an INVALID_OPERATION error.
I've read what might cause this error but i haven't found any problem in my code:
int PBOHandle = glGenBuffers(); // PBOHandle != 0
int Width = Display.getDisplayMode().getWidth(); // 800
int Height = Display.getDisplayMode().getHeight();// 600
glReadBuffer(GL_FRONT);
glBindBuffer(GL_PIXEL_PACK_BUFFER, PBOHandle);
glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
// GL_INVALID_OPERATION right here
glBindBuffer(GL_PIXEL_PACK_BUFFER, PBOHandle);
ByteBuffer Buffer = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_WRITE, null);
/* stuff */
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow