Re: Running the main loop in a separate thread



Am 07.09.2012 23:06, schrieb Petko:
>  Hello everyone , I hope the topic isn't reposted too much . I've been
> on it for about 3 hours now and Google doesn't seem to point to much info .
>  Briefly put - I have a GLUT app that I want to use gtkmm windows with
> (for input/other dialogues) . I thought I can just run the GTKmm main
> loop in a separate thread , but that turned out not to work properly .
>  So firstly - is the concept flawed , or should I refine my code till it
> works ? At the moment I can run the gtkmm window in a separate thread
> (the main loop that is) , but upon ending the thread (or closing the
> window via X or the window.hide() function) the window hangs (and
> doesn't get cleaned off the screen). The thread however (I think) closes
> properly , and my guess was that that would destroy the window but what
> do I know..
> 
[...]

I have not tried it but I think it would be a better approach to add an
idle callback to GLUT (glutIdleFunc) which runs a single iteration of
the glib main loop.

Something like this:

static void g_iter()
{
  g_main_context_iteration(NULL /*context*/, FALSE /*block*/);
}

glutIdleFunc(g_iter);

Regards,
Florian Philipp

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]