<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 - 18.0.0",
    "macOS: 10.4.0 - 15.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "CoreVideo",
  "identifier" : "/documentation/CoreVideo/CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Video"
    ],
    "preciseIdentifier" : "c:@F@CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext"
  },
  "title" : "CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(_:_:_:)"
}
-->

# CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(_:_:_:)

Selects the display link most optimal for the current renderer of an OpenGL context.

```
func CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(_ displayLink: CVDisplayLink, _ cglContext: CGLContextObj, _ cglPixelFormat: CGLPixelFormatObj) -> CVReturn
```

## Parameters

`displayLink`

The display link whose current display is to be set.

`cglContext`

The OpenGL context to retrieve the current renderer from.

`cglPixelFormat`

The OpenGL pixel format used to create the passed-in OpenGL context.

## Return Value

A Core Video result code. See [Core Video Constants](/documentation/CoreVideo/core-video-constants) for possible values.

## Discussion

This function chooses the display with the lowest refresh rate.

---

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)