在OpenGL 4中测试,glBlitFramebuffer在OpenGL ES 2.0中不受支持。
我在以前的答案固定的错误,并推广到可以支持两个帧缓冲区的函数:
// Assumes the two textures are the same dimensions
void copyFrameBufferTexture(int width, int height, int fboIn, int textureIn, int fboOut, int textureOut)
{
// Bind input FBO + texture to a color attachment
glBindFramebuffer(GL_READ_FRAMEBUFFER, fboIn);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureIn, 0);
glReadBuffer(GL_COLOR_ATTACHMENT0);
// Bind destination FBO + texture to another color attachment
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboOut);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, textureOut, 0);
glDrawBuffer(GL_COLOR_ATTACHMENT1);
// specify source, destination drawing (sub)rectangles.
glBlitFramebuffer(0, 0, width, height,
0, 0, width, height,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
// unbind the color attachments
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, 0, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
}
glBlitFramebuffer是不是在OpenGL ES 2.0的 – Kimi 2013-03-09 17:19:36
妈用,我不知道。我找不到任何文档可用的ES glBlitFramebuffer版本,只找到一个说明它可用的OpenGL ES 3.0文档。我不能等到桌面和ES标准收敛,所以我不必在所有该死的时候对功能设置感到困惑。 – 2013-03-09 17:39:55
为什么不只是附加纹理来读取缓冲区并绘制它们来绘制缓冲区? – 2013-03-11 18:11:23