[英]Firebreath OpenGl window flickering
我遵循了firebreath opengl Firebreath Opengl教程,它可以工作,但是当我调整页面大小或滚动页面时它开始闪烁,因此我在网上搜索了一个解决方案,但是除了一个小提示外,我什么都没找到
它说:
每当收到RefreshEvent时,都必须重新绘制。 如果您正在使用辅助线程进行绘制,请确保您有某种方式将消息传递到该线程,否则将会闪烁。
因此,我尝试做的是,找到一种将重绘消息传递到绘图线程的方法,我使用了Boost相当于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
}
}
好像我记得有人遇到此问题并通过处理WM_ERASEBKGND消息来解决。 你可以试试看。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.