---
title: "init(forOfflineGPUAtIndex:colorSpace:options:sharedContext:)"
framework: coreimage
role: symbol
role_heading: Initializer
path: "coreimage/cicontext/init(forofflinegpuatindex:colorspace:options:sharedcontext:)"
---

# init(forOfflineGPUAtIndex:colorSpace:options:sharedContext:)

Creates an OpenGL-based Core Image context using a GPU that is not currently driving a display, with the specified options.

## Declaration

```swift
init?(forOfflineGPUAtIndex index: UInt32, colorSpace: CGColorSpace?, options: [CIContextOption : Any]? = nil, sharedContext: CGLContextObj?)
```

## Parameters

- `index`: The index of the offline GPU with which to create the context; a number between zero and the value returned by the doc://com.apple.coreimage/documentation/CoreImage/CIContext/offlineGPUCount() method.
- `colorSpace`: A color space object encapsulating color space information that is used to specify how color values are interpreted.
- `options`: A dictionary that contains options for creating a doc://com.apple.coreimage/documentation/CoreImage/CIContext object. You can pass any of the keys defined in doc://com.apple.coreimage/documentation/CoreImage/CIContextOption along with the appropriate value.
- `sharedContext`: A CGL context with which to share OpenGL resources, obtained by calling the CGL function CGLCreateContext(_:_:_:). Pass NULL to use a context that does not share OpenGL resources.

## Return Value

Return Value A Core Image context.

## Discussion

Discussion GPU devices that are not currently being used to drive a display can be used for Core Image rendering. Use the offlineGPUCount() method to determine whether any such GPUs are available. To create a Metal-based Core Image context using an offline GPU, use the MTLCopyAllDevices() function to list Metal devices, then choose a device without a display to pass to the init(mtlDevice:) method.

## See Also

### Deprecated

- [init(cglContext:pixelFormat:colorSpace:options:)](coreimage/cicontext/init(cglcontext:pixelformat:colorspace:options:)-6rp6d.md)
- [init(eaglContext:)](coreimage/cicontext/init(eaglcontext:)-8ajef.md)
- [init(eaglContext:options:)](coreimage/cicontext/init(eaglcontext:options:)-6uyqj.md)
- [init(forOfflineGPUAtIndex:)](coreimage/cicontext/init(forofflinegpuatindex:).md)
- [createCGLayer(with:info:)](coreimage/cicontext/createcglayer(with:info:).md)
- [draw(_:at:from:)](coreimage/cicontext/draw(_:at:from:).md)
