pyglet.graphics.shader

exception ShaderException
class Shader(source_string, shader_type)

OpenGL Shader object

id
class ShaderProgram(*shaders)

OpenGL Shader Program

bind()
stop()
unbind()
use()
vertex_list(count, mode, batch=None, group=None, **data)

Create a VertexList.

Parameters:
count : int

The number of vertices in the list.

mode : int

OpenGL drawing mode enumeration; for example, one of GL_POINTS, GL_LINES, GL_TRIANGLES, etc.

batch : ~pyglet.graphics.Batch

Batch to add the VertexList to, or None if a Batch will not be used. Using a Batch is strongly recommended.

group : ~pyglet.graphics.Group

Group to add the VertexList to, or None if no group is required.

**data : str or tuple

Attribute formats and initial data for the vertex list.

Return type:

VertexList

vertex_list_indexed(count, mode, indices, batch=None, group=None, **data)

Create a IndexedVertexList.

Parameters:
count : int

The number of vertices in the list.

mode : int

OpenGL drawing mode enumeration; for example, one of GL_POINTS, GL_LINES, GL_TRIANGLES, etc.

indices : sequence of int

Sequence of integers giving indices into the vertex list.

batch : ~pyglet.graphics.Batch

Batch to add the VertexList to, or None if a Batch will not be used. Using a Batch is strongly recommended.

group : ~pyglet.graphics.Group

Group to add the VertexList to, or None if no group is required.

**data : str or tuple

Attribute formats and initial data for the vertex list.

Return type:

IndexedVertexList

attributes
id
uniform_blocks
uniforms
class ShaderSource(source: str, source_type: ctypes.c_uint)

GLSL source container for making source parsing simpler.

We support locating out attributes and applying #defines values.

NOTE: We do assume the source is neat enough to be parsed this way and don’t contain several statements in one line.

validate() → str

Return the validated shader source.

class UniformBlock(program, name, index, size, uniforms)
create_ubo(index=0)

Create a new UniformBufferObject from this uniform block.

Parameters:
index : int

The uniform buffer index the returned UBO will bind itself to. By default this is 0.

Return type:

UniformBufferObject

index
name
program
size
uniforms
view_cls
class UniformBufferObject(view_class, buffer_size, index)
bind(index=None)
read()

Read the byte contents of the buffer

buffer
id
index
view