Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / rendering / gl-drawarrays.html
blob7d06e998978082bc2613c665a6691b48c435b113
1 <!--
2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
10 <meta charset="utf-8">
11 <title>WebGL drawArrays Test</title>
12 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
13 <script src="../../js/desktop-gl-constants.js"></script>
14 <script src="../../js/js-test-pre.js"></script>
15 <script src="../../js/webgl-test-utils.js"> </script>
16 </head>
17 <body>
18 <canvas id="example" width="50" height="50"></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()
25 gl_Position = vPosition;
27 </script>
29 <script id="fshader" type="x-shader/x-fragment">
30 void main()
32 gl_FragColor = vec4(1.0,0.0,0.0,1.0);
34 </script>
36 <script>
37 "use strict";
38 function init()
40 description(document.title);
42 function checkDrawArrays(mode, count, expect, msg) {
43 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
44 gl.drawArrays(mode, 0, count);
45 wtu.glErrorShouldBe(gl, expect, msg);
48 var wtu = WebGLTestUtils;
49 var gl = wtu.create3DContext("example");
50 var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
52 var vertexObject = gl.createBuffer();
53 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
54 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW);
55 gl.enableVertexAttribArray(0);
57 checkDrawArrays(gl.TRIANGLES, 3,
58 gl.INVALID_OPERATION, "gl.DrawArrays with no buffer attached to VAO should return INVALID_OPERATION");
60 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
62 checkDrawArrays(gl.TRIANGLES, 3,
63 gl.NO_ERROR, "can call gl.DrawArrays with gl.TRIANGLES");
65 checkDrawArrays(
66 desktopGL['QUAD_STRIP'], 4,
67 gl.INVALID_ENUM, "gl.DrawArrays with QUAD_STRIP should return INVALID_ENUM");
68 checkDrawArrays(
69 desktopGL['QUADS'], 4,
70 gl.INVALID_ENUM, "gl.DrawArrays with QUADS should return INVALID_ENUM");
71 checkDrawArrays(
72 desktopGL['POLYGON'], 4,
73 gl.INVALID_ENUM, "gl.DrawArrays with POLYGON should return INVALID_ENUM");
76 init();
77 var successfullyParsed = true;
78 </script>
79 <script src="../../js/js-test-post.js"></script>
81 </body>
82 </html>