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 gl.copyTexImage2D(gl.TEXTURE_2D,
0, gl.RGBA,
0,
0,
16,
16,
0);
34 assertGLError(gl, gl.INVALID_VALUE,
"width > dst tex width", function(){
35 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,
0,
0,
0,
17,
1);
37 assertGLError(gl, gl.INVALID_VALUE,
"height > dst tex height", function(){
38 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,
0,
0,
0,
1,
17);
40 // The spec says the source image dimensions can be out of range.
41 assertOk(
"x > dst tex width", function(){
42 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,
0,
16,
0,
1,
1);
44 assertOk(
"y > dst tex width", function(){
45 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,
0,
0,
16,
1,
1);
47 assertOk(
"x < 0", function(){
48 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,
0, -
1,
0,
1,
1);
50 assertOk(
"y < 0", function(){
51 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,
0,
0,-
1,
1,
1);
53 assertGLError(gl, gl.INVALID_VALUE,
"width < 0", function(){
54 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,
0,
0,
0, -
1,
1);
56 assertGLError(gl, gl.INVALID_VALUE,
"height < 0", function(){
57 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,
0,
0,
0,
1,-
1);
59 assertGLError(gl, gl.INVALID_VALUE,
"xoffset < 0", function(){
60 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0, -
1,
0,
0,
0,
16,
16);
62 assertGLError(gl, gl.INVALID_VALUE,
"yoffset < 0", function(){
63 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,-
1,
0,
0,
16,
16);
65 assertGLError(gl, gl.INVALID_VALUE,
"dimension out of range", function(){
66 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
4,
0,
0,
0,
16,
16);
68 assertGLError(gl, gl.INVALID_VALUE,
"dimension out of range", function(){
69 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,
4,
0,
0,
16,
16);
71 assertOk(
"x < 0 full width", function(){
72 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,
0, -
1,
0,
16,
16);
74 assertOk(
"y < 0 full height", function(){
75 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,
0,
0,-
1,
16,
16);
78 gl.copyTexSubImage2D(gl.TEXTURE_2D,
0,
0,
0,
0,
0,
16,
16);
80 assertGLError(gl, gl.INVALID_ENUM,
"bad target", function(){
81 gl.copyTexSubImage2D(gl.FLOAT,
0,
0,
0,
0,
0,
16,
16);
83 assertGLError(gl, gl.INVALID_VALUE,
"", function(){
84 gl.copyTexSubImage2D(gl.TEXTURE_2D, -
1,
0,
0,
0,
0,
16,
16);
89 Tests.endUnit = function(gl) {
93 <style>canvas{ position:absolute; }
</style>
95 <canvas id=
"gl" width=
"16" height=
"16"></canvas>