<!--
{
  "availability" : [
    "iOS: 5.0.0 - 12.0.0",
    "iPadOS: 5.0.0 - 12.0.0",
    "tvOS: 9.0.0 - 12.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "GLKit",
  "identifier" : "/documentation/GLKit/GLKViewController",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "GLKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GLKViewController"
  },
  "title" : "GLKViewController"
}
-->

# GLKViewController

A view controller that manages an OpenGL ES rendering loop.

```
class GLKViewController
```

## Overview

A [`GLKViewController`](/documentation/GLKit/GLKViewController) object works in conjunction with a [`GLKView`](/documentation/GLKit/GLKView) object to display frames of animation in the view, and also provides standard view controller functionality.

To use this class, allocate and initialize a new [`GLKViewController`](/documentation/GLKit/GLKViewController) subclass and set its <doc://com.apple.documentation/documentation/UIKit/UIViewController/view> property to point to a [`GLKView`](/documentation/GLKit/GLKView) object. Then, configure the view controller’s [`preferredFramesPerSecond`](/documentation/GLKit/GLKViewController/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.

> Note:
> When you set the <doc://com.apple.documentation/documentation/UIKit/UIViewController/view> property to point to a ``doc://com.apple.glkit/documentation/GLKit/GLKView`` object, if the view does not already have a delegate, then the view controller is automatically set as the view’s delegate.

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:

1. The view controller calls its delegate’s [`glkViewControllerUpdate(_:)`](/documentation/GLKit/GLKViewControllerDelegate/glkViewControllerUpdate(_:)) method. Your delegate should update frame data that does not involve rendering the results to the screen.
2. The view controller calls its view’s [`display()`](/documentation/GLKit/GLKView/display()) method. Your view should redraw the frame.

### Subclassing Notes

Your application should subclass [`GLKViewController`](/documentation/GLKit/GLKViewController) and override the <doc://com.apple.documentation/documentation/UIKit/UIViewController/viewDidLoad()> and <doc://com.apple.documentation/documentation/UIKit/UIViewController/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(_:)`](/documentation/GLKit/GLKViewControllerDelegate/glkViewControllerUpdate(_:)) method in a delegate, your subclass can provide an update method instead. The method must have the following signature:

```objc
- (void)update;
```

## Topics

### Configuring the Frame rate

[`preferredFramesPerSecond`](/documentation/GLKit/GLKViewController/preferredFramesPerSecond)

The rate you want the view controller to call the view to update the contents of the view.

[`framesPerSecond`](/documentation/GLKit/GLKViewController/framesPerSecond)

The actual rate that the view controller attempts to call the view to update its contents.

### Configuring the Delegate

[`delegate`](/documentation/GLKit/GLKViewController/delegate)

The view controller’s delegate.

### Controlling Frame Updates

[`paused`](/documentation/GLKit/GLKViewController/isPaused)

A Boolean value that indicates whether the rendering loop is paused.

[`pauseOnWillResignActive`](/documentation/GLKit/GLKViewController/pauseOnWillResignActive)

A Boolean value that indicates whether the view controller automatically pauses the rendering loop when the application resigns the active state.

[`resumeOnDidBecomeActive`](/documentation/GLKit/GLKViewController/resumeOnDidBecomeActive)

A Boolean value that indicates whether the view controller automatically resumes the rendering loop when the application becomes active.

### Obtaining Information About View Updates

[`framesDisplayed`](/documentation/GLKit/GLKViewController/framesDisplayed)

The number of frame updates that have been sent by the view controller since it was created.

[`timeSinceFirstResume`](/documentation/GLKit/GLKViewController/timeSinceFirstResume)

The amount of time that has passed since first time the view controller resumed sending update events.

[`timeSinceLastResume`](/documentation/GLKit/GLKViewController/timeSinceLastResume)

The amount of time that has passed since the last time the view controller resumed sending update events.

[`timeSinceLastUpdate`](/documentation/GLKit/GLKViewController/timeSinceLastUpdate)

The amount of time that has passed since the last time the view controller called the delegate’s [`glkViewControllerUpdate(_:)`](/documentation/GLKit/GLKViewControllerDelegate/glkViewControllerUpdate(_:)) method.

[`timeSinceLastDraw`](/documentation/GLKit/GLKViewController/timeSinceLastDraw)

The amount of time that has passed since the last time the view controller called the view’s [`display()`](/documentation/GLKit/GLKView/display()) method.

## Relationships

### Conforms To

[`UIContentContainer`](/documentation/UIKit/UIContentContainer)

[`UIUserActivityRestoring`](/documentation/UIKit/UIUserActivityRestoring)

[`UIStateRestoring`](/documentation/UIKit/UIStateRestoring)

[`UIAppearanceContainer`](/documentation/UIKit/UIAppearanceContainer)

[`UIFocusEnvironment`](/documentation/UIKit/UIFocusEnvironment)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`UIPasteConfigurationSupporting`](/documentation/UIKit/UIPasteConfigurationSupporting)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`UIActivityItemsConfigurationProviding`](/documentation/UIKit/UIActivityItemsConfigurationProviding)

[`Hashable`](/documentation/Swift/Hashable)

[`NSExtensionRequestHandling`](/documentation/Foundation/NSExtensionRequestHandling)

[`GLKViewDelegate`](/documentation/GLKit/GLKViewDelegate)

[`UITraitChangeObservable-67e94`](/documentation/UIKit/UITraitChangeObservable-67e94)

[`Sendable`](/documentation/Swift/Sendable)

[`UITraitEnvironment`](/documentation/UIKit/UITraitEnvironment)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`UIResponderStandardEditActions`](/documentation/UIKit/UIResponderStandardEditActions)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`UIViewController`](/documentation/UIKit/UIViewController)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)