3 ms·
> Do physics at 30FPS in one thread; draw graphics as fast as you can in a separate thread This sounds like a race condition nightmare. How would one guarantee
by danhau 4y ago
> Do physics at 30FPS in one thread; draw graphics as fast as you can in a separate thread
This sounds like a race condition nightmare. How would one guarantee synchronization? One big mutex for the entire physics state? Or don‘t bother and read whatever values you get in the render thread?
I suppose a single threaded context you would automatically get something like a global mutex, just without the mutex, thanks to the leap frogging nature (frame, frame, frame, tick, frame, frame, frame, tick, …). At least with a fixed timestep.
- heavenlyblue 4y agoJust have 2 snapshots of all of the positions of all elements in the game (which is trivial in terms of storage requirements), just the same way you have it with double-buffering for the pixels on the screen.