Pro OpenGL ES for iOS

(singke) #1

CHAPTER 6: Will It Blend? (^177)
square’s color. The math yields a final color with red=.5, green=0, and blue=-.25. But
because negative colors do not occur in this plane of existence (or at least in San Jose,
California), the system clamps the blue component to 0. The result is a solid red where
the intersection is. So, in order to see something here, the front square needs to be
drawn with some blue already. So, change red’s color to be 1,0,1, or magenta. Now
when run, Figure 6-5 (right) is the result, because the blue destination can subtract from
the blue in the source, leaving a positive value that the system understands. And in this
case the value of the intersection is .5,0,.25, which is why we don’t have a pure red but
more of a magenta-ish red. Try importing it into a paint program, and verify the actual
colors using the eyedropper function.
Figure 6-5a,b. On the left, no blending takes place using the subtract operation, while it succeeds on the right.
There are still two other function calls in the extended set, and they are
glBlendEquationSeparateOES() and glBlendFuncSeparateOES(). These functions allow
you to modify the RGB channels separately from alpha. The OES suffix specifies that
t h e s e a r e e x t e n s i o n s t o O p e n G L E S ( b u t o n l y f o r 1. 1 o f O p e n G L -----they are standard in
2.0, so you don’t need the OES at the end), and are defined in glext.h. One way in which
this is useful is to counteract the effects rendering order that Figure 6-4 illustrates.

Free download pdf