<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOpenGLView/init(frame:pixelFormat:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOpenGLView(im)initWithFrame:pixelFormat:"
  },
  "title" : "init(frame:pixelFormat:)"
}
-->

# init(frame:pixelFormat:)

Returns an `NSOpenGLView` object initialized with the specified frame rectangle and pixel format.

```
init?(frame frameRect: NSRect, pixelFormat format: NSOpenGLPixelFormat?)
```

## Parameters

`frameRect`

The frame rectangle for the view, specified in the coordinate system of its parent view.

`format`

The pixel format to use when creating the view’s `NSOpenGLContext` object.

## Return Value

An initialized `NSOpenGLView` object, or `nil` if the object could not be initialized.

## See Also

[`+  defaultPixelFormat`](/documentation/AppKit/NSOpenGLView/defaultPixelFormat())

Returns a default [`NSOpenGLPixelFormat`](/documentation/AppKit/NSOpenGLPixelFormat) object.



---

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)