pyglet.gl

OpenGL interface.

This package imports all OpenGL and registered OpenGL extension functions. Functions have identical signatures to their C counterparts.

OpenGL is documented in full at the OpenGL Reference Pages.

The OpenGL Programming Guide, also known as “The Red Book”, is a popular reference manual organised by topic. It is available in digital and paper editions.

The following subpackages are imported into this “mega” package already (and so are available by importing pyglet.gl):

pyglet.gl.gl

OpenGL

pyglet.gl.gl.glext_arb

ARB registered OpenGL extension functions

pyglet.gl.gl.gl_compat

Deprecated OpenGL extension functions.

These subpackages are also available, but are not imported into this namespace by default:

pyglet.gl.glext_nv

nVidia OpenGL extension functions

pyglet.gl.agl

AGL (Mac OS X OpenGL context functions)

pyglet.gl.glx

GLX (Linux OpenGL context functions)

pyglet.gl.glxext_arb

ARB registered GLX extension functions

pyglet.gl.glxext_nv

nvidia GLX extension functions

pyglet.gl.wgl

WGL (Windows OpenGL context functions)

pyglet.gl.wglext_arb

ARB registered WGL extension functions

pyglet.gl.wglext_nv

nvidia WGL extension functions

The information modules are provided for convenience, and are documented below.

exception GLException
class Config

Graphics configuration.

A Config stores the preferences for OpenGL attributes such as the number of auxiliary buffers, size of the colour and depth buffers, double buffering, stencilling, multi- and super-sampling, and so on.

Different platforms support a different set of attributes, so these are set with a string key and a value which is integer or boolean.

accum_alpha_size: int

Bits per pixel devoted to the alpha component in the accumulation buffer.

accum_blue_size: int

Bits per pixel devoted to the blue component in the accumulation buffer.

accum_green_size: int

Bits per pixel devoted to the green component in the accumulation buffer.

accum_red_size: int

Bits per pixel devoted to the red component in the accumulation buffer.

alpha_size: int

Bits per sample per buffer devoted to the alpha component.

aux_buffers: int

The number of auxiliary color buffers.

blue_size: int

Bits per sample per buffer devoted to the blue component.

buffer_size: int

Total bits per sample per color buffer.

debug: bool

Debug mode.

depth_size: int

Bits per sample in the depth buffer.

double_buffer: bool

Specify the presence of a back-buffer for every color buffer.

forward_compatible: bool

Whether to use forward compatibility mode.

green_size: int

Bits per sample per buffer devoted to the green component.

major_version: int

The OpenGL major version.

minor_version: int

The OpenGL minor version.

opengl_api: str

The OpenGL API, such as “gl” or “gles”.

red_size: int

Bits per sample per buffer devoted to the red component.

sample_buffers: int

The number of multisample buffers.

samples: int

The number of samples per pixel, or 0 if there are no multisample buffers.

stencil_size: int

Bits per sample in the stencil buffer.

stereo: bool

Specify the presence of separate left and right buffer sets.

transparent_framebuffer: bool

If the framebuffer should be transparent.

GLDEBUGPROC

alias of CFunctionType

GLbitfield

alias of c_uint

GLboolean

alias of c_ubyte

GLbyte

alias of c_byte

GLchar

alias of c_char

GLclampd

alias of c_double

GLclampf

alias of c_float

GLclampx

alias of c_uint

GLdouble

alias of c_double

GLenum

alias of c_uint

GLfloat

alias of c_float

GLint

alias of c_int

GLint64

alias of c_long

GLintptr

alias of c_long

GLshort

alias of c_short

GLsizei

alias of c_int

GLsizeiptr

alias of c_long

GLsync

alias of LP_struct___GLsync

GLubyte

alias of c_ubyte

GLuint

alias of c_uint

GLuint64

alias of c_ulong

GLuint64EXT

alias of c_ulong

GLushort

alias of c_ushort

class GLException
__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
class ObjectSpace

A container to store shared objects that are to be removed.

class Config

Graphics configuration.

A Config stores the preferences for OpenGL attributes such as the number of auxiliary buffers, size of the colour and depth buffers, double buffering, stencilling, multi- and super-sampling, and so on.

Different platforms support a different set of attributes, so these are set with a string key and a value which is integer or boolean.

accum_alpha_size: int

Bits per pixel devoted to the alpha component in the accumulation buffer.

accum_blue_size: int

Bits per pixel devoted to the blue component in the accumulation buffer.

accum_green_size: int

Bits per pixel devoted to the green component in the accumulation buffer.

accum_red_size: int

Bits per pixel devoted to the red component in the accumulation buffer.

alpha_size: int

Bits per sample per buffer devoted to the alpha component.

aux_buffers: int

The number of auxiliary color buffers.

blue_size: int

Bits per sample per buffer devoted to the blue component.

buffer_size: int

Total bits per sample per color buffer.

debug: bool

Debug mode.

depth_size: int

Bits per sample in the depth buffer.

double_buffer: bool

Specify the presence of a back-buffer for every color buffer.

forward_compatible: bool

Whether to use forward compatibility mode.

green_size: int

Bits per sample per buffer devoted to the green component.

major_version: int

The OpenGL major version.

minor_version: int

The OpenGL minor version.

opengl_api: str

The OpenGL API, such as “gl” or “gles”.

red_size: int

Bits per sample per buffer devoted to the red component.

sample_buffers: int

The number of multisample buffers.

samples: int

The number of samples per pixel, or 0 if there are no multisample buffers.

stencil_size: int

Bits per sample in the stencil buffer.

stereo: bool

Specify the presence of separate left and right buffer sets.

transparent_framebuffer: bool

If the framebuffer should be transparent.

class DisplayConfig

Bases: Config, ABC

An OpenGL configuration for a particular display.

Use Config.match to obtain an instance of this class.

Added in version 1.2.

canvas: Canvas

The canvas this config is valid on.

class Context

A base OpenGL context for drawing.

Use DisplayConfig.create_context to create a context.

config: DisplayConfig
context_share: Context | None
object_space: ObjectSpace

A container which is shared between all contexts that share GL objects.