<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOpenGLPixelFormat",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOpenGLPixelFormat"
  },
  "title" : "NSOpenGLPixelFormat"
}
-->

# NSOpenGLPixelFormat

An object that specifies the types of buffers and other attributes of the OpenGL context.

```
class NSOpenGLPixelFormat
```

## Overview

To render with OpenGL into an [`NSOpenGLContext`](/documentation/AppKit/NSOpenGLContext), you must specify the context’s pixel format.

Every [`NSOpenGLPixelFormat`](/documentation/AppKit/NSOpenGLPixelFormat) object wraps a low-level, platform-specific Core OpenGL (CGL) pixel format object. Your application can retrieve the CGL pixel format object by calling the [`cglPixelFormatObj`](/documentation/AppKit/NSOpenGLPixelFormat/cglPixelFormatObj) method. For more information on the underling CGL pixel format object, see `CGL`.

## Topics

### Creating an OpenGL Pixel Format

[`init(cglPixelFormatObj:)`](/documentation/AppKit/NSOpenGLPixelFormat/init(cglPixelFormatObj:)-2zqw4)

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

[`init(attributes:)`](/documentation/AppKit/NSOpenGLPixelFormat/init(attributes:))

Returns an OpenGL pixel format object initialized with specified pixel format attributes.

[`initWithData:`](/documentation/AppKit/NSOpenGLPixelFormat/initWithData:)

Returns an OpenGL pixel format object initialized with specified pixel format attribute data.

### Managing the Pixel Format

[`cglPixelFormatObj`](/documentation/AppKit/NSOpenGLPixelFormat/cglPixelFormatObj)

The low-level, platform-specific Core OpenGL (CGL) pixel format object represented by the receiver.

[`getValues(_:forAttribute:forVirtualScreen:)`](/documentation/AppKit/NSOpenGLPixelFormat/getValues(_:forAttribute:forVirtualScreen:))

Gets the value for the specified pixel format attribute.

[`numberOfVirtualScreens`](/documentation/AppKit/NSOpenGLPixelFormat/numberOfVirtualScreens)

The number of virtual screens associated with the OpenGL pixel format.

### Managing Attributes

[`attributes`](/documentation/AppKit/NSOpenGLPixelFormat/attributes)

The attribute data for the pixel format object.

[`setAttributes:`](/documentation/AppKit/NSOpenGLPixelFormat/setAttributes:)

Sets the attribute data for the pixel format object.

### Constants

[`NSOpenGLPixelFormatAttribute`](/documentation/AppKit/NSOpenGLPixelFormatAttribute)

Pixel format attributes for OpenGL.

[OpenGL Pixel Format Attributes](/documentation/AppKit/opengl-pixel-format-attributes)

Pixel format attributes for OpenGL.

[OpenGL Profiles](/documentation/AppKit/opengl-profiles)

Constants that specify the functionality provided by the renderer.



---

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)