Windowing support for Deno WebGPU.

Overview

deno_desktop

Windowing support for Deno WebGPU. In very early stages at the moment.

demo

Usage

const win = Deno.createWindow({
  title: "Deno Desktop",
  width: 800,
  height: 600,
  resizable: false,
  // ...
});

const surface = win.createSurface(device);

The surface object maps to the WebGPU GPUCanvasContext object. So you first configure it then render to the texture returned for each frame by getCurrentTexture. Do note that unlike web implementations, you need to call surface.present() after rendering it.

You also need to go through the event loop in order to render. Deno.eventLoop() returns Async Iterator yielding events. Mostly you'd do something like this:

for await (const event of Deno.eventLoop()) {
  if (event.type === "windowEvent" && event.windowID === win.id) {
    if (event.event.type === "closeRequested") {
      // Do any cleanup stuff before this.
      // There is an unverified bug that causes panic if we do not 
      // exit manually.
      Deno.exit(0);
    }
  } else if (event.type === "redrawRequested" && event.windowID === win.id) {
    // Render things and then present them on Window.
    renderStuff();
    surface.present();
  }
}

And finally, in order to receive redrawRequested events, call win.requestRedraw in your program's main loop.

TODO

  • Try to match Web API. Such as not having to call present.
  • Complete the winit bindings.

Notes

  • I'm currently using a fork of Deno in this. It is to export some private structs in order to extend WebGPU API. Also, the fork uses an updated version of wgpu as of now.
  • Debug builds seem to be locked at 30 fps usually, while release builds are 60 fps in same test.

License

Check LICENSE for more info.

Copyright 2021 @ DjDeveloperr

You might also like...
RTS game/engine in Rust and WebGPU
RTS game/engine in Rust and WebGPU

What is this? A real time strategy game/engine written with Rust and WebGPU. Eventually it will be able to run in a web browser thanks to WebGPU. This

Native WebGPU implementation based on gfx-hal
Native WebGPU implementation based on gfx-hal

This is an active GitHub mirror of the WebGPU implementation in Rust, which now lives in "gfx/wgpu" of Mozilla-central. Issues and pull requests are a

wgpugd: A WebGPU Graphics Device for R
wgpugd: A WebGPU Graphics Device for R

wgpugd: A WebGPU Graphics Device for R Overview What is WebGPU? WebGPU is an API that exposes the capabilities of GPU hardware. What is wgpu? As the n

A WebGPU implementation based on the excellent wgpu crate.

A WebGPU implementation based on the excellent wgpu crate.

A hardware-accelerated GPU terminal emulator powered by WebGPU, focusing to run in desktops, browsers, tvs and everywhere.
A hardware-accelerated GPU terminal emulator powered by WebGPU, focusing to run in desktops, browsers, tvs and everywhere.

Rio term tl;dr: Rio is a terminal built to run everywhere, as a native desktop applications by Rust/WebGPU or even in the browser powered by WebAssemb

Implementation of the RWKV language model in pure WebGPU/Rust.

Web-RWKV This is an implementation of the language model of RWKV in pure WebGPU. Compile and Run Install Rust. Run cargo run --release --example gen t

Game Of Life using webgpu, written in Rust
Game Of Life using webgpu, written in Rust

Game of Life using webgpu ✨ Description This is the implementation of the tutorial Your first WebGPU app in Rust where we're using webgpu to implement

🪄 Shader art using webgpu
🪄 Shader art using webgpu

✨ Shader art using webgpu ✨ This is the implementation of An introduction to Shader Art Coding in Rust using webgpu. 🔌 Setup You need: Rust compiler

Deno Foreign Function Interface.

deno_plugin_ffi (WIP & Need Help) Deno Foreign Function Interface. deno_ffi is a Deno plugin for loading and calling dynamic libraries using pure Java

On-the-fly machine code executing from Deno

jit from js Execute raw machine code from JavaScript. I hope you know what you're doing :) const inst = new Uint8Array([0xC3]); // ret const noop = ji

