Skip to content

Commit

Permalink
IE11 supports Stencil Buffer! Its back on the cards..
Browse files Browse the repository at this point in the history
autoDetect will now return the webGL renderer in ie11 if available.
added PIXI.autoDetectRecommendedRenderer function
  • Loading branch information
GoodBoyDigital committed Apr 11, 2014
1 parent 7480234 commit 559a9fa
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions src/pixi/utils/Detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,48 @@ PIXI.autoDetectRenderer = function(width, height, view, transparent, antialias)
}
} )();

// IE11 is still a little to unstable to be the recommended renderer
var isIE11 = !!navigator.userAgent.match(/Trident.*rv[ :]*11\./);

if( webgl && !isIE1 )
if( webgl )
{
return new PIXI.WebGLRenderer(width, height, view, transparent, antialias);
}

return new PIXI.CanvasRenderer(width, height, view, transparent);
};

/**
* This helper function will automatically detect which renderer you should be using.
* This function is very similar to the autoDetectRenderer function except that is will return a canvas renderer for android.
* Even thought both android chrome suports webGL the canvas implementation perform better at the time of writing.
* This function will likely change and update as webGL performance imporoves on thease devices.
* @class getRecommendedRenderer
* @static
* @param width=800 {Number} the width of the renderers view
* @param height=600 {Number} the height of the renderers view
* @param [view] {Canvas} the canvas to use as a view, optional
* @param [transparent=false] {Boolean} the transparency of the render view, default false
* @param [antialias=false] {Boolean} sets antialias (only applicable in webGL chrome at the moment)
*
*/
PIXI.autoDetectRecommendedRenderer = function(width, height, view, transparent, antialias)
{
if(!width)width = 800;
if(!height)height = 600;

// BORROWED from Mr Doob (mrdoob.com)
var webgl = ( function () { try {
var canvas = document.createElement( 'canvas' );
return !! window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) );
} catch( e ) {
return false;
}
} )();

var isAndroid = /Android/i.test(navigator.userAgent);

if( webgl && !isAndroid)
{
return new PIXI.WebGLRenderer(width, height, view, transparent, antialias);
}

return new PIXI.CanvasRenderer(width, height, view, transparent);
}

0 comments on commit 559a9fa

Please sign in to comment.