我试图一起使用FBO和PBO,从FBO读取像素到每个帧的PBO。 代码如下:
//at the beginning:
//fbo
glGenFramebuffers(1, &m_fBO);
glBindFramebuffer(GL_FRAMEBUFFER, m_fBO);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texid, 0);
//pbo
glGenBuffersARB(1, &m_pbo);
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, m_pbo);
glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, DATA_SIZE, 0, GL_STREAM_READ_ARB);
//at each frame:
glBindFramebuffer(GL_FRAMEBUFFER, m_fBO);
Draw_some_stuff();
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, m_pbo);
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, 0); //err occurs
Ptr = glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);
Cpu_works_on_Ptr();
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);
在PC上运行正常。但是无法在我的Android手机上运行,在glReadPixels之后出现错误0x0502(GL_INVALID_OPERATION)。
我相信我的代码与此链接的底部答案相同: Reading the pixels values from the Frame Buffer Object (FBO) using Pixel Buffer Object (PBO)
有没有人知道?我在哪里做错了?