HOpenGL and --enable-threaded-rts
Sun, 16 Jun 2002 21:57:11 +0200
In short, it doesn't work :-( .
OpenGL (at least on MacOS) keeps track of the "current context" on a
per-thread basis. The GLUT library sets the current context and calls
back to the program. With GHC 5.03 compiled with --enable-threaded-rts,
the callback gets executed in a different thread. There is no OpenGL
context set up for that thread, so the first OpenGL call crashes.
This might also be a problem for other state-based interfaces that use
Has anyone already thought about how to solve this problem?
I'm thinking about adding hooks to the RTS (in grabCapability,
releaseCapability and scheduleThread_) which would be used for setting
up the correct thread-local state whenever Haskell execution "switches"
to a different OS thread. Those hook routines would have to be written
in C and would be platform-specific most of the time. It's not a nice
solution, but it's the only one I can think of at this time.
Unless someone comes up with a better idea _quickly_, I'll try it out
and then report how ugly it really is... :-)