Expand description
§Hoplite
A creative coding framework for Rust that gets out of your way.
Write shaders, render 3D scenes, and build visualizations with a single closure. No boilerplate, no ceremony—just code for the screen.
§Quick Start
use hoplite::*;
fn main() {
run(|ctx| {
ctx.default_font(16.0);
ctx.background_color(Color::rgb(0.1, 0.1, 0.15));
ctx.enable_mesh_rendering();
let cube = ctx.mesh_cube();
move |frame| {
// Fluent mesh builder API
frame.mesh(cube)
.at(0.0, 0.0, -5.0)
.color(Color::RED)
.draw();
frame.text(10.0, 10.0, &format!("FPS: {:.0}", frame.fps()));
}
});
}§Philosophy
- One closure, one call — Setup and frame logic live in closures. No traits to implement.
- Hot reload everything — Edit WGSL shaders and watch them update instantly.
- Escape hatches everywhere — Start simple, access the full wgpu API when needed.
- Type-safe handles —
MeshIdandTextureIdprevent mix-ups at compile time.
See the repository for full documentation and examples.
Modules§
- scene
- Scene management for Hoplite.
Structs§
- AppConfig
- Configuration options for creating a Hoplite application window.
- Assets
- Asset manager for loading and caching resources.
- Camera
- A 3D camera with position, orientation, and projection parameters.
- Color
- RGBA color with components in the range
[0.0, 1.0]. - Draw2d
- Immediate-mode 2D drawing API for sprites, text, and shapes.
- Effect
Node - Render node for full-screen shader effects.
- Effect
Pass - A fullscreen shader effect pass.
- Entity
- Lightweight unique ID, or handle, of an entity
- Font
Atlas - A font atlas containing pre-rasterized glyphs.
- FontId
- Opaque identifier for a loaded font.
- Frame
- Context provided each frame for rendering and game logic.
- Freelook
Camera - A first-person camera controller with seated and unseated modes.
- Geometry
Loader - A fluent builder for loading and transforming geometry.
- GpuContext
- Core GPU context holding wgpu resources.
- HotEffect
Node - Hot-reloadable render node for full-screen shader effects.
- HotEffect
Pass - A hot-reloadable fullscreen effect pass.
- HotPost
Process Node - Hot-reloadable render node for screen-space post-processing.
- HotPost
Process Pass - A hot-reloadable post-processing pass.
- HotShader
- A shader source that can be hot-reloaded from disk.
- HotWorld
Post Process Node - Hot-reloadable render node for world-aware post-processing.
- HotWorld
Post Process Pass - A hot-reloadable world-space post-processing pass.
- Input
- Tracks input state for keyboard and mouse across frames.
- Mat4
- A 4x4 column major matrix.
- Mesh
- GPU-resident 3D mesh geometry with vertex and index buffers.
- Mesh
Builder - Builder for configuring and drawing a 3D mesh.
- MeshId
- Type-safe handle to a mesh stored in the MeshQueue.
- Mesh
Loader - A fluent builder for loading geometry and registering it as a mesh.
- Mesh
Node - Render node for 3D mesh rendering with depth testing.
- Mesh
Pass - Mesh
Queue - Shared storage for meshes, textures, and the per-frame draw queue.
- Orbit
Camera - A camera controller that orbits around a target point.
- Panel
Builder - Builder for drawing panels with backgrounds, borders, and optional titles.
- Pending
Geometry - Geometry loading state that doesn’t require a GPU reference.
- Post
Process Node - Render node for screen-space post-processing effects.
- Post
Process Pass - A post-processing pass that samples from an input texture.
- Quat
- A quaternion representing an orientation.
- RawGeometry
- Raw geometry data before GPU upload.
- Ray
- A ray in 3D space, used for raycasting and picking.
- RayHit
- Information about a ray-collider intersection.
- Rect
- A rectangle in screen-space pixel coordinates.
- Render
Context - Execution context passed to each render node during graph traversal.
- Render
Graph - A composable render graph that executes a chain of render passes.
- Render
Graph Builder - Builder for constructing render graphs with a fluent API.
- Render
Mesh - Component for rendering a mesh on an entity.
- Render
Target - An off-screen render target used for intermediate pass results.
- Scene
Setup Context - Setup context extension for scene-based applications.
- Seated
Config - Configuration for seated mode with view constraints.
- Setup
Context - Context provided during the setup phase of a Hoplite application.
- Sprite
- A 2D sprite for UI/HUD rendering.
- Sprite
Id - Index into the sprite storage.
- Texture
- A GPU texture that can be bound to shaders.
- Texture
Id - Type-safe handle to a texture stored in the MeshQueue.
- Transform
- A 3D transformation representing position, rotation, and scale.
- Vec2
- A 2-dimensional vector.
- Vec3
- A 3-dimensional vector.
- Vec4
- A 4-dimensional vector.
- Vertex3d
- A vertex for 3D mesh rendering with position, normal, and texture coordinates.
- World
- An unordered collection of entities, each having any number of distinctly typed components
- World
Post Process Node - Render node for world-aware post-processing effects.
- World
Post Process Pass - A post-processing pass with camera uniforms for world-space effects.
Enums§
- Collider
- A collision shape for picking and hit detection.
- Freelook
Mode - Controls how the freelook camera operates.
- Geometry
Error - Errors that can occur when loading geometry.
- KeyCode
- Code representing the location of a physical key
- Mouse
Button - Describes a button of a mouse controller.
- Orbit
Mode - Controls how the orbit camera moves.
Traits§
- Render
Node - Trait for render graph nodes that can execute rendering operations.
Functions§
- run
- Run a Hoplite application with default configuration.
- run_
with_ config - Run a Hoplite application with custom window configuration.
- run_
with_ scenes - Run a Hoplite application with multiple scenes.
- run_
with_ scenes_ config - Run a scene-based application with custom window configuration.
Type Aliases§
- Mesh
Handle - Alias for
MeshId- used in ECS components. - Pick
Result - Result of a raycast against all colliders in the world.
- Texture
Handle - Alias for
TextureId- used in ECS components.