5 Copyright (c) 2019 The Khronos Group Inc.
6 Use of this source code is governed by an MIT-style license that can be
7 found in the LICENSE.txt file.
10 <link rel=
"stylesheet" type=
"text/css" href=
"../unit.css" />
11 <script type=
"application/javascript" src=
"../unit.js"></script>
12 <script type=
"application/javascript" src=
"../util.js"></script>
13 <script type=
"application/javascript">
15 Tests.startUnit = function () {
16 var canvas = document.getElementById('gl');
17 var gl = wrapGLContext(getGLContext(canvas));
18 var tex = gl.createTexture();
19 gl.bindTexture(gl.TEXTURE_2D, tex);
23 Tests.testTexImage2D = function(gl) {
24 var b = document.createElement('b');
25 var div = document.createElement('div');
26 var c = document.getElementById('c');
27 assertFail(
"bad element b",
28 function() {gl.texImage2D(gl.TEXTURE_2D,
0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, b); });
29 assertFail(
"bad element div",
30 function() {gl.texImage2D(gl.TEXTURE_2D,
0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, div); });
31 assertFail(
"no element",
32 function() {gl.texImage2D(gl.TEXTURE_2D,
0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE,
0); });
33 assertFail(
"string as data",
34 function() {gl.texImage2D(gl.TEXTURE_2D,
0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE,
"foo"); });
35 assertOk(
"canvas as data",
36 function() {gl.texImage2D(gl.TEXTURE_2D,
0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c); });
37 assertFail(
"bad target",
38 function() {gl.texImage2D(gl.FLOAT,
0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c); });
41 Tests.endUnit = function(gl, tex) {
42 gl.bindTexture(gl.TEXTURE_2D, null);
43 gl.deleteTexture(tex);
47 <style>canvas{ position:absolute; }
</style>
49 <canvas id=
"gl" width=
"16" height=
"16"></canvas>
50 <canvas id=
"c" width=
"16" height=
"16"></canvas>