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