Creating a canvas for immediate rendering
In the previous recipes, we learned how to make abstractions for main OpenGL entities: vertex buffers, shader programs, and textures. This basis is enough to render many sophisticated effects using OpenGL. However, there are a lot of tiny rendering tasks where you need to render only one triangle or a rectangle with a single texture, or render a fullscreen quad with a specific shader to apply some image-space effect. In this case, the code for managing buffers, shaders, and textures may become a serious burden. Let's organize a place for such a helper code, that is, a canvas that will help us to render simple things in a single line of code.
Getting ready
This recipe uses the clGLSLShaderProgram
, clGLTexture
, and clGLVertexArray
classes described in the previous recipes to hide the differences between OpenGL ES 2 and OpenGL 3. Read them carefully before proceeding.
How to do it…
We first define a
clCanvas
class as follows:class clCanvas { public: clCanvas...