1
0

Detector.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * @author alteredq / http://alteredqualia.com/
  3. * @author mr.doob / http://mrdoob.com/
  4. */
  5. Detector = {
  6. canvas : !! window.CanvasRenderingContext2D,
  7. webgl : ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )(),
  8. workers : !! window.Worker,
  9. fileapi : window.File && window.FileReader && window.FileList && window.Blob,
  10. getWebGLErrorMessage : function () {
  11. var domElement = document.createElement( 'div' );
  12. domElement.style.fontFamily = 'monospace';
  13. domElement.style.fontSize = '13px';
  14. domElement.style.textAlign = 'center';
  15. domElement.style.background = '#eee';
  16. domElement.style.color = '#000';
  17. domElement.style.padding = '1em';
  18. domElement.style.width = '475px';
  19. domElement.style.margin = '5em auto 0';
  20. if ( ! this.webgl ) {
  21. domElement.innerHTML = window.WebGLRenderingContext ? [
  22. 'Sorry, your graphics card doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a>'
  23. ].join( '\n' ) : [
  24. 'Sorry, your browser doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a><br/>',
  25. 'Please try with',
  26. '<a href="http://www.google.com/chrome">Chrome</a>, ',
  27. '<a href="http://www.mozilla.com/en-US/firefox/new/">Firefox 4</a> or',
  28. '<a href="http://nightly.webkit.org/">Webkit Nightly (Mac)</a>'
  29. ].join( '\n' );
  30. }
  31. return domElement;
  32. },
  33. addGetWebGLMessage : function ( parameters ) {
  34. var parent, id, domElement;
  35. parameters = parameters || {};
  36. parent = parameters.parent !== undefined ? parameters.parent : document.body;
  37. id = parameters.id !== undefined ? parameters.id : 'oldie';
  38. domElement = Detector.getWebGLErrorMessage();
  39. domElement.id = id;
  40. parent.appendChild( domElement );
  41. }
  42. };