I'd say the first thing to try -- if I'm understanding the problem right -- is 
having one task maintain the state, and having the callbacks communicate with 
that task through channels. Does that sound feasible for what you need to 
accomplish?

Glenn

On Feb 13, 2013, at 8:26 AM, [email protected] wrote:

> I'm currently working with GLUT bindings in Rust (or I can use GLFW, doesn't 
> matter to me), and one of the main ways that GLUT (and GLFW) manage things 
> such as key presses is with callback functions. Getting a Rust function to 
> act as a callback function for GLUT is easy enough, but I'm currently stuck 
> at figuring out how I'm supposed to manipulate the world state when input 
> happens, or when a frame "ticks", etc.
>  
> Due to the nature of Rust, just throwing an anonymous function into the 
> callback doesn't work by itself, because impure functions might be used with 
> an @WorldState (thus it doesn't compile), or moving a ~WorldState can only 
> work once, and not into the 5+ callbacks I need to setup.
>  
> How can I properly work with GLUT such that each callback can manipulate the 
> WorldState in some way? (preferably safely)
>  
>  
> !DSPAM:511bbebe36705315134984!
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
> 
> 
> !DSPAM:511bbebe36705315134984!

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to