style: Various other PEP8 fixes in Python files

Done with `autopep8 --select=E7`, fixes:

- E701 - Put colon-separated compound statement on separate lines.
- E702 - Put semicolon-separated compound statement on separate lines.
- E703 - Put semicolon-separated compound statement on separate lines.
- E711 - Fix comparison with None.
- E712 - Fix (trivial case of) comparison with boolean.
- E713 - Fix (trivial case of) non-membership check.
- E721 - Fix various deprecated code (via lib2to3).
This commit is contained in:
Rémi Verschelde 2016-11-01 00:24:30 +01:00
parent 817dd7ccbb
commit f34151ff0f
25 changed files with 370 additions and 369 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
EnsureSConsVersion(0, 14); EnsureSConsVersion(0, 14)
import string import string
@ -37,7 +37,7 @@ for x in glob.glob("platform/*"):
global_defaults.append(x[9:]) global_defaults.append(x[9:])
if (detect.is_active()): if (detect.is_active()):
active_platforms.append(detect.get_name()) active_platforms.append(detect.get_name())
active_platform_ids.append(x); active_platform_ids.append(x)
if (detect.can_build()): if (detect.can_build()):
x = x.replace("platform/", "") # rest of world x = x.replace("platform/", "") # rest of world
x = x.replace("platform\\", "") # win32 x = x.replace("platform\\", "") # win32
@ -64,7 +64,7 @@ elif (os.name == "nt"):
if (os.getenv("VCINSTALLDIR") == None or platform_arg == "android"): if (os.getenv("VCINSTALLDIR") == None or platform_arg == "android"):
custom_tools = ['mingw'] custom_tools = ['mingw']
env_base = Environment(tools=custom_tools); env_base = Environment(tools=custom_tools)
if 'TERM' in os.environ: if 'TERM' in os.environ:
env_base['ENV']['TERM'] = os.environ['TERM'] env_base['ENV']['TERM'] = os.environ['TERM']
env_base.AppendENVPath('PATH', os.getenv('PATH')) env_base.AppendENVPath('PATH', os.getenv('PATH'))
@ -140,9 +140,9 @@ opts.Add('glew', 'GLEW library for the gl_context (system/builtin)', 'builtin')
opts.Add('xaudio2', 'XAudio2 audio driver (yes/no)', 'no') opts.Add('xaudio2', 'XAudio2 audio driver (yes/no)', 'no')
opts.Add("CXX", "C++ Compiler") opts.Add("CXX", "C++ Compiler")
opts.Add("CC", "C Compiler") opts.Add("CC", "C Compiler")
opts.Add("CCFLAGS", "Custom flags for the C/C++ compiler"); opts.Add("CCFLAGS", "Custom flags for the C/C++ compiler")
opts.Add("CFLAGS", "Custom flags for the C compiler"); opts.Add("CFLAGS", "Custom flags for the C compiler")
opts.Add("LINKFLAGS", "Custom flags for the linker"); opts.Add("LINKFLAGS", "Custom flags for the linker")
opts.Add('unix_global_settings_path', 'unix-specific path to system-wide settings. Currently only used by templates.', '') opts.Add('unix_global_settings_path', 'unix-specific path to system-wide settings. Currently only used by templates.', '')
opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no") opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no")
opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no") opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no")
@ -180,11 +180,11 @@ sys.modules.pop('detect')
""" """
if (env_base['target'] == 'debug'): if (env_base['target'] == 'debug'):
env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']); env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE']) env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE'])
if (env_base['deprecated'] != 'no'): if (env_base['deprecated'] != 'no'):
env_base.Append(CPPFLAGS=['-DENABLE_DEPRECATED']); env_base.Append(CPPFLAGS=['-DENABLE_DEPRECATED'])
env_base.platforms = {} env_base.platforms = {}
@ -264,7 +264,7 @@ if selected_platform in platform_list:
sys.exit(255) sys.exit(255)
suffix += ".opt" suffix += ".opt"
env.Append(CCFLAGS=['-DNDEBUG']); env.Append(CCFLAGS=['-DNDEBUG'])
elif (env["target"] == "release_debug"): elif (env["target"] == "release_debug"):
if (env["tools"] == "yes"): if (env["tools"] == "yes"):
@ -312,7 +312,7 @@ if selected_platform in platform_list:
sys.modules.pop('config') sys.modules.pop('config')
if (env.use_ptrcall): if (env.use_ptrcall):
env.Append(CPPFLAGS=['-DPTRCALL_ENABLED']); env.Append(CPPFLAGS=['-DPTRCALL_ENABLED'])
# to test 64 bits compiltion # to test 64 bits compiltion
# env.Append(CPPFLAGS=['-m64']) # env.Append(CPPFLAGS=['-m64'])
@ -349,7 +349,7 @@ if selected_platform in platform_list:
SConscript("modules/SCsub") SConscript("modules/SCsub")
SConscript("main/SCsub") SConscript("main/SCsub")
SConscript("platform/" + selected_platform + "/SCsub"); # build selected platform SConscript("platform/" + selected_platform + "/SCsub") # build selected platform
# Microsoft Visual Studio Project Generation # Microsoft Visual Studio Project Generation
if (env['vsproj']) == "yes": if (env['vsproj']) == "yes":

View File

@ -3,4 +3,4 @@
Import('env') Import('env')
Export('env') Export('env')
SConscript('tests/SCsub'); SConscript('tests/SCsub')

View File

@ -57,10 +57,10 @@ Export('env')
import make_binders import make_binders
env.Command(['method_bind.inc', 'method_bind_ext.inc'], 'make_binders.py', make_binders.run) env.Command(['method_bind.inc', 'method_bind_ext.inc'], 'make_binders.py', make_binders.run)
SConscript('os/SCsub'); SConscript('os/SCsub')
SConscript('math/SCsub'); SConscript('math/SCsub')
SConscript('io/SCsub'); SConscript('io/SCsub')
SConscript('bind/SCsub'); SConscript('bind/SCsub')
lib = env.Library("core", env.core_sources) lib = env.Library("core", env.core_sources)

View File

@ -26,11 +26,11 @@ def write_string(_f, text, newline=True):
def escape(ret): def escape(ret):
ret = ret.replace("&", "&"); ret = ret.replace("&", "&")
ret = ret.replace("<", "&gt;"); ret = ret.replace("<", "&gt;")
ret = ret.replace(">", "&lt;"); ret = ret.replace(">", "&lt;")
ret = ret.replace("'", "&apos;"); ret = ret.replace("'", "&apos;")
ret = ret.replace("\"", "&quot;"); ret = ret.replace("\"", "&quot;")
return ret return ret
@ -138,22 +138,22 @@ def write_class(c):
for a in list(m): for a in list(m):
if (a.tag == "return"): if (a.tag == "return"):
typ = get_tag(a, "type") typ = get_tag(a, "type")
write_string(f, '<return' + typ + '>'); write_string(f, '<return' + typ + '>')
write_string(f, '</return>'); write_string(f, '</return>')
elif (a.tag == "argument"): elif (a.tag == "argument"):
default = get_tag(a, "default") default = get_tag(a, "default")
write_string(f, '<argument index="' + a.attrib["index"] + '" name="' + escape(a.attrib["name"]) + '" type="' + a.attrib["type"] + '"' + default + '>'); write_string(f, '<argument index="' + a.attrib["index"] + '" name="' + escape(a.attrib["name"]) + '" type="' + a.attrib["type"] + '"' + default + '>')
write_string(f, '</argument>'); write_string(f, '</argument>')
write_string(f, '<description>'); write_string(f, '<description>')
if (old_class != None): if (old_class != None):
old_method_descr = find_method_descr(old_class, m.attrib["name"]) old_method_descr = find_method_descr(old_class, m.attrib["name"])
if (old_method_descr): if (old_method_descr):
write_string(f, escape(escape(old_method_descr.strip()))) write_string(f, escape(escape(old_method_descr.strip())))
write_string(f, '</description>'); write_string(f, '</description>')
dec_tab() dec_tab()
write_string(f, "</method>") write_string(f, "</method>")
dec_tab() dec_tab()
@ -173,15 +173,15 @@ def write_class(c):
for a in list(m): for a in list(m):
if (a.tag == "argument"): if (a.tag == "argument"):
write_string(f, '<argument index="' + a.attrib["index"] + '" name="' + escape(a.attrib["name"]) + '" type="' + a.attrib["type"] + '">'); write_string(f, '<argument index="' + a.attrib["index"] + '" name="' + escape(a.attrib["name"]) + '" type="' + a.attrib["type"] + '">')
write_string(f, '</argument>'); write_string(f, '</argument>')
write_string(f, '<description>'); write_string(f, '<description>')
if (old_class != None): if (old_class != None):
old_signal_descr = find_signal_descr(old_class, m.attrib["name"]) old_signal_descr = find_signal_descr(old_class, m.attrib["name"])
if (old_signal_descr): if (old_signal_descr):
write_string(f, escape(old_signal_descr.strip())) write_string(f, escape(old_signal_descr.strip()))
write_string(f, '</description>'); write_string(f, '</description>')
dec_tab() dec_tab()
write_string(f, "</signal>") write_string(f, "</signal>")
dec_tab() dec_tab()

View File

