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>Rendering 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 <canvas id=
"example" width=
"50" height=
"50">
18 There is supposed to be an example drawing here, but it's not important.
20 <div id=
"description"></div>
21 <div id=
"console"></div>
22 <script id=
"vshader" type=
"x-shader/x-vertex">
23 attribute vec4 vPosition;
26 gl_Position = vPosition;
30 <script id=
"fshader" type=
"x-shader/x-fragment">
33 gl_FragColor = vec4(
1.0,
0.0,
0.0,
1.0);
41 description(document
.title
);
43 var wtu
= WebGLTestUtils
;
44 var gl
= wtu
.create3DContext("example");
45 var program
= wtu
.setupProgram(gl
, ["vshader", "fshader"], ["vPosition"]);
47 var vertexObject
= gl
.createBuffer();
48 gl
.bindBuffer(gl
.ARRAY_BUFFER
, vertexObject
);
49 gl
.bufferData(gl
.ARRAY_BUFFER
, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl
.STATIC_DRAW
);
50 gl
.enableVertexAttribArray(0);
51 gl
.vertexAttribPointer(0, 3, gl
.FLOAT
, false, 0, 0);
53 gl
.clear(gl
.COLOR_BUFFER_BIT
| gl
.DEPTH_BUFFER_BIT
);
54 gl
.drawArrays(gl
.TRIANGLES
, 0, 3);
56 // Test several locations
57 // First line should be all black
58 wtu
.checkCanvasRect(gl
, 0, 0, 50, 1, [0, 0, 0, 0]);
60 // Line 15 should be red for at least 10 red pixels starting 20 pixels in
61 wtu
.checkCanvasRect(gl
, 20, 15, 10, 1, [255, 0, 0, 255]);
63 // Last line should be all black
64 wtu
.checkCanvasRect(gl
, 0, 49, 50, 1, [0, 0, 0, 0]);
68 var successfullyParsed
= true;
70 <script src=
"../../js/js-test-post.js"></script>