Class

NSOpenGLContext

All OpenGL calls are rendered into an OpenGL graphics context, which in Cocoa is represented by the NSOpenGLContext class. The 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.

Overview

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.

Symbols

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 func current()

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

NSOpenGLContextParameter

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

Relationships

Inherits From