macroquad is a free, open source gaming project written in Rust and released under Apache-2.0. It has 4,651 GitHub stars, 426 forks and 340 open issues, and was last pushed 2 months ago. On this registry it ranks #33 of 50 tracked projects in Gaming, with 5 head-to-head comparisons available.

What is macroquad?

macroquad is a cross-platform game library for Rust, aimed at developers who want to write one codebase and ship it to Windows, Linux, macOS, HTML5, Android, and iOS.

What it is

macroquad is a simple, easy-to-use game library for the Rust programming language, heavily inspired by raylib. It is distributed as an ordinary crates.io dependency (macroquad = "0.4") and lives in the Rust game-development ecosystem, where it is positioned as a lightweight alternative to heavier engines: the project explicitly markets a minimal amount of dependencies, noting that a build after cargo clean takes only 16 seconds on an x230, a laptop roughly six years old.

The concrete problem it solves is multi-platform friction. Rather than maintaining separate build configurations per target, macroquad runs the same code on all supported platforms with no platform-dependent defines required, and it covers PC (Windows/Linux/macOS), HTML5, Android, and iOS from a single source tree. It replaces the per-platform build and packaging choreography with single-command deployment for both WASM and Android, and it bundles an immediate-mode UI library so a project does not need to pull in a separate interface toolkit.

Key capabilities

  • Consistent behaviour across platforms with no platform-dependent defines, covering Windows, Linux, macOS, HTML5, Android, and iOS.
  • Efficient 2D rendering with automatic geometry batching.
  • An included immediate-mode UI library.
  • Single-command deploy for both WASM and Android.
  • A minimal dependency tree, with a full build after cargo clean taking 16 seconds on an x230 laptop.
  • Cross-compilation to Windows from Linux via rustup target add x86_64-pc-windows-gnu and cargo run --target x86_64-pc-windows-gnu, alongside native MSVC and GNU support on Windows with no additional dependencies.
  • An async/await programming model in which frames advance through next_frame().await under the #[macroquad::main("BasicShapes")] entry-point attribute.

Who uses it and how

  • Rust developers writing 2D games and drawing primitives (draw_line, draw_rectangle, draw_circle, draw_text) who want one codebase to reach desktop, web, and mobile.
  • Web-focused developers who build with rustup target add wasm32-unknown-unknown, producing a .wasm file under target/wasm32-unknown-unknown/ that is loaded by an index.html and served locally with cargo install basic-http-server followed by basic-http-server ..
  • Mobile developers packaging iOS builds by creating a MyGame.app directory with an Info.plist, then installing and launching it through xcrun simctl install and xcrun simctl launch on the simulator, with provisioning guidance published at macroquad.rs/articles/ios/.
  • Linux developers who install system prerequisites first — for example pkg-config libx11-dev libxi-dev libgl1-mesa-dev libasound2-dev on Ubuntu, the equivalent dnf packages on Fedora, or pacman -S pkg-config libx11 libxi mesa-libgl alsa-lib on Arch.

Getting started

Create an empty project with cargo init --bin, add macroquad = "0.4" to the [dependencies] section of Cargo.toml, write a main.rs using macroquad::prelude::*, and run it natively with cargo run.

How it compares

macroquad names raylib as its direct inspiration, and it deliberately mirrors raylib's approach of a small C-style game library rather than a full scene-graph engine, but implemented as a Rust crate consumed through Cargo. That positioning means it competes on Rust idioms and dependency economy instead of on bundled tooling, which suits developers already committed to the Rust toolchain.

When to use it — and when not to

On Linux a self-hoster or developer must provide the platform libraries themselves (X11, Xi, Mesa GL, and ALSA dev packages), and iOS use requires the Xcode simulator and provisioning workflow rather than a single command. The project carries 340 open issues, so a team needing tightly triaged support should expect to read through a substantial backlog before adopting it, and the documentation published for the current series sits at version 0.4.5 on docs.rs.

project readme (upstream, from github) — read inline

macroquad

Github Actions Docs Crates.io version Discord chat

macroquad is a simple and easy to use game library for Rust programming language, heavily inspired by raylib.

Features

  • Same code for all supported platforms, no platform dependent defines required.
  • Efficient 2D rendering with automatic geometry batching.
  • Minimal amount of dependencies: build after cargo clean takes only 16s on x230(~6 years old laptop).
  • Immediate mode UI library included.
  • Single command deploy for both WASM and Android.

