Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge to master #218

Merged
merged 46 commits into from
Dec 27, 2024
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9b6fe7f
Improve buf doc comments and correctness
jdahlstrom Aug 10, 2024
2ceea2e
Add SDL2 frontend
jdahlstrom Jun 13, 2024
51a6c04
Improve frontend error handling
jdahlstrom Jul 21, 2024
6917fe1
Add dedicated error type to sdl2
jdahlstrom Jul 31, 2024
8b08363
Change crates demo to use sdl2
jdahlstrom Oct 9, 2024
4614b99
Add clear method to Frame
jdahlstrom Oct 9, 2024
c7cb7de
Fixup sdl2 feature for crates
jdahlstrom Dec 4, 2024
0b2f0e1
Move Debug impl for Real to correct module
jdahlstrom Dec 3, 2024
338360d
Tweak vector implementation details
jdahlstrom Dec 3, 2024
ef15a62
Add Point type
jdahlstrom Dec 3, 2024
017a57c
Impl Debug, Add, Sub, ApproxEq for Point
jdahlstrom Dec 4, 2024
b2eaf3d
Add alias, methods to Point
jdahlstrom Dec 4, 2024
2d9a345
Add Vertex2, Vertex3 type aliases
jdahlstrom Dec 4, 2024
d8c01f9
Add point-to-vec and vec-to-point conversion methods
jdahlstrom Dec 4, 2024
e4b0e2d
Index Buf with points rather than vecs
jdahlstrom Dec 4, 2024
fe8b9c0
Move lerping to its own trait Lerp
jdahlstrom Dec 7, 2024
4a089de
Add support for Bezier curves of affine types
jdahlstrom Dec 7, 2024
7f6fb60
Add preliminary matrix-point transform method
jdahlstrom Dec 4, 2024
f8bdf2f
Migrate to using points as vertex coordinates
jdahlstrom Dec 4, 2024
4b10f58
Add trait ZDiv for optional perspective correction
jdahlstrom Dec 5, 2024
557f876
Improve assert message
jdahlstrom Dec 7, 2024
0187910
Change pnm header to use Dims
jdahlstrom Dec 7, 2024
668f729
Remove lerp from Vary
jdahlstrom Dec 8, 2024
e62ad14
Use points as screen space positions
jdahlstrom Dec 4, 2024
728e77a
Use points as orthographic and viewport bounds
jdahlstrom Dec 4, 2024
a6626d5
Refactor clipping somewhat
jdahlstrom Dec 7, 2024
2930cb2
Add random distributions of points
jdahlstrom Dec 8, 2024
6a037a6
Remove RNG type parameter from Distrib for now
jdahlstrom Dec 8, 2024
3ae1785
Improve rand comments and doctests
jdahlstrom Dec 8, 2024
7ee0b1b
Add re-exports to render.rs root
jdahlstrom Dec 16, 2024
6094832
Impl Error trait unconditionally now that it's in core
jdahlstrom Dec 18, 2024
c0e0060
Rename read_from to read_obj for consistency
jdahlstrom Dec 18, 2024
36feadc
Improve obj comments and tests
jdahlstrom Dec 18, 2024
0a95bda
Add parse_pnm for consistency with OBJ loading
jdahlstrom Dec 18, 2024
1c7e9b3
Add P2 (text graymap) read support
jdahlstrom May 14, 2024
bff13e3
Fix edge case in read_pnm, improve pnm test coverage
jdahlstrom Jun 17, 2024
9bff5e4
Revamp math.rs re-exports
jdahlstrom Dec 19, 2024
4834d2b
Factor solids.rs to submodules
jdahlstrom Dec 16, 2024
b9fd2b0
Take IntoIterator rather than Vec in Lathe::new
jdahlstrom Dec 17, 2024
4ae5ecc
Add shortcut alias for run-demo
jdahlstrom Dec 20, 2024
d4a6356
Add segments parameter to Cylinder, Cone, and Capsule
jdahlstrom Dec 17, 2024
3d5f9b3
Add some missing operators and doc comments to Point
jdahlstrom Dec 22, 2024
4f8b65c
Change Distrib::samples to borrow the RNG
jdahlstrom Dec 22, 2024
e536a36
Add BezierSpline constructor from rays (point, dir pairs)
jdahlstrom Dec 8, 2024
718c4e1
Fix bug in github action
jdahlstrom Dec 23, 2024
3a31ab7
Fix embarrassing bug in Matrix::from_basis(), add tests
jdahlstrom Dec 26, 2024
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
Prev Previous commit
Next Next commit
Add clear method to Frame
jdahlstrom committed Dec 3, 2024
commit 4614b994927ac2cc763e6a4f8c41af3ad68ab166
19 changes: 19 additions & 0 deletions front/src/lib.rs
Original file line number Diff line number Diff line change
@@ -4,8 +4,10 @@ extern crate alloc;
extern crate core;

