Welcome to Python-flavored Magnum! Please note that, while already being rather stable, this functionality is still considered experimental and some APIs might get changed without preserving full backwards compatibility.

magnum.shaders.FlatGL2D class

2D flat OpenGL shader

Enums

class Flags: TEXTURED = 1 ALPHA_MASK = 2 VERTEX_COLOR = 2 TEXTURE_TRANSFORMATION = 8 INSTANCED_TRANSFORMATION = 64 INSTANCED_TEXTURE_OFFSET = 136 NONE = 0
Flags

Methods

def bind_texture(self, arg0: gl.Texture2D, /) -> None
Bind a color texture
def draw(self, arg0: gl.Mesh, /) -> None
Draw a mesh
def validate(self, /) -> tuple[bool, str]
Validate program

Special methods

def __init__(self, *, flags: Flags = Flags.NONE) -> None
Constructor

Properties

alpha_mask: float set
Alpha mask
color: Color4 set
Color
flags: Flags get
Flags
id: int get
OpenGL program ID
texture_matrix: Matrix3 set
Texture matrix
transformation_projection_matrix: Matrix3 set
Transformation and projection matrix

Data

COLOR3: gl.Attribute
Three-component vertex color
COLOR4: gl.Attribute
Four-component vertex color
POSITION: gl.Attribute
Vertex position
TEXTURE_COORDINATES: gl.Attribute
2D texture coordinates
TEXTURE_OFFSET: gl.Attribute
(Instanced) texture offset
TRANSFORMATION_MATRIX: gl.Attribute
(Instanced) transformation matrix
TransformFeedbackBufferMode
attach_shader
bind_attribute_location
bind_fragment_data_location
bind_fragment_data_location_indexed
dispatch_compute
retrievable_binary
separable
set_uniform
set_uniform_block_binding
uniform_block_index
uniform_location

Method documentation

def magnum.shaders.FlatGL2D.bind_texture(self, arg0: gl.Texture2D, /) -> None

Bind a color texture

Exceptions
AttributeError If the shader was not created with Flags.TEXTURED

Property documentation

magnum.shaders.FlatGL2D.alpha_mask: float set

Alpha mask

Exceptions
AttributeError If the shader was not created with Flags.ALPHA_MASK

magnum.shaders.FlatGL2D.texture_matrix: Matrix3 set

Texture matrix

Exceptions
AttributeError If the shader was not created with Flags.TEXTURE_TRANSFORMATION