|
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_gl07 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 let p = new renderer.Program({ |
|
32 vs: TiltGL.ColorShader.vs, |
|
33 fs: TiltGL.ColorShader.fs, |
|
34 attributes: ["vertexPosition"], |
|
35 uniforms: ["mvMatrix", "projMatrix", "fill"] |
|
36 }); |
|
37 |
|
38 ok(p instanceof TiltGL.Program, |
|
39 "The program object wasn't instantiated correctly."); |
|
40 |
|
41 ok(p._ref, |
|
42 "The program WebGL object wasn't created properly."); |
|
43 isnot(p._id, -1, |
|
44 "The program id wasn't set properly."); |
|
45 ok(p._attributes, |
|
46 "The program attributes cache wasn't created properly."); |
|
47 ok(p._uniforms, |
|
48 "The program uniforms cache wasn't created properly."); |
|
49 |
|
50 is(typeof p._attributes.vertexPosition, "number", |
|
51 "The vertexPosition attribute wasn't cached as it should."); |
|
52 is(typeof p._uniforms.mvMatrix, "object", |
|
53 "The mvMatrix uniform wasn't cached as it should."); |
|
54 is(typeof p._uniforms.projMatrix, "object", |
|
55 "The projMatrix uniform wasn't cached as it should."); |
|
56 is(typeof p._uniforms.fill, "object", |
|
57 "The fill uniform wasn't cached as it should."); |
|
58 } |