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

Side by Side Diff: conformance/rendering/triangle.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
« no previous file with comments | « conformance/rendering/point-size.html ('k') | conformance/resources/3x3.png » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <!--
2 Copyright (C) 2011 Apple Computer, Inc. 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
6 are met:
7 1. Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 2. Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12
13 THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 -->
25
26 <!DOCTYPE html>
27 <html>
28 <head>
29 <meta charset="utf-8">
30 <title>Rendering Test</title>
31 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
32 <script src="../../resources/js-test-pre.js"></script>
33 <script src="../resources/webgl-test.js"> </script>
34 </head>
35 <body>
36 <canvas id="example" width="50" height="50">
37 There is supposed to be an example drawing here, but it's not important.
38 </canvas>
39 <div id="description"></div>
40 <div id="console"></div>
41 <script id="vshader" type="x-shader/x-vertex">
42 attribute vec4 vPosition;
43 void main()
44 {
45 gl_Position = vPosition;
46 }
47 </script>
48
49 <script id="fshader" type="x-shader/x-fragment">
50 void main()
51 {
52 gl_FragColor = vec4(1.0,0.0,0.0,1.0);
53 }
54 </script>
55
56 <script>
57 function fail(x,y, buf, shouldBe)
58 {
59 var i = (y*50+x) * 4;
60 var reason = "pixel at ("+x+","+y+") is ("+buf[i]+","+buf[i+1]+","+b uf[i+2]+","+buf[i+3]+"), should be "+shouldBe;
61 testFailed(reason);
62 }
63
64 function pass()
65 {
66 testPassed("drawing is correct");
67 }
68
69 function init()
70 {
71 if (window.initNonKhronosFramework) {
72 window.initNonKhronosFramework(false);
73 }
74
75 gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
76
77 var vertexObject = gl.createBuffer();
78 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
79 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5 ,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW);
80 gl.enableVertexAttribArray(0);
81 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
82
83 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
84 gl.drawArrays(gl.TRIANGLES, 0, 3);
85
86 var buf = new Uint8Array(50 * 50 * 4);
87 gl.readPixels(0, 0, 50, 50, gl.RGBA, gl.UNSIGNED_BYTE, buf);
88
89 // Test several locations
90 // First line should be all black
91 for (var i = 0; i < 50; ++i)
92 if (buf[i*4] != 0 || buf[i*4+1] != 0 || buf[i*4+2] != 0 || buf[i *4+3] != 255) {
93 fail(i, 0, buf, "(0,0,0,255)");
94 return;
95 }
96
97 // Line 15 should be red for at least 10 red pixels starting 20 pixe ls in
98 var offset = (15*50+20) * 4;
99 for (var i = 0; i < 10; ++i)
100 if (buf[offset+i*4] != 255 || buf[offset+i*4+1] != 0 || buf[offs et+i*4+2] != 0 || buf[offset+i*4+3] != 255) {
101 fail(20 + i, 15, buf, "(255,0,0,255)");
102 return;
103 }
104 // Last line should be all black
105 offset = (49*50) * 4;
106 for (var i = 0; i < 50; ++i)
107 if (buf[offset+i*4] != 0 || buf[offset+i*4+1] != 0 || buf[offset +i*4+2] != 0 || buf[offset+i*4+3] != 255) {
108 fail(i, 49, buf, "(0,0,0,255)");
109 return;
110 }
111
112 pass();
113 }
114
115 init();
116 successfullyParsed = true;
117 </script>
118 <script src="../../resources/js-test-post.js"></script>
119
120 </body>
121 </html>
OLDNEW
« no previous file with comments | « conformance/rendering/point-size.html ('k') | conformance/resources/3x3.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698