186 CHAPTER 6: Will It Blend?^
First, we revisit our old friend, drawInRect(). We’re back to only a single texture, going
up and down. The color support has also been stripped out. So, you should have
something like Listing 6-4. And make sure that you are still loading a second texture.
Listing 6-4. drawInRect() Revisited, Modified for Multitexture Support
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
static const GLfloat squareVertices[] =
{
-0.5, -0.5, 0.0,
0.5, -0.5, 0.0,
-0.5, 0.5, 0.0,
0.5, 0.5, 0.0
};
static GLfloat textureCoords[] =
{
0.0, 0.0,
1.0, 0.0,
0.0, 1.0,
1.0, 1.0
};
static float transY = 0.0;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
[self setClipping];
glClearColor(0.0, 0.0,0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//Set up for using textures.
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, squareVertices);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTexture(GL_TEXTURE0); //1
glTexCoordPointer(2, GL_FLOAT,0,textureCoords);
glClientActiveTexture(GL_TEXTURE1); //2
glTexCoordPointer(2, GL_FLOAT,0,textureCoords);
glLoadIdentity();
glTranslatef(0.0, (GLfloat)(sinf(transY)/2.0), -2.5);