MCPcopy Create free account
hub / github.com/DjDeveloperr/deno_desktop / run

Method run

examples/common.js:28–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26 }
27
28 async run() {
29 this.adapter = await navigator.gpu.requestAdapter();
30 if (!this.adapter) {
31 throw new Error("No GPU adapter available!");
32 }
33
34 this.device = await this.adapter.requestDevice();
35 enableValidationErrors(this.device, true);
36
37 this.window = Deno.createWindow({
38 title: this.title,
39 width: this.width,
40 height: this.height,
41 resizable: true,
42 });
43
44 this.surface = this.window.createSurface(this.device);
45
46 this.format = this.surface.getPreferredFormat();
47 this.surface.configure({
48 format: this.format,
49 width: this.width,
50 height: this.height,
51 });
52
53 await this.init();
54
55 this.mainLoopInterval = setInterval(() => this.mainLoop(), 1000 / 60);
56
57 for await (const event of Deno.eventLoop()) {
58 await this.onEvent(event);
59 if (event.type === "windowEvent" && event.windowID === this.window.id) {
60 if (event.event.type === "closeRequested") {
61 this.cleanup();
62 Deno.exit(0);
63 } else if (event.event.type === "resized") {
64 this.width = event.event.width;
65 this.height = event.event.height;
66 this.surface.configure({
67 format: this.format,
68 width: this.width,
69 height: this.height,
70 });
71 }
72 } else if (event.type === "redrawRequested" && event.windowID === this.window.id) {
73 const texture = this.surface.getCurrentTexture();
74 const view = texture.createView();
75 const encoder = this.device.createCommandEncoder();
76 this.render(encoder, view);
77 this.device.queue.submit([encoder.finish()]);
78 this.surface.present();
79 }
80 }
81 }
82
83 cleanup() {
84 if (this.mainLoopInterval) {

Callers 3

hello_triangle.jsFile · 0.80
hello_texture.jsFile · 0.80
hello_camera.jsFile · 0.80

Calls 11

initMethod · 0.95
mainLoopMethod · 0.95
onEventMethod · 0.95
cleanupMethod · 0.95
renderMethod · 0.95
enableValidationErrorsFunction · 0.90
createSurfaceMethod · 0.80
getPreferredFormatMethod · 0.80
configureMethod · 0.80
getCurrentTextureMethod · 0.80
presentMethod · 0.80

Tested by

no test coverage detected