Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: conformance/textures/texture-transparent-pixels-initialized.html

Issue 8342021: Add webgl conformance tests r15841. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2011 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 <!DOCTYPE html>
31 <html>
32 <head>
33 <meta charset="utf-8">
34 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
35 <script src="../../resources/js-test-pre.js"></script>
36 <script src="../resources/webgl-test.js"></script>
37 <script src="../resources/webgl-test-utils.js"></script>
38 <script>
39 var wtu = WebGLTestUtils;
40 var gl = null;
41 var textureLoc = null;
42 var successfullyParsed = false;
43
44 function init()
45 {
46 if (window.initNonKhronosFramework) {
47 window.initNonKhronosFramework(true);
48 }
49
50 description('Tests there is no garbage in transparent regions of images uplo aded as textures');
51
52 wtu = WebGLTestUtils;
53 var canvas = document.getElementById("example");
54 gl = wtu.create3DContext(canvas);
55 var program = wtu.setupTexturedQuad(gl);
56 gl.clearColor(0.5,0.5,0.5,1);
57 gl.clearDepth(1);
58
59 textureLoc = gl.getUniformLocation(program, "tex");
60
61 // The input texture has 8 characters; take the leftmost one
62 var coeff = 1.0 / 8.0;
63 var texCoords = new Float32Array([
64 coeff, 1.0,
65 0.0, 1.0,
66 0.0, 0.0,
67 coeff, 1.0,
68 0.0, 0.0,
69 coeff, 0.0]);
70
71 var vbo = gl.createBuffer();
72 gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
73 gl.bufferData(gl.ARRAY_BUFFER, texCoords, gl.STATIC_DRAW);
74 gl.enableVertexAttribArray(1);
75 gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
76
77 texture = wtu.loadTexture(gl, "../resources/bug-32888-texture.png", runTest) ;
78 }
79
80 // These two declarations need to be global for "shouldBe" to see them
81 var buf = null;
82 var idx = 0;
83
84 function runTest()
85 {
86 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
87 gl.enable(gl.BLEND);
88 gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
89 // Bind the texture to texture unit 0
90 gl.bindTexture(gl.TEXTURE_2D, texture);
91 // Point the uniform sampler to texture unit 0
92 gl.uniform1i(textureLoc, 0);
93 // Draw the triangles
94 wtu.drawQuad(gl, [0, 0, 0, 255]);
95
96 // Spot check a couple of 2x2 regions in the upper and lower left
97 // corners; they should be the rgb values in the texture.
98 color = [0, 0, 0];
99 debug("Checking lower left corner");
100 wtu.checkCanvasRect(gl, 1, gl.canvas.height - 3, 2, 2, color,
101 "shouldBe " + color);
102 debug("Checking upper left corner");
103 wtu.checkCanvasRect(gl, 1, 1, 2, 2, color,
104 "shouldBe " + color);
105
106 finishTest();
107 }
108 </script>
109 </head>
110 <body onload="init()">
111 <canvas id="example" width="32px" height="32px"></canvas>
112 <div id="description"></div>
113 <div id="console"></div>
114 </body>
115 </html>
OLDNEW
« no previous file with comments | « conformance/textures/texture-size-cube-maps.html ('k') | conformance/typedarrays/00_test_list.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698