Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
efc69e0
Fix markdown in README
jdahlstrom Oct 14, 2025
afef09e
Implement arithmetic operators for colors
jdahlstrom Jul 31, 2024
72aae1a
Make Batch generic over primitive type
jdahlstrom Jan 22, 2025
3a65434
Add Target impl for Buf<Color4>
jdahlstrom Sep 7, 2025
c8174ab
Add minimal example that renders to a file to core/lib.rs docs
jdahlstrom May 28, 2025
4c5af3d
Fix line rendering
jdahlstrom May 28, 2025
7bad43c
Switch to as_chunks now that it's stable
jdahlstrom Aug 14, 2025
86c6dbb
Add origin method to Point
jdahlstrom Oct 18, 2025
fa8380b
Add Matrix constructor from affine basis
jdahlstrom Sep 7, 2025
6c6a3c2
Add Plane::new constructor
jdahlstrom Sep 26, 2025
77d371a
Add basis type to Polar and PolarVec
jdahlstrom Oct 18, 2025
a50aa2e
Impl Default for SphericalVec and PolarVec
jdahlstrom Oct 18, 2025
09b06a0
Add several methods to Tri and Plane
jdahlstrom Sep 6, 2025
aff69b5
Use new tri() convenience constructor
jdahlstrom Oct 19, 2025
6cc3f4b
Add a few missing doctests to geom
jdahlstrom Oct 19, 2025
126ca0c
Add demo rendering to terminal with ncurses
jdahlstrom May 28, 2025
3a8921e
Add "inverse lerp" function
jdahlstrom Sep 6, 2025
c5180f6
Fix Clippy warnings
jdahlstrom Oct 17, 2025
660fb5f
Add warp method to Mesh
jdahlstrom Sep 7, 2025
f2bf85e
Refactor HSL/RGB conversions, add doctests
jdahlstrom Sep 7, 2025
d75a8e3
Fix feature gate from std to fp
jdahlstrom Oct 27, 2025
b3bffb3
Add reshape method to Buf2
jdahlstrom Sep 7, 2025
56d1682
Reformat doc comments
jdahlstrom Sep 7, 2025
096c5a7
Remove abs polyfill, now available in core
jdahlstrom Sep 7, 2025
ce406fd
Add Mat3x3::determinant()
jdahlstrom Sep 24, 2025
a354475
Add a Mat2x2 type alias and methods
jdahlstrom Sep 24, 2025
c908831
Publish mat! macro, make it more general
jdahlstrom Sep 25, 2025
9a5e603
Improve mat doc comments
jdahlstrom Sep 25, 2025
2590ae6
Impl ApproxEq for Matrix
jdahlstrom Sep 25, 2025
6f59f3c
Add examples to vec doc comments
jdahlstrom Sep 25, 2025
acaf1b3
Add Polygon type, like Polyline but closed
jdahlstrom Sep 26, 2025
600dc3d
Fixup diagram in clip comment
jdahlstrom Sep 26, 2025
4f168d9
Factor common code in Target impls to two helper functions
jdahlstrom Sep 29, 2025
7eddb5c
Add crate texture
jdahlstrom Oct 1, 2025
32b10b1
Add Build trait to build meshes with different vertex attribs
jdahlstrom Oct 1, 2025
a0103ba
Impl Build for Box
jdahlstrom Oct 28, 2025
08eb75a
Fix frontface winding to be counter-clockwise
jdahlstrom Oct 28, 2025
83f4678
Use crate texture, change floor to checkers in crates demo
jdahlstrom Oct 28, 2025
f86ec2d
Use color ops in sprites now that they exist
jdahlstrom Oct 28, 2025
b4f17cd
Add cube mapping function
jdahlstrom Oct 2, 2025
57afa68
Add a few doctests to math
jdahlstrom Oct 17, 2025
3c077f2
Document the mat! macro
jdahlstrom Oct 4, 2025
8653b43
Make Tetrahedron coords const
jdahlstrom Oct 4, 2025
105320a
Add Build impls for the platonics
jdahlstrom Oct 5, 2025
f4e3b26
Try to shrink lathe code size
jdahlstrom Oct 12, 2025
936478b
Properly normalize Octahedron normals
jdahlstrom Oct 28, 2025
d529c7c
Make platonics code cleaner
jdahlstrom Oct 28, 2025
3c3b981
Add u8->f32 color conversion methods
jdahlstrom Oct 30, 2025
01516db
Add simple directional light to crates
jdahlstrom Oct 30, 2025
fab8261
Implement loading .OBJs with attributes
jdahlstrom Oct 10, 2025
5a59ca6
Support quads in addition to triangles in .OBJs
jdahlstrom Oct 11, 2025
6ffa9fb
Improve .OBJ loader error reporting a bit
jdahlstrom Oct 11, 2025
ea3648f
Add re-export of Colorbuf to render.rs
jdahlstrom Oct 11, 2025
cb60e75
Add Apply trait for generic matrix application over vectors and points
jdahlstrom Oct 23, 2025
a53f6c9
Improve matrix doc comments
jdahlstrom Oct 29, 2025
85750c8
Add inverse method to Mat3x3 too
jdahlstrom Oct 29, 2025
dc2ab98
Make packages inherit workspace lints
jdahlstrom Nov 1, 2025
bb54893
Bump version numbers to 0.4.0-pre4
jdahlstrom Nov 2, 2025
3e26342
Depend on root Retrofire crate in demos
jdahlstrom Nov 2, 2025
22efd1a
Add uniform distribs for u32 and usize
jdahlstrom Nov 2, 2025
4c5f95b
Add uniform distrib for colors
jdahlstrom Nov 2, 2025
0f09a3c
Update READMEs, add screenshots
jdahlstrom Nov 3, 2025
81512fc
Make unintentionally private accessors public
jdahlstrom Nov 3, 2025
f306e37
Tweak framing of solids
jdahlstrom Nov 3, 2025
2578331
Make load_obj and read_obj generic too
jdahlstrom Nov 3, 2025
14764d2
WIP screenshot feature for frontends
jdahlstrom Nov 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,25 @@ resolver = "2"

