5 <title>WebGL texImage2D from WebGL conformance test.
</title>
6 <script src=
"../../../resources/js-test.js"></script>
7 <script src=
"resources/webgl-test.js"> </script>
8 <script src=
"resources/webgl-test-utils.js"> </script>
11 <canvas id=
"example" width=
"256" height=
"16" style=
"width: 256px; height: 48px;"></canvas>
12 <canvas id=
"source" width=
"256" height=
"16" style=
"width: 256px; height: 48px;"></canvas>
13 <div id=
"description"></div>
14 <div id=
"console"></div>
16 description("Test texImage2D from a webgl canvas.");
17 var wtu
= WebGLTestUtils
;
18 var gl
= wtu
.create3DContext("example");
19 gl
.disable(gl
.DITHER
);
20 var program
= wtu
.setupTexturedQuad(gl
);
21 var gl1
= wtu
.create3DContext("source");
22 gl1
.disable(gl
.DITHER
);
24 glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors from setup.");
25 glErrorShouldBe(gl1
, gl1
.NO_ERROR
, "Should be no errors from setup.");
28 gl
.disable(gl
.DEPTH_TEST
);
30 gl1
.clearColor(1.0, 0.0, 0.0, 1.0);
31 gl1
.clear(gl1
.COLOR_BUFFER_BIT
);
33 var tex
= gl
.createTexture();
34 gl
.bindTexture(gl
.TEXTURE_2D
, tex
);
35 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGB
, gl
.RGB
, gl
.UNSIGNED_BYTE
, gl1
.canvas
);
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 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MAG_FILTER
, gl
.LINEAR
);
39 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MIN_FILTER
, gl
.LINEAR
);
42 wtu
.checkCanvas(gl
, [255, 0, 0, 255], "Canvas should be red");
44 gl1
.clearColor(0.0, 1.0, 0.0, 1.0);
45 gl1
.clear(gl1
.COLOR_BUFFER_BIT
);
47 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGB
, gl
.RGB
, gl
.UNSIGNED_BYTE
, gl1
.canvas
);
50 wtu
.checkCanvas(gl
, [0, 255, 0, 255], "Canvas should be green");
53 successfullyParsed
= true;