我正在尝试从帧缓冲区异步读取,但 glReadPixels() 会生成 INVALID_OPERATION 错误。
我已经阅读了可能导致此错误的原因,但我的代码中没有发现任何问题:
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);