<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.5.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "QuartzCore",
  "identifier" : "/documentation/QuartzCore/CAOpenGLLayer/draw(inCGLContext:pixelFormat:forLayerTime:displayTime:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Animation"
    ],
    "preciseIdentifier" : "c:objc(cs)CAOpenGLLayer(im)drawInCGLContext:pixelFormat:forLayerTime:displayTime:"
  },
  "title" : "draw(inCGLContext:pixelFormat:forLayerTime:displayTime:)"
}
-->

# draw(inCGLContext:pixelFormat:forLayerTime:displayTime:)

Draws the OpenGL content for the specified time.

```
func draw(inCGLContext ctx: CGLContextObj, pixelFormat pf: CGLPixelFormatObj, forLayerTime t: CFTimeInterval, displayTime ts: UnsafePointer<CVTimeStamp>?)
```

## Parameters

`ctx`

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

`pf`

The pixel format used when the `glContext` was created.

`t`

The current layer time.

`ts`

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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)