@ -17,7 +17,7 @@ if len(input_list) < 1:
def validate_tag(elem, tag): def validate_tag(elem, tag):
if (elem.tag != tag): if (elem.tag != tag):
print("Tag mismatch, expected '" + tag + "', got " + elem.tag); print("Tag mismatch, expected '" + tag + "', got " + elem.tag)
sys.exit(255) sys.exit(255)

View File

@ -40,7 +40,7 @@ if len(input_list) < 1:
def validate_tag(elem, tag): def validate_tag(elem, tag):
if (elem.tag != tag): if (elem.tag != tag):
print("Tag mismatch, expected '" + tag + "', got " + elem.tag); print("Tag mismatch, expected '" + tag + "', got " + elem.tag)
sys.exit(255) sys.exit(255)
@ -90,7 +90,7 @@ def make_html_top(body, bottom=False):
def make_html_class_list(class_list, columns): def make_html_class_list(class_list, columns):
div = ET.Element("div") div = ET.Element("div")
div.attrib["class"] = "ClassList"; div.attrib["class"] = "ClassList"
h1 = ET.SubElement(div, "h2") h1 = ET.SubElement(div, "h2")
h1.text = "Alphabetical Class List" h1.text = "Alphabetical Class List"
@ -463,7 +463,7 @@ def make_method_def(name, m, declare, event=False):
def make_html_class(node): def make_html_class(node):
div = ET.Element("div") div = ET.Element("div")
div.attrib["class"] = "class"; div.attrib["class"] = "class"
a = ET.SubElement(div, "a") a = ET.SubElement(div, "a")
a.attrib["name"] = node.attrib["name"] a.attrib["name"] = node.attrib["name"]
@ -482,7 +482,7 @@ def make_html_class(node):
ET.SubElement(div, "br") ET.SubElement(div, "br")
div2 = ET.SubElement(div, "div") div2 = ET.SubElement(div, "div")
div2.attrib["class"] = "inheritance"; div2.attrib["class"] = "inheritance"
span = ET.SubElement(div2, "span") span = ET.SubElement(div2, "span")
span.text = "Inherits: " span.text = "Inherits: "
@ -493,7 +493,7 @@ def make_html_class(node):
ET.SubElement(div, "br") ET.SubElement(div, "br")
div3 = ET.SubElement(div, "div") div3 = ET.SubElement(div, "div")
div3.attrib["class"] = "category"; div3.attrib["class"] = "category"
span = ET.SubElement(div3, "span") span = ET.SubElement(div3, "span")
span.attrib["class"] = "category" span.attrib["class"] = "category"
@ -520,7 +520,7 @@ def make_html_class(node):
h4.text = "Public Methods:" h4.text = "Public Methods:"
method_table = ET.SubElement(div, "table") method_table = ET.SubElement(div, "table")
method_table.attrib["class"] = "method_list"; method_table.attrib["class"] = "method_list"
for m in list(methods): for m in list(methods):
#li = ET.SubElement(div2, "li") #li = ET.SubElement(div2, "li")
@ -533,7 +533,7 @@ def make_html_class(node):
h4.text = "Events:" h4.text = "Events:"
event_table = ET.SubElement(div, "table") event_table = ET.SubElement(div, "table")
event_table.attrib["class"] = "method_list"; event_table.attrib["class"] = "method_list"
for m in list(events): for m in list(events):
#li = ET.SubElement(div2, "li") #li = ET.SubElement(div2, "li")
@ -545,13 +545,13 @@ def make_html_class(node):
h4 = ET.SubElement(div, "h4") h4 = ET.SubElement(div, "h4")
h4.text = "Public Variables:" h4.text = "Public Variables:"
div2 = ET.SubElement(div, "div") div2 = ET.SubElement(div, "div")
div2.attrib["class"] = "member_list"; div2.attrib["class"] = "member_list"
for c in list(members): for c in list(members):
li = ET.SubElement(div2, "li") li = ET.SubElement(div2, "li")
div3 = ET.SubElement(li, "div") div3 = ET.SubElement(li, "div")
div3.attrib["class"] = "member"; div3.attrib["class"] = "member"
make_type(c.attrib["type"], div3) make_type(c.attrib["type"], div3)
span = ET.SubElement(div3, "span") span = ET.SubElement(div3, "span")
span.attrib["class"] = "identifier member_name" span.attrib["class"] = "identifier member_name"
@ -566,12 +566,12 @@ def make_html_class(node):
h4 = ET.SubElement(div, "h4") h4 = ET.SubElement(div, "h4")
h4.text = "Constants:" h4.text = "Constants:"
div2 = ET.SubElement(div, "div") div2 = ET.SubElement(div, "div")
div2.attrib["class"] = "constant_list"; div2.attrib["class"] = "constant_list"
for c in list(constants): for c in list(constants):
li = ET.SubElement(div2, "li") li = ET.SubElement(div2, "li")
div3 = ET.SubElement(li, "div") div3 = ET.SubElement(li, "div")
div3.attrib["class"] = "constant"; div3.attrib["class"] = "constant"
span = ET.SubElement(div3, "span") span = ET.SubElement(div3, "span")
span.attrib["class"] = "identifier constant_name" span.attrib["class"] = "identifier constant_name"
@ -614,10 +614,10 @@ def make_html_class(node):
descr = m.find("description") descr = m.find("description")
if (descr == None or descr.text.strip() == ""): if (descr == None or descr.text.strip() == ""):
continue; continue
div2 = ET.SubElement(div, "div") div2 = ET.SubElement(div, "div")
div2.attrib["class"] = "method_doc"; div2.attrib["class"] = "method_doc"
div2.append(make_method_def(node.attrib["name"], m, True)) div2.append(make_method_def(node.attrib["name"], m, True))
#anchor = ET.SubElement(div2, "a") #anchor = ET.SubElement(div2, "a")
@ -675,7 +675,7 @@ for cn in class_names:
css.attrib["type"] = "text/css" css.attrib["type"] = "text/css"
body2 = ET.SubElement(html2, "body") body2 = ET.SubElement(html2, "body")
make_html_top(body2) make_html_top(body2)
body2.append(make_html_class(c)); body2.append(make_html_class(c))
make_html_bottom(body2) make_html_bottom(body2)
et_out = ET.ElementTree(html2) et_out = ET.ElementTree(html2)
et_out.write(c.attrib["name"] + ".html") et_out.write(c.attrib["name"] + ".html")

22
drivers/SCsub vendored
View File

@ -5,31 +5,31 @@ Import('env')
env.drivers_sources = [] env.drivers_sources = []
if ("builtin_zlib" in env and env["builtin_zlib"] == "yes"): if ("builtin_zlib" in env and env["builtin_zlib"] == "yes"):
SConscript("zlib/SCsub"); SConscript("zlib/SCsub")
# OS drivers # OS drivers
SConscript('unix/SCsub'); SConscript('unix/SCsub')
SConscript('windows/SCsub'); SConscript('windows/SCsub')
# Sounds drivers # Sounds drivers
SConscript('alsa/SCsub'); SConscript('alsa/SCsub')
SConscript('pulseaudio/SCsub'); SConscript('pulseaudio/SCsub')
if (env["platform"] == "windows"): if (env["platform"] == "windows"):
SConscript("rtaudio/SCsub"); SConscript("rtaudio/SCsub")
if (env["xaudio2"] == "yes"): if (env["xaudio2"] == "yes"):
SConscript("xaudio2/SCsub"); SConscript("xaudio2/SCsub")
# Graphics drivers # Graphics drivers
SConscript('gles2/SCsub'); SConscript('gles2/SCsub')
SConscript('gl_context/SCsub'); SConscript('gl_context/SCsub')
# Core dependencies # Core dependencies
SConscript("png/SCsub"); SConscript("png/SCsub")
# Tools override # Tools override
# FIXME: Should likely be integrated in the tools/ codebase # FIXME: Should likely be integrated in the tools/ codebase
if (env["tools"] == "yes"): if (env["tools"] == "yes"):
SConscript("convex_decomp/SCsub"); SConscript("convex_decomp/SCsub")
if env['vsproj'] == "yes": if env['vsproj'] == "yes":
env.AddToVSProject(env.drivers_sources) env.AddToVSProject(env.drivers_sources)

View File

@ -3,10 +3,10 @@
Import('env') Import('env')
if env['BUILDERS'].has_key('GLSL120GLES'): if env['BUILDERS'].has_key('GLSL120GLES'):
env.GLSL120GLES('material.glsl'); env.GLSL120GLES('material.glsl')
env.GLSL120GLES('canvas.glsl'); env.GLSL120GLES('canvas.glsl')
env.GLSL120GLES('canvas_shadow.glsl'); env.GLSL120GLES('canvas_shadow.glsl')
env.GLSL120GLES('blur.glsl'); env.GLSL120GLES('blur.glsl')
env.GLSL120GLES('copy.glsl'); env.GLSL120GLES('copy.glsl')
Export('env') Export('env')

View File

@ -33,7 +33,7 @@ if (env["libpng"] == "builtin"):
import os import os
if ("neon_enabled" in env and env["neon_enabled"]) and os.name != "nt": if ("neon_enabled" in env and env["neon_enabled"]) and os.name != "nt":
env_png.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=2"]) env_png.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=2"])
env_neon = env_png.Clone(); env_neon = env_png.Clone()
if "S_compiler" in env: if "S_compiler" in env:
env_neon['CC'] = env['S_compiler'] env_neon['CC'] = env['S_compiler']
neon_sources = [] neon_sources = []

View File

@ -2,8 +2,8 @@ import os
def add_source_files(self, sources, filetype, lib_env=None, shared=False): def add_source_files(self, sources, filetype, lib_env=None, shared=False):
import glob; import glob
import string; import string
# if not lib_objects: # if not lib_objects:
if not lib_env: if not lib_env:
lib_env = self lib_env = self
@ -101,8 +101,8 @@ def build_glsl_header(filename):
# texture unit # texture unit
texunit = str(int(line[line.find(":") + 1:].strip())) texunit = str(int(line[line.find(":") + 1:].strip()))
uline = line[:line.lower().find("//")] uline = line[:line.lower().find("//")]
uline = uline.replace("uniform", ""); uline = uline.replace("uniform", "")
uline = uline.replace(";", ""); uline = uline.replace(";", "")
lines = uline.split(",") lines = uline.split(",")
for x in lines: for x in lines:
@ -120,9 +120,9 @@ def build_glsl_header(filename):
# ubo # ubo
uboidx = str(int(line[line.find(":") + 1:].strip())) uboidx = str(int(line[line.find(":") + 1:].strip()))
uline = line[:line.lower().find("//")] uline = line[:line.lower().find("//")]
uline = uline[uline.find("uniform") + len("uniform"):]; uline = uline[uline.find("uniform") + len("uniform"):]
uline = uline.replace(";", ""); uline = uline.replace(";", "")
uline = uline.replace("{", ""); uline = uline.replace("{", "")
lines = uline.split(",") lines = uline.split(",")
for x in lines: for x in lines:
@ -137,8 +137,8 @@ def build_glsl_header(filename):
ubo_names += [x] ubo_names += [x]
else: else:
uline = line.replace("uniform", ""); uline = line.replace("uniform", "")
uline = uline.replace(";", ""); uline = uline.replace(";", "")
lines = uline.split(",") lines = uline.split(",")
for x in lines: for x in lines:
@ -152,9 +152,9 @@ def build_glsl_header(filename):
uniforms += [x] uniforms += [x]
if ((line.strip().find("in ") == 0 or line.strip().find("attribute ") == 0) and line.find("attrib:") != -1): if ((line.strip().find("in ") == 0 or line.strip().find("attribute ") == 0) and line.find("attrib:") != -1):
uline = line.replace("in ", ""); uline = line.replace("in ", "")
uline = uline.replace("attribute ", ""); uline = uline.replace("attribute ", "")
uline = uline.replace(";", ""); uline = uline.replace(";", "")
uline = uline[uline.find(" "):].strip() uline = uline[uline.find(" "):].strip()
if (uline.find("//") != -1): if (uline.find("//") != -1):
@ -165,8 +165,8 @@ def build_glsl_header(filename):
attributes += [(name, bind)] attributes += [(name, bind)]
if (line.strip().find("out ") == 0): if (line.strip().find("out ") == 0):
uline = line.replace("out", "").strip(); uline = line.replace("out", "").strip()
uline = uline.replace(";", ""); uline = uline.replace(";", "")
uline = uline[uline.find(" "):].strip() uline = uline[uline.find(" "):].strip()
if (uline.find("//") != -1): if (uline.find("//") != -1):
@ -190,12 +190,12 @@ def build_glsl_header(filename):
line = fs.readline() line = fs.readline()
line_offset += 1 line_offset += 1
fs.close(); fs.close()
out_file = filename + ".h" out_file = filename + ".h"
fd = open(out_file, "w") fd = open(out_file, "w")
fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n"); fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n")
out_file_base = out_file out_file_base = out_file
out_file_base = out_file_base[out_file_base.rfind("/") + 1:] out_file_base = out_file_base[out_file_base.rfind("/") + 1:]
@ -205,47 +205,47 @@ def build_glsl_header(filename):
fd.write("#ifndef " + out_file_ifdef + "\n") fd.write("#ifndef " + out_file_ifdef + "\n")
fd.write("#define " + out_file_ifdef + "\n") fd.write("#define " + out_file_ifdef + "\n")
out_file_class = out_file_base.replace(".glsl.h", "").title().replace("_", "").replace(".", "") + "ShaderGL"; out_file_class = out_file_base.replace(".glsl.h", "").title().replace("_", "").replace(".", "") + "ShaderGL"
fd.write("\n\n"); fd.write("\n\n")
fd.write("#include \"drivers/opengl/shader_gl.h\"\n\n\n"); fd.write("#include \"drivers/opengl/shader_gl.h\"\n\n\n")
fd.write("class " + out_file_class + " : public ShaderGL {\n\n"); fd.write("class " + out_file_class + " : public ShaderGL {\n\n")
fd.write("\t virtual String get_shader_name() const { return \"" + out_file_class + "\"; }\n"); fd.write("\t virtual String get_shader_name() const { return \"" + out_file_class + "\"; }\n")
fd.write("public:\n\n"); fd.write("public:\n\n")
if (len(conditionals)): if (len(conditionals)):
fd.write("\tenum Conditionals {\n"); fd.write("\tenum Conditionals {\n")
for x in conditionals: for x in conditionals:
fd.write("\t\t" + x + ",\n"); fd.write("\t\t" + x + ",\n")
fd.write("\t};\n\n"); fd.write("\t};\n\n")
if (len(uniforms)): if (len(uniforms)):
fd.write("\tenum Uniforms {\n"); fd.write("\tenum Uniforms {\n")
for x in uniforms: for x in uniforms:
fd.write("\t\t" + x.upper() + ",\n"); fd.write("\t\t" + x.upper() + ",\n")
fd.write("\t};\n\n"); fd.write("\t};\n\n")
fd.write("\t_FORCE_INLINE_ int get_uniform(Uniforms p_uniform) const { return _get_uniform(p_uniform); }\n\n"); fd.write("\t_FORCE_INLINE_ int get_uniform(Uniforms p_uniform) const { return _get_uniform(p_uniform); }\n\n")
if (len(conditionals)): if (len(conditionals)):
fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n")
fd.write("\t#define _FU if (get_uniform(p_uniform)<0) return; ERR_FAIL_COND( get_active()!=this );\n\n "); fd.write("\t#define _FU if (get_uniform(p_uniform)<0) return; ERR_FAIL_COND( get_active()!=this );\n\n ")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
#fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n");
#fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n");
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU glUniform2f(get_uniform(p_uniform),p_a,p_b); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU glUniform2f(get_uniform(p_uniform),p_a,p_b); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU glUniform3f(get_uniform(p_uniform),p_a,p_b,p_c); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU glUniform3f(get_uniform(p_uniform),p_a,p_b,p_c); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU glUniform4f(get_uniform(p_uniform),p_a,p_b,p_c,p_d); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU glUniform4f(get_uniform(p_uniform),p_a,p_b,p_c,p_d); }\n\n")
fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU
@ -276,7 +276,7 @@ def build_glsl_header(filename):
} }
"""); """)
fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Matrix32& p_transform) { _FU fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Matrix32& p_transform) { _FU
@ -307,7 +307,7 @@ def build_glsl_header(filename):
} }
"""); """)
fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU
@ -321,18 +321,18 @@ def build_glsl_header(filename):
} }
glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix); glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix);
}; """); }; """)
fd.write("\n\n#undef _FU\n\n\n"); fd.write("\n\n#undef _FU\n\n\n")
fd.write("\tvirtual void init() {\n\n"); fd.write("\tvirtual void init() {\n\n")
if (len(conditionals)): if (len(conditionals)):
fd.write("\t\tstatic const char* _conditional_strings[]={\n") fd.write("\t\tstatic const char* _conditional_strings[]={\n")
if (len(conditionals)): if (len(conditionals)):
for x in conditionals: for x in conditionals:
fd.write("\t\t\t\"#define " + x + "\\n\",\n"); fd.write("\t\t\t\"#define " + x + "\\n\",\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic const char **_conditional_strings=NULL;\n") fd.write("\t\tstatic const char **_conditional_strings=NULL;\n")
@ -341,8 +341,8 @@ def build_glsl_header(filename):
fd.write("\t\tstatic const char* _uniform_strings[]={\n") fd.write("\t\tstatic const char* _uniform_strings[]={\n")
if (len(uniforms)): if (len(uniforms)):
for x in uniforms: for x in uniforms:
fd.write("\t\t\t\"" + x + "\",\n"); fd.write("\t\t\t\"" + x + "\",\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic const char **_uniform_strings=NULL;\n") fd.write("\t\tstatic const char **_uniform_strings=NULL;\n")
@ -350,62 +350,62 @@ def build_glsl_header(filename):
fd.write("\t\tstatic AttributePair _attribute_pairs[]={\n") fd.write("\t\tstatic AttributePair _attribute_pairs[]={\n")
for x in attributes: for x in attributes:
fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n"); fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic AttributePair *_attribute_pairs=NULL;\n") fd.write("\t\tstatic AttributePair *_attribute_pairs=NULL;\n")
if (len(fbos)): if (len(fbos)):
fd.write("\t\tstatic FBOPair _fbo_pairs[]={\n") fd.write("\t\tstatic FBOPair _fbo_pairs[]={\n")
for x in fbos: for x in fbos:
fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n"); fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic FBOPair *_fbo_pairs=NULL;\n") fd.write("\t\tstatic FBOPair *_fbo_pairs=NULL;\n")
if (len(ubos)): if (len(ubos)):
fd.write("\t\tstatic UBOPair _ubo_pairs[]={\n") fd.write("\t\tstatic UBOPair _ubo_pairs[]={\n")
for x in ubos: for x in ubos:
fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n"); fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic UBOPair *_ubo_pairs=NULL;\n") fd.write("\t\tstatic UBOPair *_ubo_pairs=NULL;\n")
if (len(texunits)): if (len(texunits)):
fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n") fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n")
for x in texunits: for x in texunits:
fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n"); fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic TexUnitPair *_texunit_pairs=NULL;\n") fd.write("\t\tstatic TexUnitPair *_texunit_pairs=NULL;\n")
fd.write("\t\tstatic const char* _vertex_code=\"\\\n") fd.write("\t\tstatic const char* _vertex_code=\"\\\n")
for x in vertex_lines: for x in vertex_lines:
fd.write("\t\t\t" + x + "\n"); fd.write("\t\t\t" + x + "\n")
fd.write("\t\t\";\n\n"); fd.write("\t\t\";\n\n")
fd.write("\t\tstatic const int _vertex_code_start=" + str(vertex_offset) + ";\n") fd.write("\t\tstatic const int _vertex_code_start=" + str(vertex_offset) + ";\n")
fd.write("\t\tstatic const char* _fragment_code=\"\\\n") fd.write("\t\tstatic const char* _fragment_code=\"\\\n")
for x in fragment_lines: for x in fragment_lines:
fd.write("\t\t\t" + x + "\n"); fd.write("\t\t\t" + x + "\n")
fd.write("\t\t\";\n\n"); fd.write("\t\t\";\n\n")
fd.write("\t\tstatic const int _fragment_code_start=" + str(fragment_offset) + ";\n") fd.write("\t\tstatic const int _fragment_code_start=" + str(fragment_offset) + ";\n")
fd.write("\t\tsetup(_conditional_strings," + str(len(conditionals)) + ",_uniform_strings," + str(len(uniforms)) + ",_attribute_pairs," + str(len(attributes)) + ",_fbo_pairs," + str(len(fbos)) + ",_ubo_pairs," + str(len(ubos)) + ",_texunit_pairs," + str(len(texunits)) + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") fd.write("\t\tsetup(_conditional_strings," + str(len(conditionals)) + ",_uniform_strings," + str(len(uniforms)) + ",_attribute_pairs," + str(len(attributes)) + ",_fbo_pairs," + str(len(fbos)) + ",_ubo_pairs," + str(len(ubos)) + ",_texunit_pairs," + str(len(texunits)) + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n")
fd.write("\t};\n\n") fd.write("\t};\n\n")
fd.write("};\n\n"); fd.write("};\n\n")
fd.write("#endif\n\n"); fd.write("#endif\n\n")
fd.close(); fd.close()
def build_glsl_headers(target, source, env): def build_glsl_headers(target, source, env):
for x in source: for x in source:
build_glsl_header(str(x)); build_glsl_header(str(x))
return 0 return 0
@ -455,8 +455,8 @@ def build_hlsl_dx9_header(filename):
if (not ifdefline in conditionals): if (not ifdefline in conditionals):
conditionals += [ifdefline] conditionals += [ifdefline]
if (line.find("uniform") != -1): if (line.find("uniform") != -1):
uline = line.replace("uniform", ""); uline = line.replace("uniform", "")
uline = uline.replace(";", ""); uline = uline.replace(";", "")
lines = uline.split(",") lines = uline.split(",")
for x in lines: for x in lines:
@ -483,12 +483,12 @@ def build_hlsl_dx9_header(filename):
line = fs.readline() line = fs.readline()
line_offset += 1 line_offset += 1
fs.close(); fs.close()
out_file = filename + ".h" out_file = filename + ".h"
fd = open(out_file, "w") fd = open(out_file, "w")
fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n"); fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n")
out_file_base = out_file out_file_base = out_file
out_file_base = out_file_base[out_file_base.rfind("/") + 1:] out_file_base = out_file_base[out_file_base.rfind("/") + 1:]
@ -498,47 +498,47 @@ def build_hlsl_dx9_header(filename):
fd.write("#ifndef " + out_file_ifdef + "\n") fd.write("#ifndef " + out_file_ifdef + "\n")
fd.write("#define " + out_file_ifdef + "\n") fd.write("#define " + out_file_ifdef + "\n")
out_file_class = out_file_base.replace(".hlsl.h", "").title().replace("_", "").replace(".", "") + "ShaderDX9"; out_file_class = out_file_base.replace(".hlsl.h", "").title().replace("_", "").replace(".", "") + "ShaderDX9"
fd.write("\n\n"); fd.write("\n\n")
fd.write("#include \"drivers/directx9/shader_dx9.h\"\n\n\n"); fd.write("#include \"drivers/directx9/shader_dx9.h\"\n\n\n")
fd.write("class " + out_file_class + " : public ShaderDX9 {\n\n"); fd.write("class " + out_file_class + " : public ShaderDX9 {\n\n")
fd.write("\t virtual String get_shader_name() const { return \"" + out_file_class + "\"; }\n"); fd.write("\t virtual String get_shader_name() const { return \"" + out_file_class + "\"; }\n")
fd.write("public:\n\n"); fd.write("public:\n\n")
if (len(conditionals)): if (len(conditionals)):
fd.write("\tenum Conditionals {\n"); fd.write("\tenum Conditionals {\n")
for x in conditionals: for x in conditionals:
fd.write("\t\t" + x + ",\n"); fd.write("\t\t" + x + ",\n")
fd.write("\t};\n\n"); fd.write("\t};\n\n")
if (len(uniforms)): if (len(uniforms)):
fd.write("\tenum Uniforms {\n"); fd.write("\tenum Uniforms {\n")
for x in uniforms: for x in uniforms:
fd.write("\t\t" + x.upper() + ",\n"); fd.write("\t\t" + x.upper() + ",\n")
fd.write("\t};\n\n"); fd.write("\t};\n\n")
if (len(conditionals)): if (len(conditionals)):
fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n")
fd.write("\t#define _FU if (!_uniform_valid(p_uniform)) return; ERR_FAIL_COND( get_active()!=this );\n\n "); fd.write("\t#define _FU if (!_uniform_valid(p_uniform)) return; ERR_FAIL_COND( get_active()!=this );\n\n ")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, bool p_value) { _FU set_uniformb(p_uniform,p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, bool p_value) { _FU set_uniformb(p_uniform,p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU set_uniformf(p_uniform,p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU set_uniformf(p_uniform,p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU set_uniformf(p_uniform,p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU set_uniformf(p_uniform,p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n")
#fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n");
#fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n");
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU set_uniformi(p_uniform,p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU float col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; set_uniformfv(p_uniform,col); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU float col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; set_uniformfv(p_uniform,col); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU float vec2[4]={p_vec2.x,p_vec2.y,0,0}; set_uniformfv(p_uniform,vec2); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU float vec2[4]={p_vec2.x,p_vec2.y,0,0}; set_uniformfv(p_uniform,vec2); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU float vec3[4]={p_vec3.x,p_vec3.y,p_vec3.z,0}; set_uniformfv(p_uniform,vec3); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU float vec3[4]={p_vec3.x,p_vec3.y,p_vec3.z,0}; set_uniformfv(p_uniform,vec3); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU float vec2[4]={p_a,p_b,0,0}; set_uniformfv(p_uniform,vec2); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU float vec2[4]={p_a,p_b,0,0}; set_uniformfv(p_uniform,vec2); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU float vec3[4]={p_a,p_b,p_c,0}; set_uniformfv(p_uniform,vec3); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU float vec3[4]={p_a,p_b,p_c,0}; set_uniformfv(p_uniform,vec3); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU float vec4[4]={p_a,p_b,p_c,p_d}; set_uniformfv(p_uniform,vec4); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU float vec4[4]={p_a,p_b,p_c,p_d}; set_uniformfv(p_uniform,vec4); }\n\n")
fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU
@ -567,7 +567,7 @@ def build_hlsl_dx9_header(filename):
} }
"""); """)
fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU
@ -581,18 +581,18 @@ def build_hlsl_dx9_header(filename):
} }
set_uniformfv(p_uniform,&matrix[0],4); set_uniformfv(p_uniform,&matrix[0],4);
}; """); }; """)
fd.write("\n\n#undef _FU\n\n\n"); fd.write("\n\n#undef _FU\n\n\n")
fd.write("\tvirtual void init(IDirect3DDevice9 *p_device,ShaderSupport p_version) {\n\n"); fd.write("\tvirtual void init(IDirect3DDevice9 *p_device,ShaderSupport p_version) {\n\n")
if (len(conditionals)): if (len(conditionals)):
fd.write("\t\tstatic const char* _conditional_strings[]={\n") fd.write("\t\tstatic const char* _conditional_strings[]={\n")
if (len(conditionals)): if (len(conditionals)):
for x in conditionals: for x in conditionals:
fd.write("\t\t\t\"" + x + "\",\n"); fd.write("\t\t\t\"" + x + "\",\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic const char **_conditional_strings=NULL;\n") fd.write("\t\tstatic const char **_conditional_strings=NULL;\n")
@ -601,49 +601,49 @@ def build_hlsl_dx9_header(filename):
fd.write("\t\tstatic const char* _uniform_strings[]={\n") fd.write("\t\tstatic const char* _uniform_strings[]={\n")
if (len(uniforms)): if (len(uniforms)):
for x in uniforms: for x in uniforms:
fd.write("\t\t\t\"" + x + "\",\n"); fd.write("\t\t\t\"" + x + "\",\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
fd.write("\t\tstatic const bool _fragment_uniforms[]={\n") fd.write("\t\tstatic const bool _fragment_uniforms[]={\n")
if (len(uniforms)): if (len(uniforms)):
for x in fragment_uniforms: for x in fragment_uniforms:
if (x): if (x):
fd.write("\t\t\ttrue,\n"); fd.write("\t\t\ttrue,\n")
else: else:
fd.write("\t\t\tfalse,\n"); fd.write("\t\t\tfalse,\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic const char **_uniform_strings=NULL;\n") fd.write("\t\tstatic const char **_uniform_strings=NULL;\n")
fd.write("\t\tstatic const bool *_fragment_uniforms=NULL;\n") fd.write("\t\tstatic const bool *_fragment_uniforms=NULL;\n")
fd.write("\t\tstatic const char* _vertex_code=\"\\\n") fd.write("\t\tstatic const char* _vertex_code=\"\\\n")
for x in vertex_lines: for x in vertex_lines:
fd.write("\t\t\t" + x + "\n"); fd.write("\t\t\t" + x + "\n")
fd.write("\t\t\";\n\n"); fd.write("\t\t\";\n\n")
fd.write("\t\tstatic const int _vertex_code_start=" + str(vertex_offset) + ";\n") fd.write("\t\tstatic const int _vertex_code_start=" + str(vertex_offset) + ";\n")
fd.write("\t\tstatic const char* _fragment_code=\"\\\n") fd.write("\t\tstatic const char* _fragment_code=\"\\\n")
for x in fragment_lines: for x in fragment_lines:
fd.write("\t\t\t" + x + "\n"); fd.write("\t\t\t" + x + "\n")
fd.write("\t\t\";\n\n"); fd.write("\t\t\";\n\n")
fd.write("\t\tstatic const int _fragment_code_start=" + str(fragment_offset) + ";\n") fd.write("\t\tstatic const int _fragment_code_start=" + str(fragment_offset) + ";\n")
fd.write("\t\tsetup(p_device,p_version,_conditional_strings," + str(len(conditionals)) + ",_uniform_strings," + str(len(uniforms)) + ",_fragment_uniforms,_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") fd.write("\t\tsetup(p_device,p_version,_conditional_strings," + str(len(conditionals)) + ",_uniform_strings," + str(len(uniforms)) + ",_fragment_uniforms,_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n")
fd.write("\t};\n\n") fd.write("\t};\n\n")
fd.write("};\n\n"); fd.write("};\n\n")
fd.write("#endif\n\n"); fd.write("#endif\n\n")
fd.close(); fd.close()
def build_hlsl_dx9_headers(target, source, env): def build_hlsl_dx9_headers(target, source, env):
for x in source: for x in source:
build_hlsl_dx9_header(str(x)); build_hlsl_dx9_header(str(x))
return 0 return 0
@ -717,14 +717,14 @@ def include_file_in_legacygl_header(filename, header_data, depth):
ifdefline = ifdefline.replace(")", "").strip() ifdefline = ifdefline.replace(")", "").strip()
if (line.find("_EN_") != -1): if (line.find("_EN_") != -1):
enumbase = ifdefline[:ifdefline.find("_EN_")]; enumbase = ifdefline[:ifdefline.find("_EN_")]
ifdefline = ifdefline.replace("_EN_", "_") ifdefline = ifdefline.replace("_EN_", "_")
line = line.replace("_EN_", "_") line = line.replace("_EN_", "_")
# print(enumbase+":"+ifdefline); # print(enumbase+":"+ifdefline);
if (enumbase not in header_data.enums): if (enumbase not in header_data.enums):
header_data.enums[enumbase] = [] header_data.enums[enumbase] = []
if (ifdefline not in header_data.enums[enumbase]): if (ifdefline not in header_data.enums[enumbase]):
header_data.enums[enumbase].append(ifdefline); header_data.enums[enumbase].append(ifdefline)
elif (not ifdefline in header_data.conditionals): elif (not ifdefline in header_data.conditionals):
header_data.conditionals += [ifdefline] header_data.conditionals += [ifdefline]
@ -737,9 +737,9 @@ def include_file_in_legacygl_header(filename, header_data, depth):
else: else:
texunit = str(int(texunitstr)) texunit = str(int(texunitstr))
uline = line[:line.lower().find("//")] uline = line[:line.lower().find("//")]
uline = uline.replace("uniform", ""); uline = uline.replace("uniform", "")
uline = uline.replace("highp", ""); uline = uline.replace("highp", "")
uline = uline.replace(";", ""); uline = uline.replace(";", "")
lines = uline.split(",") lines = uline.split(",")
for x in lines: for x in lines:
@ -754,8 +754,8 @@ def include_file_in_legacygl_header(filename, header_data, depth):
header_data.texunit_names += [x] header_data.texunit_names += [x]
elif (line.find("uniform") != -1): elif (line.find("uniform") != -1):
uline = line.replace("uniform", ""); uline = line.replace("uniform", "")
uline = uline.replace(";", ""); uline = uline.replace(";", "")
lines = uline.split(",") lines = uline.split(",")
for x in lines: for x in lines:
@ -769,10 +769,10 @@ def include_file_in_legacygl_header(filename, header_data, depth):
header_data.uniforms += [x] header_data.uniforms += [x]
if ((line.strip().find("in ") == 0 or line.strip().find("attribute ") == 0) and line.find("attrib:") != -1): if ((line.strip().find("in ") == 0 or line.strip().find("attribute ") == 0) and line.find("attrib:") != -1):
uline = line.replace("in ", ""); uline = line.replace("in ", "")
uline = uline.replace("attribute ", ""); uline = uline.replace("attribute ", "")
uline = uline.replace("highp ", ""); uline = uline.replace("highp ", "")
uline = uline.replace(";", ""); uline = uline.replace(";", "")
uline = uline[uline.find(" "):].strip() uline = uline[uline.find(" "):].strip()
if (uline.find("//") != -1): if (uline.find("//") != -1):
@ -796,7 +796,7 @@ def include_file_in_legacygl_header(filename, header_data, depth):
line = fs.readline() line = fs.readline()
header_data.line_offset += 1 header_data.line_offset += 1
fs.close(); fs.close()
return header_data return header_data
@ -811,7 +811,7 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs):
enum_constants = [] enum_constants = []
fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n"); fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n")
out_file_base = out_file out_file_base = out_file
out_file_base = out_file_base[out_file_base.rfind("/") + 1:] out_file_base = out_file_base[out_file_base.rfind("/") + 1:]
@ -821,49 +821,49 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs):
fd.write("#ifndef " + out_file_ifdef + class_suffix + "_120\n") fd.write("#ifndef " + out_file_ifdef + class_suffix + "_120\n")
fd.write("#define " + out_file_ifdef + class_suffix + "_120\n") fd.write("#define " + out_file_ifdef + class_suffix + "_120\n")
out_file_class = out_file_base.replace(".glsl.h", "").title().replace("_", "").replace(".", "") + "Shader" + class_suffix; out_file_class = out_file_base.replace(".glsl.h", "").title().replace("_", "").replace(".", "") + "Shader" + class_suffix
fd.write("\n\n"); fd.write("\n\n")
fd.write("#include \"" + include + "\"\n\n\n"); fd.write("#include \"" + include + "\"\n\n\n")
fd.write("class " + out_file_class + " : public Shader" + class_suffix + " {\n\n"); fd.write("class " + out_file_class + " : public Shader" + class_suffix + " {\n\n")
fd.write("\t virtual String get_shader_name() const { return \"" + out_file_class + "\"; }\n"); fd.write("\t virtual String get_shader_name() const { return \"" + out_file_class + "\"; }\n")
fd.write("public:\n\n"); fd.write("public:\n\n")
if (len(header_data.conditionals)): if (len(header_data.conditionals)):
fd.write("\tenum Conditionals {\n"); fd.write("\tenum Conditionals {\n")
for x in header_data.conditionals: for x in header_data.conditionals:
fd.write("\t\t" + x.upper() + ",\n"); fd.write("\t\t" + x.upper() + ",\n")
fd.write("\t};\n\n"); fd.write("\t};\n\n")
if (len(header_data.uniforms)): if (len(header_data.uniforms)):
fd.write("\tenum Uniforms {\n"); fd.write("\tenum Uniforms {\n")
for x in header_data.uniforms: for x in header_data.uniforms:
fd.write("\t\t" + x.upper() + ",\n"); fd.write("\t\t" + x.upper() + ",\n")
fd.write("\t};\n\n"); fd.write("\t};\n\n")
fd.write("\t_FORCE_INLINE_ int get_uniform(Uniforms p_uniform) const { return _get_uniform(p_uniform); }\n\n"); fd.write("\t_FORCE_INLINE_ int get_uniform(Uniforms p_uniform) const { return _get_uniform(p_uniform); }\n\n")
if (len(header_data.conditionals)): if (len(header_data.conditionals)):
fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n")
fd.write("\t#define _FU if (get_uniform(p_uniform)<0) return; ERR_FAIL_COND( get_active()!=this );\n\n "); fd.write("\t#define _FU if (get_uniform(p_uniform)<0) return; ERR_FAIL_COND( get_active()!=this );\n\n ")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n")
#fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n");
#fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n");
#fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n");
#fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n");
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU glUniform2f(get_uniform(p_uniform),p_a,p_b); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU glUniform2f(get_uniform(p_uniform),p_a,p_b); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU glUniform3f(get_uniform(p_uniform),p_a,p_b,p_c); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU glUniform3f(get_uniform(p_uniform),p_a,p_b,p_c); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU glUniform4f(get_uniform(p_uniform),p_a,p_b,p_c,p_d); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU glUniform4f(get_uniform(p_uniform),p_a,p_b,p_c,p_d); }\n\n")
fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU
@ -894,7 +894,7 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs):
} }
"""); """)
fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Matrix32& p_transform) { _FU fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Matrix32& p_transform) { _FU
@ -925,7 +925,7 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs):
} }
"""); """)
fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU
@ -939,17 +939,17 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs):
} }
glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix); glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix);
}; """); }; """)
fd.write("\n\n#undef _FU\n\n\n"); fd.write("\n\n#undef _FU\n\n\n")
fd.write("\tvirtual void init() {\n\n"); fd.write("\tvirtual void init() {\n\n")
enum_value_count = 0; enum_value_count = 0
if (len(header_data.enums)): if (len(header_data.enums)):
fd.write("\t\t//Written using math, given nonstandarity of 64 bits integer constants..\n"); fd.write("\t\t//Written using math, given nonstandarity of 64 bits integer constants..\n")
fd.write("\t\tstatic const Enum _enums[]={\n") fd.write("\t\tstatic const Enum _enums[]={\n")
bitofs = len(header_data.conditionals) bitofs = len(header_data.conditionals)
@ -958,7 +958,7 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs):
for xv in header_data.enums: for xv in header_data.enums:
x = header_data.enums[xv] x = header_data.enums[xv]
bits = 1 bits = 1
amt = len(x); amt = len(x)
# print(x) # print(x)
while(2**bits < amt): while(2**bits < amt):
bits += 1 bits += 1
@ -975,18 +975,18 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs):
strs += "NULL}" strs += "NULL}"
fd.write("\t\t\t{(uint64_t(1<<" + str(bits) + ")-1)<<" + str(bitofs) + "," + str(bitofs) + "," + strs + "},\n"); fd.write("\t\t\t{(uint64_t(1<<" + str(bits) + ")-1)<<" + str(bitofs) + "," + str(bitofs) + "," + strs + "},\n")
bitofs += bits bitofs += bits
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
fd.write("\t\tstatic const EnumValue _enum_values[]={\n") fd.write("\t\tstatic const EnumValue _enum_values[]={\n")
enum_value_count = len(enum_vals); enum_value_count = len(enum_vals)
for x in enum_vals: for x in enum_vals:
fd.write("\t\t\t{" + x["set_mask"] + "," + x["clear_mask"] + "},\n"); fd.write("\t\t\t{" + x["set_mask"] + "," + x["clear_mask"] + "},\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic const Enum *_enums=NULL;\n") fd.write("\t\tstatic const Enum *_enums=NULL;\n")
fd.write("\t\tstatic const EnumValue *_enum_values=NULL;\n") fd.write("\t\tstatic const EnumValue *_enum_values=NULL;\n")
@ -996,8 +996,8 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs):
fd.write("\t\tstatic const char* _conditional_strings[]={\n") fd.write("\t\tstatic const char* _conditional_strings[]={\n")
if (len(header_data.conditionals)): if (len(header_data.conditionals)):
for x in header_data.conditionals: for x in header_data.conditionals:
fd.write("\t\t\t\"#define " + x + "\\n\",\n"); fd.write("\t\t\t\"#define " + x + "\\n\",\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic const char **_conditional_strings=NULL;\n") fd.write("\t\tstatic const char **_conditional_strings=NULL;\n")
@ -1006,8 +1006,8 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs):
fd.write("\t\tstatic const char* _uniform_strings[]={\n") fd.write("\t\tstatic const char* _uniform_strings[]={\n")
if (len(header_data.uniforms)): if (len(header_data.uniforms)):
for x in header_data.uniforms: for x in header_data.uniforms:
fd.write("\t\t\t\"" + x + "\",\n"); fd.write("\t\t\t\"" + x + "\",\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic const char **_uniform_strings=NULL;\n") fd.write("\t\tstatic const char **_uniform_strings=NULL;\n")
@ -1016,36 +1016,36 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs):
fd.write("\t\tstatic AttributePair _attribute_pairs[]={\n") fd.write("\t\tstatic AttributePair _attribute_pairs[]={\n")
for x in header_data.attributes: for x in header_data.attributes:
fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n"); fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic AttributePair *_attribute_pairs=NULL;\n") fd.write("\t\tstatic AttributePair *_attribute_pairs=NULL;\n")
if (len(header_data.texunits)): if (len(header_data.texunits)):
fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n") fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n")
for x in header_data.texunits: for x in header_data.texunits:
fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n"); fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n")
fd.write("\t\t};\n\n"); fd.write("\t\t};\n\n")
else: else:
fd.write("\t\tstatic TexUnitPair *_texunit_pairs=NULL;\n") fd.write("\t\tstatic TexUnitPair *_texunit_pairs=NULL;\n")
fd.write("\t\tstatic const char _vertex_code[]={\n") fd.write("\t\tstatic const char _vertex_code[]={\n")
for x in header_data.vertex_lines: for x in header_data.vertex_lines:
for i in range(len(x)): for i in range(len(x)):
fd.write(str(ord(x[i])) + ","); fd.write(str(ord(x[i])) + ",")
fd.write(str(ord('\n')) + ","); fd.write(str(ord('\n')) + ",")
fd.write("\t\t0};\n\n"); fd.write("\t\t0};\n\n")
fd.write("\t\tstatic const int _vertex_code_start=" + str(header_data.vertex_offset) + ";\n") fd.write("\t\tstatic const int _vertex_code_start=" + str(header_data.vertex_offset) + ";\n")
fd.write("\t\tstatic const char _fragment_code[]={\n") fd.write("\t\tstatic const char _fragment_code[]={\n")
for x in header_data.fragment_lines: for x in header_data.fragment_lines:
for i in range(len(x)): for i in range(len(x)):
fd.write(str(ord(x[i])) + ","); fd.write(str(ord(x[i])) + ",")
fd.write(str(ord('\n')) + ","); fd.write(str(ord('\n')) + ",")
fd.write("\t\t0};\n\n"); fd.write("\t\t0};\n\n")
fd.write("\t\tstatic const int _fragment_code_start=" + str(header_data.fragment_offset) + ";\n") fd.write("\t\tstatic const int _fragment_code_start=" + str(header_data.fragment_offset) + ";\n")
@ -1060,20 +1060,20 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs):
fd.write("\tenum EnumConditionals {\n") fd.write("\tenum EnumConditionals {\n")
for x in enum_constants: for x in enum_constants:
fd.write("\t\t" + x.upper() + ",\n"); fd.write("\t\t" + x.upper() + ",\n")
fd.write("\t};\n\n"); fd.write("\t};\n\n")
fd.write("\tvoid set_enum_conditional(EnumConditionals p_cond) { _set_enum_conditional(p_cond); }\n") fd.write("\tvoid set_enum_conditional(EnumConditionals p_cond) { _set_enum_conditional(p_cond); }\n")
fd.write("};\n\n"); fd.write("};\n\n")
fd.write("#endif\n\n"); fd.write("#endif\n\n")
fd.close(); fd.close()
def build_legacygl_headers(target, source, env): def build_legacygl_headers(target, source, env):
for x in source: for x in source:
build_legacygl_header(str(x), include="drivers/legacygl/shader_lgl.h", class_suffix="LGL", output_attribs=False); build_legacygl_header(str(x), include="drivers/legacygl/shader_lgl.h", class_suffix="LGL", output_attribs=False)
return 0 return 0
@ -1120,22 +1120,22 @@ def parse_cg_file(fname, uniforms, sizes, conditionals):
type = res.groups(1) type = res.groups(1)
name = res.groups(2) name = res.groups(2)
uniforms.append(name); uniforms.append(name)
if (type.find("texobj") != -1): if (type.find("texobj") != -1):
sizes.append(1); sizes.append(1)
else: else:
t = re.match(r"float(\d)x(\d)", type); t = re.match(r"float(\d)x(\d)", type)
if t: if t:
sizes.append(int(t.groups(1)) * int(t.groups(2))) sizes.append(int(t.groups(1)) * int(t.groups(2)))
else: else:
t = re.match(r"float(\d)", type); t = re.match(r"float(\d)", type)
sizes.append(int(t.groups(1))) sizes.append(int(t.groups(1)))
if line.find("[branch]") != -1: if line.find("[branch]") != -1:
conditionals.append(name); conditionals.append(name)
line = fs.readline(); line = fs.readline()
def build_cg_shader(sname): def build_cg_shader(sname):
@ -1144,36 +1144,36 @@ def build_cg_shader(sname):
vp_uniform_sizes = [] vp_uniform_sizes = []
vp_conditionals = [] vp_conditionals = []
parse_cg_file("vp_" + sname + ".cg", vp_uniforms, vp_uniform_sizes, vp_conditionals); parse_cg_file("vp_" + sname + ".cg", vp_uniforms, vp_uniform_sizes, vp_conditionals)
fp_uniforms = [] fp_uniforms = []
fp_uniform_sizes = [] fp_uniform_sizes = []
fp_conditionals = [] fp_conditionals = []
parse_cg_file("fp_" + sname + ".cg", fp_uniforms, fp_uniform_sizes, fp_conditionals); parse_cg_file("fp_" + sname + ".cg", fp_uniforms, fp_uniform_sizes, fp_conditionals)
fd = open("shader_" + sname + ".cg.h", "w"); fd = open("shader_" + sname + ".cg.h", "w")
fd.write('\n#include "shader_cell.h"\n'); fd.write('\n#include "shader_cell.h"\n')
fd.write("\nclass Shader_" + sname + " : public ShaderCell {\n"); fd.write("\nclass Shader_" + sname + " : public ShaderCell {\n")
fd.write("\n\tstatic struct VertexUniforms[] = {\n"); fd.write("\n\tstatic struct VertexUniforms[] = {\n")
offset = 0; offset = 0
for i in range(0, len(vp_uniforms)): for i in range(0, len(vp_uniforms)):
fd.write('\t\t{ "%s", %d, %d },\n' % (vp_uniforms[i], offset, vp_uniform_sizes[i])) fd.write('\t\t{ "%s", %d, %d },\n' % (vp_uniforms[i], offset, vp_uniform_sizes[i]))
offset = offset + vp_uniform_sizes[i]; offset = offset + vp_uniform_sizes[i]
fd.write("\t};\n\n"); fd.write("\t};\n\n")
fd.write("public:\n\n"); fd.write("public:\n\n")
fd.write("\tenum {\n"); fd.write("\tenum {\n")
for i in range(0, len(vp_uniforms)): for i in range(0, len(vp_uniforms)):
fd.write('\t\tVP_%s,\n' % vp_uniforms[i].upper()) fd.write('\t\tVP_%s,\n' % vp_uniforms[i].upper())
fd.write("\t};\n"); fd.write("\t};\n")
import glob import glob
@ -1440,13 +1440,13 @@ def save_active_platforms(apnames, ap):
for x in ap: for x in ap:
pth = x + "/logo.png" pth = x + "/logo.png"
# print("open path: "+pth) # print("open path: "+pth)
pngf = open(pth, "rb"); pngf = open(pth, "rb")
b = pngf.read(1); b = pngf.read(1)
str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n" str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n"
str += " static const unsigned char _" + x[9:] + "_logo[]={" str += " static const unsigned char _" + x[9:] + "_logo[]={"
while(len(b) == 1): while(len(b) == 1):
str += hex(ord(b)) str += hex(ord(b))
b = pngf.read(1); b = pngf.read(1)
if (len(b) == 1): if (len(b) == 1):
str += "," str += ","

View File

@ -682,6 +682,6 @@ env_openssl.add_source_files(env.modules_sources, "*.c")
# platform/winrt need to know openssl is available, pass to main env # platform/winrt need to know openssl is available, pass to main env
if "platform" in env and env["platform"] == "winrt": if "platform" in env and env["platform"] == "winrt":
env.Append(CPPPATH=[thirdparty_dir]) env.Append(CPPPATH=[thirdparty_dir])
env.Append(CPPFLAGS=['-DOPENSSL_ENABLED']); env.Append(CPPFLAGS=['-DOPENSSL_ENABLED'])
Export('env') Export('env')

View File

@ -49,7 +49,7 @@ def create(env):
if "applelink" in tools: if "applelink" in tools:
tools.remove("applelink") tools.remove("applelink")
env.Tool('gcc') env.Tool('gcc')
return env.Clone(tools=tools); return env.Clone(tools=tools)
def configure(env): def configure(env):
@ -124,7 +124,7 @@ def configure(env):
else: else:
env.extra_suffix = ".armv7" + env.extra_suffix env.extra_suffix = ".armv7" + env.extra_suffix
gcc_path = env["ANDROID_NDK_ROOT"] + "/toolchains/" + env["NDK_TARGET"] + "/prebuilt/"; gcc_path = env["ANDROID_NDK_ROOT"] + "/toolchains/" + env["NDK_TARGET"] + "/prebuilt/"
if (sys.platform.startswith("linux")): if (sys.platform.startswith("linux")):
if (platform.machine().endswith('64')): if (platform.machine().endswith('64')):

View File

@ -23,7 +23,7 @@ iphone_lib = [
#iphone_lib = env.Library('iphone', iphone_lib) #iphone_lib = env.Library('iphone', iphone_lib)
env_ios = env.Clone(); env_ios = env.Clone()
if env['ios_gles22_override'] == "yes": if env['ios_gles22_override'] == "yes":

View File

@ -39,7 +39,7 @@ def get_flags():
def configure(env): def configure(env):
env['ENV'] = os.environ; env['ENV'] = os.environ
env.use_windows_spawn_fix('javascript') env.use_windows_spawn_fix('javascript')
env.Append(CPPPATH=['#platform/javascript']) env.Append(CPPPATH=['#platform/javascript'])

View File

@ -267,7 +267,7 @@ def configure(env):
env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")]) env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")])
env.Append(CCFLAGS=["/I" + DIRECTX_PATH + "/Include"]) env.Append(CCFLAGS=["/I" + DIRECTX_PATH + "/Include"])
env.Append(LIBPATH=[DIRECTX_PATH + "/Lib/x86"]) env.Append(LIBPATH=[DIRECTX_PATH + "/Lib/x86"])
env['ENV'] = os.environ; env['ENV'] = os.environ
# This detection function needs the tools env (that is env['ENV'], not SCons's env), and that is why it's this far bellow in the code # This detection function needs the tools env (that is env['ENV'], not SCons's env), and that is why it's this far bellow in the code
compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV'])
@ -323,10 +323,10 @@ def configure(env):
env.Append(LINKFLAGS=['-static']) env.Append(LINKFLAGS=['-static'])
env.Append(LINKFLAGS=['-static-libgcc']) env.Append(LINKFLAGS=['-static-libgcc'])
env.Append(LINKFLAGS=['-static-libstdc++']) env.Append(LINKFLAGS=['-static-libstdc++'])
mingw_prefix = env["mingw_prefix"]; mingw_prefix = env["mingw_prefix"]
else: else:
env.Append(LINKFLAGS=['-static']) env.Append(LINKFLAGS=['-static'])
mingw_prefix = env["mingw_prefix_64"]; mingw_prefix = env["mingw_prefix_64"]
nulstr = "" nulstr = ""

