API reference / Windows and drawing
SDL_SetRenderVSync
Function, SDL3
Makes the present step wait for the screen. Without it, a program draws as fast as it can and uses a full CPU core.
Declaration
#include <SDL3/SDL.h>
bool SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync);Parameters
renderer | The renderer. |
vsync | 1 to wait for each screen refresh, or 0 to not wait. |
Return value
True on success. On failure it returns false.
Example
SDL_SetRenderVSync(renderer, 1);See this code run in Open a window. Download the full program (.zip)
In SDL2
Use SDL_RenderSetVSync.