<!--
{
  "availability" : [
    "macOS: 10.6.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOpenGLLayer/draw(in:pixelFormat:forLayerTime:displayTime:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOpenGLLayer(im)drawInOpenGLContext:pixelFormat:forLayerTime:displayTime:"
  },
  "title" : "draw(in:pixelFormat:forLayerTime:displayTime:)"
}
-->

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

Draws the OpenGL content for the specified time.

```
func draw(in context: NSOpenGLContext, pixelFormat: NSOpenGLPixelFormat, forLayerTime t: CFTimeInterval, displayTime ts: UnsafePointer<CVTimeStamp>)
```

## Parameters

`context`

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

`pixelFormat`

The pixel format used when the context 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.

---

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)