vsync limits frame rate to 60
Posted: Thu Dec 14, 2017 11:50 am
My solution in my own engine was to create an additional thread for logic and one mutex.
Then the main thread loop (drawing one) looked like this:
1. Lock the mutex.
2. Call the user code for drawing
3. Unlock the mutex.
4. Call the screen updating function which blocks.
While the updating thread loop looked like this:
1. Lock the mutex.
2. Call the user code for updating.
3. Unlock the mutex.
Voila, the blocking function (be it SDL_RenderPresent or glfwSwapBuffers) no longer interferes with the deltas.
There are a few problems, though:
1. I don't know if you'd be interested in this at all.
2. I don't know if non-rendering functions of SDL are safe to call from the other thread.
3. This would take away control of the run callback.
Anyway, just a suggestion. Maybe there's no need for a "solution", maybe this is not a problem to begin with.
I found it useful for physics - the faster the physics loop runs, the more accurate the results are, so they were not tied to 60 fps and ran at 100 fps instead.
Then the main thread loop (drawing one) looked like this:
1. Lock the mutex.
2. Call the user code for drawing
3. Unlock the mutex.
4. Call the screen updating function which blocks.
While the updating thread loop looked like this:
1. Lock the mutex.
2. Call the user code for updating.
3. Unlock the mutex.
Voila, the blocking function (be it SDL_RenderPresent or glfwSwapBuffers) no longer interferes with the deltas.
There are a few problems, though:
1. I don't know if you'd be interested in this at all.
2. I don't know if non-rendering functions of SDL are safe to call from the other thread.
3. This would take away control of the run callback.
Anyway, just a suggestion. Maybe there's no need for a "solution", maybe this is not a problem to begin with.
I found it useful for physics - the faster the physics loop runs, the more accurate the results are, so they were not tied to 60 fps and ran at 100 fps instead.