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 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
12 <script src=
"../../js/js-test-pre.js"></script>
13 <script src=
"../../js/webgl-test-utils.js"></script>
16 <div id=
"description"></div>
17 <div id=
"console"></div>
18 <canvas id=
"canvas" width=
"4" height=
"4"></canvas>
19 <script id=
"vshader" type=
"x-shader/x-vertex">
21 attribute vec4 a_color;
27 gl_Position = vec4(a_pos.xyz,
1.0);
31 <script id=
"fshader" type=
"x-shader/x-fragment">
32 precision mediump float;
38 gl_FragColor = v_color;
45 description("when antialias is enabled, verify default fbo pixels would not be changed between two readPixels without drawing operations");
46 var wtu
= WebGLTestUtils
;
49 var vertices
= new Float32Array([
52 var colors
= new Uint8Array([
56 var canvas
= document
.getElementById('canvas');
57 var gl
= wtu
.create3DContext(canvas
, {antialias
: true});
60 testFailed("context does not exist");
62 testPassed("context exists");
64 var program
= wtu
.setupProgram(gl
, ["vshader", "fshader"], ["a_pos", "a_color"]);
65 gl
.clearColor(0, 0, 0, 1);
66 gl
.clear(gl
.COLOR_BUFFER_BIT
);
68 var colorOffset
= vertices
.byteLength
;
69 var vbo
= gl
.createBuffer();
70 gl
.bindBuffer(gl
.ARRAY_BUFFER
, vbo
);
71 gl
.bufferData(gl
.ARRAY_BUFFER
, colorOffset
+ colors
.byteLength
, gl
.STATIC_DRAW
);
72 gl
.bufferSubData(gl
.ARRAY_BUFFER
, 0, vertices
);
73 gl
.bufferSubData(gl
.ARRAY_BUFFER
, colorOffset
, colors
);
75 gl
.vertexAttribPointer(0, 3, gl
.FLOAT
, false, 0, 0);
76 gl
.enableVertexAttribArray(0);
77 gl
.vertexAttribPointer(1, 4, gl
.UNSIGNED_BYTE
, true, 0, colorOffset
);
78 gl
.enableVertexAttribArray(1);
79 gl
.drawArrays(gl
.LINES
, 0, vertices
.length
/ 3);
81 var result_1
= new Uint8Array(N
* N
* 4);
82 var result_2
= new Uint8Array(N
* N
* 4);
83 gl
.readPixels(0, 0, N
, N
, gl
.RGBA
, gl
.UNSIGNED_BYTE
, result_1
);
84 gl
.readPixels(0, 0, N
, N
, gl
.RGBA
, gl
.UNSIGNED_BYTE
, result_2
);
85 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
);
88 var diff
= new Uint8Array(N
* N
* 4);
89 var failed
= wtu
.comparePixels(result_1
, result_2
, tolerance
, diff
);
92 testFailed("default fbo pixels had be changed between two readPixels without drawing operations");
94 testPassed("default fbo pixels had not be changed between two readPixels without drawing operations.");
97 gl
.bindBuffer(gl
.ARRAY_BUFFER
, null);
101 var successfullyParsed
= true;
103 <script src=
"../../js/js-test-post.js"></script>