[workspace.package]
edition = "2024"
version = "0.4.0-pre3"
version = "0.4.0-pre4"
authors = ["Johannes 'Sharlin' Dahlström <johannes.dahlstrom@gmail.com>"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/jdahlstrom/retrofire"
keywords = ["graphics", "gamedev", "demoscene", "retrocomputing", "rendering"]
categories = ["graphics", "game-development", "no-std"]

[workspace.lints]
clippy.manual_range_contains = "allow"
clippy.collapsible_if = "allow"

[features]
default = ["std"]
std = ["retrofire-core/std", "retrofire-geom/std"]

[dependencies]
retrofire-core = { version = "0.4.0-pre3", path = "core" }
retrofire-front = { version = "0.4.0-pre3", path = "front" }
retrofire-geom = { version = "0.4.0-pre3", path = "geom" }
retrofire-core = { version = "0.4.0-pre4", path = "core" }
retrofire-front = { version = "0.4.0-pre4", path = "front" }
retrofire-geom = { version = "0.4.0-pre4", path = "geom" }

[profile.release]
opt-level = 2
Expand Down
51 changes: 32 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

*Note: This document is best viewed on an 80-column VGA terminal.*

Retrofire is a software 3D rendering library
Retrofire is a software 3D rendering library focusing on performance,
correctness, and pedagogical value.

The Retrofire project began as a shamelessly nostalgic effort to explore
the state of graphics programming as it was in the mid-to-late 90s in
Expand Down Expand Up @@ -75,24 +76,24 @@ for custom allocators is planned in order to make `alloc` optional as well.

## Planned

- Material support
- Basic scene graph
- Hierarchical transforms

- Mipmapping and mipmap generation
- More procedural generation
- Basic animation and sequencing
- Particle simulations
- Support for more file types
* Material support
* Basic scene graph
* Hierarchical transforms
* Mipmapping and mipmap generation
* More procedural generation
* Basic animation and sequencing
* Particle simulations
* Support for more file types

# Organization

Retrofire is split into several packages:

* core: math, renderer, utilities; no-std compatible
* geom: geometric shapes, mesh builders, model loading
* front: frontends for writing simple graphical applications
* demos: binaries showcasing retrofire features
* retrofire: a metapackage that just re-exports core, geom, and front
* retrofire-core: math, renderer, utilities; no-std compatible
* retrofire-geom: geometric shapes, mesh builders, model loading
* retrofire-front: frontends for writing simple graphical applications
* retrofire-demos: binaries showcasing retrofire features.

# Dependencies

Expand All @@ -104,13 +105,25 @@ functions, the package is not fully functional unless either the `std`,
`libm`, or `mm` feature is enabled. Activating `std` additionally enables
APIs that do I/O.

The `front` package depends on either `sdl2`, `minifb`, or `wasm-bindgen`
and `web-sys`, depending on enabled features.
The `retrofire-front` package depends on either `sdl2`, `minifb`, or
`wasm-bindgen` and `web-sys`, depending on enabled features.

The `retrofire-geom` package has no external dependencies. It only requires
`alloc`; activating the optional feature `std` enables APIs that do I/O.

The `retrofire-demos` package depends on `retrofire`.

# Screenshots

The classic Stanford bunny.
![The classic Stanford bunny 3D model.](docs/bunny.jpg)

The `geom` package has no external dependencies. It only requires `alloc`;
activating the optional feature `std` enables APIs that do I/O.
A first-person mouse-and-keyboard scene with many "Rust crates" strewn on a
checkered floor.
![Many wooden crates on a plane, each with the Rust logo](docs/crates.jpg)

The `retrofire-demos` package depends on `retrofire-front`.
Ten thousand spherical particles positioned randomly in a sphere.
![Ten thousand spherical particles in random positions.](docs/sprites.jpg)

# License

Expand Down
3 changes: 3 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ fp = []
[dependencies]
libm = { version = "0.2", optional = true }
micromath = { version = "2.1", optional = true }

[lints]
workspace = true
4 changes: 3 additions & 1 deletion core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@

# Retrofire-core

Core functionality of the `retrofire` project.
Core functionality of the [`retrofire`][1] project.

Includes a math library with strongly typed points, vectors, matrices,
colors, and angles; basic geometry primitives; a software 3D renderer with
customizable shaders; with more to come.

[1]: https://crates.io/crates/retrofire

## Crate features

* `std`:
Expand Down
58 changes: 58 additions & 0 deletions core/examples/hello_tri.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use retrofire_core::geom::tri;
use retrofire_core::{prelude::*, util::*};

fn main() {
let verts = [
vertex(pt3(-1.0, 1.0, 0.0), rgb(1.0, 0.0, 0.0)),
vertex(pt3(1.0, 1.0, 0.0), rgb(0.0, 0.8, 0.0)),
vertex(pt3(0.0, -1.0, 0.0), rgb(0.4, 0.4, 1.0)),
];

#[cfg(feature = "fp")]
let shader = shader::new(
|v: Vertex3<Color3f>, mvp: &Mat4x4<ModelToProj>| {
// Transform vertex position from model to projection space
// Interpolate vertex colors in linear color space
vertex(mvp.apply(&v.pos), v.attrib.to_linear())
},
|frag: Frag<Color3f<_>>| frag.var.to_srgb().to_color4(),
);
#[cfg(not(feature = "fp"))]
let shader = shader::new(
|v: Vertex3<Color3f>, mvp: &Mat4x4<ModelToProj>| {
// Transform vertex position from model to projection space
// Interpolate vertex colors in normal sRGB color space
vertex(mvp.apply(&v.pos), v.attrib)
},
|frag: Frag<Color3f<_>>| frag.var.to_color4(),
);

let dims @ (w, h) = (640, 480);
let modelview = translate3(0.0, 0.0, 2.0).to();
let project = perspective(1.0, w as f32 / h as f32, 0.1..1000.0);
let viewport = viewport(pt2(0, h)..pt2(w, 0));

let mut framebuf = Buf2::<Color4>::new(dims);

render(
[tri(0, 1, 2)],
verts,
&shader,
&modelview.then(&project),
viewport,
&mut framebuf,
&Context::default(),
);

let center_pixel = framebuf[[w / 2, h / 2]];

if cfg!(feature = "fp") {
assert_eq!(center_pixel, rgba(150, 128, 186, 255));
} else {
assert_eq!(center_pixel, rgba(114, 102, 127, 255));
}
#[cfg(feature = "std")]
{
pnm::save_ppm("triangle.ppm", framebuf).unwrap();
}
}
Loading
Loading