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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/attribs/gl-vertexattribpointer.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 vertexAttribPointer Conformance Tests</title>
33 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
34 <script src="../../resources/desktop-gl-constants.js" type="text/javascript"></s cript>
35 <script src="../../resources/js-test-pre.js"></script>
36 <script src="../resources/webgl-test.js"></script>
37 <script src="../resources/webgl-test-utils.js"></script>
38 </head>
39 <body>
40 <div id="description"></div>
41 <div id="console"></div>
42 <canvas id="canvas" width="2" height="2"> </canvas>
43 <script>
44 description("This test checks vertexAttribPointer behaviors in WebGL.");
45
46 debug("");
47 debug("Canvas.getContext");
48
49 var wtu = WebGLTestUtils;
50 var gl = create3DContext(document.getElementById("canvas"));
51 if (!gl) {
52 testFailed("context does not exist");
53 } else {
54 testPassed("context exists");
55
56 debug("");
57 debug("Checking gl.vertexAttribPointer.");
58
59 if (!gl.FIXED) {
60 gl.FIXED = 0x140C;
61 }
62
63 gl.vertexAttribPointer(0, 3, gl.FLOAT, 0, 0, 12);
64 glErrorShouldBe(gl, gl.INVALID_OPERATION,
65 "vertexAttribPointer should fail if no buffer is bound");
66
67 var vertexObject = gl.createBuffer();
68 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
69 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(0), gl.STATIC_DRAW);
70
71 gl.vertexAttribPointer(0, 1, gl.INT, 0, 0, 0);
72 glErrorShouldBe(gl, gl.INVALID_ENUM,
73 "vertexAttribPointer should not support INT");
74 gl.vertexAttribPointer(0, 1, gl.UNSIGNED_INT, 0, 0, 0);
75 glErrorShouldBe(gl, gl.INVALID_ENUM,
76 "vertexAttribPointer should not support UNSIGNED_INT");
77 gl.vertexAttribPointer(0, 1, gl.FIXED, 0, 0, 0);
78 glErrorShouldBe(gl, gl.INVALID_ENUM,
79 "vertexAttribPointer should not support FIXED");
80
81 function checkVertexAttribPointer(
82 gl, err, reason, size, type, normalize, stride, offset) {
83 gl.vertexAttribPointer(0, size, type, normalize, stride, offset);
84 glErrorShouldBe(gl, err,
85 "gl.vertexAttribPointer(0, " + size +
86 ", gl." + wtu.glEnumToString(gl, type) +
87 ", " + normalize +
88 ", " + stride +
89 ", " + offset +
90 ") should " + (err == gl.NO_ERROR ? "succeed " : "fail ") + reason);
91 }
92
93 var types = [
94 { type:gl.BYTE, bytesPerComponent: 1 },
95 { type:gl.UNSIGNED_BYTE, bytesPerComponent: 1 },
96 { type:gl.SHORT, bytesPerComponent: 2 },
97 { type:gl.UNSIGNED_SHORT, bytesPerComponent: 2 },
98 { type:gl.FLOAT, bytesPerComponent: 4 },
99 ];
100
101 for (var ii = 0; ii < types.length; ++ii) {
102 var info = types[ii];
103 debug("");
104 for (var size = 1; size <= 4; ++size) {
105 debug("");
106 debug("checking: " + wtu.glEnumToString(gl, info.type) + " with size " + s ize);
107 var bytesPerElement = size * info.bytesPerComponent;
108 var offsetSet = [
109 0,
110 1,
111 info.bytesPerComponent - 1,
112 info.bytesPerComponent,
113 info.bytesPerComponent + 1,
114 info.bytesPerComponent * 2];
115 for (var jj = 0; jj < offsetSet.length; ++jj) {
116 var offset = offsetSet[jj];
117 for (var kk = 0; kk < offsetSet.length; ++kk) {
118 var stride = offsetSet[kk];
119 var err = gl.NO_ERROR;
120 var reason = ""
121 if (offset % info.bytesPerComponent != 0) {
122 reason = "because offset is bad";
123 err = gl.INVALID_OPERATION;
124 }
125 if (stride % info.bytesPerComponent != 0) {
126 reason = "because stride is bad";
127 err = gl.INVALID_OPERATION;
128 }
129 checkVertexAttribPointer(
130 gl, err, reason, size, info.type, false, stride, offset);
131 }
132 var stride = Math.floor(255 / info.bytesPerComponent) * info.bytesPerCom ponent;
133
134 if (offset == 0) {
135 checkVertexAttribPointer(
136 gl, gl.NO_ERROR, "at stride limit",
137 size, info.type, false, stride, offset);
138 checkVertexAttribPointer(
139 gl, gl.INVALID_VALUE, "over stride limit",
140 size, info.type, false,
141 stride + info.bytesPerComponent, offset);
142 }
143 }
144 }
145 }
146 }
147
148 debug("");
149 successfullyParsed = true;
150
151 </script>
152 <script src="../../resources/js-test-post.js"></script>
153
154 </body>
155 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698