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 clear after copyTexImage2D with a non-pure color
</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=
"128" height=
"128"> </canvas>
22 // This test verifies a Intel D3D driver bug.
23 var wtu
= WebGLTestUtils
;
24 var gl
= wtu
.create3DContext("canvas", {"antialias" : "true"});
26 function testClearAfterCopyTexImage2DWithoutPureOneOrZero(clearColor
, expectedColor
)
28 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, null);
29 gl
.clearColor(0, 0, 0, 1);
30 gl
.clear(gl
.COLOR_BUFFER_BIT
);
34 var texture
= gl
.createTexture();
35 gl
.bindTexture(gl
.TEXTURE_2D
, texture
);
36 gl
.copyTexImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA
, 0, 0, width
, height
, 0);
37 gl
.clearColor(clearColor
[0], clearColor
[1], clearColor
[2], clearColor
[3]);
38 gl
.clear(gl
.COLOR_BUFFER_BIT
);
40 wtu
.checkCanvasRect(gl
, 0, 0, gl
.drawingBufferWidth
, gl
.drawingBufferHeight
, expectedColor
);
42 gl
.bindTexture(gl
.TEXTURE_2D
, null);
43 gl
.deleteTexture(texture
);
46 description("Test that if clear with a color that has non-0/1 RGB components after copyTexImage2D, the final render color should be consistent with the clear color.");
48 for(var index
= 0; index
< 3; index
++)
50 var clearColor
= [0, 0, 0, 1];
51 var expectedColor
= [0, 0, 0, 255];
52 clearColor
[index
] = 0.8;
53 expectedColor
[index
] = 255 * clearColor
[index
];
54 testClearAfterCopyTexImage2DWithoutPureOneOrZero(clearColor
, expectedColor
);
58 var successfullyParsed
= true;
61 <script src=
"../../js/js-test-post.js"></script>