2 unstable releases
Uses new Rust 2024
new 0.2.0 | Apr 24, 2025 |
---|---|
0.1.0 | Apr 23, 2025 |
#262 in #wgpu
36 downloads per month
98KB
2K
SLoC
Wisp Game Engine
Wisp is a modern, lightweight 2D game engine written in Rust with a focus on performance and ease of use. It leverages the power of the wgpu graphics API to provide cross-platform rendering with hardware acceleration.
⚠️ Early Development Notice: Wisp is currently in very early stages of development and is not ready for production use. The API is unstable and subject to major changes. This is a work in progress (WIP) hobby project intended for experimentation and learning purposes only.
Features
Graphics
- Hardware-accelerated rendering via wgpu
- 2D primitives for drawing rectangles
- Sprite rendering with support for rotation, scaling, tinting, and sprite sheets
- Text rendering using the glyphon text rendering library
- Batch rendering for optimized drawing of multiple objects
- Texture management system for easy resource handling
Core Systems
- Input handling for keyboard and mouse with pressed/down/released states
- Window management with Winit for cross-platform support. Customizable window settings.
- Time management with delta time, fps calculation, and time since startup
- Application lifecycle management
Audio
- Sound effects and background music support
- Audio playback control (play, pause, resume, stop)
- Volume control
- Looping audio
Developer Experience
- Simple API designed for ease of use
- Structured logging with different categories for a window, renderer, audio, etc.
- Error handling with helpful messages
- Resource management for textures and audio assets
Changelog
0.2.0 (24.04.2025)
- Sprite Sheet Support: Render specific frames from a texture
- Batch Manager: Batch functionality is now encapsulated in a dedicated BatchManager
- Enhanced documentation and examples
- Various minor improvements and optimizations
Batch Rendering
Wisp employs a batch rendering system to optimize drawing operations. Instead of issuing individual draw calls for each object, similar objects are grouped together and rendered in batches:
- Rectangle batching - Combines multiple rectangle draw calls into a single operation
- Sprite batching - Groups sprite rendering for improved performance
- Text batching - Optimizes text rendering operations
This approach significantly reduces CPU overhead and improves rendering performance, especially for games with many objects on the screen simultaneously.
Getting Started
-
Add Wisp to your project using either method:
# Using cargo add cargo add wisp_rs
Or manually add to your Cargo.toml:
[dependencies] wisp_rs = "0.1.0"
-
Create a basic application:
//! The most basic wisp application
//! Creates a window and renders a color to the screen
use wisp_rs::prelude::*;
// Main struct for storing game state
struct MyGame;
impl MyGame {
// Initialize a new game instance
fn new(_ctx: &mut Context) -> Result<Self> {
// Set up initial state here
Ok(Self {})
}
}
impl AppState for MyGame {
// Update game logic each frame
fn frame(&mut self, _ctx: &mut Context, _dt: f32) -> Result<()> {
// Update game logic and input
Ok(())
}
// Draw everything to screen
fn draw(&mut self, ctx: &mut Context) -> Result<()> {
// Clear screen to black
ctx.submit(RenderCommand::Clear(Color::default()));
// Draw game objects here
Ok(())
}
}
fn main() -> Result<()> {
// Set up the window
let window = WindowBuilder::default();
// Start the game loop
Context::run(window, |ctx| MyGame::new(ctx))?;
Ok(())
}
Examples
To see Wisp in action, check out the examples directory in the repository.
basic
- Simple window creation and basic rendering
To run any example:
cargo run --example name_of_example
For instance:
cargo run --example basic
Requirements
System Requirements
- Windows 10/11, Linux, or macOS
- Graphics card with Vulkan, Metal, OpenGL, or DirectX 12 support
- Rust 1.86.0 or newer
Building from Source
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Clone and build
git clone https://github.com/91dns/wisp-rs.git
cd wisp
cargo build --release
Roadmap
- Physics integration
- UI system
- More primitives
- Particle system
- Animation support
- Simple ECS integration
- Debug tools
- More examples
License
This project is licensed under the MIT License—see the LICENSE file for details.
Acknowledgements
Wisp is built with the following amazing technologies:
Dependencies
~38–71MB
~1.5M SLoC