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.
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>
16 <canvas id=
"example" width=
"32" height=
"32"></canvas>
17 <div id=
"description"></div>
18 <div id=
"console"></div>
21 var wtu
= WebGLTestUtils
;
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([
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")
65 var successfullyParsed
= true;
67 <script src=
"../../js/js-test-post.js"></script>