From 92a98c6525d42a967d66492ef7bd61c4a1d7edd1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 5 Aug 2019 21:15:37 +0200 Subject: Dont use subpixel positions, it will make things blurry --- src/Body.cpp | 11 ++++++++--- src/QuickMedia.cpp | 3 ++- src/VideoPlayer.cpp | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Body.cpp b/src/Body.cpp index 79bb3c0..b9dd050 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -3,6 +3,7 @@ #include #include #include +#include const sf::Color front_color(43, 45, 47); const sf::Color back_color(33, 35, 37); @@ -84,8 +85,10 @@ namespace QuickMedia { auto result = std::make_unique(); result->setSmooth(true); std::string texture_data; - if(download_to_string(url, texture_data) == DownloadResult::OK) - result->loadFromMemory(texture_data.data(), texture_data.size()); + if(download_to_string(url, texture_data) == DownloadResult::OK) { + if(result->loadFromMemory(texture_data.data(), texture_data.size())) + result->generateMipmap(); + } return result; } @@ -141,6 +144,8 @@ namespace QuickMedia { item_background.setFillColor(sf::Color(38, 40, 42)); } + item_pos.x = std::floor(item_pos.x); + item_pos.y = std::floor(item_pos.y); item_background.setPosition(item_pos); item_background.setSize(sf::Vector2f(size.x, row_height)); window.draw(item_background); @@ -165,7 +170,7 @@ namespace QuickMedia { } title_text.setString(item->title); - title_text.setPosition(item_pos.x + text_offset_x + 10.0f, item_pos.y); + title_text.setPosition(std::floor(item_pos.x + text_offset_x + 10.0f), std::floor(item_pos.y)); window.draw(title_text); pos.y += row_height + 10.0f; diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index a867255..5ea2c43 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -7,6 +7,7 @@ #include #include #include +#include const sf::Color front_color(43, 45, 47); const sf::Color back_color(33, 35, 37); @@ -421,7 +422,7 @@ namespace QuickMedia { auto image_size = sf::Vector2f(texture_size.x, texture_size.y); image_size.x *= image_scale.x; image_size.y *= image_scale.y; - image.setPosition(window_size.x * 0.5f - image_size.x * 0.5f, window_size.y * 0.5f - image_size.y * 0.5f); + image.setPosition(std::floor(window_size.x * 0.5f - image_size.x * 0.5f), std::floor(window_size.y * 0.5f - image_size.y * 0.5f)); } } diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp index 88e2340..bcc419c 100644 --- a/src/VideoPlayer.cpp +++ b/src/VideoPlayer.cpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace QuickMedia { static void* getProcAddressMpv(void *funcContext, const char *name) { @@ -124,7 +125,7 @@ namespace QuickMedia { auto image_size = sf::Vector2f(video_size.x, video_size.y); image_size.x *= image_scale.x; image_size.y *= image_scale.y; - sprite.setPosition(desired_size.x * 0.5f - image_size.x * 0.5f, desired_size.y * 0.5f - image_size.y * 0.5f); + sprite.setPosition(std::floor(desired_size.x * 0.5f - image_size.x * 0.5f), std::floor(desired_size.y * 0.5f - image_size.y * 0.5f)); } void VideoPlayer::draw(sf::RenderWindow &window) { -- cgit v1.2.3