A GLUTtonous refresh...

Started by
-1 comments, last by Dragonus 22 years, 8 months ago
All humour aside... I''m creating a program that uses both GLUT/GL and FLTK (FastLight ToolKit). However, I''m running the GL window in a separate thread from my FLTK window because I wanted to run them independently. Anywho, I started off on my own, coding up the following little code blurb...
  idleFunction()
{
     glutPostRedisplay();
}

// . . .


createWindow( /* parameters */ )
{
     // . . .

     glutIdleFunc(idleFunction);
     glutMainLoop();
}
  
I was running my program on a P3-600MHz, and things were going great -- that is, until I went down to a P2-450MHz, when it claimed the processor so much that other programs slowed down. (I don''t know the graphics cards on either machine.) So I came back to my machine and looked at the processor resources being used, to find the number always between 80% and 100%. Taking out the glutIdleFunc() line, the processor resources went down to next to nil, and so I began to add glutPostRedisplay() commands everywhere that the GUI was changed. It worked fine if the code was ran directly from the GL side of my program (e.g., I was calling glutPostRedisplay() from the GL thread.) However, this isn''t the case when calling it from the FLTK thread (pretty much, the control panel thread). It won''t refresh the screen until I hover my mouse over the window, only then making the updates in my window. Aside from the cheap way of rewriting the idle function like
  idleFunction()
{
     static int time = 0;
     if(time == 10)
     {
          glutPostRedisplay();
          time = 0;
     }
     else time++;
}
  
is there any better way of refreshing from another thread (or another active window) instantly using GLUT and/or GL code? ~ Dragonus

This topic is closed to new replies.

Advertisement