All my OpenGL stuff so far that has included a scroller has suffered from a degree of jerkiness and I'd like to get my head around the problem if possible. I'm probably doing something wrong with my timing, so if anyone has any suggestions, I'd appreciate it.
As you're probably aware, I use IQ's 64k OpenGL framework as a base for most of my stuff. This uses timeGetTime() for timing. As suggested in various places (including here), I call timeBeginPeriod(1) at startup and timeEndPeriod(1) when my intro finishes. I understand that timeGetTime() works in milliseconds, so I wonder if the issue is related to the value not being granular enough.
My timer code looks something like this:
static long startTime = 0;
if( !startTime )
{
// set start time
startTime =timeGetTime();
}
float timeElapsed = 0.001f * (float)(timeGetTime() - startTime);
Using this for animating objects and the like works nicely and things appear smooth. However, when I use the timeElapsed to calculate an offscreen for scrolling a scroller it seems to jump about and looks quite jerky at times. I do something along the lines of:
scrollOffset = -timeElapsed*FloatValToControlScrollSpeed
The scroller is sometimes smooth, but goes through periods of jerkiness. I'd like to avoid using the swap interval GL extension if possible to ensure it runs nicely on machines where VSync is forced off in the gfx driver settings.
I should also point out that the framerate never drops below about 200 fps.
If anyone can see something I'm doing wrong or has a solution, please let me know.
Thanks,
Raizor