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

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/conformance/gl-vertexattribpointer.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 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
7 "http://www.w3.org/TR/html4/loose.dtd">
8 <html>
9 <head>
10 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
11 <title>WebGL vertexAttribPointer Conformance Tests</title>
12 <link rel="stylesheet" href="../resources/js-test-style.css"/>
13 <script src="../resources/desktop-gl-constants.js" type="text/javascript"></scri pt>
14 <script src="../resources/js-test-pre.js"></script>
15 <script src="resources/webgl-test.js"></script>
16 <script src="resources/webgl-test-utils.js"></script>
17 </head>
18 <body>
19 <div id="description"></div>
20 <div id="console"></div>
21 <canvas id="canvas" width="2" height="2"> </canvas>
22 <script>
23 description("This test checks vertexAttribPointer behaviors in WebGL.");
24
25 debug("");
26 debug("Canvas.getContext");
27
28 var wtu = WebGLTestUtils;
29 var gl = create3DContext(document.getElementById("canvas"));
30 if (!gl) {
31 testFailed("context does not exist");
32 } else {
33 testPassed("context exists");
34
35 debug("");
36 debug("Checking gl.vertexAttribPointer.");
37
38 if (!gl.FIXED) {
39 gl.FIXED = 0x140C;
40 }
41
42 gl.vertexAttribPointer(0, 3, gl.FLOAT, 0, 0, 12);
43 glErrorShouldBe(gl, gl.INVALID_OPERATION,
44 "vertexAttribPointer should fail if no buffer is bound");
45
46 var vertexObject = gl.createBuffer();
47 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
48 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(0), gl.STATIC_DRAW);
49
50 gl.vertexAttribPointer(0, 1, gl.INT, 0, 0, 0);
51 glErrorShouldBe(gl, gl.INVALID_ENUM,
52 "vertexAttribPointer should not support INT");
53 gl.vertexAttribPointer(0, 1, gl.UNSIGNED_INT, 0, 0, 0);
54 glErrorShouldBe(gl, gl.INVALID_ENUM,
55 "vertexAttribPointer should not support UNSIGNED_INT");
56 gl.vertexAttribPointer(0, 1, gl.FIXED, 0, 0, 0);
57 glErrorShouldBe(gl, gl.INVALID_ENUM,
58 "vertexAttribPointer should not support FIXED");
59
60 function checkVertexAttribPointer(
61 gl, err, reason, size, type, normalize, stride, offset) {
62 gl.vertexAttribPointer(0, size, type, normalize, stride, offset);
63 glErrorShouldBe(gl, err,
64 "gl.vertexAttribPointer(0, " + size +
65 ", gl." + wtu.glEnumToString(gl, type) +
66 ", " + normalize +
67 ", " + stride +
68 ", " + offset +
69 ") should " + (err == gl.NO_ERROR ? "succeed " : "fail ") + reason);
70 }
71
72 var types = [
73 { type:gl.BYTE, bytesPerComponent: 1 },
74 { type:gl.UNSIGNED_BYTE, bytesPerComponent: 1 },
75 { type:gl.SHORT, bytesPerComponent: 2 },
76 { type:gl.UNSIGNED_SHORT, bytesPerComponent: 2 },
77 { type:gl.FLOAT, bytesPerComponent: 4 },
78 ];
79
80 for (var ii = 0; ii < types.length; ++ii) {
81 var info = types[ii];
82 debug("");
83 for (var size = 1; size <= 4; ++size) {
84 debug("");
85 debug("checking: " + wtu.glEnumToString(gl, info.type) + " with size " + s ize);
86 var bytesPerElement = size * info.bytesPerComponent;
87 var offsetSet = [
88 0,
89 1,
90 info.bytesPerComponent - 1,
91 info.bytesPerComponent,
92 info.bytesPerComponent + 1,
93 info.bytesPerComponent * 2];
94 for (var jj = 0; jj < offsetSet.length; ++jj) {
95 var offset = offsetSet[jj];
96 for (var kk = 0; kk < offsetSet.length; ++kk) {
97 var stride = offsetSet[kk];
98 var err = gl.NO_ERROR;
99 var reason = ""
100 if (offset % info.bytesPerComponent != 0) {
101 reason = "because offset is bad";
102 err = gl.INVALID_OPERATION;
103 }
104 if (stride % info.bytesPerComponent != 0) {
105 reason = "because stride is bad";
106 err = gl.INVALID_OPERATION;
107 }
108 checkVertexAttribPointer(
109 gl, err, reason, size, info.type, false, stride, offset);
110 }
111 var stride = Math.floor(255 / info.bytesPerComponent) * info.bytesPerCom ponent;
112
113 if (offset == 0) {
114 checkVertexAttribPointer(
115 gl, gl.NO_ERROR, "at stride limit",
116 size, info.type, false, stride, offset);
117 checkVertexAttribPointer(
118 gl, gl.INVALID_VALUE, "over stride limit",
119 size, info.type, false,
120 stride + info.bytesPerComponent, offset);
121 }
122 }
123 }
124 }
125 }
126
127 debug("");
128 successfullyParsed = true;
129
130 </script>
131 <script src="../resources/js-test-post.js"></script>
132
133 <script>
134 </script>
135
136 </body>
137 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698