Game Development Reference
In-Depth Information
Here we always enable and disable blending. This causes a redundant
state changes. A better approach is to save the value of the previously
set blending mode and toggle it only when necessary.
The complete source code is in the
Canvas.cpp
and
Canvas.h
iles from the
4_Canvas
project. Usage of the canvas is trivial. For example, use this one-liner call to render
a semi-transparent magenta rectangle:
Canvas->Rect2D( 0.1f, 0.1f, 0.5f, 0.5f, vec4( 1, 0, 1, 0.5f ) );
The example
4_Canvas
shows you how to use the canvas, and produces an image similar to
the following diagram, which shows overlays rendering using
Canvas
:
There's moreā¦
The canvas is a placeholder for different immediate rendering functions. In the next two
chapters, we will augment it with other methods to render the user interface of our games.
See also
F
Unifying the OpenGL 3 core proile and OpenGL ES 2
F
Unifying the GLSL 3 and GLSL ES 2 shaders
F
Unifying vertex arrays
F
Creating a wrapper for textures