I am trying to implementing multi-threaded game loop in iOS. (Actually, two thread - Render and Update)
This is my structure.
- Has logic and at the end of loop, save update state. (Basically copy buffer for Render)
- Using CADsiplayLink
- It is on Main
- Everytime, it triggers method, get the state, and draw.
I am seeing some stuttering, and I am thinking render loop is just faster than update loop, and also inconsistent "Render" call, something like this:
- Update #1 -> Render #1
- Update #2 -> Render #1
- Update #2 -> Render #2
How can I synchronize this?
I heard that Render thread should be not on Main Thread, and I am using
CADisplayLink with default setting. (Call MainLoop); is it running on Main thread? If running on different thread, is better, can I get some suggestions working with CADisplayLink? It could be that I just lack some understanding about CADisplayLink.
Is my current structure adequate? Could it be improved?