我想在WebGL中将纹理framebuffer复制到另一个,到目前为止它只是给出了黑屏。我能够毫无问题地在纹理framebuffer中渲染。WebGL复制纹理framebuffer纹理framebuffer?
这是我认为会的工作代码(它目前适用于iOS):
// bind source fbo while we remember current fbo
glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤t_fbo);
glBindFramebuffer(GL_FRAMEBUFFER, src_framebuffer);
// setup source fbo attachments
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, src_handle, 0);
//glReadBuffer(GL_COLOR_ATTACHMENT0); <- commented out because it is not available in WebGL
// bind destination fbo
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(dest_target, dest_handle);
// copy from source to dest
glCopyTexImage2D(dest_target, 0, dest_format, 0, 0, dest_width, dest_height, 0);
// set back original fbo
//glReadBuffer(GL_NONE);
glBindFramebuffer(GL_FRAMEBUFFER, current_fbo);
的WebGL不与WEBGL_draw_buffers扩展支持glReadBuffer所以我不能指定,但它支持多渲染目标,所以我们可以设置附件没有问题(因此渲染纹理framebuffer工作完美无缺)。
我意识到,因为我不能指定读取缓冲区,也许这种技术无法正常工作?任何想法或解决方法?
我很困惑。上面的代码是OpenGL而不是WebGL – gman 2014-10-10 20:50:18
@gman是的,这是因为我正在通过Emscripten编译我的代码,所以它最终仍然是WebGL。 – Deathicon 2014-10-13 03:57:03