-
Notifications
You must be signed in to change notification settings - Fork 5
/
compileShaders.py
45 lines (31 loc) · 912 Bytes
/
compileShaders.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import imp
###################################
# compile shader source
###################################
ShaderDir = 'shaders'
src = "var Shaders = {\n\n"
commonPath = ShaderDir + '/common.glsl'
commonCode = open(commonPath).read().strip().split('\n')
debug = False
for f in os.listdir(ShaderDir):
if f == 'common.glsl': continue;
if debug:
print '\n' + '*'* 80
print f
print '*'* 80 + '\n'
if f.find('.glsl') == -1: continue
name = f.replace('.glsl', '')
src += "'%s': `\n" % name
path = os.path.join(ShaderDir, f)
lines = open(path).read().strip().split('\n')
code = list(commonCode)
code.append('')
code.extend(lines)
for i, line in enumerate(code):
src += line + '\n'
if debug: print line
if i==len(code)-1:
src += "`,\n\n"
src += "}"
open("js/shaders.js", 'w').write(src)