Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / canvas / test / webgl-mochitest / test_texsubimage_float.html
blob991066e41bc83b007d3b96040fda6a218916841e
1 <!DOCTYPE HTML>
2 <title>WebGL test: bug 1003607</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 <body>
8 <canvas id="c"></canvas>
9 <script>
11 // Give ourselves a scope to return early from:
12 (function() {
13 var gl = c.getContext('webgl');
14 if (!gl) {
15 todo(false, 'WebGL is unavailable.');
16 return;
19 function checkGLError(func, info, reference) {
20 var error = gl.getError();
21 var prefix = info ? ('[' + info + '] ') : '';
22 var text = 'gl.getError should be 0x' + reference.toString(16) +
23 ', was 0x' + error.toString(16) + '.';
24 func(error == reference, prefix + text);
27 // Begin test:
28 if (!gl.getExtension('OES_texture_float')) {
29 todo(false, 'Not having this extension is fine.');
30 return;
32 var tex = gl.createTexture();
33 gl.bindTexture(gl.TEXTURE_2D, tex);
34 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
35 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
36 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
37 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
38 checkGLError(ok, 'texture parameter setup should succeed', gl.NO_ERROR);
40 // Generate data
41 var width = 2;
42 var height = 2;
43 var numChannels = 4;
44 var data = new Float32Array(width * height * numChannels);
45 for (var ii = 0; ii < data.length; ++ii) {
46 data[ii] = 10000;
48 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.FLOAT, data);
49 checkGLError(ok, 'floating-point texture allocation should succeed', gl.NO_ERROR);
51 // Try respecifying data
52 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, width, height, gl.RGBA, gl.FLOAT, data);
53 checkGLError(ok, 'floating-point texture sub image should succeed', gl.NO_ERROR);
54 })();
56 </script>