Hello OpenGL gurus,
My usage: I need to have an arbitrary number of passes, where each pass renders to some kind of an arbitrary buffer which is then used as an input texture to the next pass.
Currently, each buffer is implemented by an FBO with a Texture attached to COLOR0. First I create the FBO (and the texture inside) with
glGenTextures(1, texIds, 0);
glBindTexture(GL_TEXTURE_2D, texIds[0]);
// ... here goes the usual glTexParameterf stuff ...
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mWidth, mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
glGenFramebuffers(1, fboIds, 0);
glBindFramebuffer(GL_FRAMEBUFFER, fboIds[0]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texIds[0], 0);
Then whenever I need to render to the Buffer I call
glBindFramebuffer(GL_FRAMEBUFFER, fboIds[0]);
and whenever I need to set the Buffer’s contents as input to the next pass, I do
glBindTexture(GL_TEXTURE_2D, texIds[0]);
and everything works.
The problem is that I read in numerous sources that the BindFramebuffer call is very slow (flushes the whole pipeline) especially on OpenGL ES targets which I work with. SongHo Ahn, for instance, clearly states that
“(…) Switching framebuffer-attachable images is much faster than switching between FBOs.”
( OpenGL Frame Buffer Object (FBO) )
Thus I am thinking to switch to a design where there’s only 1 Framebuffer, and many Textures; and each time I need to render to a Buffer I’d only attach the given texture to the sole Framebuffer’s COLOR0.
Do you think this is a good idea? Or maybe some totally different design would be best here - what about RenderBuffers?