Class

NSOpenGLContext

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

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

Context Creation

init?(format: NSOpenGLPixelFormat, share: NSOpenGLContext?)

Returns an NSOpenGLContext object initialized with the specified pixel format information.

init?(cglContextObj: UnsafeMutablePointer<_CGLContextObject>)

Initializes and returns a NSOpenGLContext object using an existing CGL context.

Managing the Current Context

class func clearCurrentContext()

Sets the current context to nil.

class var current: NSOpenGLContext?

Returns the current OpenGL graphics context.

func makeCurrentContext()

Sets the receiver as the current OpenGL context object.

Drawable Object Management

var view: NSView?

Returns the receiver’s view.

func clearDrawable()

Disassociates the receiver from its viewport.

func update()

Updates the receiver's drawable object.

Flushing the Drawing Buffer

func flushBuffer()

Copies the back buffer to the front buffer of the receiver.

Context Parameter Handling

Working with Virtual Screens

var currentVirtualScreen: GLint

Returns the current virtual screen for the receiver.

Getting the CGL Context Object

var cglContextObj: UnsafeMutablePointer<_CGLContextObject>?

Returns the low-level, platform-specific Core OpenGL (CGL) context object represented by the receiver.

Constants

enum NSOpenGLContext.Parameter

The following attribute names are used by setValues(_:for:) and getValues(_:for:):

Type Aliases

typealias NSOpenGLContext.Auxiliary

A private data structure used by NSOpenGLContext.

Relationships

Inherits From

See Also

OpenGL

class NSOpenGLLayer

A subclass of CAOpenGLLayer that is suitable for rendering OpenGL into layers.

class NSOpenGLPixelFormat

An object that specifies the types of buffers and other attributes of the NSOpenGLContext.