c++ - Firebreath OpenGl 窗口闪烁

标签 c++ opengl boost firebreath

我跟着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/

相关文章:

c++ - Visual C++ 2012 中的 getenv

c++ - 单例中未解析的外部符号

c++ - 检查类/结构是否有特定的运算符

c++11 - 以 IP 地址为键的 unordered_map

python - 如何将 Boost.Python 中的 map_indexing_suite 与自定义非 std 对象一起使用?

c++ - 制作 cv::Mat 队列

c++ - 减少 Linux 中的每个线程内存

c++ - SDL和OpenGL程序编译失败

c++ - 使用 VAO/VBO 的 OpenGL 模型/纹理渲染

c++ - 使用 openGL 的多纹理映射