PDA

View Full Version : Synching Redraw with monitor refresh rate



dnorric
02-18-2011, 03:49 AM
Hi
Ok so i have a lcd monitor with a refresh rate of 60hz. What i want to do is synchronize my drawing with the refresh rate. So i might draw a circle on the first refresh and then wait 59 refreshes after which I draw a square. Basically i need to treat it like a slide show sought of.
How would i do this.
Cheers
Damian

mobeen
02-18-2011, 04:00 AM
which platform are u in windows/linux? and which utility toolkit if any are u using. FYI glut automatically keeps vsync on by default.

dnorric
03-06-2011, 10:40 PM
windows, no im not using a toolkit thought if thats required thats no prob. Basically what i want is like being able to assing a calback to the actual draw event, such that if the monitor were 60hz it would get called 60 times per second. Is there any way to do this.
Cheers
Damian

ZbuffeR
03-07-2011, 01:41 AM
There is no callback on vsync AFAIK.

If you really want to be tied to 1/60 of the refresh rate, you can do wglSwapInterval(60);

Or simply run a timer within your code, triggered every second, with vsync on using wglSwapInterval(1); to avoid any tearing. This is a better solution, if you do not mind a little jitter (depending on timer precision, between rendered frame you may have 58 or 61 refreshes).

dnorric
03-07-2011, 09:01 PM
I am using windows and glut. What is the header for wglswapinterval. It cant find the function
Cheers
Damian

mobeen
03-07-2011, 09:22 PM
U would need glew for this and.
#include wglew.h

Alfonse Reinheart
03-07-2011, 09:33 PM
You don't specifically need GLEW. Any extension loading software would do. Or just load the swap interval extension yourself.