Newer
Older
pixi.js / src / pixi / utils / Detector.js
@Mat Groves Mat Groves on 20 Mar 2013 1 KB Interactivity Added
/**
 * @author Mat Groves http://matgroves.com/ @Doormat23
 */

/**
 * This helper function will automatically detect which renderer you should be using.
 * WebGL is the preferred renderer as it is a lot fastest. If webGL is not supported by the browser then this function will return a canvas renderer
 * @method autoDetectRenderer
 * @static
 * @param width {Number} the width of the renderers view
 * @param height {Number} the height of the renderers view
 * @param view {Canvas} the canvas to use as a view, optional
 */
PIXI.autoDetectRenderer = function(width, height, view)
{
	if(!width)width = 800;
	if(!height)height = 600;
	
	// BORROWED from Mr Doob (mrdoob.com)
	var webgl = ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )()
	
	//console.log(webgl);
	if( webgl )
	{
<<<<<<< HEAD
		return new PIXI.WebGLRenderer(width, height, view) 
=======
		return new PIXI.WebGLRenderer(width, height, view)  
>>>>>>> Interactivity Added
	}
	
	return	new PIXI.CanvasRenderer(width, height, view);
}