문제

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);   
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top