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

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/conformance/index-validation.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) 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 </head>
36 <body>
37 <div id="description"></div>
38 <div id="console"></div>
39
40 <script>
41 description("Tests that index validation verifies the correct number of indices" );
42
43 function sizeInBytes(type) {
44 switch (type) {
45 case gl.BYTE:
46 case gl.UNSIGNED_BYTE:
47 return 1;
48 case gl.SHORT:
49 case gl.UNSIGNED_SHORT:
50 return 2;
51 case gl.INT:
52 case gl.UNSIGNED_INT:
53 case gl.FLOAT:
54 return 4;
55 default:
56 throw "unknown type";
57 }
58 }
59
60 var gl = create3DContext();
61 var program = loadStandardProgram(gl);
62
63 // 3 vertices => 1 triangle, interleaved data
64 var dataComplete = new Float32Array([0, 0, 0, 1,
65 0, 0, 1,
66 1, 0, 0, 1,
67 0, 0, 1,
68 1, 1, 1, 1,
69 0, 0, 1]);
70 var dataIncomplete = new Float32Array([0, 0, 0, 1,
71 0, 0, 1,
72 1, 0, 0, 1,
73 0, 0, 1,
74 1, 1, 1, 1]);
75 var indices = new Uint16Array([0, 1, 2]);
76
77 debug("Testing with valid indices");
78
79 var bufferComplete = gl.createBuffer();
80 gl.bindBuffer(gl.ARRAY_BUFFER, bufferComplete);
81 gl.bufferData(gl.ARRAY_BUFFER, dataComplete, gl.STATIC_DRAW);
82 var elements = gl.createBuffer();
83 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elements);
84 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
85 gl.useProgram(program);
86 var vertexLoc = gl.getAttribLocation(program, "a_vertex");
87 var normalLoc = gl.getAttribLocation(program, "a_normal");
88 gl.vertexAttribPointer(vertexLoc, 4, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 0);
89 gl.enableVertexAttribArray(vertexLoc);
90 gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
91 gl.enableVertexAttribArray(normalLoc);
92 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE') ;
93 glErrorShouldBe(gl, gl.NO_ERROR);
94 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
95 glErrorShouldBe(gl, gl.NO_ERROR);
96
97 debug("Testing with out-of-range indices");
98
99 var bufferIncomplete = gl.createBuffer();
100 gl.bindBuffer(gl.ARRAY_BUFFER, bufferIncomplete);
101 gl.bufferData(gl.ARRAY_BUFFER, dataIncomplete, gl.STATIC_DRAW);
102 gl.vertexAttribPointer(vertexLoc, 4, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 0);
103 gl.enableVertexAttribArray(vertexLoc);
104 gl.disableVertexAttribArray(normalLoc);
105 debug("Enable vertices, valid");
106 glErrorShouldBe(gl, gl.NO_ERROR);
107 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
108 glErrorShouldBe(gl, gl.NO_ERROR);
109 debug("Enable normals, out-of-range");
110 gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
111 gl.enableVertexAttribArray(normalLoc);
112 glErrorShouldBe(gl, gl.NO_ERROR);
113 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
114 glErrorShouldBe(gl, gl.INVALID_OPERATION);
115
116 debug("Test with enabled attribute that does not belong to current program");
117
118 gl.disableVertexAttribArray(normalLoc);
119 var extraLoc = Math.max(vertexLoc, normalLoc) + 1;
120 gl.enableVertexAttribArray(extraLoc);
121 debug("Enable an extra attribute with null");
122 glErrorShouldBe(gl, gl.NO_ERROR);
123 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
124 glErrorShouldBe(gl, gl.INVALID_OPERATION);
125 debug("Enable an extra attribute with insufficient data buffer");
126 gl.vertexAttribPointer(extraLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
127 glErrorShouldBe(gl, gl.NO_ERROR);
128 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
129 gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), -2000000000 * sizeInBytes(gl.FLOAT));
130 glErrorShouldBe(gl, gl.NO_ERROR);
131 shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
132
133 successfullyParsed = true;
134 </script>
135
136 <script src="../resources/js-test-post.js"></script>
137 </body>
138 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698