content/canvas/test/webgl-mochitest/test_highp_fs.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <title>WebGL test: `highp` support</title>
michael@0 3 <script src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 4 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
michael@0 5 <script src="driver-info.js"></script>
michael@0 6 <script src="webgl-util.js"></script>
michael@0 7 <script id="shader-vs" type="x-shader/x-vertex">
michael@0 8
michael@0 9 void main(void) {
michael@0 10 gl_Position = vec4(vec3(0.0), 1.0);
michael@0 11 }
michael@0 12
michael@0 13 </script>
michael@0 14 <script id="shader-fs" type="x-shader/x-fragment">
michael@0 15
michael@0 16 precision highp float;
michael@0 17
michael@0 18 void main(void) {
michael@0 19 gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
michael@0 20 }
michael@0 21
michael@0 22 </script>
michael@0 23 <body>
michael@0 24 <canvas id="c"></canvas>
michael@0 25 <script>
michael@0 26
michael@0 27 // Give ourselves a scope to return early from:
michael@0 28 (function() {
michael@0 29 var gl = WebGLUtil.getWebGL('c');
michael@0 30 if (!gl) {
michael@0 31 todo(false, 'WebGL is unavailable.');
michael@0 32 return;
michael@0 33 }
michael@0 34
michael@0 35 // Catch actual WebGLUtil errors, not GL errors.
michael@0 36 function errorFunc(str) {
michael@0 37 ok(false, 'Error: ' + str);
michael@0 38 }
michael@0 39 WebGLUtil.setErrorFunc(errorFunc);
michael@0 40
michael@0 41 function checkGLError(func, info) {
michael@0 42 var error = gl.getError();
michael@0 43 var prefix = info ? ('[' + info + '] ') : ''
michael@0 44 func(!error, prefix + 'gl.getError should be 0x0, was 0x' + error.toString(16) + '.');
michael@0 45 }
michael@0 46
michael@0 47 var format = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
michael@0 48 var prog = WebGLUtil.createProgramByIds(gl, 'shader-vs', 'shader-fs');
michael@0 49 checkGLError(ok);
michael@0 50
michael@0 51 if (format) {
michael@0 52 ok(prog, 'Frag shader with unconditional `precision highp float` should ' +
michael@0 53 'link if `getShaderPrecisionFormat` gives a format for it.');
michael@0 54 } else {
michael@0 55 ok(!prog, 'Frag shader with unconditional `precision highp float` should ' +
michael@0 56 'NOT link if `getShaderPrecisionFormat` gives NO format for it.');
michael@0 57 }
michael@0 58 })();
michael@0 59
michael@0 60 </script>
michael@0 61

mercurial