pyglet.graphics.shader

exception ShaderException
class Attribute

Abstract accessor for an attribute in a mapped buffer.

c_type: Type[_SimpleCData]
count: int
element_size: int
gl_type: int
instance: bool
location: int
name: str
normalize: bool
stride: int
class ComputeShaderProgram

OpenGL Compute Shader Program.

property id: int
max_shared_memory_size: int
max_work_group_count: tuple[int, int, int]
max_work_group_invocations: int
max_work_group_size: tuple[int, int, int]
property uniform_blocks: dict[str, UniformBlock]
property uniforms: dict[str, dict[str, Any]]
class Shader

OpenGL shader.

Shader objects are compiled on instantiation. You can reuse a Shader object in multiple ShaderPrograms.

property id: int
type: Literal['vertex', 'fragment', 'geometry', 'compute', 'tesscontrol', 'tessevaluation']
class ShaderProgram

OpenGL shader program.

property attributes: dict[str, Any]

Attribute metadata dictionary.

This property returns a dictionary containing metadata of all Attributes that were introspected in this ShaderProgram. Modifying this dictionary has no effect.

property id: int
property uniform_blocks: dict[str, UniformBlock]

A dictionary of introspected UniformBlocks.

This property returns a dictionary of UniformBlock instances. They can be accessed by name. For example:

block = my_shader_program.uniform_blocks['WindowBlock']
ubo = block.create_ubo()
property uniforms: dict[str, Any]

Uniform metadata dictionary.

This property returns a dictionary containing metadata of all Uniforms that were introspected in this ShaderProgram. Modifying this dictionary has no effect. To set or get a uniform, the uniform name is used as a key on the ShaderProgram instance. For example:

my_shader_program[uniform_name] = 123
value = my_shader_program[uniform_name]
class ShaderSource

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 doesn’t contain several statements in one line.

class UniformBlock
binding: int
index: int
name: str
program: CallableProxyType[Callable[..., Any] | Any] | Any
size: int
uniform_count
uniforms: dict[int, tuple[str, GLDataType, int, int]]
view_cls: type[Structure] | None
class UniformBufferObject
binding: int
buffer: BufferObject
property id: int

The buffer ID associated with this UBO.

view: Structure