Debian Codegraph @

examples/example_glfw_wgpu/web/index.html

raw
1 <!doctype html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
6 <title>Dear ImGui Emscripten+GLFW+WebGPU example</title>
7 <style>
8 body { margin: 0; background-color: black }
9 .emscripten {
10 position: absolute;
11 top: 0px;
12 left: 0px;
13 margin: 0px;
14 border: 0;
15 width: 100%;
16 height: 100%;
17 overflow: hidden;
18 display: block;
19 image-rendering: optimizeSpeed;
20 image-rendering: -moz-crisp-edges;
21 image-rendering: -o-crisp-edges;
22 image-rendering: -webkit-optimize-contrast;
23 image-rendering: optimize-contrast;
24 image-rendering: crisp-edges;
25 image-rendering: pixelated;
26 -ms-interpolation-mode: nearest-neighbor;
27 }
28 </style>
29 </head>
30 <body>
31 <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
32 <script type='text/javascript'>
33 var Module;
34 (async () => {
35 Module = {
36 preRun: [],
37 postRun: [],
38 print: (function() {
39 return function(text) {
40 text = Array.prototype.slice.call(arguments).join(' ');
41 console.log(text);
42 };
43 })(),
44 printErr: function(text) {
45 text = Array.prototype.slice.call(arguments).join(' ');
46 console.error(text);
47 },
48 canvas: (function() {
49 var canvas = document.getElementById('canvas');
50 //canvas.addEventListener("webglcontextlost", function(e) { alert('FIXME: WebGL context lost, please reload the page'); e.preventDefault(); }, false);
51 return canvas;
52 })(),
53 setStatus: function(text) {
54 console.log("status: " + text);
55 },
56 monitorRunDependencies: function(left) {
57 // no run dependencies to log
58 }
59 };
60 window.onerror = function() {
61 console.log("onerror: " + event);
62 };
63
64 // Initialize the graphics adapter
65 {
66 if (!navigator.gpu) {
67 throw Error("WebGPU not supported.");
68 }
69
70 const adapter = await navigator.gpu.requestAdapter();
71 const device = await adapter.requestDevice();
72 Module.preinitializedWebGPUDevice = device;
73 }
74
75 {
76 const js = document.createElement('script');
77 js.async = true;
78 js.src = "index.js";
79 document.body.appendChild(js);
80 }
81 })();
82 </script>
83 </body>
84 </html>