<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: 10.6.0 - 10.7.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOpenGLPixelBuffer/initWithCGLPBufferObj:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOpenGLPixelBuffer(im)initWithCGLPBufferObj:"
  },
  "title" : "initWithCGLPBufferObj:"
}
-->

# initWithCGLPBufferObj:

Initializes and returns an OpenGL pixel buffer object that encapsulates an existing CGL pixel buffer object.

```
- (NSOpenGLPixelBuffer *) initWithCGLPBufferObj:(CGLPBufferObj) pbuffer;
```

## Parameters

`pbuffer`

The CGL pixel buffer object to wrap.

## Return Value

An initialized [`NSOpenGLPixelBuffer`](/documentation/AppKit/NSOpenGLPixelBuffer) object.

## Discussion

If your application already has a CGL pixel buffer object, you can wrap it inside an [`NSOpenGLPixelBuffer`](/documentation/AppKit/NSOpenGLPixelBuffer) object by using this initializer. This method retains the CGL pixel buffer object by calling the `CGLRetainPBuffer` function.

Your application should not call `CGLDestroyPBuffer` to dispose of the CGL pixel buffer object. Instead, your application should call `CGLReleasePBuffer` to decrement its reference count.

---

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)