Skip to content
Merged
Changes from all commits
Commits
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
14 changes: 9 additions & 5 deletions crates/processing_pyo3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Default for LoopState {
fn default() -> Self {
Self {
looping: true,
redraw_requested: true,
redraw_requested: false,
}
}
}
Expand Down Expand Up @@ -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 {
{
Expand All @@ -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);
}
Expand All @@ -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"))?
Expand Down
Loading