I'm working on my first OpenGL 2D game and I've just locked the framerate of my game. However, the way objects move is far from satisfying: they tend to lag, which is shown in this video. I've thought how more fluent animation can be achieved and started getting segmentation faults due to accessing the same object by two different threads. I've tried the following threads' setting:

  1. Drawing, creating new objects
  2. Moving player, moving objects, deleting objects

Currently my application uses this setting:

  1. Drawing, creating new objects, moving objects, deleting object
  2. Moving player

Any ideas would be appreciated.

EDIT: I've tried increasing the FPS limit but lags are noticeable even at 200 fps.


Sounds like something is causing your update loop to run in uneven intervals. Try implementing a fixed timestep loop and your problem should go away.

| improve this answer | |
  • \$\begingroup\$ This is a short answer but most probably the right one. Threading seems like trying to treat the symptom instead of the disease. Since your lagging doesn't seem connected to your FPS it's most likely a fault in your loop (thus threading won't fix it, no matter your settings). Also the video feels like it's the game loop, since I've seen it before while I was learning how to handle the loop. \$\endgroup\$ – user8363 Sep 11 '12 at 11:33
  • \$\begingroup\$ great answer, thanks :) @user8363 your medical metaphor is great. \$\endgroup\$ – Robin92 Sep 11 '12 at 12:07

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.