Supported Platforms

  • PC: Windows/Linux/macOS;
  • HTML5;
  • Android;
  • IOS.

Build Instructions

Setting Up a Macroquad Project

Macroquad is a normal rust dependency, therefore an empty macroquad project may be created with:

# Create empty cargo project
cargo init --bin

Add macroquad as a dependency to Cargo.toml:


[dependencies]
macroquad = "0.4"

Put some macroquad code in src/main.rs:

use macroquad::prelude::*;

#[macroquad::main("BasicShapes")]
async fn main() {
    loop {
        clear_background(RED);

        draw_line(40.0, 40.0, 100.0, 200.0, 15.0, BLUE);
        draw_rectangle(screen_width() / 2.0 - 60.0, 100.0, 120.0, 60.0, GREEN);
        draw_circle(screen_width() - 30.0, screen_height() - 30.0, 15.0, YELLOW);

        draw_text("IT WORKS!", 20.0, 20.0, 30.0, DARKGRAY);

        next_frame().await
    }
}

And to run it natively:

cargo run

For more examples take a look at Macroquad examples folder

Linux

# ubuntu system dependencies
apt install pkg-config libx11-dev libxi-dev libgl1-mesa-dev libasound2-dev

# fedora system dependencies
dnf install libX11-devel libXi-devel mesa-libGL-devel alsa-lib-devel

# arch linux system dependencies
pacman -S pkg-config libx11 libxi mesa-libgl alsa-lib

Windows

On windows both MSVC and GNU target are supported, no additional dependencies required.

Also cross-compilation to windows from linux is supported:

rustup target add x86_64-pc-windows-gnu

cargo run --target x86_64-pc-windows-gnu

WASM

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

This will produce .wasm file in target/wasm32-unknown-unknown/debug/CRATENAME.wasm or in target/wasm32-unknown-unknown/release/CRATENAME.wasm if built with --release.

And then use the following .html to load it:

index.html
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>TITLE</title>
    <style>
        html,
        body,
        canvas {
            margin: 0px;
            padding: 0px;
            width: 100%;
            height: 100%;
            overflow: hidden;
            position: absolute;
            background: black;
            z-index: 0;
        }
    </style>
</head>

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

</html>

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

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

IOS

To run on the simulator:

mkdir MyGame.app
cargo build --target x86_64-apple-ios --release
cp target/x86_64-apple-ios/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">
<dict>
<key>CFBundleExecutable</key>
<string>mygame</string>
<key>CFBundleIdentifier</key>
<string>com.mygame</string>
<key>CFBundleName</key>
<string>mygame</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
</dict>
</plist>
EOF

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/

Tips Adding the following snippet to your Cargo.toml ensures that all dependencies compile in release even in debug mode. In macroquad, this has the effect of making images load several times faster and your applications much more performant, while keeping compile times miraculously low.
[profile.dev.package.'*']
opt-level = 3

async/await

While macroquad attempts to use as few Rust-specific concepts as possible, .await in all examples looks a bit scary. Rust's async/await is used to solve just one problem - cross platform main loop organization.

Details

The problem: on WASM and android it's not really easy to organize the main loop like this:

fn main() {
    // do some initialization

    // start main loop
    loop {
        // handle input

        // update logic

        // draw frame
    }
}

It is fixable on Android with threads, but on web there is not way to "pause" and "resume" WASM execution, so no WASM code should block ever. While that loop is blocking for the entire game execution! The C++ solution for that problem: https://kripken.github.io/blog/wasm/2019/07/16/asyncify.html

But in Rust we have async/await. Rust's futures are basically continuations - future's stack may be stored into a variable to pause/resume execution of future's code at a later point.

async/await support in macroquad comes without any external dependencies - no runtime, no executors and futures-rs is not involved. It's just a way to preserve main's stack on WASM and keep the code cross platform without any WASM-specific main loop.

Community

  • Quads Discord server - a place to chat with the library's devs and other community members.
  • Awesome Quads - a curated list of links to miniquad/macroquad-related code & resources.

Platinum sponsors

Macroquad is supported by:

SourceGear

Frequently asked questions

Is macroquad free to use?

macroquad is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does macroquad do?

Cross-platform game engine in Rust.

What is macroquad written in?

macroquad is primarily written in Rust. Its source is publicly available at https://github.com/not-fl3/macroquad, and it has 4,651 GitHub stars.