···11+#!/usr/bin/env python
22+33+def write_shader_header(outfile, infiles):
44+ output = ""
55+66+ shname = outfile.name
77+ shname = shname[:shname.find(".glsl.h")].replace("-", "_").upper()
88+99+ for file in infiles:
1010+ if file.name.find("vert") > 0:
1111+ shtype = "VERT"
1212+ elif file.name.find("frag") > 0:
1313+ shtype = "FRAG"
1414+ else:
1515+ raise Exception("i have no idea what kind of shader \"{0}\" is.".format(file.name))
1616+1717+ output += "static const char *{0}_{1}_SHADER = ".format(shname, shtype)
1818+1919+ f = open(file.abspath())
2020+ for line in f:
2121+ line = line.rstrip()
2222+2323+ if len(line) == 0:
2424+ output += "\n"
2525+ else:
2626+ output += "\n\t\"{0}\\n\"".format(line.replace("\"", '\\\"'))
2727+2828+ output += ";\n\n"
2929+3030+ # get rid of the last newline
3131+ output = output[:len(output) - 1]
3232+ outfile.write(output)
+1-30
src/wscript
···2233top = ".."
4455-def write_shader_header(outfile, infiles):
66- output = ""
77-88- shname = outfile.name
99- shname = shname[:shname.find(".glsl.h")].replace("-", "_").upper()
1010-1111- for file in infiles:
1212- if file.name.find("vert") > 0:
1313- shtype = "VERT"
1414- elif file.name.find("frag") > 0:
1515- shtype = "FRAG"
1616- else:
1717- raise Exception("i have no idea what kind of shader \"{0}\" is.".format(file.name))
1818-1919- output += "static const char *{0}_{1}_SHADER = ".format(shname, shtype)
2020-2121- f = open(file.abspath())
2222- for line in f:
2323- line = line.rstrip()
2424-2525- if len(line) == 0:
2626- output += "\n"
2727- else:
2828- output += "\n\t\"{0}\\n\"".format(line.replace("\"", '\\\"'))
2929-3030- output += ";\n\n"
3131-3232- # get rid of the last newline
3333- output = output[:len(output) - 1]
3434- outfile.write(output)
55+from glsl2h import write_shader_header
356367def shader_header(bld, dest):
378 def shader(task):
+2
wscript
···1717 # print() (as a function) doesn't work in python <2.7
1818 sys.stdout.write("\n")
19192020+sys.path.append("./python")
2121+2022#
2123# dep checking functions
2224#