cjcliffe edited this page Oct 24, 2011 · 1 revision

CubicVR.start function

CubicVR.start provides a very simple way to start your application. For more refined startup with additional options, see the CubicVR.init function.

Note that core_vs and core_fs are typically left undefined as they will be automatically bundled with CubicVR.js when consolidated or minified. While in expanded form the paths to the core shaders will be determined automatically based on the inclusion of CubicVR.js.

If a canvas is not provided a full-browser one will be created for you with resize support. To add any object that has a .resize(x,y) method to the resize call just use CubicVR.addResizable(object). Most relevant objects such as Scene, Layout, Camera, PostProcessingChain and more already support being added to the global-resize list.

CubicVR.start( pass, fail, canvas, core_vs, core_fs )


  • pass : Function to call if successfully initialized. It will be passed the GL context and Canvas. format: function(gl,canvas).
  • fail (optional) : A function to call if WebGL init fails, optionally a string to display. A default string is used if not provided.
  • canvas (optional) : This can be the ID of a canvas in the format "#idname" or if left undefined will create it's own full-browser canvas.
  • core_vs (optional) : This can be the path to the core vertex shader, if left undefined the default path will be determined automatically.
  • core_fs (optional) : This can be the path to the core fragment shader, if left undefined the default path will be determined automatically.

Typical usage:

    <script src="../../CubicVR.js" type="text/javascript"></script>
    <script type='text/javascript'>
            function webGLStart(gl, canvas) {

                // do WebGL setup and render stuff here...
    <body onLoad="CubicVR.start(webGLStart,'Sorry, no WebGL support.');"></body>



A valid WebGL context if successful, falsey value if not.