* @brief Limit FPS to avoid high CPU load, use when v-sync isn't available */
| 237 | * @brief Limit FPS to avoid high CPU load, use when v-sync isn't available |
| 238 | */ |
| 239 | void LimitFrameRate() |
| 240 | { |
| 241 | static uint32_t frameDeadline; |
| 242 | uint32_t tc = SDL_GetTicks() * 1000; |
| 243 | uint32_t v = 0; |
| 244 | if (frameDeadline > tc) { |
| 245 | v = tc % refreshDelay; |
| 246 | SDL_Delay(v / 1000 + 1); // ceil |
| 247 | } |
| 248 | frameDeadline = tc + v + refreshDelay; |
| 249 | } |
| 250 | |
| 251 | void RenderPresent() |
| 252 | { |