RPS - Rust Page System
A small, opinionated page/state management system built with Rust and SDL3.
This repository contains an example application and a lightweight page manager useful for games, tools, demos, or any SDL-based application that benefits from push/pop page stacks, deterministic update/rendering, and simple resource lifetimes.
This README explains the features, the dependencies you need to build and run the project, how to get started quickly, suggested workflows, and tips for troubleshooting.
Table of contents
- Features
- Requirements
- Example usage
- Project layout
- Development notes & recommended workflow
- Contributing
- Troubleshooting
- Roadmap
- License
- Acknowledgements & References
Features
- Lightweight page system for SDL-based Rust apps
- Push/pop pages (stack-based scene management)
- Centralized input/event routing to active page(s)
- Simple render ordering (top-of-stack renders last)
- Minimal, idiomatic Rust API (designed to be easy to adapt)
- Example pages in the repository that demonstrate:
- Simple single Page with Persistent Elements and UserInputText
- Basic input handling (keyboard / mouse)
- More complex example with Multiples Pages, Persistent Elements and UserInputText
- Designed to work with SDL3 (native windowing, events, rendering, textures, fonts, images)
Requirements
-
Rust toolchain
- rustup recommended
- Stable Rust (we recommend Rust 1.70+ or the latest stable release)
-
SDL3 and optional SDL3 extensions (development headers / libraries)
- SDL3 (required) — runtime and development headers
- Optional but recommended:
- SDL3_image (for loading PNG/JPEG etc.)
- SDL3_ttf (for TrueType fonts)
- SDL3_mixer (for audio, if used)
- Note: You must install the platform-specific development packages for SDL3 and the extensions for the build to link successfully.
-
Common build tools
- cargo (comes with rustup)
- A C toolchain (gcc/clang / build essentials) to link native SDL libraries
- pkg-config (to link libraries in general)
- FontConfig (for font use)
If you need the official SDL source and instructions:
- SDL GitHub: https://github.com/libsdl-org/SDL
- SDL docs and downloads: https://www.libsdl.org/
- SDL3 Rust-Bindings Github: https://github.com/vhspace/sdl3-rs
Example usage
Below is a example of how a page system might be used. The exact API in the repository may vary slightly; use this as a guide to how the system is intended to behave. for more accurate examples you can see them here
use ;
use ;
use
;
//==========================================================================================================================================================================
//=======================================================================# main function recommended setup #===============================================================
//==========================================================================================================================================================================
//==========================================================================================================================================================================
//===============================================================# can be a different file, like: buttons_actions.rs #======================================================
//==========================================================================================================================================================================
//==========================================================================================================================================================================
//===============================================================# can be a different file, like: setup_page_data.rs #======================================================
//==========================================================================================================================================================================
//==========================================================================================================================================================================
//====================================================================# can be a different file, like: style.rs #===========================================================
//==========================================================================================================================================================================
pub const BACKGROUND_COLOR: Color = RGB;
pub const TEXT_COLOR: Color = RGB;
pub const SUBTEXT_COLOR: Color = RGB;
pub const PURPLE_COLOR: Color = RGB;
pub const PINK_COLOR: Color = RGB;
pub const ORANGE_COLOR: Color = RGB;
pub const BLACK_COLOR: Color = RGB;
pub const RED_COLOR: Color = RGB;
//==========================================================================================================================================================================
//===============================================================# can be a different file, like: pages.rs #================================================================
//==========================================================================================================================================================================
/// Defines The ID for your Pages
/// Defines The ID for your Buttons
// Define Your Pages Here:
This pattern lets you:
- Swap entire screens/pages cleanly
- Keep page-specific state encapsulated
- Easily implement pause screens, modal dialogs (by stacking pages)
Suggested Project layout
- Cargo.toml — Rust project configuration
- assets/ — images, fonts, audio used by examples (if included)
- src/
- main.rs — application entrypoint
- ui/your_pages.rs — page implementations (menu/game/demo)
- ui/style.rs — style of page elements (buttons/rects/texts)
- actions/buttons_actions.rs - actions that buttons take when pressed
Development notes & recommended workflow
- Use cargo clippy
- When adding features (audio, fonts, etc.), gate them behind Cargo features and document required system dependencies.
Suggested Cargo features (example)
- features:
- "image" => enables SDL_image usage
- "ttf" => enables SDL_ttf usage
- "audio" => enables SDL_mixer usage
Contributing
- Fork the repository, create a feature branch, and open a pull request.
- When opening PRs:
- Include a short description of the change
- Don't Run cargo fmt and run cargo clippy
- For larger proposals, open an issue first to discuss the design.
Troubleshooting
Linker errors (cannot find -lSDL3, undefined references)
- Ensure the SDL3 dev libraries are installed and visible to your linker.
- On Linux, verify pkg-config can find SDL3: pkg-config --cflags --libs sdl3
- Set PKG_CONFIG_PATH to the directory where the SDL3 .pc files are installed.
Missing headers at compile time
- Install the development package (headers). On Debian/Ubuntu that is normally libsdl3-dev (if available) or build SDL3 from source.
Runtime errors on Windows
- Make sure SDL3 DLLs are either on the PATH or next to the executable.
- Ensure you built/run with the same runtime (MSVC vs MinGW) as your SDL binaries.
Roadmap / Ideas
- Deterministic update loop with fixed timestep guidance
- Smooth transitions (fade/slide) between pages
- Resource manager for textures/fonts/sounds
- Input remapping and configurable controls
- Add more unit/integration tests for the page manager logic
License
This Project are licensed under the MIT licence. Please see the license file for more information. tl;dr you can do whatever you want as long as you include the original copyright and license notice in any copy of the software/source.
Acknowledgements & References
- SDL: https://www.libsdl.org/
- SDL GitHub: https://github.com/libsdl-org/SDL
- SDL3 Rust-Bindings: https://github.com/vhspace/sdl3-rs
- Rust: https://www.rust-lang.org/