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

Side by Side Diff: conformance/more/functions/vertexAttribBadArgs.html

Issue 41503006: Add ToT WebGL conformance tests : part 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 7 years, 1 month 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
## -0,0 +1 ##
+LF
\ No newline at end of property
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <!--
6
7 /*
8 ** Copyright (c) 2012 The Khronos Group Inc.
9 **
10 ** Permission is hereby granted, free of charge, to any person obtaining a
11 ** copy of this software and/or associated documentation files (the
12 ** "Materials"), to deal in the Materials without restriction, including
13 ** without limitation the rights to use, copy, modify, merge, publish,
14 ** distribute, sublicense, and/or sell copies of the Materials, and to
15 ** permit persons to whom the Materials are furnished to do so, subject to
16 ** the following conditions:
17 **
18 ** The above copyright notice and this permission notice shall be included
19 ** in all copies or substantial portions of the Materials.
20 **
21 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
25 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
28 */
29
30 -->
31 <link rel="stylesheet" type="text/css" href="../unit.css" />
32 <script type="application/x-javascript" src="../unit.js"></script>
33 <script type="application/x-javascript" src="../util.js"></script>
34 <script type="application/x-javascript">
35
36 var verts = [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0];
37 var normals = [0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0];
38 var texcoords = [0.0,0.0, 1.0,0.0, 0.0,1.0];
39
40 Tests.startUnit = function () {
41 var canvas = document.getElementById('gl');
42 var gl = wrapGLContext(getGLContext(canvas));
43 var prog = new Shader(gl, 'vert', 'frag');
44 prog.use();
45 var sh = prog.shader.program;
46 // log(gl.getShaderInfoLog(prog.shaders[1]));
47 var v = gl.getAttribLocation(sh, 'Vertex');
48 var n = gl.getAttribLocation(sh, 'Normal');
49 var t = gl.getAttribLocation(sh, 'Tex');
50 return [gl,prog,v,n,t];
51 }
52
53 Tests.setup = function(gl, prog, v,n,t) {
54 assert(0 == gl.getError());
55 return [gl, prog, v,n,t];
56 }
57 Tests.teardown = function(gl, prog, v,n,t) {
58 gl.disableVertexAttribArray(v);
59 gl.disableVertexAttribArray(n);
60 gl.disableVertexAttribArray(t);
61 }
62
63 Tests.endUnit = function(gl, prog, v,n,t) {
64 prog.destroy();
65 }
66
67
68 Tests.testVertexAttrib = function(gl, prog, v,n,t) {
69 var vbo = gl.createBuffer();
70 var vertsArr = new Float32Array(verts);
71 gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
72 gl.bufferData(gl.ARRAY_BUFFER, vertsArr, gl.STATIC_DRAW);
73 gl.enableVertexAttribArray(v);
74 gl.vertexAttribPointer(v, 3, gl.FLOAT, false, 0, 0);
75 assertFail("bad index",
76 function(){gl.vertexAttrib1f(-1, 1);});
77 assertFail("bad index (big negative)",
78 function(){gl.vertexAttrib1f(-69092342, 1);});
79 assertFail("bad index (big positive)",
80 function(){gl.vertexAttrib1f(58928938, 1);});
81 assertOk("array too large",
82 function(){gl.vertexAttrib1fv(v, [1,2,3,4,5]);});
83 assertFail("array too small",
84 function(){gl.vertexAttrib1fv(v, []);});
85 assertOk("draw",
86 function(){gl.drawArrays(gl.TRIANGLES, 0, 3);});
87 throwError(gl);
88 }
89
90 </script>
91 <script id="vert" type="x-shader/x-vertex">
92 attribute vec3 Vertex;
93 attribute vec3 Normal;
94 attribute vec2 Tex;
95
96 varying vec4 texCoord0;
97 void main()
98 {
99 gl_Position = vec4(Vertex * Normal, 1.0);
100 texCoord0 = vec4(Tex,0.0,0.0) + gl_Position;
101 }
102 </script>
103 <script id="frag" type="x-shader/x-fragment">
104 precision mediump float;
105
106 varying vec4 texCoord0;
107 void main()
108 {
109 vec4 c = texCoord0;
110 gl_FragColor = c;
111 }
112 </script>
113
114
115 <style>canvas{ position:absolute; }</style>
116 </head><body>
117 <canvas id="gl" width="1" height="1"></canvas>
118 </body></html>
OLDNEW
« no previous file with comments | « conformance/more/functions/vertexAttrib.html ('k') | conformance/more/functions/vertexAttribPointer.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698