我想知道是否有比这更好的解决方案:我有渲染代码和颜色选择代码,我已经分享了可以在这两个代码(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的想法似乎是一个糟糕的解决方案。
你还有其他更好的主意吗?
答案 0 :(得分:1)
使用setAutoBufferSwap(false)并自己调用QGLWidget :: swapBuffers。您还可以将采样渲染为未渲染的缓冲区/纹理。
答案 1 :(得分:1)
因为无论如何都要执行可见渲染,为什么不这样实现它:
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 */
}