Search code examples
c++openglboostfirebreath

Firebreath OpenGl window flickering


I followed the firebreath opengl Firebreath Opengl tutorial, it works but it start flickering when I resizeing or scrolling the page, so I searched the web for a solution but I did not find any thing except for a small hint

FireBreath Tips: Drawing on Windows

it says:

Whenever a RefreshEvent is received, you must redraw. If you are using a secondary thread to draw, make sure you have some way of passing the message to that thread or you will get flickering.

so that what I tried to do, find a way to pass redraw message to the drawing thread, I used Boost equivalent of ManualResetEvent to force the main thread to redraw but nothing happened.

the code I used:

bool threadedOpenGLTestPlugin::draw( FB::RefreshEvent *evt, FB::PluginWindow* win )
{
   Event.Set(); // Event is Boost equivalent of ManualResetEvent
   //Refresh Events... nothing todo since the opengl is running in it's own thread
   return true;
}
void threadedOpenGLTestPlugin::drawThreaded()
{
   while(true)
   {
      Event.Wait(30);// the event waits for 30 milisec or for event fired by the threadedOpenGLTestPlugin::draw function
      Event.Reset();
      //.......... drawing loop 
   }
}

Solution

  • Seems like I remember someone having this issue and fixing it by handling the WM_ERASEBKGND message. You could try that.