Foreign Function Interface Plugin for Deno.

Deno FFI Plugin to call dynamic library functions in Deno. Usage import { Library } from "https://deno.land/x/[email protected]/mod.ts"; const lib = new

The module graph logic for Deno CLI

deno_graph The module graph/dependency logic for the Deno CLI. This repository is a Rust crate which provides the foundational code to be able to buil

SDL2 module for Deno
SDL2 module for Deno

Deno SDL2 Cross platform and stable bindings to SDL2. Have fun! Features Bindings to Video, Graphics, Font and Mixer subsystems. (Uses rodio instead o

Source text parsing, lexing, and AST related functionality for Deno

Source text parsing, lexing, and AST related functionality for Deno.

Simplified glue code generation for Deno FFI libraries written in Rust.

deno_bindgen This tool aims to simplify glue code generation for Deno FFI libraries written in Rust. Quickstart # install CLI deno install -Afq -n den

 Diplo is a script runner and dependency manager made in rust mainly for Deno.
Diplo is a script runner and dependency manager made in rust mainly for Deno.

Diplo is a script runner and dependency manager made in rust mainly for Deno. Documentation Tricked.pro/diplo Installing - windows installer Features

Prototype for a Deno to npm package build tool.

dnt - Deno to Node Transform Prototype for a Deno to npm package build tool. What does this do? It takes a Deno module and creates an npm package for

Prototype for a Deno to npm package build tool.

dnt - Deno to Node Transform Prototype for a Deno to npm package build tool. What does this do? It takes a Deno module and creates an npm package for

A Secure Capability-Based Runtime for JavaScript Based on Deno
A Secure Capability-Based Runtime for JavaScript Based on Deno

Secure Runtime secure-runtime, as the name implies, is a secure runtime for JavaScript, designed for the multi-tenant serverless environment. It is an

Owner
DjDeveloper
Hi! I'm a hobby programmer, currently using JS/TS and Rust.
DjDeveloper
SDL2 module for Deno

Deno SDL2 Cross platform and stable bindings to SDL2. Have fun! Features Bindings to Video, Graphics, Font and Mixer subsystems. (Uses rodio instead o

Divy Srivastava 102 Jan 4, 2023
Prototype for a Deno to npm package build tool.

dnt - Deno to Node Transform Prototype for a Deno to npm package build tool. What does this do? It takes a Deno module and creates an npm package for

David Sherret 573 Jan 9, 2023
Prototype for a Deno to npm package build tool.

dnt - Deno to Node Transform Prototype for a Deno to npm package build tool. What does this do? It takes a Deno module and creates an npm package for

Deno Land 570 Dec 28, 2022
Examples for Deno Deploy

Deno Deploy Examples This repository contains a list of examples for Deno Deploy. fetch - Make outbound requests using the fetch() API. json_html - Re

Deno Land 118 Dec 19, 2022
Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.

Deno Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust. Features Secure by default. No file,

Derek Jones 2 Aug 13, 2022
autogen website (with Deno Core)

Kurit Static website generator ?? Warning WIP: It is still under development, so some of the features may not be developed. Project Structures graph T

null 11 Oct 16, 2023
SixtyFPS is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications. We support multiple programming languages, such as Rust, C++ or JavaScript.

SixtyFPS is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications. We support multiple programming languages, such as Rust, C++ or JavaScript.

SixtyFPS 5.5k Jan 1, 2023
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
Redirect Deno dependencies from semantic versions to the newest fitting version on deno.land/x

Deno Semver Redirect Redirect Deno dependencies from semantic versions to the newest fitting version on deno.land/x. See also this Deno Issue. How to

EdJoPaTo 8 Mar 12, 2022
A low-level windowing system geared towards making audio plugin UIs.

baseview A low-level windowing system geared towards making audio plugin UIs. baseview abstracts the platform-specific windowing APIs (winapi, cocoa,

null 155 Dec 30, 2022