A view that displays OpenGL content in a view.


class NSOpenGLView : NSView


An NSOpenGLView object maintains an NSOpenGLPixelFormat and NSOpenGLContext object into which OpenGL calls can be rendered. The view provides methods for accessing and managing the NSOpenGLPixelFormat and NSOpenGLContext objects, as well as notifications of visible region changes.

An NSOpenGLView object cannot have subviews. You can, however, divide a single NSOpenGLView into multiple rendering areas using the glViewport function.

When creating an NSOpenGLView object in Interface Builder, you use the inspector window to specify the pixel format attributes you want for the view. Only those attributes listed in the Interface Builder inspector are set when the view is instantiated.


Initializing an NSOpenGLView

init?(frame: NSRect, pixelFormat: NSOpenGLPixelFormat?)

Returns an NSOpenGLView object initialized with the specified frame rectangle and pixel format.

Managing the NSOpenGLPixelFormat

Managing the NSOpenGLContext

func prepareOpenGL()

Used by subclasses to initialize OpenGL state.

func clearGLContext()

Releases the NSOpenGLContext object associated with the view.

var openGLContext: NSOpenGLContext?

The NSOpenGLContext object associated with the receiver.

Managing the Visible Region

func reshape()

Called by Cocoa when the view's visible rectangle or bounds change.

func update()

Called by Cocoa when the view’s window moves or when the view itself moves or is resized.

Instance Properties

See Also

Content Views

Browser View

Provide a column-based interface for viewing and navigating hierarchical information.

Collection View

Display one or more subviews in a highly configurable arrangement.

Outline View

Display a list-based interface for hierarchical data, where each level of hierarchy is indented from the previous one.

Table View

Display custom data in rows and columns.

class NSTextView

A view that draws text and handles user interactions with that text.