Mac Developer Library

Developer

QuartzCore Framework Reference CAOpenGLLayer Class Reference

Options
Deployment Target:

On This Page
Language:

CAOpenGLLayer

Conforms To


Import Statement


Swift

import QuartzCore

Objective-C

@import QuartzCore;

Availability


Available in OS X v10.5 and later.

CAOpenGLLayer provides a layer suitable for rendering OpenGL content.

To provide OpenGL content you subclass CAOpenGLLayer and override drawInCGLContext:pixelFormat:forLayerTime:displayTime:. You can specify that the OpenGL content is static by setting the asynchronous property to NOfalse.

  • Determines when the contents of the layer are updated.

    Declaration

    Swift

    var asynchronous: Bool

    Objective-C

    @property(getter=isAsynchronous) BOOL asynchronous

    Discussion

    If NOfalse, the contents of the layer are updated only in response to receiving a setNeedsDisplay message. When YEStrue, the receiver’s canDrawInCGLContext:pixelFormat:forLayerTime:displayTime: is called periodically to determine if the OpenGL content should be updated.

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • A synthesized accessor for the asynchronous property.

    Declaration

    Objective-C

    - (BOOL)isAsynchronous

    See Also

    asynchronous

  • Returns whether the receiver should draw OpenGL content for the specified time.

    Declaration

    Swift

    func canDrawInCGLContext(_ glContext: CGLContextObj, pixelFormat pixelFormat: CGLPixelFormatObj, forLayerTime timeInterval: CFTimeInterval, displayTime timeStamp: UnsafePointer<CVTimeStamp>) -> Bool

    Objective-C

    - (BOOL)canDrawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp

    Parameters

    glContext

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

    pixelFormat

    The pixel format used when the glContext 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 QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Draws the OpenGL content for the specified time.

    Declaration

    Swift

    func drawInCGLContext(_ glContext: CGLContextObj, pixelFormat pixelFormat: CGLPixelFormatObj, forLayerTime timeInterval: CFTimeInterval, displayTime timeStamp: UnsafePointer<CVTimeStamp>)

    Objective-C

    - (void)drawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp

    Parameters

    glContext

    The rendering context in to which the OpenGL content should be rendered.

    pixelFormat

    The pixel format used when the glContext 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. The viewport of glContext is set correctly for the size of the layer. No other state is defined. If the method enables OpenGL features, it should disable them before returning.

    The default implementation of the method flushes the context.

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Returns the OpenGL pixel format suitable for rendering to the set of displays specified by the display mask.

    Declaration

    Swift

    func copyCGLPixelFormatForDisplayMask(_ mask: UInt32) -> CGLPixelFormatObj

    Objective-C

    - (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask

    Parameters

    mask

    The display mask the OpenGL content will be rendered on.

    Discussion

    This method is called when a pixel format object is needed for the receiver. The default implementation returns a 32bpp fixed point pixelf format, with the NoRecovery and Accelerated flags set.

    You should not call this method directly, it is intended to be overridden by subclasses.

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Releases the specified OpenGL pixel format object.

    Declaration

    Swift

    func releaseCGLPixelFormat(_ pixelFormat: CGLPixelFormatObj)

    Objective-C

    - (void)releaseCGLPixelFormat:(CGLPixelFormatObj)pixelFormat

    Parameters

    pixelFormat

    The pixel format object to release.

    Discussion

    This method is called when the OpenGL pixel format that was previously returned by copyCGLContextForPixelFormat:.

    You should not call this method directly, it is intended to be overridden by subclasses.

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Returns the rendering context the receiver requires for the specified pixel format.

    Declaration

    Swift

    func copyCGLContextForPixelFormat(_ pixelFormat: CGLPixelFormatObj) -> CGLContextObj

    Objective-C

    - (CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat

    Parameters

    pixelFormat

    The pixel format for the rendering context.

    Return Value

    A new CGLContext with renderers for pixelFormat.

    Discussion

    This method is called when a rendering context is needed by the receiver. The default implementation allocates a new context with a null share context.

    You should not call this method directly, it is intended to be overridden by subclasses.

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Releases the specified rendering context.

    Declaration

    Swift

    func releaseCGLContext(_ glContext: CGLContextObj)

    Objective-C

    - (void)releaseCGLContext:(CGLContextObj)glContext

    Parameters

    glContext

    The rendering context to release.

    Discussion

    This method is called when the OpenGL context that was previously returned by copyCGLContextForPixelFormat: is no longer needed.

    You should not call this method directly, it is intended to be overridden by subclasses.

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.