Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / buffers / element-array-buffer-delete-recreate.html
blobd4fb81af9b1b9775d9a8009670e3e8de0f9fe6d2
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 -->
6 <!DOCTYPE html>
7 <html>
8 <head>
9 <meta charset="utf-8">
10 <title>Element Array Buffer Deletion and Recreation Test</title>
11 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
12 <script src="../../js/js-test-pre.js"></script>
13 <script src="../../js/webgl-test-utils.js"> </script>
14 </head>
15 <body>
16 <canvas id="example" width="32" height="32"></canvas>
17 <div id="description"></div>
18 <div id="console"></div>
19 <script>
20 "use strict";
21 var wtu = WebGLTestUtils;
22 function init()
24 description();
26 // Clear the background with red.
27 var gl = wtu.create3DContext("example");
28 wtu.setupSimpleColorProgram(gl);
29 var color = [0, 255, 0, 255];
30 wtu.setUByteDrawColor(gl, color);
32 var vertexBuffer = gl.createBuffer();
33 gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
34 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
35 -1, -1,
36 1, -1,
37 -1, 1,
38 1, 1
39 ]), gl.STATIC_DRAW);
40 gl.enableVertexAttribArray(0);
41 gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
43 // Create an element array buffer.
44 var indexBuffer = gl.createBuffer();
45 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
46 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint8Array([0, 1, 2, 3]), gl.STATIC_DRAW);
48 // Delete the element array buffer.
49 gl.deleteBuffer(indexBuffer);
51 // Create a new element array buffer.
52 indexBuffer = gl.createBuffer();
53 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
54 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint8Array([0, 1, 2, 3]), gl.STATIC_DRAW);
56 // Draw with the new element array buffer.
57 // If the geometry is drawn successfully, the fragment shader will color it green.
58 gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_BYTE, 0);
60 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no errors from draw");
61 wtu.checkCanvas(gl, color, "should be green")
64 init();
65 var successfullyParsed = true;
66 </script>
67 <script src="../../js/js-test-post.js"></script>
68 </body>
69 </html>