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

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

Issue 8342021: Add webgl conformance tests r15841. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 years, 2 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 <!DOCTYPE html>
2 <html><head>
3 <meta charset="utf-8">
4 <!--
5 Tests for the OpenGL ES 2.0 HTML Canvas context
6
7 Copyright (C) 2011 Ilmari Heikkinen <ilmari.heikkinen@gmail.com>
8
9 Permission is hereby granted, free of charge, to any person
10 obtaining a copy of this software and associated documentation
11 files (the "Software"), to deal in the Software without
12 restriction, including without limitation the rights to use,
13 copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the
15 Software is furnished to do so, subject to the following
16 conditions:
17
18 The above copyright notice and this permission notice shall be
19 included in all copies or substantial portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 OTHER DEALINGS IN THE SOFTWARE.
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(canvas.getContext(GL_CONTEXT_ID));
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