1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-mochitest/test_highp_fs.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<title>WebGL test: `highp` support</title> 1.6 +<script src="/tests/SimpleTest/SimpleTest.js"></script> 1.7 +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> 1.8 +<script src="driver-info.js"></script> 1.9 +<script src="webgl-util.js"></script> 1.10 +<script id="shader-vs" type="x-shader/x-vertex"> 1.11 + 1.12 +void main(void) { 1.13 + gl_Position = vec4(vec3(0.0), 1.0); 1.14 +} 1.15 + 1.16 +</script> 1.17 +<script id="shader-fs" type="x-shader/x-fragment"> 1.18 + 1.19 +precision highp float; 1.20 + 1.21 +void main(void) { 1.22 + gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); 1.23 +} 1.24 + 1.25 +</script> 1.26 +<body> 1.27 +<canvas id="c"></canvas> 1.28 +<script> 1.29 + 1.30 +// Give ourselves a scope to return early from: 1.31 +(function() { 1.32 + var gl = WebGLUtil.getWebGL('c'); 1.33 + if (!gl) { 1.34 + todo(false, 'WebGL is unavailable.'); 1.35 + return; 1.36 + } 1.37 + 1.38 + // Catch actual WebGLUtil errors, not GL errors. 1.39 + function errorFunc(str) { 1.40 + ok(false, 'Error: ' + str); 1.41 + } 1.42 + WebGLUtil.setErrorFunc(errorFunc); 1.43 + 1.44 + function checkGLError(func, info) { 1.45 + var error = gl.getError(); 1.46 + var prefix = info ? ('[' + info + '] ') : '' 1.47 + func(!error, prefix + 'gl.getError should be 0x0, was 0x' + error.toString(16) + '.'); 1.48 + } 1.49 + 1.50 + var format = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT); 1.51 + var prog = WebGLUtil.createProgramByIds(gl, 'shader-vs', 'shader-fs'); 1.52 + checkGLError(ok); 1.53 + 1.54 + if (format) { 1.55 + ok(prog, 'Frag shader with unconditional `precision highp float` should ' + 1.56 + 'link if `getShaderPrecisionFormat` gives a format for it.'); 1.57 + } else { 1.58 + ok(!prog, 'Frag shader with unconditional `precision highp float` should ' + 1.59 + 'NOT link if `getShaderPrecisionFormat` gives NO format for it.'); 1.60 + } 1.61 +})(); 1.62 + 1.63 +</script> 1.64 +