Skip to content

Commit f3f3327

Browse files
committed
Shader: Allow transposing of matrices in uniforms
1 parent 8ee41e7 commit f3f3327

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

demosys/opengl/shader.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,19 +632,20 @@ def uniform_4b(self, name, x, y, z, w):
632632

633633
# --- Matrices ---
634634

635-
def uniform_mat3(self, name, mat):
635+
def uniform_mat3(self, name, mat, transpose=GL.GL_FALSE):
636636
"""
637637
Sets a mat3 uniform
638638
639639
:param name: Name of the uniform
640640
:param mat: matrix
641+
:param transpose: Traspose the matrix
641642
"""
642643
if mat is None:
643644
raise ShaderError("Attempted to set uniform to None")
644645
uniform = self.uniform_check(name, GL.GL_FLOAT_MAT3)
645-
GL.glUniformMatrix3fv(uniform.location, 1, GL.GL_FALSE, mat)
646+
GL.glUniformMatrix3fv(uniform.location, 1, transpose, mat)
646647

647-
def uniform_mat4(self, name, mat):
648+
def uniform_mat4(self, name, mat, transpose=GL.GL_FALSE):
648649
"""
649650
Set a mat4 uniform
650651
@@ -654,7 +655,7 @@ def uniform_mat4(self, name, mat):
654655
if mat is None:
655656
raise ShaderError("Attempted to set uniform to None")
656657
uniform = self.uniform_check(name, GL.GL_FLOAT_MAT4)
657-
GL.glUniformMatrix4fv(uniform.location, 1, GL.GL_FALSE, mat)
658+
GL.glUniformMatrix4fv(uniform.location, 1, transpose, mat)
658659

659660
# --- Sampler ---
660661

0 commit comments

Comments
 (0)