aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-01-01 15:56:26 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-01-01 15:56:26 -0800
commitfc015116c71b77cef3e34a3f72eda460474216c8 (patch)
treeb4b29320a0f638e3486bacbe4cca74ace1302a35
parent8aff0e85bea475f6b89b5939aeed58638c8e9a90 (diff)
ensure we add precision in gl emulation to both fragment and vertex shaders
-rw-r--r--src/library_gl.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index f5fc5f35..6af4a86c 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1919,6 +1919,13 @@ var LibraryGL = {
return id;
};
+ function ensurePrecision(source) {
+ if (!/precision +(low|medium|high)p +float *;/.test(source)) {
+ source = 'precision mediump float;\n' + source;
+ }
+ return source;
+ }
+
var glShaderSource = _glShaderSource;
_glShaderSource = function _glShaderSource(shader, count, string, length) {
var source = GL.getSource(shader, count, string, length);
@@ -1992,6 +1999,7 @@ var LibraryGL = {
source = 'varying float v_fogFragCoord; \n' +
source.replace(/gl_FogFragCoord/g, 'v_fogFragCoord');
}
+ source = ensurePrecision(source);
} else { // Fragment shader
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
var old = source;
@@ -2023,7 +2031,7 @@ var LibraryGL = {
source = 'varying float v_fogFragCoord; \n' +
source.replace(/gl_FogFragCoord/g, 'v_fogFragCoord');
}
- source = 'precision mediump float;\n' + source;
+ source = ensurePrecision(source);
}
#if GL_DEBUG
GL.shaderSources[shader] = source;