[Openmcl-devel] OpenGL and threading
gb at clozure.com
Fri Jun 9 17:14:10 PDT 2006
This is more of a stab in the dark than a suggested workaround, but
the stab worked a few weeks ago and seems worth another try ...
OpenGL contexts are bound per-thread; if a given thread hasn't
established a context (via some Cocoa/AGL/GLUT mechanism), then
any OpenGL call made in that thread that requires a GL context
will crash and burn (and segfault.)
I -think- (and I'd have to read the docs and double-check) that
GL is otherwise not thread-safe in and of itself; that if you
did something like:
? (process-run-function "background GL thread"
#'(lambda () (setup-opengl-context ...) (some-sort-of-event-loop)))
and also did (in a listener):
? (setup-opengl-context (same-context-as-background-thread))
that you'd have to provide your own locking/synchronization mechanisms
- or depend on luck - to avoid problems.
(It would be good if I was mistaken about that.)
On Fri, 9 Jun 2006, Kaveh Kardan wrote:
> I'm calling an OpenGL-based library from OpenMCL, following the
> example given in the distribution. The example runs OpenGL/GLUT in a
> thread, so that the listener can be active.
> The problem I'm running into is any interactive code which invokes
> OpenGL calls (and is therefore not running in the same thread as the
> OpenGL process), causes a crash.
> Does anyone have a suggested workaround?
> Kaveh Kardan Chief Technologist
> kaveh at hawaii.edu Academy for Creative Media
> (808)956-5302 University of Hawaii
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel