
setUniformMatrix4(name, list, transpose)
- Transposes the way the matrix is read. By column or by row.
name:
- Type: string
- your name for the matrix
- Type: List [ 4x4 Matrix ]
- example: ([1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1])
- Type: boolean
- True = row
- False = column
Note:
- Shaders work with Viewport Shading GLSL and Viewport Shading Multitexture.
- Shaders don't work with Viewport Shading Singletexture.

Sample Code
############################# transpose 4x4 matrix
############## main program
def main():
# import bge
import bge
# get the current controller
cont = bge.logic.getCurrentController()
# get object that owns this controller
obj = cont.owner
# Get a list of the mesh
meshList = obj.meshes
# Get the first mesh on the object
mesh = meshList[0]
# only one material on mesh
mat = mesh.materials[0]
# Using Blender GLSL Materials or Blender Multitexture Materials?
if hasattr( mat, 'getMaterialIndex') == True:
import bge
# get the current controller
cont = bge.logic.getCurrentController()
# get object that owns this controller
obj = cont.owner
# Get a list of the mesh
meshList = obj.meshes
# Get the first mesh on the object
mesh = meshList[0]
# only one material on mesh
mat = mesh.materials[0]
# Using Blender GLSL Materials or Blender Multitexture Materials?
if hasattr( mat, 'getMaterialIndex') == True:
# get shader envelope
shader = mat.getShader()
# did it get the shader envelope?
if shader != None:
shader = mat.getShader()
# did it get the shader envelope?
if shader != None:
# set the source and use it
shader.setSource(VertexProgram,FragmentProgram, True)
# Example 4x4 list
exampleList = ([1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1])
# transpose way OpenGL uniform mat3 variable # named "myMatrix" is read
shader.setUniformMatrix4("myMatrix", exampleList, True)
shader.setSource(VertexProgram,FragmentProgram, True)
# Example 4x4 list
exampleList = ([1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1])
# transpose way OpenGL uniform mat3 variable # named "myMatrix" is read
shader.setUniformMatrix4("myMatrix", exampleList, True)
####### end of main program
VertexProgram = """
void main() {
// OpenGL glsl code
gl_Position = ftransform();
}
"""
FragmentProgram = """
// float passed from main program
uniform mat4 myMatrix;
void main()
{
// OpenGL GLSL code
}
"""
############ Run Program
main()