---
title: "init(api:)"
framework: opengles
role: symbol
role_heading: Initializer
path: "opengles/eaglcontext/init(api:)-q09o"
---

# init(api:)

Initializes and returns a newly allocated rendering context with the specified version of the OpenGL ES rendering API.

## Declaration

```swift
convenience init?(api: EAGLRenderingAPI)
```

## Parameters

- `api`: The desired version of the OpenGL ES rendering API. For legal values, see doc://com.apple.opengles/documentation/OpenGLES/EAGLRenderingAPI.

## Return Value

Return Value An initialized context object, or nil if the object couldn’t be created.

## Discussion

Discussion To issue OpenGL ES commands to this context, you must first make the context current by calling setCurrent(_:). Calling init(api:) creates a new EAGLSharegroup object and attaches it to this context.

## See Also

### Related Documentation

- [OpenGL ES Programming Guide](apple-archive/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/Introduction.md)
