I tried to write code that reproduces the problem, but it does not reproduce it, apparently the problem is still somewhere, thank you
#include <SFML/Graphics.hpp>
float calculateMediumFPS(std::vector<float>& lastFPS) {
float sum = 0.0f;
for(const auto &fps: lastFPS) {
sum += fps;
}
return sum / static_cast<float>(lastFPS.size());
}
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
sf::RenderTarget* renderTarget = &window; //When the pointer type is sf::RenderWindow, it works faster
sf::Clock clock;
std::vector<float> lastFPS(60, 0.0f);
while (window.isOpen())
{
lastFPS[0] = 1.f / clock.restart().asSeconds();
std::rotate(lastFPS.begin(), lastFPS.begin() + 1, lastFPS.end());
float mediumFPS = calculateMediumFPS(lastFPS);
window.setTitle(std::to_string(static_cast<int>(mediumFPS)));
clock.restart(); //to count only the game cycle, not taking into account the cost of the FPS meter
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
renderTarget->draw(shape);
window.display();
}
return 0;
}