We make a copy of the front buffer to render from. We do this so that we can render from the copy and let the sim thread do it's thing in parallel.
Making big changes. One thread is spawned, gets world context, prints it's dimensions.
No real processing done by the thread yet, need to tighten up some functions first for proper lock/unlocking.
Spawned now quits when the main thread wants to quit so we don't hang waiting for thread to join like in last commit.
Some quick benchmarking in this commit.
Allocating a render buffer and destroying it each generation drops gens/s by ~10. Whether this is big or not depends on your perspective.
The hit will be considerably less when it's only happening syncRate times per second. Much more functional style too. See next commit!
SyncWorldToScreen is now thread safe (I think!). Much faster than last commit already, since we are only allocating a new buffer when we actually need it.
Wrote thread-safe SwapThreadWorldContextPointers function.
Yay! Simulation and rendering are now running in separate threads.
Speedup is significant, now ~600 gens/s up from ~450 gens/s in single thread.
Fixed randomization of world by pressing spacebar.
Input thread just tells simulation thread we need a new random world, rather than doing it itself.
Awesome! Original functionality is back, with +33% simulation speed!
Next up, clean up this code... not terribly ugly, but could be more concise.