syncing between refreshes in OpenGl

I am currently developing a program for use in the psychology lab I work in. For this program to work effectively, I must swap images at every refresh rate (a black square appears on the bakground, and must be switched with a white square at the next refresh to cause the brain to ocellate to that refresh). If you could help me solve this image swapping problem, I would be very thankful.

sorry this is windows specific but theres an extension u can use 4 this ive got a demo here

Some graphic cards allow you to do just that, what you need is to check if there is a Vertical Sync switch. GeForce has one under the OpenGL toolbar.