1
Window / Framerate Limit not working properly on OSX
« on: July 22, 2013, 12:55:30 pm »
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)
This gives a framerate of 57 while it should be 60
The FPS.hpp can be found here
https://gist.github.com/posva/6052868
I created a (rejected) issue here: https://github.com/SFML/SFML/issues/433
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;
}
// 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
The FPS.hpp can be found here
https://gist.github.com/posva/6052868
I created a (rejected) issue here: https://github.com/SFML/SFML/issues/433