When I started using openGL and making some nice effects, I started to use the typical “copy to texture” functions: glTexImage2D and glTexSubImage2D. But the technology evolves, and, hopefully, someone implemented in the OpenGL extensions the Frame Buffer Objects (fbo), wich provides us a way to render a scene to a different buffer but the frame-buffer.
Anybody should know that writing to a frame-buffer is much better than writing to a buffer by “the old way” (glTexImage2D), but… can we express this in real numbers?
I was doing some experiments with Shadow Mapping and I did what everybody does: search for tutorials! đŸ˜€ I found 2 really good tutorials: Paul’s projects tutorial, and Fabien Sanglard’s tutorial. Both tutorials are brilliant, but the first one is a little bit outdated (it does not use fbo’s or shaders), and the second one has some ugly MoirĂ© pattern effect which I was unable to make it disappear, despite it uses recent techniques (fbo’s and shaders).
The Moiré pattern can be appreciated in the image below (and the effect is much more spectacular in movement):
Due to that, Fabien’s tutorial was not an option for what I wanted to do, so I gave a second chance to Paul’s tutorial, but instead of using the typical glTexImage2D, I used the fbo (it took 5 minutes of my time to modify the provided example), the results: 562fps vs 630fps (both peak values)!, almost 70fps more! more than 10% of diference!
So please, next time, spend 5 minutes of your time and do not use glTexImage2D, use fbo’s!