Skip to content
Snippets Groups Projects
Commit e1a71a97 authored by David Parks's avatar David Parks
Browse files

SH-2908 Potential fix for pink textures on some OpenGL 3.1 implementations.

parent 48f5b69c
No related branches found
No related tags found
No related merge requests found
...@@ -614,6 +614,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade ...@@ -614,6 +614,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
//some implementations of GLSL 1.30 require integer precision be explicitly declared //some implementations of GLSL 1.30 require integer precision be explicitly declared
text[count++] = strdup("precision mediump int;\n"); text[count++] = strdup("precision mediump int;\n");
text[count++] = strdup("precision highp float;\n");
} }
else else
{ //set version to 400 { //set version to 400
...@@ -668,20 +669,22 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade ...@@ -668,20 +669,22 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
VARYING_FLAT ivec4 vary_texture_index; VARYING_FLAT ivec4 vary_texture_index;
vec4 ret = vec4(1,0,1,1);
vec4 diffuseLookup(vec2 texcoord) vec4 diffuseLookup(vec2 texcoord)
{ {
switch (vary_texture_index.r)) switch (vary_texture_index.r))
{ {
case 0: return texture2D(tex0, texcoord); case 0: ret = texture2D(tex0, texcoord); break;
case 1: return texture2D(tex1, texcoord); case 1: ret = texture2D(tex1, texcoord); break;
case 2: return texture2D(tex2, texcoord); case 2: ret = texture2D(tex2, texcoord); break;
. .
. .
. .
case N: return texture2D(texN, texcoord); case N: return texture2D(texN, texcoord); break;
} }
return vec4(0,0,0,0); return ret;
} }
*/ */
...@@ -708,18 +711,19 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade ...@@ -708,18 +711,19 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
} }
else if (major_version > 1 || minor_version >= 30) else if (major_version > 1 || minor_version >= 30)
{ //switches are supported in GLSL 1.30 and later { //switches are supported in GLSL 1.30 and later
text[count++] = strdup("\tvec4 ret = vec4(1,0,1,1);\n");
text[count++] = strdup("\tswitch (vary_texture_index.r)\n"); text[count++] = strdup("\tswitch (vary_texture_index.r)\n");
text[count++] = strdup("\t{\n"); text[count++] = strdup("\t{\n");
//switch body //switch body
for (S32 i = 0; i < texture_index_channels; ++i) for (S32 i = 0; i < texture_index_channels; ++i)
{ {
std::string case_str = llformat("\t\tcase %d: return texture2D(tex%d, texcoord);\n", i, i); std::string case_str = llformat("\t\tcase %d: ret = texture2D(tex%d, texcoord); break;\n", i, i);
text[count++] = strdup(case_str.c_str()); text[count++] = strdup(case_str.c_str());
} }
text[count++] = strdup("\t}\n"); text[count++] = strdup("\t}\n");
text[count++] = strdup("\treturn vec4(1,0,1,1);\n"); text[count++] = strdup("\treturn ret;\n");
text[count++] = strdup("}\n"); text[count++] = strdup("}\n");
} }
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment