fix: FPS limit and counter fix

This commit is contained in:
Pc
2026-01-26 22:41:02 +01:00
parent 780e852596
commit ffa5a929df
5 changed files with 159 additions and 54 deletions

View File

@@ -1,4 +1,4 @@
#include <iostream>
#include <iostream>
#include <chrono>
class FPSCounter {
@@ -10,10 +10,14 @@ public:
auto currentTime = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = currentTime - lastTime;
// Aktualizujemy FPS co 1 sekundê
// Aktualizujemy i wypisujemy TYLKO jeśli minęła co najmniej 1 sekunda
if (elapsed.count() >= 1.0) {
double fps = frameCount / elapsed.count();
std::cout << "FPS: " << fps << "\n";
double msPerFrame = 1000.0 / fps;
std::cout << "FPS: " << (int)fps
<< " | Czas klatki: " << msPerFrame << " ms" << std::endl;
frameCount = 0;
lastTime = currentTime;
}
@@ -22,4 +26,4 @@ public:
private:
int frameCount;
std::chrono::time_point<std::chrono::high_resolution_clock> lastTime;
};
};