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

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/conformance/tex-sub-image-2d.html

Issue 9360034: Remove everthing except conformance tests in the deps/third_party/webgl (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 10 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
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6 <html>
7 <head>
8 <link rel="stylesheet" href="../resources/js-test-style.css"/>
9 <script src="../resources/js-test-pre.js"></script>
10 <script src="resources/webgl-test.js"></script>
11 <script src="resources/webgl-test-utils.js"></script>
12 <script id="fshader" type="x-shader/x-fragment">
13 #ifdef GL_ES
14 precision highp float;
15 #endif
16 uniform sampler2D tex;
17 varying vec2 texCoord;
18
19 void main()
20 {
21 float intensity = texture2D(tex, texCoord).a;
22 gl_FragColor = vec4(intensity, intensity, intensity, 1.0);
23 }
24 </script>
25
26 </head>
27 <body>
28 <canvas id="example" width="256px" height="1px"></canvas>
29 <div id="description"></div>
30 <div id="console"></div>
31 <script>
32 description('Tests texSubImage2D upload path from Uint8Array');
33
34 var wtu = WebGLTestUtils;
35 var canvas = document.getElementById("example");
36 var gl = wtu.create3DContext(canvas);
37 var program = wtu.setupProgram(
38 gl,
39 [wtu.setupSimpleTextureVertexShader(gl),
40 wtu.loadShaderFromScript(gl, "fshader")],
41 ['vPosition', 'texCoord0']);
42 wtu.setupUnitQuad(gl);
43 var textureWidth = 256;
44 var textureHeight = 1;
45
46 textureLoc = gl.getUniformLocation(program, "tex");
47
48 var texture = gl.createTexture();
49 gl.bindTexture(gl.TEXTURE_2D, texture);
50 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
51 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
52 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
53 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
54 // Allocate the texture object
55 gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, textureWidth, textureHeight, 0, gl.ALP HA, gl.UNSIGNED_BYTE, null);
56 // Prepare the image data
57 var array = new Uint8Array(textureWidth);
58 for (var i = 0; i < textureWidth; i++)
59 array[i] = i;
60 // Fill the texture object with data -- this is actually the code path being tes ted
61 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, textureWidth, textureHeight, gl.ALPHA, gl.UNSIGNED_BYTE, array);
62
63 // Clear and set up
64 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
65 gl.bindTexture(gl.TEXTURE_2D, texture);
66 gl.useProgram(program);
67 gl.uniform1i(textureLoc, 0);
68 // Draw the texture to the frame buffer
69 gl.drawArrays(gl.TRIANGLES, 0, 6);
70
71 // Read back the frame buffer
72 var buf = new Uint8Array(textureWidth * textureHeight * 4);
73 gl.readPixels(0, 0, textureWidth, textureHeight, gl.RGBA, gl.UNSIGNED_BYTE, buf) ;
74
75 // Verify the frame buffer's contents
76 var passed = true;
77 for (var i = 0; i < textureWidth; i++) {
78 var val = i;
79 if (buf[4 * i + 0] != val ||
80 buf[4 * i + 1] != val ||
81 buf[4 * i + 2] != val) {
82 testFailed("pixel at (" + i + ", 0) was (" +
83 buf[4 * i + 0] + ", " +
84 buf[4 * i + 1] + ", " +
85 buf[4 * i + 2] + "), should be (" +
86 val + ", " + val + ", " + val + ")");
87 passed = false;
88 break;
89 }
90 }
91
92 if (passed)
93 testPassed("");
94
95 successfullyParsed = true;
96 </script>
97 <script src="../resources/js-test-post.js"></script>
98 </body>
99 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698