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

Side by Side Diff: conformance/attribs/gl-vertex-attrib-zero-issues.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 <!--
2 // Copyright (c) 2011 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>
7 <html>
8 <head>
9 <meta charset="utf-8">
10 <title>WebGL Enable Vertex Attrib Zero Test</title>
11 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
12 <script src="../../resources/js-test-pre.js"></script>
13 <script src="../resources/webgl-test.js"> </script>
14 <script src="../resources/webgl-test-utils.js"> </script>
15 </head>
16 <body>
17 <canvas id="example" width="50" height="50">
18 </canvas>
19 <div id="description"></div>
20 <div id="console"></div>
21 <script id="vshader" type="x-shader/x-vertex">
22 attribute vec4 vPosition;
23 void main()
24 {
25 gl_Position = vPosition;
26 }
27 </script>
28
29 <script id="fshader" type="x-shader/x-fragment">
30 void main()
31 {
32 gl_FragColor = vec4(0.0,0.0,0.0,0.0);
33 }
34 </script>
35
36 <script>
37 description("Test some of the issues of the difference between attrib 0 on OpenG L vs WebGL");
38 debug("");
39 var wtu = WebGLTestUtils;
40 var canvas = document.getElementById("example");
41 var gl = wtu.create3DContext(canvas);
42
43 function setup(numVerts, attribIndex) {
44 var program = wtu.setupProgram(
45 gl,
46 [wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER),
47 wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)],
48 ['vPosition'], [attribIndex]);
49 // draw with something on attrib zero with a small number of vertices
50 var vertexObject = gl.createBuffer();
51 g_program = program;
52 g_attribLocation = attribIndex;
53 shouldBe("g_attribLocation", "gl.getAttribLocation(g_program, 'vPosition')");
54 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
55 gl.bufferData(
56 gl.ARRAY_BUFFER, new Float32Array(numVerts * 3), gl.STATIC_DRAW);
57 gl.vertexAttribPointer(attribIndex, 3, gl.FLOAT, false, 0, 0);
58 var indices = new Uint16Array(numVerts);
59 for (var ii = 0; ii < numVerts; ++ii) {
60 indices[ii] = ii;
61 }
62 var indexBuffer = gl.createBuffer();
63 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
64 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
65 return program;
66 }
67
68 var p1 = setup(3, 0);
69 var p2 = setup(60000, 3);
70
71 for (var ii = 0; ii < 5; ++ii) {
72 gl.useProgram(p1);
73 gl.enableVertexAttribArray(0);
74 gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
75 glErrorShouldBe(
76 gl, gl.NO_ERROR,
77 "drawing using attrib 0 with 3 verts");
78
79 gl.useProgram(p2);
80 gl.enableVertexAttribArray(3);
81 gl.drawArrays(gl.LINES, 0, 60000);
82 glErrorShouldBe(
83 gl, gl.NO_ERROR,
84 "drawing using attrib 3 with 60000 verts");
85 }
86
87 wtu.checkCanvas(gl, [0, 0, 0, 0], "canvas should be 0, 0, 0, 0");
88
89 successfullyParsed = true;
90 </script>
91 <script src="../../resources/js-test-post.js"></script>
92
93 </body>
94 </html>
95
OLDNEW
« no previous file with comments | « conformance/attribs/gl-vertex-attrib.html ('k') | conformance/attribs/gl-vertexattribpointer.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698