Game Development Reference
In-Depth Information
In the case of RGB888 Bob, the blending is performed via the alpha values in the per-vertex
colors. Since we set those to 0.5f, Bob is 50 percent translucent.
In the case of RGBA8888 Bob, the per-vertex colors all have an alpha value of 1. However,
since the background pixels of that texture have alpha values of 0, and since the vertex and
texel colors are modulated, the background of this version of Bob disappears. If we'd have set
the per-vertex colors' alpha values to 0.5f as well, then Bob himself would also have been 50
percent as translucent as his clone in the bottom of the screen. Figure 7-17 shows what that
would have looked like.
Figure 7-17. An alternative version of RGBA8888 Bob using per-vertex alpha of 0.5f (top of the screen)
That's basically all we need to know about blending with OpenGL ES in 2D.
However, there is one more very important thing we'd like to point out: Blending is expensive !
Seriously, don't overuse it. Current mobile GPUs are not all that good at blending massive
amounts of pixels. You should only use blending if absolutely necessary.
More Primitives: Points, Lines, Strips, and Fans
When we told you that OpenGL ES was a big, nasty triangle-rendering machine, we were not
being 100 percent honest. In fact, OpenGL ES can also render points and lines. Best of all,
these are also defined via vertices, and thus all of the above also applies to them (texturing, per-
vertex colors, and so forth). All we need to do to render these primitives is use something other
than GL10.GL_TRIANGLES when we call glDrawArrays() / glDrawElements() . We can also perform
indexed rendering with these primitives, although that's a bit redundant (in the case of points at
least). Figure 7-18 shows a list of all the primitive types OpenGL ES offers.
 
Search WWH ::




Custom Search