aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp11
-rw-r--r--src/Vsync.cpp4
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