2013-01-18 125 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