3 <script src=
"../../../resources/js-test.js"></script>
4 <script src=
"resources/webgl-test.js"></script>
5 <script src=
"resources/webgl-test-utils.js"></script>
7 var wtu
= WebGLTestUtils
;
13 if (window
.initNonKhronosFramework
) {
14 window
.initNonKhronosFramework(true);
17 description('Tests there is no garbage in transparent regions of images uploaded as textures');
20 var canvas
= document
.getElementById("example");
21 gl
= wtu
.create3DContext(canvas
);
22 var program
= wtu
.setupTexturedQuad(gl
);
23 gl
.clearColor(0.5,0.5,0.5,1);
26 textureLoc
= gl
.getUniformLocation(program
, "tex");
28 // The input texture has 8 characters; take the leftmost one
29 var coeff
= 1.0 / 8.0;
30 var texCoords
= new Float32Array([
38 var vbo
= gl
.createBuffer();
39 gl
.bindBuffer(gl
.ARRAY_BUFFER
, vbo
);
40 gl
.bufferData(gl
.ARRAY_BUFFER
, texCoords
, gl
.STATIC_DRAW
);
41 gl
.enableVertexAttribArray(1);
42 gl
.vertexAttribPointer(1, 2, gl
.FLOAT
, false, 0, 0);
44 texture
= wtu
.loadTexture(gl
, "resources/bug-32888-texture.png", runTest
);
47 // These two declarations need to be global for "shouldBe" to see them
53 gl
.clear(gl
.COLOR_BUFFER_BIT
| gl
.DEPTH_BUFFER_BIT
);
55 gl
.blendFunc(gl
.SRC_ALPHA
, gl
.ONE_MINUS_SRC_ALPHA
);
56 // Bind the texture to texture unit 0
57 gl
.bindTexture(gl
.TEXTURE_2D
, texture
);
58 // Point the uniform sampler to texture unit 0
59 gl
.uniform1i(textureLoc
, 0);
61 wtu
.drawQuad(gl
, [0, 0, 0, 255]);
63 // Spot check a couple of 2x2 regions in the upper and lower left
64 // corners; they should be the rgb values in the texture.
66 debug("Checking lower left corner");
67 wtu
.checkCanvasRect(gl
, 1, gl
.canvas
.height
- 3, 2, 2, color
,
69 debug("Checking upper left corner");
70 wtu
.checkCanvasRect(gl
, 1, 1, 2, 2, color
,
77 <body onload=
"init()">
78 <canvas id=
"example" width=
"32px" height=
"32px"></canvas>
79 <div id=
"description"></div>
80 <div id=
"console"></div>