<!--
{
  "availability" : [
    "macOS: 10.6.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOpenGLPixelFormat/init(cglPixelFormatObj:)-2zqw4",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOpenGLPixelFormat(im)initWithCGLPixelFormatObj:"
  },
  "title" : "init(cglPixelFormatObj:)"
}
-->

# init(cglPixelFormatObj:)

Returns an OpenGL pixel format object initialized with using an existing CGL pixel format object.

```
init?(cglPixelFormatObj format: CGLPixelFormatObj)
```

## Parameters

`format`

An existing CGL pixel format object.

## Return Value

An intialized [`NSOpenGLPixelFormat`](/documentation/AppKit/NSOpenGLPixelFormat) object that wraps the CGL pixel format object.

## Discussion

If your application already has a low-level CGL pixel format object, you can create an [`NSOpenGLPixelFormat`](/documentation/AppKit/NSOpenGLPixelFormat) object to wrap it by calling this initializer. The [`NSOpenGLPixelFormat`](/documentation/AppKit/NSOpenGLPixelFormat) object retains the CGL pixel format object by calling the `CGLRetainPixelFormat(_:)` function.

Your application should not call `CGLDestroyPixelFormat(_:)` to dispose of the CGL pixel format object. Instead, your application should call `CGLReleasePixelFormat(_:)` 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)