|
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_gl03 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.defaults(); |
|
32 is(gl.getParameter(gl.DEPTH_TEST), true, |
|
33 "The depth test wasn't set to the correct default value."); |
|
34 is(gl.getParameter(gl.STENCIL_TEST), false, |
|
35 "The stencil test wasn't set to the correct default value."); |
|
36 is(gl.getParameter(gl.CULL_FACE), false, |
|
37 "The cull face wasn't set to the correct default value."); |
|
38 is(gl.getParameter(gl.FRONT_FACE), gl.CCW, |
|
39 "The front face wasn't set to the correct default value."); |
|
40 is(gl.getParameter(gl.BLEND), true, |
|
41 "The blend mode wasn't set to the correct default value."); |
|
42 is(gl.getParameter(gl.BLEND_SRC_ALPHA), gl.SRC_ALPHA, |
|
43 "The soruce blend func wasn't set to the correct default value."); |
|
44 is(gl.getParameter(gl.BLEND_DST_ALPHA), gl.ONE_MINUS_SRC_ALPHA, |
|
45 "The destination blend func wasn't set to the correct default value."); |
|
46 |
|
47 |
|
48 ok(isApproxVec(renderer._fillColor, [1, 1, 1, 1]), |
|
49 "The fill color wasn't set to the correct default value."); |
|
50 ok(isApproxVec(renderer._strokeColor, [0, 0, 0, 1]), |
|
51 "The stroke color wasn't set to the correct default value."); |
|
52 is(renderer._strokeWeightValue, 1, |
|
53 "The stroke weight wasn't set to the correct default value."); |
|
54 is(gl.getParameter(gl.LINE_WIDTH), 1, |
|
55 "The stroke weight wasn't applied with the correct default value."); |
|
56 |
|
57 |
|
58 ok(isApproxVec(renderer.projMatrix, [ |
|
59 1.2071068286895752, 0, 0, 0, 0, -2.4142136573791504, 0, 0, 0, 0, |
|
60 -1.0202020406723022, -1, -181.06602478027344, 181.06602478027344, |
|
61 148.14492797851562, 181.06602478027344 |
|
62 ]), "The default perspective projection matrix wasn't set correctly."); |
|
63 |
|
64 ok(isApproxVec(renderer.mvMatrix, [ |
|
65 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 |
|
66 ]), "The default model view matrix wasn't set correctly."); |
|
67 } |