# Class pyglet.gl.Context

OpenGL context for drawing.

Windows in pyglet each have their own GL context. This class boxes the context in a platform-independent manner. Applications will have no need to deal with contexts directly.

## Methods

| __init__(self, context_share=None)
| __repr__(self)
| set_current(self)
| destroy(self) Release the context.
| delete_texture(self, texture_id) Safely delete a texture belonging to this context.
| delete_buffer(self, buffer_id) Safely delete a buffer object belonging to this context.

## Instance Variables

ObjectSpace | object_space An object which is shared between all contexts that share GL objects.

## Constants

| CONTEXT_SHARE_NONE = `None`
| CONTEXT_SHARE_EXISTING = `1`

## Method Details

### destroy

destroy(self)

Release the context.

The context will not be usable 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.

### delete_texture

delete_texture(self, 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.

### delete_buffer

delete_buffer(self, 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.

Since: pyglet 1.1