---
title: "openGLContext(for:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsopengllayer/openglcontext(for:)"
---

# openGLContext(for:)

Returns the OpenGL context to use for the requested pixel format.

## Declaration

```swift
func openGLContext(for pixelFormat: NSOpenGLPixelFormat) -> NSOpenGLContext
```

## Parameters

- `pixelFormat`: The pixel format.

## Return Value

Return Value An autoreleased NSOpenGLContext.

## See Also

### Managing the Rendering Context

- [openGLContext](appkit/nsopengllayer/openglcontext.md)
