OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (c) 2010 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 <html> | |
7 <head> | |
8 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
9 <script src="../resources/js-test-pre.js"></script> | |
10 <script src="resources/webgl-test.js"></script> | |
11 </head> | |
12 <body> | |
13 <div id="description"></div> | |
14 <div id="console"></div> | |
15 | |
16 <script> | |
17 description('Tests that index validation for drawElements does not examine too m
any indices'); | |
18 | |
19 var context = create3DContext(); | |
20 var program = loadStandardProgram(context); | |
21 | |
22 context.useProgram(program); | |
23 var vertexObject = context.createBuffer(); | |
24 context.enableVertexAttribArray(0); | |
25 context.bindBuffer(context.ARRAY_BUFFER, vertexObject); | |
26 // 4 vertices -> 2 triangles | |
27 context.bufferData(context.ARRAY_BUFFER, new Float32Array([ 0,0,0, 0,1,0, 1,0,0,
1,1,0 ]), context.STATIC_DRAW); | |
28 context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0); | |
29 | |
30 var indexObject = context.createBuffer(); | |
31 | |
32 debug("Test out of range indices") | |
33 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject); | |
34 context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 10000, 0, 1,
2, 3, 10000 ]), context.STATIC_DRAW); | |
35 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T
RIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)"); | |
36 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(
context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)"); | |
37 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(
context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)"); | |
38 | |
39 debug("") | |
40 successfullyParsed = true; | |
41 </script> | |
42 | |
43 <script src="../resources/js-test-post.js"></script> | |
44 </body> | |
45 </html> | |
OLD | NEW |