---
title: "initWithCGLPBufferObj:"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsopenglpixelbuffer/initwithcglpbufferobj:"
---

# initWithCGLPBufferObj:

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

## Declaration

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

## Parameters

- `pbuffer`: The CGL pixel buffer object to wrap.

## Return Value

Return Value An initialized NSOpenGLPixelBuffer object.

## Discussion

Discussion If your application already has a CGL pixel buffer object, you can wrap it inside an 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.

## See Also

### Initializing an OpenGL Pixel Buffer

- [initWithTextureTarget:textureInternalFormat:textureMaxMipMapLevel:pixelsWide:pixelsHigh:](appkit/nsopenglpixelbuffer/initwithtexturetarget:textureinternalformat:texturemaxmipmaplevel:pixelswide:pixelshigh:.md)