View File

@ -49,7 +49,7 @@ def configure(env):
sys.exit() sys.exit()
arch = "" arch = ""
env['ENV'] = os.environ; env['ENV'] = os.environ
# ANGLE # ANGLE
angle_root = os.getenv("ANGLE_SRC_PATH") angle_root = os.getenv("ANGLE_SRC_PATH")

View File

@ -7,14 +7,14 @@ env.add_source_files(env.scene_sources, "*.cpp")
Export('env') Export('env')
SConscript('main/SCsub'); SConscript('main/SCsub')
SConscript('gui/SCsub'); SConscript('gui/SCsub')
SConscript('3d/SCsub'); SConscript('3d/SCsub')
SConscript('2d/SCsub'); SConscript('2d/SCsub')
SConscript('animation/SCsub'); SConscript('animation/SCsub')
SConscript('audio/SCsub'); SConscript('audio/SCsub')
SConscript('resources/SCsub'); SConscript('resources/SCsub')
SConscript('io/SCsub'); SConscript('io/SCsub')
lib = env.Library("scene", env.scene_sources) lib = env.Library("scene", env.scene_sources)

View File

@ -7,4 +7,4 @@ env.add_source_files(env.scene_sources, "*.c")
Export('env') Export('env')
SConscript("default_theme/SCsub"); SConscript("default_theme/SCsub")

