GLKViewController class provides all of the standard view controller functionality, but additionally implements an OpenGL ES rendering loop. A
GLKViewController object works in conjunction with a
GLKView object to display frames of animation in the view.
- iOS 5.0+
- tvOS 5.0+
To use this class, allocate and initialize a new
GLKViewController subclass and set its
view property to point to a
GLKView object. Then, configure the view controller’s
preferredFramesPerSecond property to the desired frame rate your application requires. You can set a delegate or configure other properties on the view controller, such as whether the animation loop is automatically paused or resumed when the application moves into the background.
When active, rendering loop automatically updates the view’s contents each time a new frame must be displayed. Each frame is rendered by the view controller using these steps:
Your application should subclass
GLKViewController and override the
viewDidUnload methods. Your
viewDidLoad() method should set up your context and any drawable properties and can perform other resource allocation and initialization. Similarly, your class’s
viewDidUnload method should delete the drawable object and free any unneeded resources.
As an alternative to implementing a
glkViewControllerUpdate(_:) method in a delegate, your subclass can provide an update method instead. The method must have the following signature: