Skip to content

Instantly share code, notes, and snippets.

@Groovounet
Created October 7, 2013 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Groovounet/6870215 to your computer and use it in GitHub Desktop.
Save Groovounet/6870215 to your computer and use it in GitHub Desktop.
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