View File

@ -1,71 +1,71 @@
import os; import os
import glob; import glob
import string; import string
# Generate include files # Generate include files
f = open("theme_data.h", "wb") f = open("theme_data.h", "wb")
f.write("// THIS FILE HAS BEEN AUTOGENERATED, DONT EDIT!!\n"); f.write("// THIS FILE HAS BEEN AUTOGENERATED, DONT EDIT!!\n")
f.write("\n\n"); f.write("\n\n")
# Generate png image block # Generate png image block
pixmaps = glob.glob("*.png"); pixmaps = glob.glob("*.png")
pixmaps.sort(); pixmaps.sort()
f.write("\n\n\n"); f.write("\n\n\n")
for x in pixmaps: for x in pixmaps:
var_str = x[:-4] + "_png"; var_str = x[:-4] + "_png"
f.write("static const unsigned char " + var_str + "[]={\n"); f.write("static const unsigned char " + var_str + "[]={\n")
pngf = open(x, "rb"); pngf = open(x, "rb")
b = pngf.read(1); b = pngf.read(1)
while(len(b) == 1): while(len(b) == 1):
f.write(hex(ord(b))) f.write(hex(ord(b)))
b = pngf.read(1); b = pngf.read(1)
if (len(b) == 1): if (len(b) == 1):
f.write(",") f.write(",")
f.write("\n};\n\n\n"); f.write("\n};\n\n\n")
pngf.close(); pngf.close()
# Generate shaders block # Generate shaders block
shaders = glob.glob("*.gsl") shaders = glob.glob("*.gsl")
shaders.sort(); shaders.sort()
f.write("\n\n\n"); f.write("\n\n\n")
for x in shaders: for x in shaders:
var_str = x[:-4] + "_shader_code"; var_str = x[:-4] + "_shader_code"
f.write("static const char *" + var_str + "=\n"); f.write("static const char *" + var_str + "=\n")
sf = open(x, "rb"); sf = open(x, "rb")
b = sf.readline(); b = sf.readline()
while(b != ""): while(b != ""):
if (b.endswith("\r\n")): if (b.endswith("\r\n")):
b = b[:-2] b = b[:-2]
if (b.endswith("\n")): if (b.endswith("\n")):
b = b[:-1] b = b[:-1]
f.write(" \"" + b) f.write(" \"" + b)
b = sf.readline(); b = sf.readline()
if (b != ""): if (b != ""):
f.write("\"\n") f.write("\"\n")
f.write("\";\n\n\n"); f.write("\";\n\n\n")
sf.close(); sf.close()
f.close(); f.close()

