Browse Source

Improved Detector.js a bit more.

Mr.doob 14 years ago
parent
commit
847276d4a0
1 changed files with 15 additions and 22 deletions
  1. 15 22
      examples/js/Detector.js

+ 15 - 22
examples/js/Detector.js

@@ -6,18 +6,28 @@
 Detector = {
 
 	canvas : !! window.CanvasRenderingContext2D,
-	webgl : !! window.WebGLRenderingContext,
-	webglGfxCard : ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )(),
+	webgl : ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )(),
 	workers : !! window.Worker,
 	fileapi : window.File && window.FileReader && window.FileList && window.Blob,
 
 	getWebGLErrorMessage : function () {
 
-		var html;
+		var domElement = document.createElement( 'div' );
+
+		domElement.style.fontFamily = 'monospace';
+		domElement.style.fontSize = '13px';
+		domElement.style.textAlign = 'center';
+		domElement.style.background = '#eee';
+		domElement.style.color = '#000';
+		domElement.style.padding = '1em';
+		domElement.style.width = '475px';
+		domElement.style.margin = '5em auto 0';
 
 		if ( ! this.webgl ) {
 
-			html = [
+			domElement.innerHTML = window.WebGLRenderingContext ? [
+				'Sorry, your graphics card doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a>'
+			].join( '\n' ) : [
 				'Sorry, your browser doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a><br/>',
 				'Please try with',
 				'<a href="http://www.google.com/chrome">Chrome 10</a>, ',
@@ -25,26 +35,9 @@ Detector = {
 				'<a href="http://nightly.webkit.org/">Safari 6</a>'
 			].join( '\n' );
 
-		} else if ( ! this.webglGfxCard ) {
-
-			html = [
-				'Sorry, your browser supports <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a><br/> but you may need to upgrade your graphics card.'
-			].join( '\n' );
-
 		}
 
-		var msg = document.createElement( 'div' );
-		msg.style.fontFamily = 'monospace';
-		msg.style.fontSize = '13px';
-		msg.style.textAlign = 'center';
-		msg.style.background = '#eee';
-		msg.style.color = '#000';
-		msg.style.padding = '1em';
-		msg.style.width = '475px';
-		msg.style.margin = '5em auto 0';
-		msg.innerHTML = html;
-
-		return msg;
+		return domElement;
 
 	},