diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-09-14 05:03:14 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-09-14 05:03:14 +0200 |
commit | 46c0e4438c7092a5f45468475f0dffcc3dad041c (patch) | |
tree | 26c929b2545f7106e09bad68069f4f5129cce8c8 /src | |
parent | f270df634d9391f0488df04e2fc466b53dab5ee3 (diff) |
Fix vsync..
Diffstat (limited to 'src')
-rw-r--r-- | src/QuickMedia.cpp | 11 | ||||
-rw-r--r-- | src/Vsync.cpp | 4 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 68111a3..691357f 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -791,7 +791,9 @@ namespace QuickMedia { sf::RectangleShape tab_drop_shadow; tab_drop_shadow.setFillColor(sf::Color(23, 25, 27)); - VSync vsync(60); + VSync vsync(monitor_hz); + //sf::Clock tt; + //int fps = 0; while (current_page == Page::SEARCH_SUGGESTION) { while (window.pollEvent(event)) { base_event_handler(event, Page::EXIT, false); @@ -900,6 +902,13 @@ namespace QuickMedia { } search_bar->draw(window, false); vsync.display(window); + + // fps++; + // if(tt.getElapsedTime().asSeconds() >= 1.0f) { + // fprintf(stderr, "fps: %d\n", fps); + // fps = 0; + // tt.restart(); + // } } search_bar->onTextBeginTypingCallback = nullptr; diff --git a/src/Vsync.cpp b/src/Vsync.cpp index ab88205..d46f9fa 100644 --- a/src/Vsync.cpp +++ b/src/Vsync.cpp @@ -8,13 +8,13 @@ namespace QuickMedia { } void VSync::display(sf::RenderWindow &window) { - sf::Int64 sleep_time_micro = target_frame_delta_micro - timer.getElapsedTime().asMicroseconds(); window.display(); + sf::Int64 sleep_time_micro = target_frame_delta_micro - timer.getElapsedTime().asMicroseconds(); if(sleep_time_micro > 0) { if(usleep(sleep_time_micro) != 0) { fprintf(stderr, "failed to sleep!\n"); } - timer.restart(); } + timer.restart(); } }
\ No newline at end of file |