| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 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> | |
| 6 <script> | |
| 7 var wtu = WebGLTestUtils; | |
| 8 var gl = null; | |
| 9 var textureLoc = null; | |
| 10 | |
| 11 function init() | |
| 12 { | |
| 13 if (window.initNonKhronosFramework) { | |
| 14 window.initNonKhronosFramework(true); | |
| 15 } | |
| 16 | |
| 17 description('Tests there is no garbage in transparent regions of images uplo
aded as textures'); | |
| 18 | |
| 19 wtu = WebGLTestUtils; | |
| 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); | |
| 24 gl.clearDepth(1); | |
| 25 | |
| 26 textureLoc = gl.getUniformLocation(program, "tex"); | |
| 27 | |
| 28 // The input texture has 8 characters; take the leftmost one | |
| 29 var coeff = 1.0 / 8.0; | |
| 30 var texCoords = new Float32Array([ | |
| 31 coeff, 1.0, | |
| 32 0.0, 1.0, | |
| 33 0.0, 0.0, | |
| 34 coeff, 1.0, | |
| 35 0.0, 0.0, | |
| 36 coeff, 0.0]); | |
| 37 | |
| 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); | |
| 43 | |
| 44 texture = wtu.loadTexture(gl, "resources/bug-32888-texture.png", runTest); | |
| 45 } | |
| 46 | |
| 47 // These two declarations need to be global for "shouldBe" to see them | |
| 48 var buf = null; | |
| 49 var idx = 0; | |
| 50 | |
| 51 function runTest() | |
| 52 { | |
| 53 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); | |
| 54 gl.enable(gl.BLEND); | |
| 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); | |
| 60 // Draw the triangles | |
| 61 wtu.drawQuad(gl, [0, 0, 0, 255]); | |
| 62 | |
| 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. | |
| 65 color = [0, 0, 0]; | |
| 66 debug("Checking lower left corner"); | |
| 67 wtu.checkCanvasRect(gl, 1, gl.canvas.height - 3, 2, 2, color, | |
| 68 "shouldBe " + color); | |
| 69 debug("Checking upper left corner"); | |
| 70 wtu.checkCanvasRect(gl, 1, 1, 2, 2, color, | |
| 71 "shouldBe " + color); | |
| 72 | |
| 73 finishJSTest(); | |
| 74 } | |
| 75 </script> | |
| 76 </head> | |
| 77 <body onload="init()"> | |
| 78 <canvas id="example" width="32px" height="32px"></canvas> | |
| 79 <div id="description"></div> | |
| 80 <div id="console"></div> | |
| 81 </body> | |
| 82 </html> | |
| OLD | NEW |