4 <style type=
"text/css" media=
"screen">
6 outline:
10px solid transparent; /* affects layer sizes */
12 background-color: rgba(
0,
0,
128,
0.0);
16 if (window
.testRunner
)
17 testRunner
.overridePreference("WebKitWebGLEnabled", "1");
19 function initWebGL(canvasName
, vshader
, fshader
, attribs
, clearColor
, clearDepth
, premultAlpha
)
21 var canvas
= document
.getElementById(canvasName
);
22 var gl
= canvas
.getContext("webgl", {premultipliedAlpha
: premultAlpha
});
24 alert("No WebGL context found");
28 gl
.clearColor(clearColor
[0], clearColor
[1], clearColor
[2], clearColor
[3]);
29 gl
.clearDepth(clearDepth
);
31 gl
.enable(gl
.DEPTH_TEST
);
33 gl
.blendFunc(gl
.SRC_ALPHA
, gl
.ONE
);
38 function drawCanvas(canvasID
, premultAlpha
)
40 var blueColor
= 128.0 / 255.0 * (premultAlpha
? 0.5 : 1.0);
41 var gl
= initWebGL(canvasID
, "", "", [], [ 0, 0, blueColor
, 0.5 ], 1, premultAlpha
);
42 gl
.viewport(0, 0, 200, 200);
43 gl
.clear(gl
.COLOR_BUFFER_BIT
| gl
.DEPTH_BUFFER_BIT
);
48 drawCanvas('canvas1', false);
49 drawCanvas('canvas2', true);
53 <body onload=
"init()">
55 <canvas class=
"canvas" id=
"canvas1" style=
"left: 20px" width=
"200" height=
"200"></canvas>
56 <canvas class=
"canvas" id=
"canvas2" style=
"left: 20px" width=
"200" height=
"200"></canvas>
58 <!-- Both should look the same. -->