[Haskell-beginners] opengl and application state
Sean Charles
sean at objitsu.com
Wed Jun 29 23:34:53 CEST 2011
How!?!?! LOL
I am getting back into OpenGL again with Haskell now and I have a
program that listens to all the callbacks and prints stuff out,
terminates on Ctrl+X and draws a grey sphere. Earth shattering.
If I was using C/C++ I'd be using a (shudder) global pointer to a record
containing state that the render callback would use to know what to do.
I smell state monads or something but I cannot see how to pass them into
"the loop".
I want to organise my code so that all input events cause a record to be
updated and then the render part just uses the current values to draw
the right things, with the obvious caveat of "what if a key event
happens half way through the render phase." MVars? Threads? What??? I'm
a real newb on this right now!
How do I,or what is a "best practice" for passing a continuously
changing record across calls given that the "displayCallback" doesnt
have any obvious place to plug one on? In Erlang or even Haskell, there
is the idion of making a tail call back to yourself with the new
modified record and so on but I cannot figure out where to actually pass
it around!
Thanks in advance.
Sean.
More information about the Beginners
mailing list