1
Window / Re: [SFML 2.5] sf::RenderWindow::setTitle crashes in main loop
« on: July 29, 2019, 06:59:43 pm »
I don't think the windows title is meant to be updated this much.
#include <SFML/Graphics.hpp>
#include <string>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "Test");
sf::Clock clock;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
}
float fps = 1.0f / clock.getElapsedTime().asSeconds();
window.setTitle("FPS: " + std::to_string(fps));
sf::sleep(sf::seconds(1));
window.clear();
window.display();
}
return 0;
}
#include <string>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "Test");
sf::Clock clock;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
}
float fps = 1.0f / clock.getElapsedTime().asSeconds();
window.setTitle("FPS: " + std::to_string(fps));
sf::sleep(sf::seconds(1));
window.clear();
window.display();
}
return 0;
}