Is there any command/function to find out when the image is accually displayed on the monitor. As you know, at 60 fps, 1 frame is displayed every 16.67 msec. So i could call swapbuffers but i wouldn’t know if it was displayed imediatly or sometime within 16.67ms. Is there anyway to find out when it was accually displayed on the monitor, or even an time consistently close to the time it was displayed on the monitor?
You could take your own direct time by issuing a graphics call (like a glNormal()) after the swap and calling glFinish(). This should block on swap and sync your software to the framebuffer swap and if that’s in sync with vertical retrace then you’re good to go. Once you start taking this measurement you can keep a running timer and measure elapsed time from the anticipated retrace.
Given the questions you’re asking this should be straightforward for you. You’ll also get the added advantage of lowering your latency (the graphics driver can buffer a frame of graphics under the covers) but you’ll pay a performance penalty for this (well worth it IMHO and essential for some applications).
There may be a platform specific system interrupt or call you can make to determine vertical retrace time but YMMV.
That’s clever, thanks. Although I don’t understand why we would have to issue a graphics call after the swap. If we didn’t do that, shouldn’t the glFinish() return after the screen refreshes anyways?