From a536d46bb4d69d8c6431a2cc291aedde680143e6 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Wed, 2 Aug 2023 20:22:14 -0500 Subject: [PATCH] Don't interpolate placefile icon pixels This is a 90% solution to icon placement/blurring. The pixel coordinates will need rounded in the vertex shader once the MVP and map matrices are broken out for proper rotation. --- scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp index 35952346..b23ec909 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp @@ -52,6 +52,7 @@ struct PlacefileIconInfo numIcons_ = columns_ * rows_; + // Pixel size float xFactor = 0.0f; float yFactor = 0.0f; @@ -221,6 +222,10 @@ void PlacefileIcons::Render( UseMapProjection( params, p->uMapMatrixLocation_, p->uMapScreenCoordLocation_); + // Don't interpolate texture coordinates + gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + // Draw icons gl.glDrawArrays(GL_TRIANGLES, 0, p->numVertices_); } @@ -312,10 +317,10 @@ void PlacefileIcons::Impl::Update() static_cast(icon.iconFile_->iconHeight_) * 0.5f; // Final X/Y offsets in pixels - const float lx = x - hw; - const float rx = x + hw; - const float by = y - hh; - const float ty = y + hh; + const float lx = std::roundf(x - hw); + const float rx = std::roundf(x + hw); + const float by = std::roundf(y - hh); + const float ty = std::roundf(y + hh); // Angle in degrees // TODO: Properly convert