QGLWidget中的渲染和颜色拾取:如何处理这两者
rendering and color picking in QGLWidget : how to cope with both
我想知道是否有比这更好的解决方案:我有一个渲染代码和一个颜色选择代码,我已经共享了这两个代码(VBO等)之间可以共享的所有内容,我的代码看起来像:
void paintGL()
{
label1:
if(picking_running)
{
... code to draw the colors for the picking
}
else
{
... normal code to draw the scene the user should see
}
if(picking_running)
{
... do the colorpick and identify the clicked element...
picking_running = FALSE;
goto label1; // this prevent the paintGL function to end and get swapBuffers called, I don't want the "flickering" to be visible to the user between the color picking mode and the normal mode
}
} // end of the paintGL, here swapBuffers is called automatically
代码是有效的,用户不会看到闪烁,但坦率地说,在我的代码中使用goto的想法似乎是一个糟糕的解决方案。
你还有其他更好的主意吗?
使用setAutoBufferSwap(false)并自己调用QGLWidget::swapBuffers。也可以将颜色拾取渲染到未渲染的缓冲区/纹理。
既然你无论如何都执行可见渲染,为什么不这样实现呢:
void paintGL()
{
if(picking_running)
{
/* ... code to draw the colors for the picking */
/* ... do the colorpick and identify the clicked element... */
}
/* ... normal code to draw the scene the user should see */
}
相关文章:
- 警告处理为错误这里有什么问题
- 在C#中处理C++指针而不使用unsafe的最佳方法
- 处理多个异常集合的C++方法
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 使用流处理接收到的数据
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 基于多个条件处理地图中的所有元素
- 如何用数字处理log(0)
- SSL上的`curl_easy_send`和`curl_asy_recv`:如何处理`CURLE_AGAIN`
- 错误处理.将系统错误代码映射到泛型
- 从文本文件中读取时钟时间和事件时间并进行处理
- 在运行时处理类型擦除的数据-如何不重新发明轮子
- 在for循环中使用auto vs decltype(vec.size())来处理字符串的向量
- 用于矢量处理的多个线程
- 对字符串进行排序时,在c++中处理sort()
- 如何处理linux终端中带有负号(-)的C++中的命令行参数
- 处理除以零会导致<csignal>意外行为
- 是否可以在c++中处理字符串流中的各个元素
- 在简单的外壳中进行批处理处理