Miniquad
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;
- Linux, OpenGL 3, GLES 2, GLES 3;
- macOS, OpenGL 3;
- iOS, GLES 2, GLES 3;
- WASM, WebGL 1 - tested on iOS Safari, Firefox, Chrome;
- Android, GLES 2, GLES 3.
Not Supported, but Desirable Platforms
- Metal. For both macOS and iOS metal rendering backend next to opengl one is highly desirable. But I just dont have any macOS capable hardware to start working on it :/
Examples
examples/quad.rs: web demo examples/offscreen.rs: web demo
PonasKovas/miniquad-mandelbrot: web demo
Building examples
Linux
On NixOS Linux you can use shell.nix
to start a development
environment where Miniquad can be built and run.
Windows
# both MSVC and GNU target is supported:
# or
WASM
And then use the following .html to load .wasm:
<!-- Minified and statically hosted version of https://github.com/not-fl3/miniquad/blob/master/native/sapp-wasm/js/gl.js -->
<!-- Your compiled wasm file -->
TITLE
One of the ways to server static .wasm and .html:
cargo install basic-http-server
basic-http-server .
Android
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.
iOS
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
CFBundleExecutable
mygame
CFBundleIdentifier
com.mygame
CFBundleName
mygame
CFBundleVersion
1
CFBundleShortVersionString
1.0
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/
Cross Compilation
# windows target from linux host:
# this is how windows builds are tested from linux machine:
Goals
-
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.
Non-goals
-
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: