summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/41-tess/matrices.sh
blob: b52e56846405f7cbb38c44814355075a8ebc975f (plain) (blame)
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
63
64
65
66
67
68
//I decided to keep the non square matrices definition in the example, since I am still not sure how non square matrices should be treated in bgfx (Daniel Gavin)

#ifndef MATRICES_H_HEADER_GUARD
#define MATRICES_H_HEADER_GUARD

#ifndef __cplusplus

#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_SPIRV || BGFX_SHADER_LANGUAGE_METAL

#   define mat3x4 float4x3
#   define mat4x3 float3x4

#else


#endif // BGFX_SHADER_LANGUAGE_*

mat4x3 mtxFromRows(vec4 _0, vec4 _1, vec4 _2)
{
#if BGFX_SHADER_LANGUAGE_GLSL
    return transpose(mat3x4(_0, _1, _2) );
#else
	return mat4x3(_0, _1, _2);
#endif // BGFX_SHADER_LANGUAGE_GLSL
}

vec4 mtxGetRow(mat4x3 _0, uint row)
{
#if BGFX_SHADER_LANGUAGE_GLSL
    return vec4(_0[0][row], _0[1][row], _0[2][row], _0[3][row]);
#else
    return vec4(_0[row]);
#endif // BGFX_SHADER_LANGUAGE_GLSL
}

vec4 mtxGetRow(mat4 _0, uint row)
{
#if BGFX_SHADER_LANGUAGE_GLSL
    return vec4(_0[0][row], _0[1][row], _0[2][row], _0[3][row]);
#else
    return vec4(_0[row]);
#endif // BGFX_SHADER_LANGUAGE_GLSL
}

vec4 mtxGetColumn(mat4 _0, uint column)
{
#if BGFX_SHADER_LANGUAGE_GLSL
    return vec4(_0[column]);
#else
    return vec4(_0[0][column], _0[1][column], _0[2][column], _0[3][column]);
#endif // BGFX_SHADER_LANGUAGE_GLSL
}

float mtxGetElement(mat4 _0, uint column, uint row)
{
#if BGFX_SHADER_LANGUAGE_GLSL
    return _0[column][row];
#else
    return _0[row][column];
#endif // BGFX_SHADER_LANGUAGE_GLSL
}


#endif // __cplusplus

#endif // MATRICES_H_HEADER_GUARD