<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOpenGLView",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOpenGLView"
  },
  "title" : "NSOpenGLView"
}
-->

# NSOpenGLView

A view that displays OpenGL content in a view.

```
class NSOpenGLView
```

## Overview

An [`NSOpenGLView`](/documentation/AppKit/NSOpenGLView) object maintains an [`NSOpenGLPixelFormat`](/documentation/AppKit/NSOpenGLPixelFormat) and [`NSOpenGLContext`](/documentation/AppKit/NSOpenGLContext) object into which OpenGL calls can be rendered. The view provides methods for accessing and managing the [`NSOpenGLPixelFormat`](/documentation/AppKit/NSOpenGLPixelFormat) and [`NSOpenGLContext`](/documentation/AppKit/NSOpenGLContext) objects, as well as notifications of visible region changes.

An `NSOpenGLView` object cannot have subviews. You can, however, divide a single `NSOpenGLView` into multiple rendering areas using the `glViewport` function.

When creating an `NSOpenGLView` object in Interface Builder, you use the inspector window to specify the pixel format attributes you want for the view. Only those attributes listed in the Interface Builder inspector are set when the view is instantiated.

> Note:
> In versions of the Xcode Tools that shipped prior to OS X v10.4, the Interface Builder inspector does not list any pixel format attributes for `NSOpenGLView`.

## Topics

### Initializing an NSOpenGLView

[`init(frame:pixelFormat:)`](/documentation/AppKit/NSOpenGLView/init(frame:pixelFormat:))

Returns an `NSOpenGLView` object initialized with the specified frame rectangle and pixel format.

### Managing the NSOpenGLPixelFormat

[`defaultPixelFormat()`](/documentation/AppKit/NSOpenGLView/defaultPixelFormat())

Returns a default [`NSOpenGLPixelFormat`](/documentation/AppKit/NSOpenGLPixelFormat) object.

[`pixelFormat`](/documentation/AppKit/NSOpenGLView/pixelFormat)

The [`NSOpenGLPixelFormat`](/documentation/AppKit/NSOpenGLPixelFormat) object associated with the receiver.

### Managing the NSOpenGLContext

[`prepareOpenGL()`](/documentation/AppKit/NSOpenGLView/prepareOpenGL())

Used by subclasses to initialize OpenGL state.

[`clearGLContext()`](/documentation/AppKit/NSOpenGLView/clearGLContext())

Releases the [`NSOpenGLContext`](/documentation/AppKit/NSOpenGLContext) object associated with the view.

[`openGLContext`](/documentation/AppKit/NSOpenGLView/openGLContext)

The [`NSOpenGLContext`](/documentation/AppKit/NSOpenGLContext) object associated with the receiver.

### Managing the Visible Region

[`reshape()`](/documentation/AppKit/NSOpenGLView/reshape())

Called by Cocoa when the view’s visible rectangle or bounds change.

[`update()`](/documentation/AppKit/NSOpenGLView/update())

Called by Cocoa when the view’s window moves or when the view itself moves or is resized.

### Extended Dynamic Range

[`wantsExtendedDynamicRangeOpenGLSurface`](/documentation/AppKit/NSOpenGLView/wantsExtendedDynamicRangeOpenGLSurface)

Enables extended dynamic range values on the screen.

### Instance Properties

[`wantsBestResolutionOpenGLSurface`](/documentation/AppKit/NSOpenGLView/wantsBestResolutionOpenGLSurface)

A Boolean value indicating whether the view wants an OpenGL backing surface with a resolution greater than 1 pixel per point.

[`wantsExtendedDynamicRangeOpenGLSurface`](/documentation/AppKit/NSOpenGLView/wantsExtendedDynamicRangeOpenGLSurface)

Enables extended dynamic range values on the screen.



---

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)