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>
8 <canvas id=
"c"></canvas>
11 // Give ourselves a scope to return early from:
13 var gl
= c
.getContext('webgl');
15 todo(false, 'WebGL is unavailable.');
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
);
28 if (!gl
.getExtension('OES_texture_float')) {
29 todo(false, 'Not having this extension is fine.');
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
);
44 var data
= new Float32Array(width
* height
* numChannels
);
45 for (var ii
= 0; ii
< data
.length
; ++ii
) {
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
);