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

# CVOpenGLBufferAttach(_:_:_:_:_:)

Attaches an OpenGL context to a Core Video OpenGL buffer.

```
func CVOpenGLBufferAttach(_ openGLBuffer: CVOpenGLBuffer, _ cglContext: CGLContextObj, _ face: GLenum, _ level: GLint, _ screen: GLint) -> CVReturn
```

## Parameters

`openGLBuffer`

The buffer you want to attach an OpenGL context to.

`cglContext`

The OpenGL context you want to attach.

`face`

The OpenGL face enumeration (`0` for non-cube maps.)

`level`

The mipmap level for drawing in the OpenGL context. This value cannot exceed the maximum mipmap level for this buffer.

`screen`

The virtual screen number you want to use for this context.

## Return Value

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

## See Also

  [Core Video Programming Guide](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/CoreVideo/CVProg_Intro/CVProg_Intro.html#//apple_ref/doc/uid/TP40001536)



---

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)