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_gl03 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: renderer.defaults(); michael@0: is(gl.getParameter(gl.DEPTH_TEST), true, michael@0: "The depth test wasn't set to the correct default value."); michael@0: is(gl.getParameter(gl.STENCIL_TEST), false, michael@0: "The stencil test wasn't set to the correct default value."); michael@0: is(gl.getParameter(gl.CULL_FACE), false, michael@0: "The cull face wasn't set to the correct default value."); michael@0: is(gl.getParameter(gl.FRONT_FACE), gl.CCW, michael@0: "The front face wasn't set to the correct default value."); michael@0: is(gl.getParameter(gl.BLEND), true, michael@0: "The blend mode wasn't set to the correct default value."); michael@0: is(gl.getParameter(gl.BLEND_SRC_ALPHA), gl.SRC_ALPHA, michael@0: "The soruce blend func wasn't set to the correct default value."); michael@0: is(gl.getParameter(gl.BLEND_DST_ALPHA), gl.ONE_MINUS_SRC_ALPHA, michael@0: "The destination blend func wasn't set to the correct default value."); michael@0: michael@0: michael@0: ok(isApproxVec(renderer._fillColor, [1, 1, 1, 1]), michael@0: "The fill color wasn't set to the correct default value."); michael@0: ok(isApproxVec(renderer._strokeColor, [0, 0, 0, 1]), michael@0: "The stroke color wasn't set to the correct default value."); michael@0: is(renderer._strokeWeightValue, 1, michael@0: "The stroke weight wasn't set to the correct default value."); michael@0: is(gl.getParameter(gl.LINE_WIDTH), 1, michael@0: "The stroke weight wasn't applied with the correct default value."); michael@0: michael@0: michael@0: ok(isApproxVec(renderer.projMatrix, [ michael@0: 1.2071068286895752, 0, 0, 0, 0, -2.4142136573791504, 0, 0, 0, 0, michael@0: -1.0202020406723022, -1, -181.06602478027344, 181.06602478027344, michael@0: 148.14492797851562, 181.06602478027344 michael@0: ]), "The default perspective projection matrix wasn't set correctly."); michael@0: michael@0: ok(isApproxVec(renderer.mvMatrix, [ michael@0: 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 michael@0: ]), "The default model view matrix wasn't set correctly."); michael@0: }