Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gelisam/glut-events
For writing GLUT's main loop in the style of Haskell's main function.
https://github.com/gelisam/glut-events
Last synced: 22 days ago
JSON representation
For writing GLUT's main loop in the style of Haskell's main function.
- Host: GitHub
- URL: https://github.com/gelisam/glut-events
- Owner: gelisam
- Created: 2013-03-13T03:16:06.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-04-03T02:57:14.000Z (over 11 years ago)
- Last Synced: 2023-04-13T07:57:01.826Z (over 1 year ago)
- Language: Haskell
- Size: 168 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
glut-events
===========For writing GLUT's main loop in the style of Haskell's main function.
(in development)
purpose
-------Haskell's [Graphics.UI.GLUT](http://cvs.haskell.org/Hugs/pages/libraries/GLUT/Graphics-UI-GLUT.html) library exposes [GLUT](http://www.opengl.org/resources/libraries/glut/)'s approach to event handling: register global callbacks for the Keyboard, Mouse, Timer, Resizing, Redrawing, and Idle events. This encourages a style of development focussing on a shared global state, a style which is not typical in Haskell.
The purpose of this library will be to offer a Haskell-style wrapper around GLUT's platform-independent Input and Timing routines. In particular, much like Haskell's main method is typically written as an infinite tree of alternative IO sequences:
main = do putStrLn "are you sure? (y/n)"
s <- getLine
case s of
"y" -> putStrLn "full steam ahead!"
"n" -> putStrLn "ok then."
_ -> do putStrLn "please answer with 'y' or 'n'."
mainThe goal is to allow you to write GLUT programs as an infinite tree of alternatives in some yet-to-be-determined monad:
glutMessage = do clear [ColorBuffer]
renderString Helvetica18 "are you sure? (y/n)"
swapBuffers
glut_main = do lift $ glutMessage "are you sure? (y/n)"
Char c <- getKeypress
case c of
'y' -> lift $ glutMessage "full steam ahead!"
'n' -> lift $ glutMessage "ok then."
_ -> do lift $ glutMessage "please answer with 'y' or 'n'."
waitForTimeout 1000
glut-mainlong term goal
--------------The above doesn't look to hard to implement. The hard part would be to allow waiting on multiple events (C-style select()), forking cooperative threads, sending events between threads, and releasing GLUT's idle callback when no threads are waiting for input. I still have no idea how to do this in a typesafe way, though, so don't hold your breath!