Skip to main content

Deno Window Manager

Tags Doc Checks License Sponsor

Cross-platform window management library for Deno.

Example

import { createWindow, mainloop } from "https://deno.land/x/dwm@0.2.1/mod.ts";

const win = createWindow({
  title: "Hello World",
  width: 800,
  height: 600,
  resizable: true,
  // To create OpenGL context, set the version:
  glVersion: "v3.3",
  // By default, no Client API is used.
});

// For OpenGL:
// By default, context is made current when window is created
// You can also make it current manually
win.makeContextCurrent();

// You can also create Vulkan Surface using:
const surfaceKHR = win.createSurface(instancePointer);

// Many DOM events are supported, such as:

addEventListener("resize", (event) => {
  console.log("Window resized", event.width, event.height);
});

await mainloop(() => {
  // drawing logic ...

  // For OpenGL, you have to call this:
  win.swapBuffers();
});

For drawing, you can use:

To package your application you can use:

See examples.

Usage

Since this module depends on unstable FFI API, you need to pass --unstable along with --allow-ffi, --allow-write and --allow-env.

deno run --unstable --allow-ffi --allow-write --allow-env <file>

Maintainers

License

Apache-2.0 licensed.

Copyright 2023 © The Deno Windowing Team