#miniquad #graphics #rendering #binding #web #cross-platform


Part of miniquad rendering library. Binding and JS implementation of GL and sokol-app API.

26 releases

0.1.26 May 14, 2021
0.1.23 Mar 22, 2021
0.1.20 Dec 31, 2020
0.1.19 Oct 5, 2020
0.1.15 Mar 31, 2020

#176 in Graphics APIs

Download history 440/week @ 2023-12-17 277/week @ 2023-12-24 120/week @ 2023-12-31 383/week @ 2024-01-07 403/week @ 2024-01-14 348/week @ 2024-01-21 163/week @ 2024-01-28 269/week @ 2024-02-04 422/week @ 2024-02-11 530/week @ 2024-02-18 458/week @ 2024-02-25 447/week @ 2024-03-03 443/week @ 2024-03-10 569/week @ 2024-03-17 531/week @ 2024-03-24 1070/week @ 2024-03-31

2,711 downloads per month
Used in 15 crates (2 directly)


3.5K SLoC

Rust 2.5K SLoC // 0.0% comments JavaScript 1K SLoC // 0.0% comments


Github Actions Docs Crates.io version Discord chat Matrix

Miniquad is a manifestation of a dream in a world where we do not need a deep dependencies tree and thousands lines of code to draw things with a computer.

Miniquad aims to provide a graphics abstraction that works the same way on any platform with a GPU, being as light weight as possible while covering as many machines as possible.

Supported Platforms

  • Windows, OpenGL 3, OpenGL 2.2;
  • Linux, OpenGL 2.2, OpenGL 3, GLES 2, GLES 3;
  • macOS, OpenGL 3, Metal;
  • iOS, GLES 2, GLES 3, Metal;
  • WASM, WebGL 1 - tested on iOS Safari, Firefox, Chrome;
  • Android, GLES 2, GLES 3.



examples/quad.rs: web demo
examples/offscreen.rs: web demo

PonasKovas/miniquad-mandelbrot: web demo

Building examples


cargo run --example quad

On NixOS Linux you can use shell.nix to start a development environment where Miniquad can be built and run.


# both MSVC and GNU target is supported:
rustup target add x86_64-pc-windows-msvc
# or
rustup target add x86_64-pc-windows-gnu

cargo run --example quad


rustup target add wasm32-unknown-unknown
cargo build --example quad --target wasm32-unknown-unknown

And then use the following .html to load .wasm:

<html lang="en">

    <meta charset="utf-8">
        canvas {
            margin: 0px;
            padding: 0px;
            width: 100%;
            height: 100%;
            overflow: hidden;
            position: absolute;
            background: black;
            z-index: 0;

    <canvas id="glcanvas" tabindex='1'></canvas>
    <!-- Minified and statically hosted version of https://github.com/not-fl3/miniquad/blob/master/native/sapp-wasm/js/gl.js -->
    <script src="https://not-fl3.github.io/miniquad-samples/gl.js"></script>
    <script>load("quad.wasm");</script> <!-- Your compiled wasm file -->


One of the ways to server static .wasm and .html:

cargo install basic-http-server
basic-http-server .


Recommended way to build for android is using Docker.
miniquad uses slightly modifed version of cargo-apk

docker run --rm -v $(pwd)":/root/src" -w /root/src notfl3/cargo-apk cargo quad-apk build --example quad

APK file will be in target/android-artifacts/(debug|release)/apk

With "log-impl" enabled all log calls will be forwarded to adb console. No code modifications for Android required, everything should just works.


To run on the simulator:

mkdir MyGame.app
cargo build --target x86_64-apple-ios --release
cp target/release/mygame MyGame.app
# only if the game have any assets
cp -r assets MyGame.app
cat > MyGame.app/Info.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

xcrun simctl install booted MyGame.app/
xcrun simctl launch booted com.mygame

For details and instructions on provisioning for real iphone, check https://macroquad.rs/articles/ios/

Cross Compilation

# windows target from linux host:
# this is how windows builds are tested from linux machine:
rustup target add x86_64-pc-windows-gnu
cargo run --example quad --target x86_64-pc-windows-gnu


  • Fast compilation time. Right now it is ~5s from "cargo clean" for both desktop and web.

  • Cross platform. Amount of platform specific user code required should be kept as little as possible.

  • Low-end devices support.

  • Hackability. Working on your own game, highly probable some hardware incompability will be found. Working around that kind of bugs should be easy, implementation details should not be hidden under layers of abstraction.

  • Forkability. Each platform implementation is, usually, just one pure Rust file. And this file is very copy-paste friendly - it doesnt use any miniquad specific abstractions. It is very easy to just copy some part of miniquad's platform implementation and use it standalone.


  • Ultimate type safety. Library should be entirely safe in Rust's definition of safe - no UB or memory unsafety. But correct GPU state is not type guaranteed. Feel free to provide safety abstraction in the user code then!

  • High-end API, like Vulkan/DirectX 12. Take a look on gfx-rs or vulkano instead!

Platinum sponsors

Miniquad is supported by:

No runtime deps