[HOpenGL] problem with displayCallback and Double buffering
Wolfgang Thaller
wolfgang.thaller at gmx.net
Wed Nov 5 01:04:30 EST 2003
On 05.11.2003, at 00:34, Marc A. Ziegert wrote:
> i've installed ghc-6.3.20031102 (still the "-lGL" <--> "-lGLU" bug in
> package.conf).
> that version works now, thanks.
>
> now i want to use ghci, especially with
> forkIO mainLoop
> , but that does not seem to work anymore. is that a forkIO bug?
Hmm... did you build ghc with the --enable-threaded-rts flag? If so,
you should be using forkOS instead of forkIO; forkIO creates a
lightweight thread, but most OpenGL implementations require a
(heavyweight) OS thread to run reliably. With GHC 6.3
--enable-threaded-rts, this means you can call GLUT/OpenGL from the
main thread, from threads created using forkOS, and from foreign
exported functions, but not from threads created using forkIO.
If you're not using --enable-threaded-rts, then you could encounter a
different problem: GHCi only gets a chance to run while the GLUT
mainLoop is inside a callback, and while GHCi is waiting for input
using readline, the GLUT mainLoop will be blocked. Things might work if
you build GHC without readline support and install an idle callback
into the GLUT event loop.
In both cases, keep in mind that all the OpenGL drawing has to be done
from the thread that GLUT is running in. You can use MVars to
communicate with that thread from the GHCi prompt, but doing OpenGL
drawing from the GHCi prompt while a GLUT mainLoop is running in the
background will never work reliably.
Grüße,
Wolfgang
More information about the HOpenGL
mailing list