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>Tests if fake black textures are corectly implemented on desktops
</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 <canvas id=
"example" width=
"24" height=
"24"></canvas>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
23 function createTexture(gl
,r
,g
,b
,a
) {
24 // setup render target texture //
26 var texture
= gl
.createTexture();
27 gl
.bindTexture(gl
.TEXTURE_2D
, texture
);
28 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MAG_FILTER
, gl
.LINEAR
);
29 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MIN_FILTER
, gl
.LINEAR
);
30 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_S
, gl
.CLAMP_TO_EDGE
);
31 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_T
, gl
.CLAMP_TO_EDGE
);
32 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA
, 3, 3, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, null);
33 gl
.bindTexture(gl
.TEXTURE_2D
, null);
35 // setup framebuffer //
36 var fbo
= gl
.createFramebuffer();
37 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fbo
);
38 gl
.framebufferTexture2D(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.TEXTURE_2D
, texture
, 0);
39 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, null);
41 // fill the framebuffer //
42 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fbo
);
43 gl
.clearColor(r
, g
, b
, a
);
44 gl
.clear(gl
.COLOR_BUFFER_BIT
);
45 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, null);
47 gl
.deleteFramebuffer(fbo
);
54 * This test has been written due to a bug found in firefox's code
55 * and fixed in the following patch :
56 * https://bugzilla.mozilla.org/show_bug.cgi?id=879952#c5
58 var wtu
= WebGLTestUtils
;
61 var gl
= wtu
.create3DContext("example");
62 var program
= wtu
.setupTexturedQuad(gl
);
64 var texture0
= createTexture(gl
,1,0,0,1);
65 var texture1
= createTexture(gl
,0,1,0,1);
67 gl
.bindTexture(gl
.TEXTURE_2D
, texture0
);
68 gl
.drawArrays(gl
.TRIANGLES
, 0, 6);
69 wtu
.checkCanvas(gl
, [255, 0, 0, 255]);
71 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_S
, gl
.REPEAT
);
72 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_T
, gl
.REPEAT
);
73 gl
.drawArrays(gl
.TRIANGLES
, 0, 6);
74 wtu
.checkCanvas(gl
, [0, 0, 0, 255]);
76 gl
.bindTexture(gl
.TEXTURE_2D
, texture1
);
77 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_S
, gl
.CLAMP_TO_EDGE
);
78 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_T
, gl
.CLAMP_TO_EDGE
);
79 gl
.drawArrays(gl
.TRIANGLES
, 0, 6);
80 wtu
.checkCanvas(gl
, [0, 255, 0, 255]);
82 gl
.bindTexture(gl
.TEXTURE_2D
, texture0
);
83 gl
.drawArrays(gl
.TRIANGLES
, 0, 6);
84 wtu
.checkCanvas(gl
, [0, 0, 0, 255]);
88 var successfullyParsed
= true;
90 <script src=
"../../../js/js-test-post.js"></script>