Problem calling GDI after SwapBuffers()

Hi folks;

I’m working on an interactive modeling program using OpenGL. My application runs on Win32, and I’m using double buffering. Sometimes I need to use GDI to do some drawing on top of the window after I have called SwapBuffers().

I’ve experimented some, and I am coming to the inescapable conclusion that the actual buffer swap is delayed and is happening after I make my GDI calls. Here’s the order of things:

  1. Do OpenGL rendering
  2. SwapBuffers()
  3. glFlush()
  4. GDI calls

And yet it seems that my OpenGL graphics are in fact overwriting the display generated by my GDI calls.

If I insert a long delay between just before calling GDI, then it works as expected.

Can anyone explain what is going on here?


Have you tried to call glFinish instead of glFlush?

Perfect. Thanks!

I wasn’t aware of glFinish(), just looked it up. Things work now.