Skip to content

Instantly share code, notes, and snippets.

@floooh
Created April 13, 2014 16:39
Show Gist options
  • Save floooh/10591621 to your computer and use it in GitHub Desktop.
Save floooh/10591621 to your computer and use it in GitHub Desktop.
GLSL Macros
#if ORYOL_OPENGLES2
strBuilder.Append("#define ORYOL_OPENGLES2 (1)\n");
if (GL_VERTEX_SHADER == glShaderType) {
strBuilder.Append("#define VS_INPUT(type,name) attribute type name\n");
strBuilder.Append("#define VS_OUTPUT(type,name) varying type name\n");
}
if (GL_FRAGMENT_SHADER == glShaderType) {
strBuilder.Append("precision mediump float;\n");
strBuilder.Append("#define FS_INPUT(type,name) varying type name\n");
strBuilder.Append("#define TEXTURE2D(x,y) texture2D(x,y)\n");
strBuilder.Append("#define FragmentColor gl_FragColor\n");
}
#else
strBuilder.Append("#version 150\n");
strBuilder.Append("#define ORYOL_OPENGL (1)\n");
strBuilder.Append("#define lowp\n");
strBuilder.Append("#define mediump\n");
strBuilder.Append("#define highp\n");
if (GL_VERTEX_SHADER == glShaderType) {
strBuilder.Append("#define VS_INPUT(type,name) in type name\n");
strBuilder.Append("#define VS_OUTPUT(type,name) out type name\n");
}
if (GL_FRAGMENT_SHADER == glShaderType) {
strBuilder.Append("#define FS_INPUT(type,name) in type name\n");
strBuilder.Append("#define TEXTURE2D(x,y) texture(x,y)\n");
strBuilder.Append("out vec4 FragmentColor;\n");
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment