OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
3 | |
4 Redistribution and use in source and binary forms, with or without | |
5 modification, are permitted provided that the following conditions are | |
6 met: | |
7 | |
8 * Redistributions of source code must retain the above copyright | |
9 notice, this list of conditions and the following disclaimer. | |
10 * Redistributions in binary form must reproduce the above | |
11 copyright notice, this list of conditions and the following disclaimer | |
12 in the documentation and/or other materials provided with the | |
13 distribution. | |
14 * Neither the name of Google Inc. nor the names of its | |
15 contributors may be used to endorse or promote products derived from | |
16 this software without specific prior written permission. | |
17 | |
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 --> | |
30 <html> | |
31 <head> | |
32 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
33 <script src="../resources/js-test-pre.js"></script> | |
34 <script src="resources/webgl-test.js"></script> | |
35 <script src="resources/webgl-test-utils.js"></script> | |
36 <script> | |
37 var wtu = WebGLTestUtils; | |
38 var gl = null; | |
39 var textureLoc = null; | |
40 var successfullyParsed = false; | |
41 | |
42 function init() | |
43 { | |
44 if (window.initNonKhronosFramework) { | |
45 window.initNonKhronosFramework(true); | |
46 } | |
47 | |
48 description('Tests there is no garbage in transparent regions of images uplo
aded as textures'); | |
49 | |
50 wtu = WebGLTestUtils; | |
51 var canvas = document.getElementById("example"); | |
52 gl = wtu.create3DContext(canvas); | |
53 var program = wtu.setupTexturedQuad(gl); | |
54 gl.clearColor(0.5,0.5,0.5,1); | |
55 gl.clearDepth(1); | |
56 | |
57 textureLoc = gl.getUniformLocation(program, "tex"); | |
58 | |
59 // The input texture has 8 characters; take the leftmost one | |
60 var coeff = 1.0 / 8.0; | |
61 var texCoords = new Float32Array([ | |
62 coeff, 1.0, | |
63 0.0, 1.0, | |
64 0.0, 0.0, | |
65 coeff, 1.0, | |
66 0.0, 0.0, | |
67 coeff, 0.0]); | |
68 | |
69 var vbo = gl.createBuffer(); | |
70 gl.bindBuffer(gl.ARRAY_BUFFER, vbo); | |
71 gl.bufferData(gl.ARRAY_BUFFER, texCoords, gl.STATIC_DRAW); | |
72 gl.enableVertexAttribArray(1); | |
73 gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0); | |
74 | |
75 texture = wtu.loadTexture(gl, "resources/bug-32888-texture.png", runTest); | |
76 } | |
77 | |
78 // These two declarations need to be global for "shouldBe" to see them | |
79 var buf = null; | |
80 var idx = 0; | |
81 | |
82 function runTest() | |
83 { | |
84 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); | |
85 gl.enable(gl.BLEND); | |
86 gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); | |
87 // Bind the texture to texture unit 0 | |
88 gl.bindTexture(gl.TEXTURE_2D, texture); | |
89 // Point the uniform sampler to texture unit 0 | |
90 gl.uniform1i(textureLoc, 0); | |
91 // Draw the triangles | |
92 wtu.drawQuad(gl, [0, 0, 0, 255]); | |
93 | |
94 // Spot check a couple of 2x2 regions in the upper and lower left | |
95 // corners; they should be the rgb values in the texture. | |
96 color = [0, 0, 0]; | |
97 debug("Checking lower left corner"); | |
98 wtu.checkCanvasRect(gl, 1, gl.canvas.height - 3, 2, 2, color, | |
99 "shouldBe " + color); | |
100 debug("Checking upper left corner"); | |
101 wtu.checkCanvasRect(gl, 1, 1, 2, 2, color, | |
102 "shouldBe " + color); | |
103 | |
104 finishTest(); | |
105 } | |
106 </script> | |
107 </head> | |
108 <body onload="init()"> | |
109 <canvas id="example" width="32px" height="32px"></canvas> | |
110 <div id="description"></div> | |
111 <div id="console"></div> | |
112 </body> | |
113 </html> | |
OLD | NEW |