sawine@6: /* sawine@6: * Copyright 2010, Google Inc. sawine@6: * All rights reserved. sawine@6: * sawine@6: * Redistribution and use in source and binary forms, with or without sawine@6: * modification, are permitted provided that the following conditions are sawine@6: * met: sawine@6: * sawine@6: * * Redistributions of source code must retain the above copyright sawine@6: * notice, this list of conditions and the following disclaimer. sawine@6: * * Redistributions in binary form must reproduce the above sawine@6: * copyright notice, this list of conditions and the following disclaimer sawine@6: * in the documentation and/or other materials provided with the sawine@6: * distribution. sawine@6: * * Neither the name of Google Inc. nor the names of its sawine@6: * contributors may be used to endorse or promote products derived from sawine@6: * this software without specific prior written permission. sawine@6: * sawine@6: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS sawine@6: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT sawine@6: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR sawine@6: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT sawine@6: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, sawine@6: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT sawine@6: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, sawine@6: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY sawine@6: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT sawine@6: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE sawine@6: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. sawine@6: */ sawine@6: sawine@6: sawine@6: /** sawine@6: * @fileoverview This file contains functions every webgl program will need sawine@6: * a version of one way or another. sawine@6: * sawine@6: * Instead of setting up a context manually it is recommended to sawine@6: * use. This will check for success or failure. On failure it sawine@6: * will attempt to present an approriate message to the user. sawine@6: * sawine@6: * gl = WebGLUtils.setupWebGL(canvas); sawine@6: * sawine@6: * For animated WebGL apps use of setTimeout or setInterval are sawine@6: * discouraged. It is recommended you structure your rendering sawine@6: * loop like this. sawine@6: * sawine@6: * function render() { sawine@6: * window.requestAnimFrame(render, canvas); sawine@6: * sawine@6: * // do rendering sawine@6: * ... sawine@6: * } sawine@6: * render(); sawine@6: * sawine@6: * This will call your rendering function up to the refresh rate sawine@6: * of your display but will stop rendering if your app is not sawine@6: * visible. sawine@6: */ sawine@6: sawine@6: WebGLUtils = function() { sawine@6: sawine@6: /** sawine@6: * Creates the HTLM for a failure message sawine@6: * @param {string} canvasContainerId id of container of th sawine@6: * canvas. sawine@6: * @return {string} The html. sawine@6: */ sawine@6: var makeFailHTML = function(msg) { sawine@6: return '' + sawine@6: '
' +
sawine@6: ' ' +
sawine@6: ' ' +
sawine@6: '' + msg + ' ' +
sawine@6: ' |