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 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
11 <script src=
"../../js/js-test-pre.js"></script>
12 <script src=
"../../js/webgl-test-utils.js"></script>
15 <div id=
"description"></div>
16 <div id=
"console"></div>
20 description('Test that client data is always copied during bufferData and bufferSubData calls, because otherwise the data the GL uses to draw may differ from that checked by the index validation code.')
22 var wtu
= WebGLTestUtils
;
23 var context
= wtu
.create3DContext();
24 var program
= wtu
.loadStandardProgram(context
);
26 context
.useProgram(program
);
27 var vertexObject
= context
.createBuffer();
28 context
.enableVertexAttribArray(0);
29 context
.bindBuffer(context
.ARRAY_BUFFER
, vertexObject
);
30 // 4 vertices -> 2 triangles
31 context
.bufferData(context
.ARRAY_BUFFER
, new Float32Array([ 0,0,0, 0,1,0, 1,0,0, 1,1,0 ]), context
.STATIC_DRAW
);
32 context
.vertexAttribPointer(0, 3, context
.FLOAT
, false, 0, 0);
34 var indexObject
= context
.createBuffer();
36 context
.bindBuffer(context
.ELEMENT_ARRAY_BUFFER
, indexObject
);
37 var indices
= new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]);
38 context
.bufferData(context
.ELEMENT_ARRAY_BUFFER
, indices
, context
.STATIC_DRAW
);
39 wtu
.shouldGenerateGLError(context
, context
.NO_ERROR
, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
40 var indexValidationError
= wtu
.shouldGenerateGLError(context
,
41 [context
.INVALID_OPERATION
, context
.NO_ERROR
],
42 "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
43 wtu
.shouldGenerateGLError(context
, indexValidationError
, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
46 wtu
.shouldGenerateGLError(context
, context
.NO_ERROR
, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
47 wtu
.shouldGenerateGLError(context
, indexValidationError
, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
48 wtu
.shouldGenerateGLError(context
, indexValidationError
, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
51 var successfullyParsed
= true;
54 <script src=
"../../js/js-test-post.js"></script>