-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmat.py
27 lines (24 loc) · 824 Bytes
/
mat.py
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
import pystache
template_mat = '''
{{comment}}
struct mat<{{genType}}, {{N}}, {{M}}> : std::array<vec<{{genType}}, {{M}}>, {{N}}>{
// constructor
mat<{{genType}}, {{N}}, {{M}}>();
mat<{{genType}}, {{N}}, {{M}}>({{genType}});
{{{constructors}}}
{{{submat}}}
};
'''
class mat:
def __init__(self, genType, N, M) -> None:
self.content = {"content": pystache.render(template_mat, {
"comment": "// GLSL matrix. Lack of irregular constructor support.",
"genType": genType,
"N":N,
"M":M,
"constructors": f'''\
mat<{genType}, {N}, {M}>({", ".join([f"{genType}"]*(N*M))});
mat<{genType}, {N}, {M}>({", ".join([f"vec<{genType}, M>"]*N)});
template<uint NN, uint MM>
mat<{genType}, {N}, {M}>(mat<{genType}, NN, MM>);''',
})}