An EAGLContext object manages an OpenGL ES rendering context—the state information, commands, and resources needed to draw using OpenGL ES. To execute OpenGL ES commands, you need a current rendering context.


Drawing resources, such as textures and renderbuffers, are managed for the EAGLContext object by an EAGLSharegroup object associated with the context. When you initialize a new EAGLContext object, you can choose to have it create a new sharegroup, or you can use one obtained from a previously created context.

Before drawing to a context, you must bind a complete framebuffer object to the context. For more information on configuring rendering contexts, see OpenGL ES Programming Guide.


Creating Contexts

init?(api: EAGLRenderingAPI)

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

init?(api: EAGLRenderingAPI, sharegroup: EAGLSharegroup)

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

Setting the Current Context

class func setCurrent(EAGLContext?)

Makes the specified context the current rendering context for the calling thread.

Attaching Storage to a Renderbuffer

func renderbufferStorage(Int, from: EAGLDrawable?)

Binds a drawable object’s storage to an OpenGL ES renderbuffer object.

Displaying a Renderbuffer

func presentRenderbuffer(Int)

Displays a renderbuffer’s contents on screen.

Getting Context Information

var api: EAGLRenderingAPI

The OpenGL ES rendering API version supported by the context. (read-only)

var sharegroup: EAGLSharegroup

The context’s sharegroup object. (read-only)

var debugLabel: String?

A label describing the context for use in debugging.

class func current()

Returns the current rendering context for the calling thread.

Enabling OpenGL ES Multithreading

var isMultiThreaded: Bool

A Boolean value that determines whether OpenGL ES defers work to another thread.


enum EAGLRenderingAPI

Versions of OpenGL ES that a rendering context provides.


Inherits From

Conforms To

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software