Vertical sync and keyboard input woes

Started by Morgrog, December 17, 2003, 22:58:19

Previous topic - Next topic

Morgrog

when I run Nehe's examples (which I'm trying to continue porting to help me learn) with the vertical sync on, the movement (keyboard control) is smooth as it should be.  As soon as I turn it off, the keyboard becomes extra sensitive (the cube spins like a cat on crack).  Could anyone explain to my pea size brain why such a behavior is occuring?

Numknuf

You're probably using framebased animation: you add a little bit of rotation in degrees for each frame. With vsync the framerate is the same as your monitors refreshrate, maybe 100 Hz. If you turn vsync off opengl tries to do as many frames as possible every second...  :)

Morgrog

oh, I c, so in order to smooth things out, I need to force the framerate to a certain number?

Is that how games are programmed? I mean, how can u force your game to work at the same speed on different computers?

Numknuf

Instead of frame based animation you can do time based animation. So instead of rotating 1 degree every frame you do 1 degree every 1/60 of a second.