diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-08-05 21:15:37 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2019-08-05 21:15:40 +0200 |
commit | 92a98c6525d42a967d66492ef7bd61c4a1d7edd1 (patch) | |
tree | c42d58a473095fba0e2ec2156032c73e5e622203 /src | |
parent | 458bec27a375a94a4fbdcc547c3cfff05583985f (diff) |
Dont use subpixel positions, it will make things blurry
Diffstat (limited to 'src')
-rw-r--r-- | src/Body.cpp | 11 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 3 | ||||
-rw-r--r-- | src/VideoPlayer.cpp | 3 |
3 files changed, 12 insertions, 5 deletions
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 <SFML/Graphics/RectangleShape.hpp> #include <SFML/Graphics/Sprite.hpp> #include <assert.h> +#include <cmath> 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<sf::Texture>(); 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 <SFML/Graphics/Text.hpp> #include <SFML/Window/Event.hpp> #include <assert.h> +#include <cmath> 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 <mpv/opengl_cb.h> #include <SFML/OpenGL.hpp> #include <clocale> +#include <cmath> 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) { |