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

Side by Side Diff: conformance/more/functions/vertexAttrib.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 Tests.testVertexAttrib = function(gl, prog, v,n,t) {
68 var vbo = gl.createBuffer();
69 var vertsArr = new Float32Array(verts);
70 gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
71 gl.bufferData(gl.ARRAY_BUFFER, vertsArr, gl.STATIC_DRAW);
72 gl.enableVertexAttribArray(v);
73 gl.vertexAttribPointer(v, 3, gl.FLOAT, false, 0, 0);
74 assertOk(function(){gl.drawArrays(gl.TRIANGLES, 0, 3);});
75 gl.vertexAttrib1fv(v, [1]);
76 gl.vertexAttrib2fv(v, [1,2]);
77 gl.vertexAttrib3fv(v, [1,2,3]);
78 gl.vertexAttrib4fv(v, [1,2,3,4]);
79 gl.vertexAttrib1f(v, 1);
80 gl.vertexAttrib2f(v, 1,2);
81 gl.vertexAttrib3f(v, 1,2,3);
82 gl.vertexAttrib4f(v, 1,2,3,4);
83 assertOk(function(){gl.drawArrays(gl.TRIANGLES, 0, 3);});
84 throwError(gl);
85 gl.bindBuffer(gl.ARRAY_BUFFER, null);
86 gl.deleteBuffer(vbo);
87 throwError(gl);
88 }
89 Tests.testVertexAttribVBO = function(gl, prog, v,n,t) {
90 var vbo = gl.createBuffer();
91 var vertsArr = new Float32Array(verts);
92 gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
93 gl.bufferData(gl.ARRAY_BUFFER, vertsArr, gl.STATIC_DRAW);
94 gl.enableVertexAttribArray(v);
95 gl.vertexAttribPointer(v, 3, gl.FLOAT, false, 0, 0);
96 gl.vertexAttrib1fv(v, [1]);
97 gl.vertexAttrib2fv(v, [1,2]);
98 gl.vertexAttrib3fv(v, [1,2,3]);
99 gl.vertexAttrib4fv(v, [1,2,3,4]);
100 gl.vertexAttrib1f(v, 1);
101 gl.vertexAttrib2f(v, 1,2);
102 gl.vertexAttrib3f(v, 1,2,3);
103 gl.vertexAttrib4f(v, 1,2,3,4);
104 assertOk(function(){gl.vertexAttribPointer(v, 3, gl.FLOAT, false, 0, 0);});
105 assertOk(function(){gl.drawArrays(gl.TRIANGLES, 0, 3);});
106 gl.vertexAttrib4fv(v, [1,2,3,4]);
107 assertOk(function(){gl.drawArrays(gl.TRIANGLES, 0, 3);});
108 throwError(gl);
109 gl.bindBuffer(gl.ARRAY_BUFFER, null);
110 gl.deleteBuffer(vbo);
111 throwError(gl);
112 }
113
114 </script>
115 <script id="vert" type="x-shader/x-vertex">
116 attribute vec3 Vertex;
117 attribute vec3 Normal;
118 attribute vec2 Tex;
119
120 varying vec4 texCoord0;
121 void main()
122 {
123 gl_Position = vec4(Vertex * Normal, 1.0);
124 texCoord0 = vec4(Tex,0.0,0.0) + gl_Position;
125 }
126 </script>
127 <script id="frag" type="x-shader/x-fragment">
128 precision mediump float;
129
130 varying vec4 texCoord0;
131 void main()
132 {
133 vec4 c = texCoord0;
134 gl_FragColor = c;
135 }
136 </script>
137
138
139 <style>canvas{ position:absolute; }</style>
140 </head><body>
141 <canvas id="gl" width="1" height="1"></canvas>
142 </body></html>
OLDNEW
« no previous file with comments | « conformance/more/functions/uniformiBadArgs.html ('k') | conformance/more/functions/vertexAttribBadArgs.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698