6 Copyright (c) 2019 The Khronos Group Inc.
7 Use of this source code is governed by an MIT-style license that can be
8 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));
21 Tests.setup = function(gl) {
22 var tex = gl.createTexture();
23 gl.bindTexture(gl.TEXTURE_2D, tex);
27 Tests.teardown = function(gl,tex) {
28 gl.bindTexture(gl.TEXTURE_2D, null);
29 gl.deleteTexture(tex);
32 Tests.testTexImage2D = function(gl) {
33 assertOk(
"height > backHeight", function(){
34 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.RGBA,
0,
0,
17,
1,
0);
36 assertOk(
"width > backWidth", function(){
37 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.RGBA,
0,
0,
1,
17,
0);
39 assertOk(
"x + width > backWidth", function(){
40 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.RGBA,
16,
0,
1,
1,
0);
42 assertOk(
"y + height > backHeight", function(){
43 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.RGBA,
0,
16,
1,
1,
0);
45 assertOk(
"Negative X", function(){
46 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.RGBA, -
1,
0,
1,
1,
0);
48 assertOk(
"Negative Y", function(){
49 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.RGBA,
0,-
1,
1,
1,
0);
51 assertFail(
"Negative height", function(){
52 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.RGBA,
0,
0, -
1,
1,
0);
54 assertFail(
"Negative width", function(){
55 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.RGBA,
0,
0,
1,-
1,
0);
57 assertFail(
"Non 0 border", function(){
58 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.RGBA,
0,
0,
1,
1,
1);
60 assertFail(
"Negative border",function(){
61 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.RGBA,
0,
0,
1,
1,-
1);
63 assertOk(
"Good Args", function(){
64 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.RGBA,
0,
0,
16,
16,
0);
66 assertFail(
"NPOT texture to > level 0", function(){
67 gl.copyTexImage2D(gl.TEXTURE_2D,
1, gl.RGBA,
0,
0,
15,
16,
0);
69 assertFail(
"Bad target", function(){
70 gl.copyTexImage2D(gl.FLOAT,
0, gl.RGBA,
0,
0,
16,
16,
0);
72 assertFail(
"Bad internal format", function(){
73 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.FLOAT,
0,
0,
16,
16,
0);
75 assertFail(
"Negative level", function(){
76 gl.copyTexImage2D(gl.TEXTURE_2D, -
1, gl.RGBA,
0,
0,
16,
16,
0);
81 Tests.endUnit = function(gl) {
85 <style>canvas{ position:absolute; }
</style>
87 <canvas id=
"gl" width=
"16" height=
"16"></canvas>