我想知道是否有比这更好的解决方案:我有一个渲染代码和一个颜色选择代码,我已经共享了可以在这两个代码(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 的想法在我看来是一个糟糕的解决方案。
您还有其他更好的主意吗?