<!--
{
  "availability" : [
    "macOS: 10.4.0 - 10.6.0"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIContext/contextWithCGLContext:pixelFormat:options:",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Core Image"
    ],
    "preciseIdentifier" : "c:objc(cs)CIContext(cm)contextWithCGLContext:pixelFormat:options:"
  },
  "title" : "contextWithCGLContext:pixelFormat:options:"
}
-->

# contextWithCGLContext:pixelFormat:options:

Creates a Core Image context from a CGL context, using the specified options and pixel format object.

```
+ (CIContext *) contextWithCGLContext:(CGLContextObj) cglctx pixelFormat:(CGLPixelFormatObj) pixelFormat options:(NSDictionary<NSString *,id> *) options;
```

## Parameters

`cglctx`

A CGL context (`CGLContextObj` object) obtain by calling the CGL function `CGLCreateContext`.

`pixelFormat`

A CGL pixel format object (`CGLPixelFormatObj` object) created by calling the CGL function `CGLChoosePixelFormat`. This argument must be the same pixel format object used to create the CGL context. The pixel format object must be valid for the lifetime of the Core Image context. Don’t release the pixel format object until after you release the Core Image context.

`options`

A dictionary that contains color space information. You can provide the keys [`outputColorSpace`](/documentation/CoreImage/CIContextOption/outputColorSpace) or [`workingColorSpace`](/documentation/CoreImage/CIContextOption/workingColorSpace) along with a <doc://com.apple.documentation/documentation/CoreGraphics/CGColorSpace> object for each color space.

## See Also

[`init(cgContext:options:)`](/documentation/CoreImage/CIContext/init(cgContext:options:)-6p78w)

Creates a Core Image context from a Quartz context, using the specified options.



---

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)