Author Topic: Help with jerky scroller problem  (Read 4858 times)

0 Members and 1 Guest are viewing this topic.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Help with jerky scroller problem
« on: April 26, 2012 »
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


raizor

Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: Help with jerky scroller problem
« Reply #1 on: April 26, 2012 »
timeGetTime and getTickCount have a resolution of about 16ms which is not precise enough to do proper timing at >=60hz.
Use QueryPerformanceCounter and QueryPerformanceFrequency instead.
Or get the timer from your music player (which usually runs at 44100 hz).

Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Help with jerky scroller problem
« Reply #2 on: April 26, 2012 »
Thanks Hellfire, I'll give that a go. Many thanks :)
raizor

Challenge Trophies Won:

Offline Knurz

  • Atari ST
  • ***
  • Posts: 121
  • Karma: 25
    • View Profile
    • GitHub Repository
Re: Help with jerky scroller problem
« Reply #3 on: April 26, 2012 »
I'm using GetSystemTimeAsFileTime.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724397(v=vs.85).aspx

Code: [Select]
            ULARGE_INTEGER liconvert;
            GetSystemTimeAsFileTime (&ftCurrent);
            liconvert.LowPart = ftCurrent.dwLowDateTime;
            liconvert.HighPart = ftCurrent.dwHighDateTime;
            liCurrent = (double)liconvert.QuadPart/10000;
            if (liCurrent - li_oldTime > 16) {
            ...
            sleep (1);
            }
Remember what the dormouse said: Feed your head

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Help with jerky scroller problem
« Reply #4 on: April 26, 2012 »
Thanks Knurz.

I found this also. Looks interesting.
raizor

Challenge Trophies Won:

Offline Knurz

  • Atari ST
  • ***
  • Posts: 121
  • Karma: 25
    • View Profile
    • GitHub Repository
Re: Help with jerky scroller problem
« Reply #5 on: April 26, 2012 »
Thanks Knurz.

I found this also. Looks interesting.

Bookmarked  ;D
Remember what the dormouse said: Feed your head