Last active
June 19, 2019 08:48
-
-
Save Nehon/ed67076eab1033f2f6b23658dfe2302c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void update(){ // as in the update we call on each frame, be it RAF or dopeUpdate | |
pollEvent(); | |
Barrier updateBarrier; | |
scheduler.runTask(logicUpdate, updateBarrier); // launch the frame update task with a barrier | |
render(); // the actual render called on the main thread | |
scheduler.wait(updateBarrier); | |
render::swapQueues(); | |
} | |
// single threaded : the logicUpdate will run before the render, and the wait after the render will have no effect. | |
// So basically it will be: | |
// loop{ | |
// update frame N; | |
// render frame N; | |
// } | |
// multi threaded: the logic update is called in a separate thread and the render of the previous frame is done in parallel | |
// if the render is longer than the logicUpdate, the wait has no effect. | |
// if the update is longer than the render, it waits for the update to finish. | |
// basically it will be: | |
// loop { | |
// render frame N-1, update frame N; | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment