gpt4 book ai didi

c++ - Firebreath OpenGl 窗口闪烁

转载 作者:太空宇宙 更新时间:2023-11-04 12:00:18 26 4
gpt4 key购买 nike

我跟着firebreath opengl Firebreath Opengl教程,它可以工作,但是当我调整页面大小时或滚动页面时它开始闪烁,所以我在网上搜索了解决方案,但除了一个小提示外,我没有找到任何东西

FireBreath Tips: Drawing on Windows

它说:

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.

所以我尝试做的是找到一种将重绘消息传递给绘图线程的方法,我使用了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
}
}

最佳答案

好像我记得有人遇到过这个问题并通过处理 WM_ERASEBKGND 解决了它信息。你可以试试看。

关于c++ - Firebreath OpenGl 窗口闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14403217/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com