FPS can be limited

This commit is contained in:
Robert 2020-05-18 16:53:01 +02:00
parent 85ab65737a
commit 7d178b36cb
4 changed files with 51 additions and 6 deletions

View file

@ -15,10 +15,14 @@ int main(int argc, char** argv)
}
}
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
Uint64 diff = 1;
MyWindow window(800, 800, "Test");
SDL_SetWindowTitle(window.GetWindow(), "New Title");
window.SetIcon(64, 64, icon_data);
window.SetMaxFramerate(144);
SDL_Event event;
float t = 0.f;
@ -42,6 +46,11 @@ int main(int argc, char** argv)
window.Display();
t += 0.01;
diff = std::chrono::duration_cast<std::chrono::microseconds>
(std::chrono::steady_clock::now() - start).count();
window.SetTitle(std::to_string(1000000 / diff) + " FPS");
start = std::chrono::steady_clock::now();
}
SDL_Quit();