|
1 <!-- |
|
2 Copyright (c) 2011 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 <!DOCTYPE html> |
|
7 <html> |
|
8 <head> |
|
9 <meta charset="utf-8"> |
|
10 <title>WebGL BindBuffer conformance test.</title> |
|
11 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
|
12 <script src="../../resources/js-test-pre.js"></script> |
|
13 <script src="../resources/webgl-test.js"> </script> |
|
14 </head> |
|
15 <body> |
|
16 <canvas id="example" width="40" height="40" style="width: 40px; height: 40px;"></canvas> |
|
17 <div id="description"></div> |
|
18 <div id="console"></div> |
|
19 <script> |
|
20 description("Checks a buffer can only be bound to 1 target."); |
|
21 |
|
22 debug(""); |
|
23 debug("Canvas.getContext"); |
|
24 |
|
25 var gl = create3DContext(document.getElementById("canvas")); |
|
26 if (!gl) { |
|
27 testFailed("context does not exist"); |
|
28 } else { |
|
29 testPassed("context exists"); |
|
30 |
|
31 debug(""); |
|
32 |
|
33 var buf = gl.createBuffer(); |
|
34 gl.bindBuffer(gl.ARRAY_BUFFER, buf); |
|
35 glErrorShouldBe(gl, gl.NO_ERROR, |
|
36 "should be able to bind buffer."); |
|
37 gl.bindBuffer(gl.ARRAY_BUFFER, null); |
|
38 glErrorShouldBe(gl, gl.NO_ERROR, |
|
39 "should be able to unbind buffer."); |
|
40 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buf); |
|
41 glErrorShouldBe(gl, gl.INVALID_OPERATION, |
|
42 "should get INVALID_OPERATION if attempting to bind buffer to different target"); |
|
43 |
|
44 var buf = gl.createBuffer(); |
|
45 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buf); |
|
46 glErrorShouldBe(gl, gl.NO_ERROR, |
|
47 "should be able to bind buffer."); |
|
48 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); |
|
49 glErrorShouldBe(gl, gl.NO_ERROR, |
|
50 "should be able to unbind buffer."); |
|
51 gl.bindBuffer(gl.ARRAY_BUFFER, buf); |
|
52 glErrorShouldBe(gl, gl.INVALID_OPERATION, |
|
53 "should get INVALID_OPERATION if attempting to bind buffer to different target"); |
|
54 } |
|
55 |
|
56 debug(""); |
|
57 successfullyParsed = true; |
|
58 </script> |
|
59 <script>finishTest();</script> |
|
60 |
|
61 </body> |
|
62 </html> |
|
63 |