I am trying to completely unlimit the SFML framerate, so that as many frames will be displayed as possible. The reason for this is I want to loop through one section of code which calculates positions of objects in a physics simulation, and update the screen after perhaps 100 iterations.
I have done:
window.SetFramerateLimit(0);
window.UseVerticalSync(false);
The SFML documentation says this should set the frame rate to "infinity", but I still think it's stuck at about 60-ish.
Does anyone know how I can get more performance out of this?
Also once unlimited, I need to be able to do the equivalent of this in SFML, from SDL:
SDL.Delay(1000);
Is there a way of doing this? The SDL Delay is good because it frees CPU time for other processes.
By not setting a framerate limit, or setting it to zero, which is the default, the sfml window should display frames as fast as it is able too. Unfortunately, the problem appears to be with the drivers, which are forcing vsync to be enabled. Because this is a Macbook Pro, with HD3000 graphics and an Intel driver, I don't know how to force vsync off.
There are other ways around this problem, such as using an if statement to decide whether to update the screen each loop. That is what I have done, although it is not an ideal solution.
In regards to SDL's delay function, SFML provides a sf::Sleep()
function. This function is called with the argument of a sf::Time
object, to which the user can set the number of microseconds, milliseconds and seconds to delay.
However note that this function does not "sleep" or "delay" for this exact amount of time - the OS comes back at "some time later which is at least after the requested sleep time". I do not understand fully how it works, or what "time resolution" you can expect to achieve with sf::Sleep()
or SDL_Delay()
.