1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-15 13:51:40 +00:00

Remove trailing spaces

(cherry picked from commit 0a5472e697)
This commit is contained in:
Rémi Verschelde
2016-04-02 20:26:12 +02:00
committed by Rémi Verschelde
parent 69e67d51c7
commit bac8248316
42 changed files with 815 additions and 817 deletions

View File

@@ -15,19 +15,19 @@ def add_source_files(self, sources, filetype, lib_env = None, shared = False):
else:
for f in filetype:
sources.append(self.Object(f))
def build_shader_header( target, source, env ):
def build_shader_header( target, source, env ):
for x in source:
print x
name = str(x)
name = name[ name.rfind("/")+1: ]
name = name[ name.rfind("\\")+1: ]
name = name.replace(".","_")
fs = open(str(x),"r")
fd = open(str(x)+".h","w")
fd.write("/* this file has been generated by SCons, do not edit! */\n")
@@ -40,17 +40,17 @@ def build_shader_header( target, source, env ):
line=line.replace("\"","\\\"")
fd.write("\""+line+"\\n\"\n")
line=fs.readline()
fd.write(";\n")
return 0
def build_glsl_header( filename ):
fs = open(filename,"r")
def build_glsl_header( filename ):
fs = open(filename,"r")
line=fs.readline()
vertex_lines=[]
fragment_lines=[]
uniforms=[]
@@ -68,21 +68,21 @@ def build_glsl_header( filename ):
fragment_offset=0
while(line):
if (line.find("[vertex]")!=-1):
reading="vertex"
line=fs.readline()
line_offset+=1
vertex_offset=line_offset
continue
if (line.find("[fragment]")!=-1):
reading="fragment"
line=fs.readline()
line_offset+=1
fragment_offset=line_offset
continue
if (line.find("#ifdef ")!=-1):
ifdefline = line.replace("#ifdef ","").strip()
if (not ifdefline in conditionals):
@@ -159,49 +159,49 @@ def build_glsl_header( filename ):
uline = uline.replace("attribute ","");
uline = uline.replace(";","");
uline = uline[ uline.find(" "): ].strip()
if (uline.find("//")!=-1):
name,bind = uline.split("//")
if (bind.find("attrib:")!=-1):
name=name.strip()
bind=bind.replace("attrib:","").strip()
attributes+=[(name,bind)]
if (line.strip().find("out ")==0):
uline = line.replace("out","").strip();
uline = uline.replace(";","");
uline = uline[ uline.find(" "): ].strip()
if (uline.find("//")!=-1):
name,bind = uline.split("//")
if (bind.find("drawbuffer:")!=-1):
name=name.strip()
bind=bind.replace("drawbuffer:","").strip()
fbos+=[(name,bind)]
line=line.replace("\r","")
line=line.replace("\n","")
line=line.replace("\\","\\\\")
line=line.replace("\"","\\\"")
#line=line+"\\n\\" no need to anymore
if (reading=="vertex"):
vertex_lines+=[line]
if (reading=="fragment"):
fragment_lines+=[line]
line=fs.readline()
line_offset+=1
fs.close();
out_file = filename+".h"
fd = open(out_file,"w")
fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n");
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: ]
@@ -209,14 +209,14 @@ def build_glsl_header( filename ):
out_file_ifdef = out_file_base.replace(".","_").upper()
fd.write("#ifndef "+out_file_ifdef+"\n")
fd.write("#define "+out_file_ifdef+"\n")
out_file_class = out_file_base.replace(".glsl.h","").title().replace("_","").replace(".","")+"ShaderGL";
fd.write("\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("\t virtual String get_shader_name() const { return \""+out_file_class+"\"; }\n");
fd.write("public:\n\n");
if (len(conditionals)):
fd.write("\tenum Conditionals {\n");
for x in conditionals:
@@ -227,11 +227,11 @@ def build_glsl_header( filename ):
for x in uniforms:
fd.write("\t\t"+x.upper()+",\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)):
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_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");
@@ -251,11 +251,11 @@ def build_glsl_header( filename ):
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, 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
const Transform &tr = p_transform;
GLfloat matrix[16]={ /* build a 16x16 matrix */
tr.basis.elements[0][0],
tr.basis.elements[1][0],
@@ -272,15 +272,15 @@ def build_glsl_header( filename ):
tr.origin.x,
tr.origin.y,
tr.origin.z,
1
1
};
glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix);
}
""");
fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Matrix32& p_transform) { _FU
@@ -315,25 +315,25 @@ def build_glsl_header( filename ):
""");
fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU
GLfloat matrix[16];
for (int i=0;i<4;i++) {
for (int j=0;j<4;j++) {
matrix[i*4+j]=p_matrix.matrix[i][j];
}
}
}
glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix);
}; """);
fd.write("\n\n#undef _FU\n\n\n");
fd.write("\tvirtual void init() {\n\n");
if (len(conditionals)):
fd.write("\t\tstatic const char* _conditional_strings[]={\n")
if (len(conditionals)):
for x in conditionals:
@@ -341,9 +341,9 @@ def build_glsl_header( filename ):
fd.write("\t\t};\n\n");
else:
fd.write("\t\tstatic const char **_conditional_strings=NULL;\n")
if (len(uniforms)):
fd.write("\t\tstatic const char* _uniform_strings[]={\n")
if (len(uniforms)):
for x in uniforms:
@@ -351,18 +351,18 @@ def build_glsl_header( filename ):
fd.write("\t\t};\n\n");
else:
fd.write("\t\tstatic const char **_uniform_strings=NULL;\n")
if (len(attributes)):
fd.write("\t\tstatic AttributePair _attribute_pairs[]={\n")
for x in attributes:
fd.write("\t\t\t{\""+x[0]+"\","+x[1]+"},\n");
fd.write("\t\t};\n\n");
else:
fd.write("\t\tstatic AttributePair *_attribute_pairs=NULL;\n")
if (len(fbos)):
fd.write("\t\tstatic FBOPair _fbo_pairs[]={\n")
for x in fbos:
@@ -404,20 +404,20 @@ def build_glsl_header( filename ):
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("};\n\n");
fd.write("#endif\n\n");
fd.close();
def build_glsl_headers( target, source, env ):
def build_glsl_headers( target, source, env ):
for x in source:
build_glsl_header(str(x));
return 0
return 0
@@ -1084,12 +1084,12 @@ def build_gles2_headers( target, source, env ):
def update_version():
rev = "custom_build"
if (os.getenv("BUILD_REVISION")!=None):
rev=os.getenv("BUILD_REVISION")
print("Using custom revision: "+rev)
import version
f=open("core/version.h","wb")
f.write("#define VERSION_SHORT_NAME "+str(version.short_name)+"\n")
@@ -1134,7 +1134,7 @@ def parse_cg_file(fname, uniforms, sizes, conditionals):
line = fs.readline();
def build_cg_shader(sname):
vp_uniforms = []
@@ -1172,7 +1172,7 @@ def build_cg_shader(sname):
fd.write("\t};\n");
import glob
def detect_modules():
@@ -1371,7 +1371,7 @@ def save_active_platforms(apnames,ap):
str+=","
str+="};\n"
wf = x+"/logo.h"
logow = open(wf,"wb")
logow.write(str)