Browse Source

Simplified shader source code modification.

Lasse Öörni 12 years ago
parent
commit
cc6e6504f9
1 changed files with 7 additions and 10 deletions
  1. 7 10
      Source/Engine/Graphics/Shader.cpp

+ 7 - 10
Source/Engine/Graphics/Shader.cpp

@@ -94,21 +94,18 @@ bool Shader::Load(Deserializer& source)
     if (!ProcessSource(shaderCode, source))
     if (!ProcessSource(shaderCode, source))
         return false;
         return false;
     
     
-    // OpenGL: customize the vertex & pixel shader source code to not include the unnecessary shader,
-    // and rename either VS() or PS() to main()
-    #ifdef USE_OPENGL
+    // Comment out the unneeded shader function
     vsSourceCode_ = shaderCode;
     vsSourceCode_ = shaderCode;
+    psSourceCode_ = shaderCode;
+    CommentOutFunction(vsSourceCode_, "void PS(");
+    CommentOutFunction(psSourceCode_, "void VS(");
+    
+    // OpenGL: rename either VS() or PS() to main()
+    #ifdef USE_OPENGL
     vsSourceCode_.Replace("uniform sampler", "// uniform sampler");
     vsSourceCode_.Replace("uniform sampler", "// uniform sampler");
     vsSourceCode_.Replace("void VS(", "void main(");
     vsSourceCode_.Replace("void VS(", "void main(");
-    CommentOutFunction(vsSourceCode_, "void PS(");
-
-    psSourceCode_ = shaderCode;
     psSourceCode_.Replace("attribute ", "// attribute ");
     psSourceCode_.Replace("attribute ", "// attribute ");
     psSourceCode_.Replace("void PS(", "void main(");
     psSourceCode_.Replace("void PS(", "void main(");
-    CommentOutFunction(psSourceCode_, "void VS(");
-    #else
-    vsSourceCode_ = shaderCode;
-    psSourceCode_ = shaderCode;
     #endif
     #endif
     
     
     // If variations had already been created, release them and require recompile
     // If variations had already been created, release them and require recompile