saving the image - how to know when display() is finished? (threading)

Hi,

in an overview my program does this:

      canvas.display();      // invoke a render
      save_and_process_results();     // process based on what was drawn
      canvas.display();     // another render...
      ... more processing

I’ve just realized that the weird resuts I’m getting must be due to the fact that GLcanvas.display()
probably just schedules a display() call and returns immediately. So the save_and_process_results()
starts before the image is finished displaying, and sometimes even before it starts displaying.

Is there an easy way to call display() synchronously, or to know when it is done
so it is safe to process the results?

I suppose the two threads could communicate by setting a flag…

You would be better off doing a glFlush/glFinish at the end of your GLEventListener’s display() callback and performing a glReadPixels from the back buffer at that point. GLCanvas.display() is however synchronous so if you read from the front buffer (in general not a good idea). See this issue for some pointers to threads on this forum containing useful code snippets which haven’t been integrated yet. You’ll need to search for the titles of the threads as the links are back to the old forums.

thanks

err, if anyone is reading this, ignore what I wrote in the original post.

I had concluded that canvas.display() was asynchronous since it nicely explained my bug,
but was wrong.