michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: "use strict"; michael@0: michael@0: let isWebGLAvailable; michael@0: michael@0: function onWebGLFail() { michael@0: isWebGLAvailable = false; michael@0: } michael@0: michael@0: function onWebGLSuccess() { michael@0: isWebGLAvailable = true; michael@0: } michael@0: michael@0: function test() { michael@0: if (!isWebGLSupported()) { michael@0: info("Skipping tilt_gl07 because WebGL isn't supported on this hardware."); michael@0: return; michael@0: } michael@0: michael@0: let canvas = createCanvas(); michael@0: michael@0: let renderer = new TiltGL.Renderer(canvas, onWebGLFail, onWebGLSuccess); michael@0: let gl = renderer.context; michael@0: michael@0: if (!isWebGLAvailable) { michael@0: return; michael@0: } michael@0: michael@0: michael@0: let p = new renderer.Program({ michael@0: vs: TiltGL.ColorShader.vs, michael@0: fs: TiltGL.ColorShader.fs, michael@0: attributes: ["vertexPosition"], michael@0: uniforms: ["mvMatrix", "projMatrix", "fill"] michael@0: }); michael@0: michael@0: ok(p instanceof TiltGL.Program, michael@0: "The program object wasn't instantiated correctly."); michael@0: michael@0: ok(p._ref, michael@0: "The program WebGL object wasn't created properly."); michael@0: isnot(p._id, -1, michael@0: "The program id wasn't set properly."); michael@0: ok(p._attributes, michael@0: "The program attributes cache wasn't created properly."); michael@0: ok(p._uniforms, michael@0: "The program uniforms cache wasn't created properly."); michael@0: michael@0: is(typeof p._attributes.vertexPosition, "number", michael@0: "The vertexPosition attribute wasn't cached as it should."); michael@0: is(typeof p._uniforms.mvMatrix, "object", michael@0: "The mvMatrix uniform wasn't cached as it should."); michael@0: is(typeof p._uniforms.projMatrix, "object", michael@0: "The projMatrix uniform wasn't cached as it should."); michael@0: is(typeof p._uniforms.fill, "object", michael@0: "The fill uniform wasn't cached as it should."); michael@0: }