commit 81fe1ef9
Use scalemode nearest to avoid gaps between tiles.
Changed files
| M | src/sago/SagoDataHolder.cpp before |
| M | src/sago/SagoLogicalResize.hpp before |
diff --git a/src/sago/SagoDataHolder.cpp b/src/sago/SagoDataHolder.cpp
index 3f8d338..59268f4 100644
--- a/src/sago/SagoDataHolder.cpp
+++ b/src/sago/SagoDataHolder.cpp
@@ -136,6 +136,8 @@ SDL_Texture* SagoDataHolder::getTexturePtr(const std::string& textureName) const
if (!ret) {
std::cerr << "getTextureFailed to load " << path << "\n";
}
+ // Nearest ensure that we do not have gab between tiles
+ SDL_SetTextureScaleMode(ret, SDL_ScaleModeNearest);
SDL_FreeSurface(surface);
data->textures[textureName] = ret;
return ret;
diff --git a/src/sago/SagoLogicalResize.hpp b/src/sago/SagoLogicalResize.hpp
index 53db267..20a9b05 100644
--- a/src/sago/SagoLogicalResize.hpp
+++ b/src/sago/SagoLogicalResize.hpp
@@ -24,6 +24,7 @@ SOFTWARE.
#pragma once
#include <algorithm>
+#include <cmath>
#include "SDL.h"
@@ -123,10 +124,10 @@ public:
*/
void LogicalToPhysical(int* x, int* y) const {
if (x) {
- *x = *x * scale_factor_ + left_margin_;
+ *x = std::round(*x * scale_factor_ + left_margin_);
}
if (y) {
- *y = *y * scale_factor_ + top_margin_;
+ *y = std::round(*y * scale_factor_ + top_margin_);
}
}