-
Notifications
You must be signed in to change notification settings - Fork 2
/
matrix_scalar.glsl
62 lines (41 loc) · 1.25 KB
/
matrix_scalar.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//precision highp float;
mat3 m3;
vec3 r1;
vec3 r2;
vec3 r3;
bool test(){
m3[0] = r1;
m3[1] = r2;
m3[2] = r3;
m3 *= 2.0;
bool checkpoint = m3[0][0] == 2.0 && m3[1][1] == 10.0 && m3[2][1] == 16.0;
++m3;
checkpoint = checkpoint && m3[0][0] == 3.0 && m3[1][1] == 11.0 && m3[2][1] == 17.0;
m3--;
checkpoint = checkpoint && m3[0][0] == 2.0 && m3[1][1] == 10.0 && m3[2][1] == 16.0;
m3 = -m3;
checkpoint = checkpoint && m3[0][0] == -2.0 && m3[1][1] == -10.0 && m3[2][1] == -16.0;
m3 = +m3;
m3 = m3;
checkpoint = checkpoint && m3[0][0] == -2.0 && m3[1][1] == -10.0 && m3[2][1] == -16.0;
m3 = 1.0 - m3;
checkpoint = checkpoint && m3[0][0] == 3.0 && m3[1][1] == 11.0 && m3[2][1] == 17.0;
m3 = m3 - 1.0;
checkpoint = checkpoint && m3[0][0] == 2.0 && m3[1][1] == 10.0 && m3[2][1] == 16.0;
m3 = m3 * 2.0;
checkpoint = checkpoint && m3[0][0] == 4.0 && m3[1][1] == 20.0 && m3[2][1] == 32.0;
m3 += 1.0;
m3 /= 1.0;
checkpoint = checkpoint && m3[0].x == 5.0 && m3[1].y == 21.0 && m3[2].y == 33.0;
return checkpoint;
}
// Expected output: 3432355
/*
void main()
{
if(test() == 14911715) // Assert function returns expected value
gl_FragColor = vec4(0,1,0,1.0); // green
else
gl_FragColor = vec4(1,0,0,1.0); // red
}
*/