use core::time::Duration;
use retrofire_core::prelude::AsMutSlice2;

use retrofire_core::render::ctx::Context;
use retrofire_core::render::target::Framebuf;

#[cfg(feature = "minifb")]
pub mod minifb;
@@ -67,3 +69,20 @@ pub mod dims {
pub const DCI_2K_2048_1080: Dims = (2048, 1080);
pub const DCI_4K_4096_2160: Dims = (4096, 2160);
}

impl<W, C: AsMutSlice2<u32>, Z: AsMutSlice2<f32>> Frame<'_, W, Framebuf<C, Z>> {
pub fn clear(&mut self) {
if let Some(c) = self.ctx.color_clear {
// TODO Assumes pixel format
self.buf
.color_buf
.as_mut_slice2()
.fill(c.to_argb_u32());
}
if let Some(z) = self.ctx.depth_clear {
// Depth buffer contains reciprocal depth values
// TODO Assumes depth format
self.buf.depth_buf.as_mut_slice2().fill(z.recip());
}
}
}
10 changes: 2 additions & 8 deletions front/src/minifb.rs
Original file line number Diff line number Diff line change
@@ -119,14 +119,6 @@ impl Window {
if self.should_quit() {
break;
}
if let Some(c) = ctx.color_clear {
cbuf.fill(c.to_argb_u32());
}
if let Some(c) = ctx.depth_clear {
// Depth buffer contains reciprocal depth values
zbuf.fill(c.recip());
}

let frame = &mut Frame {
t: start.elapsed(),
dt: last.elapsed(),
@@ -137,6 +129,8 @@ impl Window {
win: self,
ctx: &mut ctx,
};
frame.clear();

last = Instant::now();
if let Break(_) = frame_fn(frame) {
break;
3 changes: 1 addition & 2 deletions front/src/sdl2.rs
Original file line number Diff line number Diff line change
@@ -88,13 +88,12 @@ impl<'t> Builder<'t> {
.build()?;

win.set_fullscreen(fs)?;
sdl.mouse().set_relative_mouse_mode(true);

let mut canvas = win.into_canvas();

if vsync {
canvas = canvas.present_vsync();
}

let canvas = canvas.accelerated().build()?;

let ev_pump = sdl.event_pump()?;
10 changes: 1 addition & 9 deletions front/src/wasm.rs
Original file line number Diff line number Diff line change
@@ -103,15 +103,6 @@ impl Window {
outer
.borrow_mut()
.replace(Closure::new(move |ms| {
// TODO add clear method to Framebuf?
if let Some(c) = ctx.color_clear {
cbuf.fill(c.to_argb_u32());
}
if let Some(z) = ctx.depth_clear {
// Depth buffer contains reciprocal depth values
zbuf.fill(z.recip());
}

let t = Duration::from_secs_f32(ms / 1e3);
let dt = t - t_last;
let buf = Framebuf {
@@ -125,6 +116,7 @@ impl Window {
ctx: &mut ctx,
win: &mut self,
};
frame.clear();

if let Continue(_) = frame_fn(&mut frame) {
requestAnimationFrame(inner.borrow().as_ref().unwrap());