diff --git a/src/easymesh/shiny.lolfx b/src/easymesh/shiny.lolfx index 19f5b378..18bc596f 100644 --- a/src/easymesh/shiny.lolfx +++ b/src/easymesh/shiny.lolfx @@ -1,10 +1,6 @@ -- GLSL.Vert -- -#if defined GL_ES -#version 100 -#else #version 120 -#endif attribute vec3 in_Vertex; attribute vec3 in_Normal; @@ -13,7 +9,8 @@ attribute vec4 in_Color; uniform mat4 in_ModelView; uniform mat4 in_Proj; uniform mat3 in_NormalMat; -uniform vec3 in_LightDir = vec3(0.3, 0.3, 0.7); +// FIXME: the light direction should be passed in the code +vec3 in_LightDir = vec3(0.3, 0.3, 0.7); uniform float in_Damage; varying vec4 pass_Color; @@ -53,11 +50,7 @@ void main(void) } -- GLSL.Frag -- -#if defined GL_ES -#version 100 -#else #version 120 -#endif #if defined GL_ES precision highp float; diff --git a/src/gpu/shader.cpp b/src/gpu/shader.cpp index f813b2d3..df6121e7 100644 --- a/src/gpu/shader.cpp +++ b/src/gpu/shader.cpp @@ -216,7 +216,7 @@ Shader::Shader(char const *vert, char const *frag) Log::Error("failed to compile vertex shader: %s", errbuf); Log::Error("shader source:\n%s\n", buf); } - else if (len > 1) + else if (len > 16) { Log::Debug("compile log for vertex shader: %s", errbuf); Log::Debug("shader source:\n%s\n", buf); @@ -260,7 +260,7 @@ Shader::Shader(char const *vert, char const *frag) Log::Error("failed to compile fragment shader: %s", errbuf); Log::Error("shader source:\n%s\n", buf); } - else if (len > 1) + else if (len > 16) { Log::Debug("compile log for fragment shader: %s", errbuf); Log::Debug("shader source:\n%s\n", buf); @@ -308,7 +308,7 @@ Shader::Shader(char const *vert, char const *frag) { Log::Error("failed to link program: %s", errbuf); } - else if (len > 1) + else if (len > 16) { Log::Debug("link log for program: %s", errbuf); } @@ -610,6 +610,10 @@ int ShaderData::GetVersion() #if !defined USE_D3D9 && !defined _XBOX && !defined __CELLOS_LV2__ if (!version) { +#if defined HAVE_GLES_2X + /* GLES 2.x supports #version 100, that's all. */ + return 100; +#else char buf[4096]; GLsizei len; @@ -643,6 +647,7 @@ int ShaderData::GetVersion() version = 110; glDeleteShader(id); +#endif } #endif @@ -650,9 +655,6 @@ int ShaderData::GetVersion() } /* Simple shader source patching for old GLSL versions. - * If supported version is 1.30, do nothing. - * If supported version is 1.20: - * - replace "#version 130" with "#version 120" */ void ShaderData::Patch(char *dst, char const *vert, char const *frag) { @@ -667,6 +669,22 @@ void ShaderData::Patch(char *dst, char const *vert, char const *frag) if (parser) ver_shader = atoi(parser + strlen("#version")); + /* This is GL ES, we only know version 100. */ + if (ver_shader > 100 && ver_driver == 100) + { + /* FIXME: this isn't elegant but honestly, we don't care, this + * whole file is going to die soon. */ + char *p = strstr(dst, "#version"); + if (p) + { + p += 8; + while (*p == ' ') + p++; + if (p[0] == '1' && p[1] && p[2]) + p[1] = p[2] = '0'; + } + } + if (ver_shader > 120 && ver_driver <= 120) { char const *end = dst + strlen(dst) + 1; diff --git a/tutorial/11_fractal.lolfx b/tutorial/11_fractal.lolfx index b507a509..f5ed9d1a 100644 --- a/tutorial/11_fractal.lolfx +++ b/tutorial/11_fractal.lolfx @@ -2,7 +2,7 @@ #version 120 -#if defined HAVE_GLES_2X +#if defined GL_ES precision highp float; #endif @@ -53,7 +53,7 @@ void main(void) #version 120 -#if defined HAVE_GLES_2X +#if defined GL_ES precision highp float; #endif