0
\$\begingroup\$

I'm working on a 2D side-scroller, and I've got the technical aspects working. OpenGL renderer, camera movement using acceleration.

However, while scrolling I'm constantly seeing tiny random hiccups. Split-second pauses, just enough to cause the perception of smooth scrolling to feel choppy instead. Turning on VSync actually accentuates the hiccups. But when I display frame render times, it's always constant (well, constantly flipping between 0.016 and 0.017 second). So far it's just a render loop, no processing going on in the background.

When I look at other 2D side-scrolling games, I never see this stutter, so I don't know if there's something I'm missing that other games know to do...

I recorded a video of it from my phone, on a repeating row of tiles, to show what I mean. It's poor quality, but recorded at slow-motion to emphasize the hiccups. Any tips on how to get rid of this would be great.

\$\endgroup\$
1
\$\begingroup\$

Are you measuring the rendering rate using external tool like FRAPS, etc? If not, I would first suggest that.

As far as troubleshooting goes, try lowering the framerate to anything lower than the VSync, like 30 or whatever, and see if the problem persists. If it does not, then your rendering rate/game loop mechanisms are a likely culprit.

If it does persist even at lower framerate, it may possibly due to rounding errors in the logic.

Another question, likely unrelated, but what language or base framework are you using?

\$\endgroup\$
  • \$\begingroup\$ Sounds promising, I'll give these a try this evening and see if I can narrow it down. \$\endgroup\$ – Nairou Jun 7 '18 at 15:30
  • \$\begingroup\$ As far as language and framework, it's written from scratch in C, using a few libraries like SDL2 (which provides the time functions I'm using). \$\endgroup\$ – Nairou Jun 7 '18 at 15:32
  • \$\begingroup\$ Okay, it took a little time to eliminate other quirks (like SDL2 having VSync turned on all the time, even when I didn't request it), but I finally narrowed it down. At extremely high frame rates (VSync actually off) and frame rates under VSync (i.e. 40), there is no stuttering. When I turn on VSync, or lock the frame rate to something close (i.e. 65), it stutters a great deal. I'll start looking at my render loop, but can you elaborate on how that would be the culprit? \$\endgroup\$ – Nairou Jun 8 '18 at 23:13
  • \$\begingroup\$ Likely what you are seeing is screen tearing, which is caused when the rendering is not in sync with the screen's refresh rate, and you get multiple frames rendered in the same screen draw. Typically double-buffering solves this issue. \$\endgroup\$ – ForeverZer0 Jun 9 '18 at 7:13
  • \$\begingroup\$ I can look into double-buffering, but this stuttering definitely isn't screen tearing, which is pretty easy to recognize. If you watch the video in my post, there's no tearing, the entire scene is pausing. My guess is there is a timing conflict between when I'm ready to draw a frame and when vsync occurs, forcing my code to stall and wait for the next vsync window. But I have no idea how you get around that problem. \$\endgroup\$ – Nairou Jun 9 '18 at 13:21
0
\$\begingroup\$

I had the same thing only in 3D - upgrading the NVIDIA driver fixed it without making any other changes to my code.

\$\endgroup\$
  • \$\begingroup\$ I tried that as well, upgraded the driver to the latest version. No change in the stutter. But even before the upgrade, other games still didn't show this stutter that I could see. \$\endgroup\$ – Nairou Jun 7 '18 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.