Pergunta

I'm wondering if there's a better solution than this: I have a rendering code and a color picking code, I already shared everything that could be shared between these two codes (VBOs, etc..) and my code looks like:

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

The code works and there's no flickering visible to the user, but the idea of a goto in my code frankly seems to me a poor solution.

Do you kindly have any other better idea?

Foi útil?

Solução

Use setAutoBufferSwap(false) and call QGLWidget::swapBuffers yourself. You could also render the colorpicking to a buffer/texture that isn't rendered.

Outras dicas

Since you execute the visible rendering anyway, why not implement it like this:

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 */
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top