Skip to content

Conversation

@tychedelia
Copy link
Member

Two small changes:

  1. Pull out the run method to avoid re-entrancy. This is how I originally had it but wanted to hide it behind a method on Graphics. The problem is that running the user's sketch (i.e. draw.call0) will call back into graphics_mut for any operations, so if we are already holding a mutable borrow inside the run loop, we will blow up when we try to do anything.

There's a number of more appropriate fixes. Namely, only GlfwContext actually need to be mutably accessed through Rust. Everything else could in theory just be &self. This is a broader thing we'll want to consider. I think just switching to winit is probably the right call.

  1. Correctly decompose Graphics re: Refactor rendering crate to clarify primary Processing API #34. I just fixed the compile errors but didn't correctly pull out surface into its own object.

@tychedelia tychedelia requested a review from catilac December 10, 2025 19:33
fn run(module: &Bound<'_, PyModule>, draw_fn: Option<Py<PyAny>>) -> PyResult<()> {
get_graphics_mut(module)?.run(draw_fn)
loop {
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block ensures graphics is dropped after begin_draw but before we call the user's sketch function.

Copy link
Contributor

@catilac catilac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YAY it works. So we need to get to make sure the Entity gets dropped every frame?
Noted: Winit
Could you remove the .DS_Store file before merging?

@catilac catilac merged commit 8cea5b3 into processing:main Dec 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants