Mac Developer Library

Developer

AppKit Framework Reference NSOpenGLLayer Class Reference

Options
Deployment Target:

On This Page
Language:

NSOpenGLLayer

Inheritance


Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.6 and later.

NSOpenGLLayer is a subclass of CAOpenGLLayer that is suitable for rendering OpenGL into layers. Unlike CAOpenGLLayer, NSOpenGLLayer uses distinctly Application Kit types.

  • Invoked to ask the layer whether it can (or should) draw.

    Declaration

    Swift

    func canDrawInOpenGLContext(_ context: NSOpenGLContext!, pixelFormat pixelFormat: NSOpenGLPixelFormat!, forLayerTime timeInterval: CFTimeInterval, displayTime timeStamp: UnsafePointer<CVTimeStamp>) -> Bool

    Objective-C

    - (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp

    Parameters

    context

    The NSOpenGLContext in to which the OpenGL content would be drawn.

    pixelFormat

    The pixel format used when the context was created.

    timeInterval

    The current layer time.

    timeStamp

    The display timestamp associated with timeInterval. Can be null.

    Return Value

    YEStrue if the receiver should render OpenGL content, NOfalse otherwise.

    Discussion

    This method is called before attempting to render the frame for the layer time specified by timeInterval. If the method returns NOfalse, the frame is skipped. The default implementation always returns YEStrue.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Draws the OpenGL content for the specified time.

    Declaration

    Swift

    func drawInOpenGLContext(_ context: NSOpenGLContext!, pixelFormat pixelFormat: NSOpenGLPixelFormat!, forLayerTime timeInterval: CFTimeInterval, displayTime timeStamp: UnsafePointer<CVTimeStamp>)

    Objective-C

    - (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp

    Parameters

    context

    The NSOpenGLContext in to which the OpenGL content would be drawn.

    pixelFormat

    The pixel format used when the context was created.

    timeInterval

    The current layer time.

    timeStamp

    The display timestamp associated with timeInterval. Can be null.

    Discussion

    This method is called when a new frame needs to be generated for the layer time specified by timeInterval.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Provides access to the layer's associated NSOpenGLPixelFormat.

    Declaration

    Swift

    var openGLPixelFormat: NSOpenGLPixelFormat!

    Objective-C

    @property(strong) NSOpenGLPixelFormat *openGLPixelFormat

    Discussion

    Subclasses shouldn't invoke setOpenGLPixelFormat:, but can override it if desired to intercept assignment of the layer's pixel format.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Returns the OpenGL pixel format suitable for the specified displays.

    Declaration

    Swift

    func openGLPixelFormatForDisplayMask(_ mask: UInt32) -> NSOpenGLPixelFormat!

    Objective-C

    - (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask

    Parameters

    mask

    A mask specifying the displays the returned NSOpenGLPixelFormat must be suitable for.

    Return Value

    An autoreleased NSOpenGLPixelFormat object suitable for the displays.

    Discussion

    You must include an NSOpenGLPFAScreenMask specification in the pixel format attribute list that's used to instantiate the NSOpenGLPixelFormat.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • The layer’s NSOpenGLContext.

    Declaration

    Swift

    var openGLContext: NSOpenGLContext!

    Objective-C

    @property(strong) NSOpenGLContext *openGLContext

    Discussion

    Provides access to the layer's associated NSOpenGLContext. Subclasses shouldn't invoke setOpenGLContext:, but can override it if desired to intercept assignment of the layer's context.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

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

    Declaration

    Swift

    func openGLContextForPixelFormat(_ pixelFormat: NSOpenGLPixelFormat!) -> NSOpenGLContext!

    Objective-C

    - (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat

    Parameters

    pixelFormat

    The pixel format.

    Return Value

    An autoreleased NSOpenGLContext.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • view view Property

    Returns the view associated with the layer.

    Declaration

    Swift

    unowned(unsafe) var view: NSView!

    Objective-C

    @property(assign) NSView *view

    Discussion

    Subclasses shouldn't invoke setView:, but can override it if desired to intercept the layer's association to, or dissociation from, a view.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.