Wed, 31 Dec 2014 06:09:35 +0100
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: bug 1003607</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 | <body> |
michael@0 | 8 | <canvas id="c"></canvas> |
michael@0 | 9 | <script> |
michael@0 | 10 | |
michael@0 | 11 | // Give ourselves a scope to return early from: |
michael@0 | 12 | (function() { |
michael@0 | 13 | var gl = WebGLUtil.getWebGL('c'); |
michael@0 | 14 | if (!gl) { |
michael@0 | 15 | todo(false, 'WebGL is unavailable.'); |
michael@0 | 16 | return; |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | // Catch actual WebGLUtil errors, not GL errors. |
michael@0 | 20 | function errorFunc(str) { |
michael@0 | 21 | ok(false, 'Error: ' + str); |
michael@0 | 22 | } |
michael@0 | 23 | WebGLUtil.setErrorFunc(errorFunc); |
michael@0 | 24 | |
michael@0 | 25 | function checkGLError(func, info, reference) { |
michael@0 | 26 | var error = gl.getError(); |
michael@0 | 27 | var prefix = info ? ('[' + info + '] ') : ''; |
michael@0 | 28 | var text = 'gl.getError should be 0x' + reference.toString(16) + |
michael@0 | 29 | ', was 0x' + error.toString(16) + '.'; |
michael@0 | 30 | func(error == reference, prefix + text); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | // Begin test: |
michael@0 | 34 | if (!gl.getExtension('OES_texture_float')) { |
michael@0 | 35 | todo(false, 'Not having this extension is fine.'); |
michael@0 | 36 | return; |
michael@0 | 37 | } |
michael@0 | 38 | var tex = gl.createTexture(); |
michael@0 | 39 | gl.bindTexture(gl.TEXTURE_2D, tex); |
michael@0 | 40 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); |
michael@0 | 41 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); |
michael@0 | 42 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); |
michael@0 | 43 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); |
michael@0 | 44 | checkGLError(ok, 'texture parameter setup should succeed', gl.NO_ERROR); |
michael@0 | 45 | |
michael@0 | 46 | // Generate data |
michael@0 | 47 | var width = 2; |
michael@0 | 48 | var height = 2; |
michael@0 | 49 | var numChannels = 4; |
michael@0 | 50 | var data = new Float32Array(width * height * numChannels); |
michael@0 | 51 | for (var ii = 0; ii < data.length; ++ii) { |
michael@0 | 52 | data[ii] = 10000; |
michael@0 | 53 | } |
michael@0 | 54 | gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.FLOAT, data); |
michael@0 | 55 | checkGLError(ok, 'floating-point texture allocation should succeed', gl.NO_ERROR); |
michael@0 | 56 | |
michael@0 | 57 | // Try respecifying data |
michael@0 | 58 | gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, width, height, gl.RGBA, gl.FLOAT, data); |
michael@0 | 59 | checkGLError(ok, 'floating-point texture sub image should succeed', gl.NO_ERROR); |
michael@0 | 60 | })(); |
michael@0 | 61 | |
michael@0 | 62 | </script> |