Context Class

Inheritance diagram of Context

class Context(config, context_share=None)

OpenGL context for drawing.

Use CanvasConfig.create_context to create a context.

Variables:object_space – An object which is shared between all contexts that share GL objects.

Constructor:

__init__(config, context_share=None)

Methods:

attach(canvas)
delete_buffer(buffer_id) Safely delete a buffer object belonging to this context.
delete_texture(texture_id) Safely delete a texture belonging to this context.
destroy() Release the context.
detach()
get_info() Get the OpenGL information for this context.
set_current()

Attributes:

Methods

Context.attach(canvas)
Context.delete_buffer(buffer_id)

Safely delete a buffer object belonging to this context.

This method behaves similarly to delete_texture, though for glDeleteBuffers instead of glDeleteTextures.

Parameters:buffer_id (int) – The OpenGL name of the buffer to delete.

Note

Since pyglet 1.1

Context.delete_texture(texture_id)

Safely delete a texture belonging to this context.

Usually, the texture is released immediately using glDeleteTextures, however if another context that does not share this context’s object space is currently active, the deletion will be deferred until an appropriate context is activated.

Parameters:texture_id (int) – The OpenGL name of the texture to delete.
Context.destroy()

Release the context.

The context will not be useable after being destroyed. Each platform has its own convention for releasing the context and the buffer(s) that depend on it in the correct order; this should never be called by an application.

Context.detach()
Context.get_info()

Get the OpenGL information for this context.

Note

Since pyglet 1.2

Return type:GLInfo
Context.set_current()

Attributes

Context.CONTEXT_SHARE_EXISTING = 1

Context share behaviour indicating that objects are shared with the most recently created context (the default).

Context.CONTEXT_SHARE_NONE = None

Context share behaviour indicating that objects should not be shared with existing contexts.

Table Of Contents

Previous topic

Config Class

Next topic

ObjectSpace Class