Pro OpenGL ES for iOS

(singke) #1

170 CHAPTER 6: Will It Blend?^


„ But we want two squares to show how they can blend. So in line 5, the
color is changed to red and is given an alpha of .5, half that of the blue
one.
„ Following that is a translation of only 3 units in line 6, and as a result,
the red square will be larger because it is closer. Also, notice that the x
value is now being translated. Instead of the up and down movement
of the blue square, the closer red one will move left and right.
„ And in line 7, the red square is rendered. Because there is no depth
buffer being used right now, the only reason why the red square
covers the blue one is that it is drawn after the blue square.
„ In line 8 the value of the translation is cut down so as to decrease the
motion, making it a little easier to catch the blending effects when
turned on.
If all works, you should have something that looks like Figure 6-1.

Figure 6-1. The blue square goes up and down; the red one goes left and right.

w
Free download pdf