|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 "use strict"; |
|
4 |
|
5 let isWebGLAvailable; |
|
6 |
|
7 function onWebGLFail() { |
|
8 isWebGLAvailable = false; |
|
9 } |
|
10 |
|
11 function onWebGLSuccess() { |
|
12 isWebGLAvailable = true; |
|
13 } |
|
14 |
|
15 function test() { |
|
16 if (!isWebGLSupported()) { |
|
17 info("Skipping tilt_gl02 because WebGL isn't supported on this hardware."); |
|
18 return; |
|
19 } |
|
20 |
|
21 let canvas = createCanvas(); |
|
22 |
|
23 let renderer = new TiltGL.Renderer(canvas, onWebGLFail, onWebGLSuccess); |
|
24 let gl = renderer.context; |
|
25 |
|
26 if (!isWebGLAvailable) { |
|
27 return; |
|
28 } |
|
29 |
|
30 |
|
31 renderer.fill([1, 0, 0, 1]); |
|
32 ok(isApproxVec(renderer._fillColor, [1, 0, 0, 1]), |
|
33 "The fill color wasn't set correctly."); |
|
34 |
|
35 renderer.stroke([0, 1, 0, 1]); |
|
36 ok(isApproxVec(renderer._strokeColor, [0, 1, 0, 1]), |
|
37 "The stroke color wasn't set correctly."); |
|
38 |
|
39 renderer.strokeWeight(2); |
|
40 is(renderer._strokeWeightValue, 2, |
|
41 "The stroke weight wasn't set correctly."); |
|
42 is(gl.getParameter(gl.LINE_WIDTH), 2, |
|
43 "The stroke weight wasn't applied correctly."); |
|
44 } |