From 54f6f8355e919d30e3c2311a5537ae40686b7c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?charlotte=20=F0=9F=8C=B8?= Date: Sat, 25 Apr 2026 12:57:19 -0700 Subject: [PATCH] First iteration always draws. --- crates/processing_pyo3/src/lib.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/processing_pyo3/src/lib.rs b/crates/processing_pyo3/src/lib.rs index af5324e..566485a 100644 --- a/crates/processing_pyo3/src/lib.rs +++ b/crates/processing_pyo3/src/lib.rs @@ -55,7 +55,7 @@ impl Default for LoopState { fn default() -> Self { Self { looping: true, - redraw_requested: true, + redraw_requested: false, } } } @@ -915,6 +915,7 @@ mod mewnala { return Ok(()); } let draw_fn_ref = draw_fn.as_mut().expect("checked above"); + let mut first_frame = true; loop { { @@ -939,6 +940,7 @@ mod mewnala { *draw_fn_ref = locals.get_item("draw").unwrap().unwrap(); globals = draw_fn_ref.getattr("__globals__")?; reset_tracked_globals(); + first_frame = true; dbg!(locals); } @@ -950,15 +952,17 @@ mod mewnala { dispatch_event_callbacks(&locals)?; - let should_draw = LOOP_STATE.with(|s| { - let state = s.get(); - state.looping || state.redraw_requested - }); + let should_draw = first_frame + || LOOP_STATE.with(|s| { + let state = s.get(); + state.looping || state.redraw_requested + }); if !should_draw { std::thread::sleep(std::time::Duration::from_millis(16)); continue; } + first_frame = false; get_graphics_mut(module)? .ok_or_else(|| PyRuntimeError::new_err("call size() first"))?