| Crates.io | termgpu |
| lib.rs | termgpu |
| version | 0.1.0 |
| created_at | 2025-06-09 21:01:50.09906+00 |
| updated_at | 2025-06-09 21:01:50.09906+00 |
| description | A GPU-accelerated terminal graphics engine for Rust, enabling real-time 3D rendering in the terminal. |
| homepage | https://github.com/yourusername/termgpu |
| repository | https://github.com/yourusername/termgpu |
| max_upload_size | |
| id | 1706390 |
| size | 142,410 |
A GPU-accelerated terminal graphics engine for Rust, enabling real-time rendering of 3D graphics directly in your terminal. Built on top of wgpu and crossterm, termgpu brings modern rendering techniques to the command line.
(WIP)Render a rotating triangle in your terminal:
use std::time::Duration;
use termgpu::prelude::*;
fn main() {
let mut app = TermApp::new(Duration::from_millis(20));
let mut triangle = Triangle::default();
triangle.update(app.renderer_mut());
let mut transform = Transform::identity();
let mut direction = -1.0;
let pipeline = Pipeline::new_render(app.renderer(), &RenderPipelineDescriptor {
shader: include_wgsl!("basic.wgsl"),
bindings: &[],
label: "Basic pipeline",
use_vertices: true,
surface_formats: &[TextureFormat::Rgba8Unorm]
});
app.run(|event: Event| {
match event {
Event::Resize(size) => {
// Handle resize if needed
},
Event::Input(input) => {
if input.kind == KeyEventKind::Press {
match input.code {
KeyCode::Esc => exit(),
KeyCode::Char(' ') => direction *= -1.0,
_ => {}
}
}
},
Event::Update => {
// Animate rotation
transform.rotation *= glm::quat_angle_axis(
0.05 * direction,
&glm::Vec3::z()
);
},
Event::Render(renderer) => {
let canvas = renderer.canvas();
let canvases: &[&dyn RenderSurface] = &[&canvas];
let mut ctx = renderer.draw_ctx();
{
let mut render_pass = ctx.render_pass(canvases, renderer.depth_texture());
render_pass.draw(renderer, DrawDescriptor {
drawable: Some(&triangle),
instance_data: Some(&transform),
pipeline: &pipeline,
shader_resources: &[],
});
}
ctx.apply(canvas, renderer);
},
Event::DrawUi(_ctx) => {
// Draw UI overlays here (WIP)
},
}
});
}
See examples/basic.rs for the full example.
[dependencies]
termgpu = { path = "." }
cargo run --example basic
Basic 3D rendering in terminal
Input and resize handling
Compute shader support
UI widgets (labels, buttons, overlays)
More mesh primitives and materials
This project is licensed under the Unlicense License. See the LICENSE file for details.