---
title: "CVOpenGLBufferAttach(_:_:_:_:_:)"
framework: Core Video
role: symbol
role_heading: Function
platforms: [macOS 10.4+]
path: "corevideo/cvopenglbufferattach(_:_:_:_:_:)"
---

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

Attaches an OpenGL context to a Core Video OpenGL buffer.

## Declaration

```swift
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

Return Value A Core Video result code. See Core Video Constants for possible values.

## See Also

### Related Documentation

- [Core Video Programming Guide](apple-archive/documentation/GraphicsImaging/Conceptual/CoreVideo/CVProg_Intro.md)

### Functions

- [CVOpenGLBufferCreate(_:_:_:_:_:)](corevideo/cvopenglbuffercreate(_:_:_:_:_:).md)
- [CVOpenGLBufferGetAttributes(_:)](corevideo/cvopenglbuffergetattributes(_:).md)
- [CVOpenGLBufferGetTypeID()](corevideo/cvopenglbuffergettypeid().md)
