Backed out changeset 8fc3326bce7f (bug 1943032) for causing failures at browser_tab_g...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / rendering / triangle.html
blob98a04c9050819129847cde2dbf1b906b6c14d385
1 <!--
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.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
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>
15 </head>
16 <body>
17 <canvas id="example" width="50" height="50">
18 There is supposed to be an example drawing here, but it's not important.
19 </canvas>
20 <div id="description"></div>
21 <div id="console"></div>
22 <script id="vshader" type="x-shader/x-vertex">
23 attribute vec4 vPosition;
24 void main()
26 gl_Position = vPosition;
28 </script>
30 <script id="fshader" type="x-shader/x-fragment">
31 void main()
33 gl_FragColor = vec4(1.0,0.0,0.0,1.0);
35 </script>
37 <script>
38 "use strict";
39 function init()
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]);
67 init();
68 var successfullyParsed = true;
69 </script>
70 <script src="../../js/js-test-post.js"></script>
72 </body>
73 </html>