View File

@ -7,12 +7,12 @@ env.add_source_files(env.servers_sources, "*.cpp")
Export('env') Export('env')
SConscript('physics/SCsub'); SConscript('physics/SCsub')
SConscript('physics_2d/SCsub'); SConscript('physics_2d/SCsub')
SConscript('visual/SCsub'); SConscript('visual/SCsub')
SConscript('audio/SCsub'); SConscript('audio/SCsub')
SConscript('spatial_sound/SCsub'); SConscript('spatial_sound/SCsub')
SConscript('spatial_sound_2d/SCsub'); SConscript('spatial_sound_2d/SCsub')
lib = env.Library("servers", env.servers_sources) lib = env.Library("servers", env.servers_sources)

View File

@ -47,11 +47,11 @@ def make_translations_header(target, source, env):
xl_names.append([name, len(buf), str(decomp_size)]) xl_names.append([name, len(buf), str(decomp_size)])
g.write("struct EditorTranslationList {\n") g.write("struct EditorTranslationList {\n")
g.write("\tconst char* lang;\n"); g.write("\tconst char* lang;\n")
g.write("\tint comp_size;\n"); g.write("\tint comp_size;\n")
g.write("\tint uncomp_size;\n"); g.write("\tint uncomp_size;\n")
g.write("\tconst unsigned char* data;\n"); g.write("\tconst unsigned char* data;\n")
g.write("};\n\n"); g.write("};\n\n")
g.write("static EditorTranslationList _editor_translations[]={\n") g.write("static EditorTranslationList _editor_translations[]={\n")
for x in xl_names: for x in xl_names:
g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ",_translation_" + x[0] + "_compressed},\n") g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ",_translation_" + x[0] + "_compressed},\n")
@ -112,8 +112,8 @@ if (env["tools"] != "no"):
env.Depends('#tools/editor/builtin_fonts.h', flist) env.Depends('#tools/editor/builtin_fonts.h', flist)
env.Command('#tools/editor/builtin_fonts.h', flist, make_fonts_header) env.Command('#tools/editor/builtin_fonts.h', flist, make_fonts_header)
SConscript('editor/SCsub'); SConscript('editor/SCsub')
SConscript('collada/SCsub'); SConscript('collada/SCsub')
SConscript('doc/SCsub') SConscript('doc/SCsub')
lib = env.Library("tool", env.tool_sources) lib = env.Library("tool", env.tool_sources)

View File

@ -74,7 +74,7 @@ if (env["tools"] == "yes"):
env.add_source_files(env.tool_sources, "*.cpp") env.add_source_files(env.tool_sources, "*.cpp")
Export('env') Export('env')
SConscript('icons/SCsub'); SConscript('icons/SCsub')
SConscript('plugins/SCsub'); SConscript('plugins/SCsub')
SConscript('fileserver/SCsub'); SConscript('fileserver/SCsub')
SConscript('io_plugins/SCsub'); SConscript('io_plugins/SCsub')

View File

@ -22,42 +22,42 @@ def make_editor_icons_action(target, source, env):
for x in pixmaps: for x in pixmaps:
x = str(x) x = str(x)
var_str = os.path.basename(x)[:-4] + "_png"; var_str = os.path.basename(x)[:-4] + "_png"
# print(var_str) # print(var_str)
s.write("static const unsigned char " + var_str + "[]={\n"); s.write("static const unsigned char " + var_str + "[]={\n")
pngf = open(x, "rb"); pngf = open(x, "rb")
b = pngf.read(1); b = pngf.read(1)
while(len(b) == 1): while(len(b) == 1):
s.write(hex(ord(b))) s.write(hex(ord(b)))
b = pngf.read(1); b = pngf.read(1)
if (len(b) == 1): if (len(b) == 1):
s.write(",") s.write(",")
s.write("\n};\n\n"); s.write("\n};\n\n")
pngf.close(); pngf.close()
var_str = os.path.basename(x)[:-4] + "_hidpi_png"; var_str = os.path.basename(x)[:-4] + "_hidpi_png"
try: try:
pngf = open(os.path.dirname(x) + "/2x/" + os.path.basename(x), "rb") pngf = open(os.path.dirname(x) + "/2x/" + os.path.basename(x), "rb")
s.write("static const unsigned char " + var_str + "[]={\n"); s.write("static const unsigned char " + var_str + "[]={\n")
b = pngf.read(1); b = pngf.read(1)
while(len(b) == 1): while(len(b) == 1):
s.write(hex(ord(b))) s.write(hex(ord(b)))
b = pngf.read(1); b = pngf.read(1)
if (len(b) == 1): if (len(b) == 1):
s.write(",") s.write(",")
s.write("\n};\n\n\n"); s.write("\n};\n\n\n")
hidpi_list.append(x) hidpi_list.append(x)
except: except:
s.write("static const unsigned char* " + var_str + "=NULL;\n\n\n"); s.write("static const unsigned char* " + var_str + "=NULL;\n\n\n")
s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n")
s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n") s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n")
@ -74,12 +74,12 @@ def make_editor_icons_action(target, source, env):
for x in pixmaps: for x in pixmaps:
x = os.path.basename(str(x)) x = os.path.basename(str(x))
type = x[5:-4].title().replace("_", ""); type = x[5:-4].title().replace("_", "")
var_str = x[:-4] + "_png"; var_str = x[:-4] + "_png"
var_str_hidpi = x[:-4] + "_hidpi_png"; var_str_hidpi = x[:-4] + "_hidpi_png"
s.write("\tp_theme->set_icon(\"" + type + "\",\"EditorIcons\",make_icon(" + var_str + "," + var_str_hidpi + "));\n"); s.write("\tp_theme->set_icon(\"" + type + "\",\"EditorIcons\",make_icon(" + var_str + "," + var_str_hidpi + "));\n")
s.write("\n\n}\n\n"); s.write("\n\n}\n\n")
f = open(dst, "wb") f = open(dst, "wb")
f.write(s.getvalue()) f.write(s.getvalue())

View File

@ -9,7 +9,8 @@ def tof(filepath):
content = content.replace("0x", "") content = content.replace("0x", "")
content = content.split(',') content = content.split(',')
for i in range(len(content)): for i in range(len(content)):
if len(content[i]) == 1: content[i] = "0" + content[i] if len(content[i]) == 1:
content[i] = "0" + content[i]
content = "".join(content) content = "".join(content)
with open(filepath + ".file", 'wb') as f: with open(filepath + ".file", 'wb') as f:
content = f.write(content.decode("hex")) content = f.write(content.decode("hex"))

View File

@ -61,7 +61,7 @@ for x in (range(len(sys.argv) - 1)):
if (glpos == -1): if (glpos == -1):
continue continue
ret = line[:glpos].strip(); ret = line[:glpos].strip()
line = line[glpos:].strip() line = line[glpos:].strip()
namepos = line.find("(") namepos = line.find("(")
@ -127,14 +127,14 @@ header_code = """\
f.write("#include <stddef.h>\n\n\n") f.write("#include <stddef.h>\n\n\n")
f.write(header_code); f.write(header_code)
f.write("#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n") f.write("#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n")
f.write("#if defined(_WIN32) && !defined(__CYGWIN__)\n") f.write("#if defined(_WIN32) && !defined(__CYGWIN__)\n")
f.write("#define GLWRP_APIENTRY __stdcall\n") f.write("#define GLWRP_APIENTRY __stdcall\n")
f.write("#else\n"); f.write("#else\n")
f.write("#define GLWRP_APIENTRY \n") f.write("#define GLWRP_APIENTRY \n")
f.write("#endif\n\n"); f.write("#endif\n\n")
for x in types: for x in types:
f.write(x + "\n") f.write(x + "\n")
@ -150,7 +150,7 @@ for x in functions:
f.write("#define " + x["name"] + " __wrapper_" + x["name"] + "\n") f.write("#define " + x["name"] + " __wrapper_" + x["name"] + "\n")
f.write("\n\n") f.write("\n\n")
f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n"); f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n")
f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) );\n") f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) );\n")
f.write("#ifdef __cplusplus\n}\n#endif\n") f.write("#ifdef __cplusplus\n}\n#endif\n")