Multithreading with opengl is a bad idea, but only because of drivers 
using tls (thread local storage).    Nvidia's driver is one such driver 
and a context can only be access/manipulated in the thread that created 
it.  Essentially this means you must communicate with an opengl 
drawing/managing thread using message passing.  The whole multithreading 
topic really leads to a nightmarish situation and difficult debugging 
given the sad state of affairs with many video card drivers, so if you 
want your program to run reliably on different computers, run all the 
direct gui code in a single thread.  You might consider using processes 
instead of threads even, then tls cannot be an issue.

Norbert Schultz wrote:
> Hi out there,
>
> I have a strange multi threading problem using GtkGLextmm. Thread 1 creates a 
> Gtk::GL::DrawingArea, does some initialization. Then Thread 1 (regular 
> Actualisation) and Thread 2 (which handles all GTK Events) want to update 
> things. But Thread2 cannot get a the start operations with 
>
> Glib::RefPtr<Gdk::GL::Context> context=m_glDrawingArea->get_gl_context();
> Glib::RefPtr<Gdk::GL::Drawable>  drawable=m_glDrawingArea->get_gl_drawable();
> drawable->gl_begin (context); // fails
>
> At the console I receive just:
>  GdkGLExt-WARNING **: glXMakeCurrent() failed
>
> But this happens only to Thread2. Sometimes the situation is changed and only 
> Thread 2 can paint. All OpenGL code fenced with a Lock so that only one 
> Thread can do OpenGL actions at once. I think it's possible to put all the 
> drawing commands into a third thread (and let Thread 1 and 2 call them for 
> repainting operations) but before I do that I want to ask if someone has 
> another idea?
>
>
> According to the man page glXMakeCurrent() should generate an error when it 
> fails, but I don't receive one (at least nobody kills my program, which seems 
> usual on X11 errors without error handler).
>
> Single threaded OpenGL seems to work, OS is a Gutsy AMD64 with current nVidia 
> Drivers 169.09 on a Geforce8.
>
> Greetings from France,
> Norbert
> _______________________________________________
> gtkglext-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtkglext-list
>   

_______________________________________________
gtkglext-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkglext-list

Reply via email to