deltaphc / raylib-rs

Rust bindings for raylib
Other
715 stars 123 forks source link

Can't access RaylibHandle while holding RaylibDrawHandle #156

Closed mhcerri closed 1 year ago

mhcerri commented 1 year ago

The way the lib was designed to use RAII with mutable references makes impossible to write anything a bit more complex than simple examples.

For instance:

let mut d = rl.begin_drawing(&thread);
let t = rl.get_frame_time(); // That will fail to compile
current_scene.draw(&rl, &mut d); // That will fail too

This make impossible to setup the drawing context, for example to draw to a texture, and delegate the composition to something else, because you can't access the raylib API anymore while holding a a RaylibDrawHandle or any similar type.