build shaders for either desktop gl or gles2

This commit is contained in:
Konstantin Käfer
2014-03-25 13:16:48 +01:00
parent b4d5378bc7
commit 77f58960c4
6 changed files with 48 additions and 98 deletions

View File

@@ -102,20 +102,9 @@ bool Shader::compileShader(GLuint *shader, GLenum type, const GLchar *source) {
GLint status;
*shader = glCreateShader(type);
#if defined(GL_ES_VERSION_2_0)
// Add OpenGL ES precision premable
const GLchar *preamble = "precision highp float;\n\n";
#else
// Desktop GLSL
const GLchar *preamble = "#version 120\n\n";
#endif
const GLchar *strings[] = { preamble, source };
const GLint lengths[] = { (GLint)strlen(preamble), (GLint)strlen(source) };
glShaderSource(*shader, 2, strings, lengths);
const GLchar *strings[] = { source };
const GLint lengths[] = { (GLint)strlen(source) };
glShaderSource(*shader, 1, strings, lengths);
glCompileShader(*shader);