glFinished() ?

Hello all,

Is there a way for me to find out if/when OpenGL is finished after I call glFlush()? Maybe there’s a simple way to do this and I’m just not searching for it in the right way, but I can’t seem to find any info on such a thing. If there was a “glFinished()”, here’s what I would like to do:

while ( simulationRunning )
{
  DoSetupStuff();  

  glBegin();
  Render();
  glEnd();
  glFlush();

  DoMiscOtherStuff();

  if ( TRUE == glFinished() ) // Here!
  {
    SwapBuffers();
    ProcessSimulation();
  }
  else
  {
    ProcessSimulation();
    GLFinish(); // Wait if needed.
    SwapBuffers();
  }
}

I have some very good reasons for wanting to do this (and not just processing the same way every pass through the loop).

Thanks in advance!

Originally posted by Schpidah:
Is there a way for me to find out if/when OpenGL is finished after I call glFlush()?

On NV cards you can use NV_fence extension to determine when all commands preceeding fence are completed.

I have some very good reasons for wanting to do this (and not just processing the same way every pass through the loop).

May I know your reasons? On current OGL implementations is is likely that SwapBuffers will be queued and will not block unless you are sending images too fast because drivers are likely to be optimized for the most commonly used case. Also by delaying SwapBuffers you are risking that you miss vertical blank and swap will have to wait for the next one.

Is your problem that SwapBuffers() is queued and you want to execute the draw instantly independent of other tasks? I would be interested in that one too.
I tried it (in windows) by flushing paint messages by hand but it did not work as I wanted.

Kilam.

Originally posted by Kilam Malik:
[b] Is your problem that SwapBuffers() is queued and you want to execute the draw instantly independent of other tasks? I would be interested in that one too.
I tried it (in windows) by flushing paint messages by hand but it did not work as I wanted.

Kilam. [/b]
If I understood well, what you need is calling glFinish() and doing “other (non-GL) tasks” in a different thread.