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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/textures/texture-active-bind-2.html

Issue 10399113: Roll webgl conformance tests to r17874: part 2, adding r17874 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 7 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
3 /*
4 ** Copyright (c) 2012 The Khronos Group Inc.
5 **
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
24 */
25
26 -->
27
28 <!DOCTYPE html>
29 <html>
30 <head>
31 <meta charset="utf-8">
32 <title>WebGL ActiveTexture BindTexture conformance test #2</title>
33 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
34 <script src="../../resources/js-test-pre.js"></script>
35 <script src="../resources/webgl-test.js"> </script>
36 </head>
37 <body>
38 <canvas id="example" width="2" height="2" style="width: 40px; height: 40px;"></c anvas>
39 <canvas id="canvas2d" width="1" height="1" style="width: 40px; height: 40px;"></ canvas>
40 <div id="description"></div>
41 <div id="console"></div>
42 <script id="vshader" type="x-shader/x-vertex">
43 uniform mat4 world;
44 attribute vec3 vPosition;
45 attribute vec2 texCoord0;
46 varying vec2 texCoord;
47 void main()
48 {
49 gl_Position = world * vec4(vPosition, 1);
50 texCoord = texCoord0;
51 }
52 </script>
53 <script id="fshader2d" type="x-shader/x-fragment">
54 precision mediump float;
55
56 uniform sampler2D tex2d;
57 varying vec2 texCoord;
58 void main()
59 {
60 gl_FragColor = texture2D(tex2d, texCoord);
61 }
62 </script>
63 <script id="fshaderCube" type="x-shader/x-fragment">
64 precision mediump float;
65
66 uniform samplerCube texCube;
67 void main()
68 {
69 gl_FragColor = textureCube(texCube, vec3(0,1,0));
70 }
71 </script>
72
73 <script>
74 function init()
75 {
76 if (window.initNonKhronosFramework) {
77 window.initNonKhronosFramework(false);
78 }
79
80 description(
81 "Tests that binding both TEXTURE_2D and TEXTURE_CUBE_MAP to the same" +
82 "active texture unit works as long as they are not used" +
83 "simultaneously in the same shader program.");
84
85 var canvas2d = document.getElementById("canvas2d");
86 var ctx2d = canvas2d.getContext("2d");
87 ctx2d.globalCompositeOperation = "copy";
88
89 gl = initWebGL("example");
90 program = setupProgram(gl, "vshader", "fshader2d", ["vPosition", "texCoord0"]) ;
91
92 var program2d = program;
93 var programCube = createProgram(
94 gl, "vshader", "fshaderCube", ["vPosition", "texCoord0"]);
95
96 gl.disable(gl.DEPTH_TEST);
97 gl.disable(gl.BLEND);
98
99 var vertexObject = gl.createBuffer();
100 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
101 gl.bufferData(
102 gl.ARRAY_BUFFER,
103 new Float32Array([-1, 1,0, 1,1,0, -1,-1,0,
104 -1,-1,0, 1,1,0, 1,-1,0]),
105 gl.STATIC_DRAW);
106 gl.enableVertexAttribArray(0);
107 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
108
109 var vertexObject = gl.createBuffer();
110 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
111 gl.bufferData(
112 gl.ARRAY_BUFFER,
113 new Float32Array([ 0,0, 1,0, 0,1,
114 0,1, 1,0, 1,1]),
115 gl.STATIC_DRAW);
116 gl.enableVertexAttribArray(1);
117 gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
118
119 // Make texture unit 1 active.
120 gl.activeTexture(gl.TEXTURE1);
121
122 // Make a 2d texture
123 var tex2d = gl.createTexture();
124 gl.bindTexture(gl.TEXTURE_2D, tex2d);
125 ctx2d.fillStyle = "rgba(0, 0, 255, 255)";
126 ctx2d.fillRect(0, 0, 1, 1);
127 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
128
129 // make a cube texture
130 var texCube = gl.createTexture();
131 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCube);
132 ctx2d.fillStyle = "rgba(255, 0, 255, 255)";
133 ctx2d.fillRect(0, 0, 1, 1);
134 var targets = [
135 gl.TEXTURE_CUBE_MAP_POSITIVE_X,
136 gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
137 gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
138 gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
139 gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
140 gl.TEXTURE_CUBE_MAP_NEGATIVE_Z];
141 for (var ii = 0; ii < targets.length; ++ii) {
142 gl.texImage2D(targets[ii], 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
143 }
144
145 // Setup program2d and programCube
146 var tex2dLoc = gl.getUniformLocation(program2d, "tex2d");
147 var world2dLoc = gl.getUniformLocation(program2d, "world");
148 var texCubeLoc = gl.getUniformLocation(programCube, "texCube");
149 var worldCubeLoc = gl.getUniformLocation(programCube, "world");
150
151 gl.useProgram(program2d);
152 gl.uniform1i(tex2dLoc, 1);
153 gl.useProgram(programCube);
154 gl.uniform1i(texCubeLoc, 1);
155
156 gl.clearColor(1,0,0,1);
157 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
158
159 var programs = [program2d, programCube];
160 var worldLocs = [world2dLoc, worldCubeLoc];
161 for (var ii = 0; ii < 4; ++ii) {
162 var x = ii % 2;
163 var y = Math.floor(ii / 2);
164 gl.useProgram(programs[x]);
165 gl.uniformMatrix4fv(
166 worldLocs[x], false,
167 [0.5, 0, 0, 0,
168 0, 0.5, 0, 0,
169 0, 0, 1, 0,
170 -0.5 + x, -0.5 + y, 0, 1]);
171 gl.drawArrays(gl.TRIANGLES, 0, 6);
172 }
173
174 var colors = [
175 [0,0,255,255],
176 [255,0,255,255],
177 [0,0,255,255],
178 [255,0,255,255]];
179
180 for (var ii = 0; ii < colors.length; ++ii) {
181 var c = colors[ii];
182 var x = ii % 2;
183 var y = Math.floor(ii / 2);
184 var buf = new Uint8Array(4);
185 gl.readPixels(x, y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf);
186 var msg = 'expected:' +
187 c[0] + ', ' + c[1] + ', ' + c[2] + ', ' + c[3] + ' found: ' +
188 buf[0] + ', ' +
189 buf[1] + ', ' +
190 buf[2] + ', ' +
191 buf[3];
192 if (buf[0] != c[0] ||
193 buf[1] != c[1] ||
194 buf[2] != c[2] ||
195 buf[3] != c[3]) {
196 testFailed(msg);
197 return;
198 }
199
200 testPassed(msg);
201 }
202 }
203
204 init();
205 successfullyParsed = true;
206 </script>
207 <script src="../../resources/js-test-post.js"></script>
208
209 </body>
210 </html>
211
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698