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.Phong class

Phong shader

Enums

class Flags: AMBIENT_TEXTURE = 1 DIFFUSE_TEXTURE = 2 SPECULAR_TEXTURE = 4 NORMAL_TEXTURE = 16 ALPHA_MASK = 8 VERTEX_COLOR = 32 NONE = 0
Flags
class TransformFeedbackBufferMode: INTERLEAVED_ATTRIBUTES = 35980 SEPARATE_ATTRIBUTES = 35981
Buffer mode for transform feedback

Methods

def attach_shader(self, arg0: gl.Shader, /) -> None
Attach a shader
def bind_ambient_texture(self, arg0: gl.Texture2D, /) -> None
Bind an ambient texture
def bind_attribute_location(self, location: int, name: str) -> None
Bind an attribute to given location
def bind_diffuse_texture(self, arg0: gl.Texture2D, /) -> None
Bind a diffuse texture
def bind_fragment_data_location(self, location: int, name: str) -> None
Bind fragment data to given location and first color input index
def bind_fragment_data_location_indexed(self, location: int, index: int, name: str) -> None
Bind fragment data to given location and first color input index
def bind_normal_texture(self, arg0: gl.Texture2D, /) -> None
Bind a normal texture
def bind_specular_texture(self, arg0: gl.Texture2D, /) -> None
Bind a specular texture
def bind_textures(self, ambient: gl.Texture2D = None, diffuse: gl.Texture2D = None, specular: gl.Texture2D = None, normal: gl.Texture2D = None) -> None
Bind textures
def dispatch_compute(self, arg0: Vector3ui, /) -> None
Dispatch compute
Link the shader
def set_uniform(self, arg0: int, arg1: float, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: int, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: int, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Vector2, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Vector3, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Vector4, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Vector2i, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Vector3i, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Vector4i, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Vector2ui, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Vector3ui, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Vector4ui, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Vector2d, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Vector3d, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Vector4d, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix2x2, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix3x3, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix4x4, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix2x3, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix3x2, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix2x4, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix4x2, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix3x4, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix4x3, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix2x3d, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix3x2d, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix2x4d, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix4x2d, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix3x4d, /) -> None
Set uniform value
def set_uniform(self, arg0: int, arg1: Matrix4x3d, /) -> None
Set uniform value
def set_uniform_block_binding(self, arg0: int, arg1: int, /) -> None
Set uniform block binding
def uniform_block_index(self, arg0: str, /) -> int
Get uniform block index
def uniform_location(self, arg0: str, /) -> int
Get uniform location
def validate(self, /) -> typing.Tuple[bool, str]
Validate program

Special methods

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

Properties

alpha_mask: float set
Alpha mask
ambient_color: Color4 set
Ambient color
diffuse_color: Color4 set
Diffuse color
flags: Flags get
Flags
id: int get
OpenGL program ID
light_colors: typing.List[Color4] set
Light colors
light_count: int get
Light count
light_positions: typing.List[Vector3] set
Light positions
normal_matrix: Matrix3x3 set
Set normal matrix
projection_matrix: Matrix4 set
Set projection matrix
retrievable_binary: bool set
Allow retrieving program binary
separable: bool set
Allow the program to be bound to individual pipeline stages
shininess: float set
Shininess
specular_color: Color4 set
Specular color
transformation_matrix: Matrix4 set
Set transformation matrix

Data

COLOR3: gl.Attribute
Three-component vertex color
COLOR4: gl.Attribute
Four-component vertex color
NORMAL: gl.Attribute
Normal direction
POSITION: gl.Attribute
Vertex position
TANGENT: gl.Attribute
Tangent direction
TEXTURE_COORDINATES: gl.Attribute
2D texture coordinates

Method documentation

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

Bind an ambient texture

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

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

Bind a diffuse texture

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

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

Bind a normal texture

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

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

Bind a specular texture

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

def magnum.shaders.Phong.bind_textures(self, ambient: gl.Texture2D = None, diffuse: gl.Texture2D = None, specular: gl.Texture2D = None, normal: gl.Texture2D = None) -> None

Bind textures

Exceptions
AttributeError If the shader was not created with any of Flags.AMBIENT_TEXTURE, Flags.DIFFUSE_TEXTURE, Flags.SPECULAR_TEXTURE or Flags.NORMAL_TEXTURE

Property documentation

magnum.shaders.Phong.alpha_mask: float set

Alpha mask

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

magnum.shaders.Phong.light_colors: typing.List[Color4] set

Light colors

Exceptions
ValueError If list length is different from light_count

magnum.shaders.Phong.light_positions: typing.List[Vector3] set

Light positions

Exceptions
ValueError If list length is different from light_count