---
title: NSOpenGLContext
framework: appkit
role: symbol
role_heading: Class
path: appkit/nsopenglcontext
---

# NSOpenGLContext

An object that represents an OpenGL graphics context, into which all OpenGL calls are rendered.

## Declaration

```swift
class NSOpenGLContext
```

## Overview

Overview An OpenGL context is created using an NSOpenGLPixelFormatobject that specifies the context’s buffer types and other attributes. A context can be full-screen, offscreen, or associated with an NSView object. A context draws into its drawable object, which is the frame buffer that is the target of OpenGL drawing operations. Every NSOpenGLContext object wraps a low-level, platform-specific Core OpenGL (CGL) context. Your application can retrieve the CGL context by calling the cglContextObj method. For more information on the underling CGL context, see CGL.

## Topics

### Creating Contexts

- [init(format:share:)](appkit/nsopenglcontext/init(format:share:).md)
- [init(cglContextObj:)](appkit/nsopenglcontext/init(cglcontextobj:)-30lqr.md)

### Managing the Current Context

- [clearCurrentContext()](appkit/nsopenglcontext/clearcurrentcontext().md)
- [current](appkit/nsopenglcontext/current.md)
- [makeCurrentContext()](appkit/nsopenglcontext/makecurrentcontext().md)

### Managing the Drawable Object

- [view](appkit/nsopenglcontext/view.md)
- [clearDrawable()](appkit/nsopenglcontext/cleardrawable().md)
- [update()](appkit/nsopenglcontext/update().md)

### Flushing the Drawing Buffer

- [flushBuffer()](appkit/nsopenglcontext/flushbuffer().md)

### Context Parameter Handling

- [setValues(_:for:)](appkit/nsopenglcontext/setvalues(_:for:).md)
- [getValues(_:for:)](appkit/nsopenglcontext/getvalues(_:for:).md)

### Working with Virtual Screens

- [currentVirtualScreen](appkit/nsopenglcontext/currentvirtualscreen.md)

### Getting the CGL Context Object

- [cglContextObj](appkit/nsopenglcontext/cglcontextobj.md)

### Getting the Pixel Format

- [pixelFormat](appkit/nsopenglcontext/pixelformat.md)

### Getting the OpenGL Version

- [openGLVersion](appkit/nsopenglcontext/openglversion.md)

### Constants

- [NSOpenGLContext.Parameter](appkit/nsopenglcontext/parameter.md)

### Initializers

- [init(CGLContextObj:)](appkit/nsopenglcontext/init(cglcontextobj:)-4jlgm.md)
- [init(format:shareContext:)](appkit/nsopenglcontext/init(format:sharecontext:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSLocking](foundation/nslocking.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Classes

- [NSOpenGLView](appkit/nsopenglview.md)
- [NSOpenGLLayer](appkit/nsopengllayer.md)
- [NSOpenGLPixelFormat](appkit/nsopenglpixelformat.md)
- [NSDrawer](appkit/nsdrawer.md)
- [NSForm](appkit/nsform.md)
- [NSFormCell](appkit/nsformcell.md)
- [NSMenuItemCell](appkit/nsmenuitemcell.md)
