shell.emscripten.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <!--
  2. Note: see the shell.emscripten.html in this folder:
  3. we are using a custom shell, that calls coi-serviceworker.js
  4. coi-serviceworker.js was found at https://github.com/gzuidhof/coi-serviceworker, and manually patched:
  5. see https://github.com/gzuidhof/coi-serviceworker/issues/20
  6. and https://github.com/gzuidhof/coi-serviceworker/compare/master...tamo:coi-serviceworker:coep-ua-brand
  7. coi-serviceworker.js provides Cross-origin isolation (COOP and COEP) through a service worker
  8. for situations in which you can't control the headers (e.g. GitHub pages).
  9. We are also using goatcounter for simple stats
  10. -->
  11. <!doctype html>
  12. <html lang="en-us">
  13. <head>
  14. <meta charset="utf-8">
  15. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
  16. <script data-goatcounter="https://pthom-imgui-bundle.goatcounter.com/count"
  17. async src="//gc.zgo.at/count.js"></script>
  18. <title>ImGui Bundle Demo</title>
  19. <style>
  20. body { margin: 0; background-color: black }
  21. .emscripten {
  22. position: absolute;
  23. top: 0px;
  24. left: 0px;
  25. margin: 0px;
  26. border: 0;
  27. width: 100%;
  28. height: 100%;
  29. overflow: hidden;
  30. display: block;
  31. image-rendering: optimizeSpeed;
  32. image-rendering: -moz-crisp-edges;
  33. image-rendering: -o-crisp-edges;
  34. image-rendering: -webkit-optimize-contrast;
  35. image-rendering: optimize-contrast;
  36. image-rendering: crisp-edges;
  37. image-rendering: pixelated;
  38. -ms-interpolation-mode: nearest-neighbor;
  39. }
  40. #loading-overlay {
  41. position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  42. background: black;
  43. display: flex; flex-direction: column;
  44. align-items: center; justify-content: center;
  45. z-index: 10;
  46. }
  47. #loading-spinner {
  48. width: 48px; height: 48px;
  49. border: 4px solid #333; border-top-color: #999;
  50. border-radius: 50%;
  51. animation: spin 0.8s linear infinite;
  52. }
  53. #loading-status {
  54. color: #999; margin-top: 16px; font-family: sans-serif; font-size: 14px;
  55. }
  56. @keyframes spin { to { transform: rotate(360deg); } }
  57. </style>
  58. </head>
  59. <body>
  60. <div id="loading-overlay">
  61. <div id="loading-spinner"></div>
  62. <div id="loading-status">Loading...</div>
  63. </div>
  64. <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
  65. <!-- Call coi-serviceworker at startup -->
  66. <script src="coi-serviceworker.js"></script>
  67. <script type='text/javascript'>
  68. var Module = {
  69. preRun: [],
  70. postRun: [],
  71. print: (function() {
  72. return function(text) {
  73. text = Array.prototype.slice.call(arguments).join(' ');
  74. console.log(text);
  75. };
  76. })(),
  77. printErr: function(text) {
  78. text = Array.prototype.slice.call(arguments).join(' ');
  79. console.error(text);
  80. },
  81. canvas: (function() {
  82. var canvas = document.getElementById('canvas');
  83. canvas.addEventListener("webglcontextlost", function(e) {
  84. alert('WebGL context lost, please reload the page');
  85. e.preventDefault();
  86. }, false);
  87. // Explicitly create a WebGL 2 context with stencil buffer enabled.
  88. if (typeof WebGL2RenderingContext !== 'undefined') {
  89. var gl = canvas.getContext('webgl2', { stencil: true });
  90. if (!gl) {
  91. console.error('WebGL 2 not available, falling back to WebGL');
  92. gl = canvas.getContext('webgl', { stencil: true });
  93. }
  94. if (!gl) {
  95. alert('WebGL not available with stencil buffer');
  96. }
  97. return canvas;
  98. } else {
  99. alert('WebGL 2 not supported by this browser');
  100. }
  101. })(),
  102. setStatus: function(text) {
  103. console.log("status: " + text);
  104. var overlay = document.getElementById('loading-overlay');
  105. if (overlay) {
  106. if (!text || text === '') {
  107. overlay.remove();
  108. } else {
  109. var display = text.replace(/\((\d+)\/(\d+)\)/, function(_, a, b) {
  110. return '(' + (a / 1024 | 0) + ' KB / ' + (b / 1024 | 0) + ' KB)';
  111. });
  112. document.getElementById('loading-status').innerText = display;
  113. }
  114. }
  115. },
  116. monitorRunDependencies: function(left) {
  117. var el = document.getElementById('loading-status');
  118. if (el && left > 0) el.innerText = 'Initializing...';
  119. }
  120. };
  121. window.onerror = function() {
  122. console.log("onerror: " + event);
  123. };
  124. </script>
  125. {{{ SCRIPT }}}
  126. </body>
  127. </html>