CHAPTER 5: Textures (^147)
Notice how the texture is also picking up the colors from the vertices? Comment out the
line glEnableClientState(GL_COLOR_ARRAY) in drawInRect(), and you should now see
Figure 5-13 (right). If you don’t see any image, double-check your file and ensure that it
really is a power-of-two in size, such as 128 ̄128 or 256 ̄256.
Figure 5-13. Applying texture to the bouncy square. Using vertex colors (left) and not (right).
So, now we can replicate some of the examples in the first part of this chapter. The first
is to pick out only a portion of the texture to display. Change textureCoords in
drawInRect to the following:
static GLfloat textureCoords[] =
{
0.0, 0.5,
0.5, 0.5,
0.0, 1.0,
0.5, 1.0
};
Did you get Figure 5-14?
singke
(singke)
#1