Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the best way to separate render and game logic threads?

I'd like to make logic-heavy game (ai, machine learning, and network) in which world updates 50-60 times per second.

I want to separate rendering so it will not waste logic's thread power.

I'm planning to use c++ with boost.

share|improve this question

Threading in games has pretty much the same issues you'll find in any other application. Think in terms of parallelization: you have some interrelated task that must be run concurrently without interfering with each other's work.

The drawing stage should not be affected by any other computation, so the gamestate must remain stable while drawing, i.e., these tasks must be synchronized. Drawing should not start until the whole gamestate step has finished. Gamesate-changing tasks must run sequentially with drawing code (update-draw-update-draw-...) while you can still concurrently run code that doesn't immediately change gamestate (e.g. pathfinding for the next frame.) You can also keep local copies of the whole gamestate (if it's not too big) or parts of it, computing them but only updating the gamestate upon synchronization with the drawing code (after the drawing for the current frame had ended.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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