<!--
{
  "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/GLKView",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "GLKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GLKView"
  },
  "title" : "GLKView"
}
-->

# GLKView

A default implementation for views that draw their content using OpenGL ES.

```
class GLKView
```

## Overview

The [`GLKView`](/documentation/GLKit/GLKView) class simplifies the effort required to create an OpenGL ES application by  directly managing a framebuffer object on your behalf; your application simply needs to draw into the framebuffer when the contents need to be updated.

To use this class in your application, create a new [`GLKView`](/documentation/GLKit/GLKView) object and provide it an OpenGL ES context. Then, modify the view’s [`drawableColorFormat`](/documentation/GLKit/GLKView/drawableColorFormat), [`drawableDepthFormat`](/documentation/GLKit/GLKView/drawableDepthFormat), [`drawableStencilFormat`](/documentation/GLKit/GLKView/drawableStencilFormat), and [`drawableMultisample`](/documentation/GLKit/GLKView/drawableMultisample) properties to configure the format of the drawable’s framebuffer object. After this, the view automatically creates or updates the framebuffer object whenever the view must be redrawn. A [`GLKView`](/documentation/GLKit/GLKView) object uses the regular view drawing cycle for a <doc://com.apple.documentation/documentation/UIKit/UIView>object, calling its <doc://com.apple.documentation/documentation/UIKit/UIView/draw(_:)> method whenever the contents of the view need to be updated. Before calling its `draw `method, the view makes its <doc://com.apple.documentation/documentation/OpenGLES/EAGLContext> object the current OpenGL ES context and binds its framebuffer object to the OpenGL ES context as the target for rendering commands. Your application’s implementation of the `draw` method should call one or more OpenGL ES functions to render an image into the framebuffer object. Then, the view resolves any multisampling that you may have enabled and delivers the finished results.

> Important:
> Your drawing method should only modify the contents of the framebuffer object. Never attempt to read the pixel information from the underlying framebuffer object, modify or dispose of the framebuffer object, or read its other properties by calling OpenGL ES functions. Instead, rely on the properties and methods provided by the ``doc://com.apple.glkit/documentation/GLKit/GLKView`` class.

The [`GLKView`](/documentation/GLKit/GLKView) class can be used in conjunction with a [`GLKViewController`](/documentation/GLKit/GLKViewController) object to create an animation rendering loop that redraws the contents of the view at a specified frame rate.

### Subclassing Notes

Typically, there is no need to subclass the [`GLKView`](/documentation/GLKit/GLKView) class. Instead, provide a delegate object to draw the view’s contents. See [`GLKViewDelegate`](/documentation/GLKit/GLKViewDelegate).

## Topics

### Initializing the View

[`init(frame:context:)`](/documentation/GLKit/GLKView/init(frame:context:))

Initializes a new view.

### Delegate

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

The view’s delegate.

### Configuring the Framebuffer Object

[`drawableColorFormat`](/documentation/GLKit/GLKView/drawableColorFormat)

The format of the color renderbuffer.

[`drawableDepthFormat`](/documentation/GLKit/GLKView/drawableDepthFormat)

The format of the depth renderbuffer

[`drawableStencilFormat`](/documentation/GLKit/GLKView/drawableStencilFormat)

The format of the stencil renderbuffer.

[`drawableMultisample`](/documentation/GLKit/GLKView/drawableMultisample)

The format of the multisampling buffer.

### Read-only Framebuffer Properties

[`drawableHeight`](/documentation/GLKit/GLKView/drawableHeight)

The height, in pixels, of the underlying framebuffer object.

[`drawableWidth`](/documentation/GLKit/GLKView/drawableWidth)

The width, in pixels, of the underlying framebuffer object.

### Drawing Your View’s Contents

[`context`](/documentation/GLKit/GLKView/context)

The OpenGL ES context used when drawing the view’s contents.

[`bindDrawable()`](/documentation/GLKit/GLKView/bindDrawable())

Binds the underlying framebuffer object to OpenGL ES.

[`enableSetNeedsDisplay`](/documentation/GLKit/GLKView/enableSetNeedsDisplay)

A Boolean value that indicates whether the view responds to messages that invalidate the view’s contents.

[`display()`](/documentation/GLKit/GLKView/display())

Redraws the view’s contents immediately.

[`snapshot`](/documentation/GLKit/GLKView/snapshot)

Draws the contents of the view and returns them as a new image object.

### Deleting the View’s Underlying Framebuffer Object

[`deleteDrawable()`](/documentation/GLKit/GLKView/deleteDrawable())

Deletes the drawable object associated with the view.

### Constants

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

The format of the color renderbuffer.

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

The format of the depth renderbuffer.

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

The format of the stencil renderbuffer.

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

The format of the multisampling buffer.



---

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)