Question

I'm new in SDL2, and cannot find any ticking system in SDL2 c++.

I wanna get something like that:

bool running = true;
while(running)
{
    render(); //my own created render void
    // some kind of FPS optimalization with redraw
    // here
}
Was it helpful?

Solution

In general you want to run your render loop at a whole multiple of the display refresh period. Since after a call to SwapBuffers the next drawing OpenGL call will block until the actual swap got executed this automatically limits you to the display refresh frequency. No need to implement a custom timing scheme.

Only if you disabled V-Sync in the graphics drivers you'll may run faster than the display refresh.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top