Created
October 7, 2013 15:53
-
-
Save Groovounet/6870215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::string PreprocessGLES3Shader (const std::string& source, bool autoNormalizeNormals, bool fullVertexShaderPreprocess) | |
{ | |
std::string remainder1, remainder2; | |
std::string vertexShaderSource = ExtractDefineBlock (source, "VERTEX", &remainder1); | |
std::string fragmentShaderSource = ExtractDefineBlock (remainder1, "FRAGMENT", &remainder2); | |
if (fullVertexShaderPreprocess) | |
vertexShaderSource = PreprocessGLESVertexShader (vertexShaderSource, kShaderAPIGLES3, autoNormalizeNormals); | |
vertexShaderSource = PreprocessVertexShader(vertexShaderSource, autoNormalizeNormals); | |
fragmentShaderSource = PreprocessFragmentShader(fragmentShaderSource); | |
std::string output = "#version 300 es\n" | |
+ remainder2 | |
+ "\n#ifdef VERTEX\n" | |
+ vertexShaderSource | |
+ "\n#endif\n#ifdef FRAGMENT\n" | |
+ fragmentShaderSource | |
+ "\n#endif"; | |
return output; | |
} | |
std::string PreprocessGLSLShader (const std::string& source) | |
{ | |
// OpenGL has no precision types, let's remove them | |
std::string prefix = "#define highp\n#define mediump\n#define lowp\n"; | |
return prefix + source; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment