Pro OpenGL ES for iOS

(singke) #1

CHAPTER 5: Textures (^141)
Figure 5-10. A mirrored-repeat for just the s-axis (left), the texture clamped (right)
Note The problem with the right edge in Figure 5-10 suggests that textures designed to be
clamped should have a 1-pixel-wide border to match the colors of the object to which they are
bound. Unless you think it’s really cool, then of course that trumps nearly everything.
O p e n G L E S , a s y o u k n o w b y n o w , d o e s n ’ t d o q u a d r i l a t e r a l s -----that is, faces with four
sides (as opposed to its big desktop brother). So, we have to fabricate them using two
triangles, giving us structures such as the triangle strips and fans that we experimented
with in Chapter 3. Applying textures to this ‘‘fake’’ quadrilateral is a simple affair. One
triangle has texture coordinates of (0,0), (1,0), and (0,1), while the other has coordinates
of (1,0), (1,1), and (0,1). It should make more sense if you study Figure 5-11.
Figure 5-11. Placing a texture across two faces
And finally, let’s take a look at how a single texture can be stretched across a whole
bunch of faces, as shown in Figure 5-12, and then we can get back to the fun stuff.

Free download pdf