---
title: "copyCGLContext(forPixelFormat:)"
framework: quartzcore
role: symbol
role_heading: Instance Method
path: "quartzcore/caopengllayer/copycglcontext(forpixelformat:)"
---

# copyCGLContext(forPixelFormat:)

Returns the rendering context the receiver requires for the specified pixel format.

## Declaration

```swift
func copyCGLContext(forPixelFormat pf: CGLPixelFormatObj) -> CGLContextObj
```

## Parameters

- `pf`: The pixel format for the rendering context.

## Return Value

Return Value A new CGLContext with renderers for pixelFormat.

## Discussion

Discussion This method is called when a rendering context is needed by the receiver. The default implementation allocates a new context with a null share context. You should not call this method directly, it is intended to be overridden by subclasses.

## See Also

### Managing the Rendering Context

- [releaseCGLContext(_:)](quartzcore/caopengllayer/releasecglcontext(_:).md)
