Skip to content
Permalink
Browse files

tests: add unit test for passing plain mat3/mat4 to GLSL shader

  • Loading branch information
rdb committed Jan 25, 2020
1 parent 508444d commit 6c66c8618db806841a47b858d5e05c7071eeaa72
Showing with 48 additions and 0 deletions.
  1. +48 −0 tests/display/test_glsl_shader.py
@@ -261,6 +261,54 @@ def test_glsl_bool(gsg):
run_glsl_test(gsg, code, preamble, flags)


def test_glsl_mat3(gsg):
param1 = core.LMatrix4(core.LMatrix3(1, 2, 3, 4, 5, 6, 7, 8, 9))

param2 = core.NodePath("param2")
param2.set_mat(core.LMatrix3(10, 11, 12, 13, 14, 15, 16, 17, 18))

preamble = """
uniform mat3 param1;
uniform mat3 param2;
"""
code = """
assert(param1[0] == vec3(1, 2, 3));
assert(param1[1] == vec3(4, 5, 6));
assert(param1[2] == vec3(7, 8, 9));
assert(param2[0] == vec3(10, 11, 12));
assert(param2[1] == vec3(13, 14, 15));
assert(param2[2] == vec3(16, 17, 18));
"""
run_glsl_test(gsg, code, preamble, {'param1': param1, 'param2': param2})


def test_glsl_mat4(gsg):
param1 = core.LMatrix4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)

param2 = core.NodePath("param2")
param2.set_mat(core.LMatrix4(
17, 18, 19, 20,
21, 22, 23, 24,
25, 26, 27, 28,
29, 30, 31, 32))

preamble = """
uniform mat4 param1;
uniform mat4 param2;
"""
code = """
assert(param1[0] == vec4(1, 2, 3, 4));
assert(param1[1] == vec4(5, 6, 7, 8));
assert(param1[2] == vec4(9, 10, 11, 12));
assert(param1[3] == vec4(13, 14, 15, 16));
assert(param2[0] == vec4(17, 18, 19, 20));
assert(param2[1] == vec4(21, 22, 23, 24));
assert(param2[2] == vec4(25, 26, 27, 28));
assert(param2[3] == vec4(29, 30, 31, 32));
"""
run_glsl_test(gsg, code, preamble, {'param1': param1, 'param2': param2})


def test_glsl_pta_int(gsg):
pta = core.PTA_int((0, 1, 2, 3))

0 comments on commit 6c66c86

Please sign in to comment.
You can’t perform that action at this time.