<!--
{
  "availability" : [
    "macOS: 10.6.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOpenGLLayer/openGLContext",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOpenGLLayer(py)openGLContext"
  },
  "title" : "openGLContext"
}
-->

# openGLContext

The layer’s OpenGL context.

```
var openGLContext: NSOpenGLContext? { get set }
```

## Discussion

Provides access to the layer’s associated [`NSOpenGLContext`](/documentation/AppKit/NSOpenGLContext).  Subclasses shouldn’t invoke `setOpenGLContext:`, but can override it if desired to intercept assignment of the layer’s context.

---

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)