For the last couple of weeks, I've been working on developing cat-box.
The first thing I did was looking into various rendering backends. In the end, I settled on
SDL, particularly the sdl2 crate for Rust, because I felt it was simple and lightweight.
First, I created a
Game struct which stored basic window information such as dimensions and window title. I then added a
run method which took Rust's version of a function pointer. To this function I passed a reference to SDL's
EventPump structs. After that, I just called this function and updated the canvas inside a loop.
At this point, I didn't have any way to terminate the render loop. To this end, I made a
terminate method. Only one problem: I had to rely on interior mutability because Rust only lets you have one mutable reference to a thing at a time, so I couldn't let
terminate take a mutable reference to the
After this, I made a simple program which opened a window and waited for a certain key to be pressed before closing the window.