2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <title>WebGL copy into cube map texture conformance test
</title>
12 <link rel=
"stylesheet" href=
"../../../resources/js-test-style.css"/>
13 <script src=
"../../../js/js-test-pre.js"></script>
14 <script src=
"../../../js/webgl-test-utils.js"></script>
17 <div id=
"description"></div>
18 <div id=
"console"></div>
19 <canvas id=
"canvas" width=
"2" height=
"2"> </canvas>
22 var wtu
= WebGLTestUtils
;
31 internalformat
: "RGBA8",
33 type
: "UNSIGNED_BYTE",
34 data
: new Uint8Array(width
* height
* 4)
37 internalformat
: "RGBA8I",
38 format
: "RGBA_INTEGER",
40 data
: new Int8Array(width
* height
* 4)
43 internalformat
: "RGBA8UI",
44 format
: "RGBA_INTEGER",
45 type
: "UNSIGNED_BYTE",
46 data
: new Uint8Array(width
* height
* 4)
49 if (gl
.getExtension("EXT_color_buffer_float")) {
51 internalformat
: "RGBA32F",
54 data
: new Float32Array(width
* height
* 4)
57 cases
.forEach(function(testcase
) {
59 debug("Testing internalformat: " + testcase
.internalformat
);
61 var internalformat
= gl
[testcase
.internalformat
];
62 var format
= gl
[testcase
.format
];
63 var type
= gl
[testcase
.type
];
64 var texture
= gl
.createTexture();
65 gl
.bindTexture(gl
.TEXTURE_2D
, texture
);
66 var data
= testcase
.data
;
67 gl
.texImage2D(gl
.TEXTURE_2D
, level
, internalformat
, width
, height
, 0, format
, type
, data
);
68 var fbo
= gl
.createFramebuffer();
69 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fbo
);
70 gl
.framebufferTexture2D(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.TEXTURE_2D
, texture
, level
);
71 shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
72 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Setup framebuffer with texture should succeed.");
74 var cubeTexture
= gl
.createTexture();
75 gl
.bindTexture(gl
.TEXTURE_CUBE_MAP
, cubeTexture
);
77 for (var face
= gl
.TEXTURE_CUBE_MAP_POSITIVE_X
; face
< gl
.TEXTURE_CUBE_MAP_POSITIVE_X
+ 6; face
++) {
78 gl
.copyTexImage2D(face
, level
, internalformat
, 0, 0, width
, height
, 0);
79 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "CopyTexImage2D should succeed.");
80 gl
.copyTexSubImage2D(face
, level
, 0, 0, 0, 0, width
, height
);
81 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "CopyTexSubImage2D should succeed.");
84 gl
.deleteTexture(cubeTexture
);
85 gl
.deleteTexture(texture
);
86 gl
.deleteFramebuffer(fbo
);
91 debug("This is a regression test for <a href='https://bugs.chromium.org/p/chromium/issues/detail?id=712117'>Chromium Issue 712117</a>");
93 var canvas
= document
.getElementById("canvas");
94 shouldBeNonNull("gl = wtu.create3DContext(canvas, undefined, 2)");
98 var successfullyParsed
= true;
101 <script src=
"../../../js/js-test-post.js"></script>