? ? ?
? glVertexAttribPointer(? ? ? ? ? // STEP 5
? ? ? GLKVertexAttribPosition,
? ? ? 3,? ? ? ? ? ? ? ? ? // three components per vertex
? ? ? GL_FLOAT,? ? ? ? ? ? // data is floating point
? ? ? GL_FALSE,? ? ? ? ? ? // no fixed point scaling
? ? ? sizeof(SceneVertex), // no gaps in data
? ? ? NULL);? ? ? ? ? ? ? // NULL tells GPU to start at
? ? ? ? ? ? ? ? ? ? ? ? ? // beginning of bound buffer
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? // Draw triangles using the first three vertices in the
? // currently bound vertex buffer
? glDrawArrays(GL_TRIANGLES,? ? ? // STEP 6
? ? ? 0,? // Start with first vertex in currently bound buffer
? ? ? 3); // Use three vertices from currently bound buffer
}
/////////////////////////////////////////////////////////////////
// Called when the view controller's view has been unloaded
// Perform clean-up that is possible when you know the view
// controller's view won't be asked to draw again soon.
- (void)viewDidUnload
{
? [super viewDidUnload];
?
? // Make the view's context current
? GLKView *view = (GLKView *)self.view;
? [EAGLContext setCurrentContext:view.context];
? ?
? // Delete buffers that aren't needed when view is unloaded
? if (0 != vertexBufferID)
? {
? ? ? glDeleteBuffers (1,? ? ? ? ? // STEP 7
? ? ? ? ? ? ? ? ? ? ? &vertexBufferID);?
? ? ? vertexBufferID = 0;
? }
?
? // Stop using the context created in -viewDidLoad
? ((GLKView *)self.view).context = nil;
? [EAGLContext setCurrentContext:nil];
}
@end

-------------------------------------分割线-------------------------------------