Screen Refresh Event

Hi,
I am very new to opengl.
The thing is I would like to synchronize flickering spot (rectangle changing color) with the refresh rate.
To accomplish that, I want to count the refreshes (e.g. white color during first 3 refreshes, black during next 4 etc.)

Is that possible at all ?
Any ideas ?

Rgds,
Piotr

If your using double buffering SwapBuffers will normally wait for the next refresh to draw, so unless you are rendering something that is to slow then every frame you render is normally synced to the refresh rate.

Make sure you ask for vsync, with wglSwapInterval(1) or glXSwapInterval(1)
Make sure you draw simple stuff, wich should render much faster than refreshrate.
Use glFinish() after each swap, to avoid command buffering of GL commands.
Then count the number of renderings.

Can you explain a bit the context of your needs ?

Thanks ZbuffeR.

I have to implement a visual stimulator, which has to be as precise as possible. I would go for GDI, because what I need are only a few flickering squares, but it is not possible to enable vsync in it.