forked from Queatz/glmpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·362 lines (322 loc) · 8.44 KB
/
setup.py
File metadata and controls
executable file
·362 lines (322 loc) · 8.44 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#!/usr/bin/env python3
import parseme
glmParse = parseme.Project()
# In the VECTOR section,
# p is a prefix to the name
# n is the number of components in the vector
# type is the common type of the vector
# Make sure to include all three of a type because swizzling relies on them
VECTOR = parseme.Section('VECTOR')
for t in (('', 'float'), ('i', 'int')):
for n in range(2, 5):
VECTOR.add(parseme.Round(p = t[0], n = n, type = t[1]))
glmParse.add(VECTOR)
VECTOR_MATH = parseme.Section('VECTOR_MATH')
VECTOR_MATH.add(parseme.Round(s = '+', f = 'add', only = None))
VECTOR_MATH.add(parseme.Round(s = '-', f = 'subtract', only = None))
VECTOR_MATH.add(parseme.Round(s = '*', f = 'multiply', only = None))
VECTOR_MATH.add(parseme.Round(s = '/', f = 'true_divide', only = None))
VECTOR_MATH.add(parseme.Round(s = '<<', f = 'lshift', only = 'int'))
VECTOR_MATH.add(parseme.Round(s = '>>', f = 'rshift', only = 'int'))
VECTOR_MATH.add(parseme.Round(s = '&', f = 'and', only = 'int'))
VECTOR_MATH.add(parseme.Round(s = '^', f = 'xor', only = 'int'))
VECTOR_MATH.add(parseme.Round(s = '|', f = 'or', only = 'int'))
glmParse.add(VECTOR_MATH)
# In the MATRIX section,
# p is a prefix to the name
# cols and rows is the size of the vector
# type is the common type of the vector
# n is is the name, such as 3x4
MATRIX = parseme.Section('MATRIX')
for cols in range(2, 5):
for rows in range(2, 5):
MATRIX.add(parseme.Round(p = '', rows = rows, cols = cols,
n = (str(rows) if rows == cols else str(rows) + 'x' + str(cols)), type = 'float'))
glmParse.add(MATRIX)
# In the MATRIX_FUNCTION section,
# func is the name of the function
# func_doc is the doc string
# args is the type of arguments
# availableTo is which types support it
# Matrix Transform
MATRIX_FUNCTION = parseme.Section('MATRIX_FUNCTION')
MATRIX_FUNCTION.add(parseme.Round(
func = 'translate',
func_doc = 'Translates a 4x4 matrix.',
args = ('vec3',),
availableTo = ('4',)
))
MATRIX_FUNCTION.add(parseme.Round(
func = 'rotate',
func_doc = 'Rotates a 4x4 matrix.',
args = (float, 'vec3',),
availableTo = ('4',)
))
MATRIX_FUNCTION.add(parseme.Round(
func = 'scale',
func_doc = 'Scales a 4x4 matrix.',
args = ('vec3',),
availableTo = ('4',)
))
# Core
MATRIX_FUNCTION.add(parseme.Round(
func = 'inverse',
func_doc = 'Matrix\'s inverse.',
args = (),
argsT = '',
availableTo = ('2','3','4',)
))
MATRIX_FUNCTION.add(parseme.Round(
func = 'transpose',
func_doc = 'Transposed matrix.',
args = (),
argsT = '',
availableTo = ('2','3','4',)
))
MATRIX_FUNCTION.add(parseme.Round(
func = 'mat3',
func_doc = 'Trunc to mat3.',
args = (),
argsT = '',
availableTo = ('4',)
))
glmParse.add(MATRIX_FUNCTION)
# In the VECTOR_FUNCTION section,
# func is the name of the function
# func_doc is the doc string
VECTOR_FUNCTION = parseme.Section('VECTOR_FUNCTION')
VECTOR_FUNCTION.add(parseme.Round(
func = 'length',
func_doc = 'Length of the vector.',
args = (),
availableTo = ('2','3','4',),
returns = 'float'
))
VECTOR_FUNCTION.add(parseme.Round(
func = 'normalize',
func_doc = 'Returns the normalized vector.',
args = (),
availableTo = ('2','3','4',),
returns = 'vec'
))
VECTOR_FUNCTION.add(parseme.Round(
func = 'dot',
func_doc = 'Returns the dot product of this ond other vector.',
args = ('vec3', ),
availableTo = ('2','3','4',),
returns = 'float'
))
VECTOR_FUNCTION.add(parseme.Round(
func = 'cross',
func_doc = 'Returns the cross product of this ond other vector.',
args = ('vec3', ),
availableTo = ('3',),
returns = 'vec'
))
glmParse.add(VECTOR_FUNCTION)
# In the NUMBER_FUNCTION section,
# func is the name of the function
# func_doc is the doc string
# argc is the number of arguments
# argoc is the number of optional arguments
# returns is the return type
# type is the argument type
# p is the short name of the in type, used to build value
# base the base type of the return
NUMBER_FUNCTION = parseme.Section('NUMBER_FUNCTION')
NUMBER_FUNCTION.add(
parseme.Round(
func = 'ortho',
func_glm_name = 'ortho',
func_doc = 'Creates an 3d orthographic matrix.',
argc = 6,
argoc = 0,
returns = 'mat4',
type = 'float',
p = 'f',
base = 'mat'
)
)
NUMBER_FUNCTION.add(
parseme.Round(
func = 'ortho2d',
func_glm_name = 'ortho',
func_doc = 'Creates an 2d orthographic matrix.',
argc = 4,
argoc = 0,
returns = 'mat4',
type = 'float',
p = 'f',
base = 'mat'
)
)
NUMBER_FUNCTION.add(
parseme.Round(
func = 'frustum',
func_glm_name = 'frustum',
func_doc = 'Creates a frustum matrix.',
argc = 6,
argoc = 0,
returns = 'mat4',
type = 'float',
p = 'f',
base = 'mat'
)
)
NUMBER_FUNCTION.add(
parseme.Round(
func = 'perspective',
func_glm_name = 'perspective',
func_doc = 'Creates a perspective matrix.',
argc = 4,
argoc = 0,
returns = 'mat4',
type = 'float',
p = 'f',
base = 'mat'
)
)
NUMBER_FUNCTION.add(
parseme.Round(
func = 'perspective_fov',
func_glm_name = 'perspectiveFov',
func_doc = 'Creates a perspective matrix with a defined FOV.',
argc = 5,
argoc = 0,
returns = 'mat4',
type = 'float',
p = 'f',
base = 'mat'
)
)
NUMBER_FUNCTION.add(
parseme.Round(
func = 'infinite_perspective',
func_glm_name = 'infinitePerspective',
func_doc = 'Creates a matrix for a symmetric perspective-view frustum with far plane at infinite.',
argc = 3,
argoc = 0,
returns = 'mat4',
type = 'float',
p = 'f',
base = 'mat'
)
)
NUMBER_FUNCTION.add(
parseme.Round(
func = 'tweaked_infinite_perspective',
func_glm_name = 'tweakedInfinitePerspective',
func_doc = "Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.",
argc = 3,
argoc = 0,
returns = 'mat4',
type = 'float',
p = 'f',
base = 'mat'
)
)
NUMBER_FUNCTION.add(
parseme.Round(
func = 'perlin',
func_glm_name = 'perlin',
func_doc = 'Perlin noise.',
argc = 1,
argoc = 0,
returns = 'float',
type = 'vec2',
p = 'O',
base = 'vec'
)
)
NUMBER_FUNCTION.add(
parseme.Round(
func = 'perlin_periodic',
func_glm_name = 'perlin',
func_doc = 'Perlin noise.',
argc = 2,
argoc = 0,
returns = 'float',
type = 'vec2',
p = 'O',
base = 'vec'
)
)
NUMBER_FUNCTION.add(
parseme.Round(
func = 'step',
func_glm_name = 'step',
func_doc = 'Step function.',
argc = 2,
argoc = 0,
returns = 'vec3',
type = 'vec3',
p = 'O',
base = 'vec'
)
)
NUMBER_FUNCTION.add(
parseme.Round(
func = 'radians',
func_glm_name = 'radians',
func_doc = 'Step function.',
argc = 1,
argoc = 0,
returns = 'float',
type = 'float',
p = 'f',
base = 'float'
)
)
NUMBER_FUNCTION.add(
parseme.Round(
func = 'look_at',
func_glm_name = 'lookAt',
func_doc = 'Build a look at view matrix.',
argc = 3,
argoc = 0,
returns = 'mat4',
type = 'vec3',
p = 'O',
base = 'mat'
)
)
NUMBER_FUNCTION.add(
parseme.Round(
func = 'yaw_pitch_roll',
func_glm_name = 'yawPitchRoll',
func_doc = 'Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z).',
argc = 3,
argoc = 0,
returns = 'mat4',
type = 'float',
p = 'f',
base = 'mat'
)
)
glmParse.add(NUMBER_FUNCTION)
BASETYPEDEF = parseme.Section('BASETYPEDEF')
BASETYPEDEF.add(parseme.Round(type = 'Vector', doc = 'This is a basic vector type that you can isinstance against. It is also used for global function checking, and in theory you could make your own vector types which define custom calls for global functions.'))
BASETYPEDEF.add(parseme.Round(type = 'Matrix', doc = 'A matrix.'))
glmParse.add(BASETYPEDEF)
if glmParse.parse('pyglm/glm/python.parseme.hpp', 'pyglm/glm/python.parseme.cpp') > 0:
raise SystemExit
import sys
from distutils.core import setup, Extension
import platform
architecture = platform.architecture()[0]
if sys.platform == "win32":
compile_args = ["/Ox", "/Ob2", "/Oi", "/Ot", "/Oy", "/GT", "/GL"]
compile_args += [] if architecture == "64bit" else ["/arch:IA32"]
else:
compile_args = ["-O3", "-ffast-math", "-s"]
# This might be needed on posix
# compile_args += [] if architecture == "64bit" else ["-no-vec"]
glm = Extension('glm', sources = ['pyglm/glm/python.cpp'], extra_compile_args=compile_args, include_dirs = ['../'])
setup(name='glm',
version='0.9.3',
description='glm',
author='JacobF | G-Truc Creation',
author_email='jacobaferrero@gmail.com | glm@g-truc.net',
url='http://glm.g-truc.net/',
ext_modules=[glm]
)