在 OpenGL ES 中,是否可以一个接一个地多次调用glReadPixels
FBO glDrawArrays
?我面临的问题是我得到的图像都是乱码。
示例代码:
// Activate Off-Screen FBO
glBindFramebuffer(GL_FRAMEBUFFER, fboHandle);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, textureHandle);
glViewport(0, 0, 640, 480);
// 1st Render
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(filter_A);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 640, 480, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgb_pixels_A);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glReadPixels(0, 0, 640, 480, GL_RGBA, GL_UNSIGNED_BYTE, pixels_A);
// 2st Render
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(filter_B);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 640, 480, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgb_pixels_B);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glReadPixels(0, 0, 640, 480, GL_RGBA, GL_UNSIGNED_BYTE, pixels_B);
// Back to the screen FB
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glActiveTexture(GL_TEXTURE0);