1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
5 <title>WebGL BindBuffer conformance test.
</title>
6 <script src=
"../../../resources/js-test.js"></script>
7 <script src=
"resources/webgl-test.js"> </script>
10 <canvas id=
"example" width=
"40" height=
"40" style=
"width: 40px; height: 40px;"></canvas>
11 <div id=
"description"></div>
12 <div id=
"console"></div>
14 description("Checks a buffer can only be bound to 1 target.");
17 debug("Canvas.getContext");
20 window
.internals
.settings
.setWebGLErrorsToConsoleEnabled(false);
22 var gl
= create3DContext(document
.getElementById("canvas"));
24 testFailed("context does not exist");
26 testPassed("context exists");
30 var buf
= gl
.createBuffer();
31 gl
.bindBuffer(gl
.ARRAY_BUFFER
, buf
);
32 assertMsg(gl
.getError() == gl
.NO_ERROR
,
33 "should be able to bind buffer.");
34 gl
.bindBuffer(gl
.ARRAY_BUFFER
, null);
35 assertMsg(gl
.getError() == gl
.NO_ERROR
,
36 "should be able to unbind buffer.");
37 gl
.bindBuffer(gl
.ELEMENT_ARRAY_BUFFER
, buf
);
38 assertMsg(gl
.getError() == gl
.INVALID_OPERATION
,
39 "should get INVALID_OPERATION if attempting to bind buffer to different target");
41 var buf
= gl
.createBuffer();
42 gl
.bindBuffer(gl
.ELEMENT_ARRAY_BUFFER
, buf
);
43 assertMsg(gl
.getError() == gl
.NO_ERROR
,
44 "should be able to bind buffer.");
45 gl
.bindBuffer(gl
.ELEMENT_ARRAY_BUFFER
, null);
46 assertMsg(gl
.getError() == gl
.NO_ERROR
,
47 "should be able to unbind buffer.");
48 gl
.bindBuffer(gl
.ARRAY_BUFFER
, buf
);
49 assertMsg(gl
.getError() == gl
.INVALID_OPERATION
,
50 "should get INVALID_OPERATION if attempting to bind buffer to different target");