Testing the same piece of code on Windows, Linux (ubuntu) and OS X (10.8.4) doesn't have the right FPS on OSX.
Here is the code sample (from base project)
#include <SFML/Graphics.hpp>
// Here is a small helper for you ! Have a look.
#include "ResourcePath.hpp"
#include "FPS.hpp"
int main(int, char const**)
{
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
window.setFramerateLimit(60);
sf::Texture texture;
if (!texture.loadFromFile(resourcePath() + "cute_image.jpg")) {
return EXIT_FAILURE;
}
sf::Sprite sprite(texture);
sf::Font font;
font.loadFromFile(resourcePath()+"sansation.ttf");
FPS fps(font);
fps.setColor(sf::Color::Black);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed || (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape))
window.close();
}
window.clear();
window.draw(sprite);
fps.step();
window.draw(fps);
window.display();
}
return EXIT_SUCCESS;
}
This gives a framerate of 57 while it should be 60
(https://f.cloud.github.com/assets/664177/834364/09971066-f2bc-11e2-9ff8-ca7013eb1262.png)
The FPS.hpp can be found here
https://gist.github.com/posva/6052868 (https://gist.github.com/posva/6052868)
I created a (rejected) issue here: https://github.com/SFML/SFML/issues/433 (https://github.com/SFML/SFML/issues/433)
window.setFramerateLimit(30); // call it once, after creating the window
Unlike setVerticalSyncEnabled, this feature is implemented by SFML itself, using a combination of sf::Clock and sf::sleep. An important consequence is that it is not 100% reliable, especially for high framerates: sf::sleep's resolution depends on the underlying OS, and can be as high as 10 or 15 milliseconds. Don't rely on this feature to implement precise timing.
sf::sleep can be quite inaccurate. ;)