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

Side by Side Diff: conformance/rendering/gl-drawelements.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
« no previous file with comments | « conformance/rendering/gl-clear.html ('k') | conformance/rendering/gl-scissor-test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 drawElements 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/desktop-gl-constants.js" type="text/javascript" ></script>
15 </head>
16 <body>
17 <canvas id="example" width="50" height="50"></canvas>
18 <div id="description"></div>
19 <div id="console"></div>
20 <script id="vshader" type="x-shader/x-vertex">
21 attribute vec4 vPosition;
22 void main()
23 {
24 gl_Position = vPosition;
25 }
26 </script>
27
28 <script id="fshader" type="x-shader/x-fragment">
29 void main()
30 {
31 gl_FragColor = vec4(1.0,0.0,0.0,1.0);
32 }
33 </script>
34
35 <script>
36 function init()
37 {
38 if (window.initNonKhronosFramework) {
39 window.initNonKhronosFramework(false);
40 }
41
42 function checkDrawElements(mode, count, type, expect, msg) {
43 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
44 gl.drawElements(mode, count, type, 0);
45 glErrorShouldBe(gl, expect, msg);
46 }
47
48 gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
49
50 var vertexObject = gl.createBuffer();
51 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
52 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5 ,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW);
53 gl.enableVertexAttribArray(0);
54 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
55
56 var vertexObject = gl.createBuffer();
57 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vertexObject);
58 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 0, 1, 2]), gl.STATIC_DRAW);
59
60 checkDrawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT,
61 gl.NO_ERROR, "can call gl.DrawElements with UNSIGN ED_SHORT");
62
63 var vertexObject = gl.createBuffer();
64 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vertexObject);
65 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint8Array([ 0, 1, 2, 0]) , gl.STATIC_DRAW);
66
67 checkDrawElements(
68 gl.TRIANGLES, 3, gl.UNSIGNED_BYTE,
69 gl.NO_ERROR, "can call gl.DrawElements with UNSIGNED_BYTE");
70 checkDrawElements(
71 desktopGL['QUAD_STRIP'], 4, gl.UNSIGNED_BYTE,
72 gl.INVALID_ENUM, "gl.DrawElements with QUAD_STRIP should return INVALID_ENUM");
73 checkDrawElements(
74 desktopGL['QUADS'], 4, gl.UNSIGNED_BYTE,
75 gl.INVALID_ENUM, "gl.DrawElements with QUADS should return INVAL ID_ENUM");
76 checkDrawElements(
77 desktopGL['POLYGON'], 4, gl.UNSIGNED_BYTE,
78 gl.INVALID_ENUM, "gl.DrawElements with POLYGON should return INV ALID_ENUM");
79
80 var vertexObject = gl.createBuffer();
81 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vertexObject);
82 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([ 0, 1, 2]), gl.STATIC_DRAW);
83
84 checkDrawElements(
85 gl.TRIANGLES, 3, gl.UNSIGNED_INT,
86 gl.INVALID_ENUM, "gl.DrawElements should return INVALID_ENUM wit h UNSIGNED_INT");
87
88 }
89
90 init();
91 successfullyParsed = true;
92 </script>
93 <script src="../../resources/js-test-post.js"></script>
94
95 </body>
96 </html>
OLDNEW
« no previous file with comments | « conformance/rendering/gl-clear.html ('k') | conformance/rendering/gl-scissor-test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698