2013-01-18 129 views
1

我跟着firebreath opengl Firebreath Opengl教程,它的工作原理,但它调整或滚动页面时,它开始闪烁,所以我搜索网络的解决方案,但我没有发现任何东西,除了一个小提示Firebreath OpenGl窗口闪烁

FireBreath Tips: Drawing on Windows

它说:

只要接收到RefreshEvent,你必须重新绘制。如果您使用辅助线程进行绘制,请确保您有某种方式将消息传递到该线程,否则您将闪烁。

因此,我试图做的,找到一种方法将重绘消息传递给绘图线程,我用Boost equivalent of ManualResetEvent强制主线程重绘,但没有发生任何事情。

我使用的代码:

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 
    } 
} 

回答

1

好像我记得有这个问题,并通过处理WM_ERASEBKGND消息固定它的人。你可以试试。

+0

它的工作非常感谢,但为什么剂量getSuppressEraseBackground()默认返回false? – user1748906

+0

呵呵。不知道那是在那里;我没有添加=]我认为这是错误的,因为这是默认行为。 – taxilian