Re: GlGtk + Thread?

Jacques Garrigue <[email protected]>
Newsgroups gmane.comp.lang.ocaml.lib.gtk
Message-ID <[email protected]>
From: Matthieu Dubuget <[email protected]>

> I'm using lablgtk installed from godi on a linux box.
> 
> I tried to modify the "simple.ml" example (GL sub-directory) in order to
> have thread enabled:
> - I replaced Main.main by GtkThread.main
> - and ran the example with: lablgtk2 -thread gtkThread.cmo simple.ml
> 
> Unfortunately, this did not work. No idea why. There is the message
> (from the C part?):
> 
> GlGtk-WARNING **: could not make current
> 
> Any idea?
> 
> My initial goal was to try to make a gtk application, with a separated
> thread re-drawing the GlGtk area.

I'm not sure of the reason, but it probably means that GL doesn't like
to be called from different threads. Usually this problem of calling
threads rather happens on windows, but apparently with GL this is the
case for Unix too. The solution is to look at the explanations in
GtkThread.mli, and issue all GL related calls through GtkThread.sync
or GtkThread.async.
Note that of course all calls directly from callbacks should be safe
without wrappers, since they are called from the GUI thread
themselves.

Tell us whether it solves your problem.

Cheers,

Jacques
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.