[colobot] 36/145: Fix for #738

Didier Raboud odyx at moszumanska.debian.org
Mon Jul 11 12:56:15 UTC 2016


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 72f966b1184eec4fee04260cd2fedb544e80ee6a
Author: Piotr Dziwinski <piotrdz at gmail.com>
Date:   Sun Apr 3 16:45:13 2016 +1200

    Fix for #738
    
    Add one-pixel boundary and fix texture coordinates for font characters
    This should finally fix the issue of pixelated text
---
 src/graphics/engine/text.cpp | 15 ++++++++-------
 src/graphics/engine/text.h   |  1 -
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index c1317f1..7ecf204 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -944,10 +944,11 @@ void CText::DrawCharAndAdjustPos(UTF8Char ch, FontType font, float size, Math::P
         Math::Point p1(pos.x, pos.y);
         Math::Point p2(pos.x + charInterfaceSize.x, pos.y + charInterfaceSize.y);
 
-        Math::Point texCoord1(static_cast<float>(tex.charPos.x) / FONT_TEXTURE_SIZE.x,
-                              static_cast<float>(tex.charPos.y) / FONT_TEXTURE_SIZE.y);
-        Math::Point texCoord2(static_cast<float>(tex.charPos.x + tex.charSize.x) / FONT_TEXTURE_SIZE.x,
-                              static_cast<float>(tex.charPos.y + tex.charSize.y) / FONT_TEXTURE_SIZE.y);
+        const float halfPixelMargin = 0.5f;
+        Math::Point texCoord1(static_cast<float>(tex.charPos.x + halfPixelMargin) / FONT_TEXTURE_SIZE.x,
+                              static_cast<float>(tex.charPos.y + halfPixelMargin) / FONT_TEXTURE_SIZE.y);
+        Math::Point texCoord2(static_cast<float>(tex.charPos.x + tex.charSize.x + halfPixelMargin) / FONT_TEXTURE_SIZE.x,
+                              static_cast<float>(tex.charPos.y + tex.charSize.y + halfPixelMargin) / FONT_TEXTURE_SIZE.y);
         Math::Vector n(0.0f, 0.0f, -1.0f);  // normal
 
         Vertex quad[4] =
@@ -1061,8 +1062,9 @@ CharTexture CText::CreateCharTexture(UTF8Char ch, CachedFont* font)
         return texture;
     }
 
-    Math::IntPoint tileSize(Math::NextPowerOfTwo(textSurface->w),
-                            Math::NextPowerOfTwo(textSurface->h));
+    const int pixelMargin = 1;
+    Math::IntPoint tileSize(Math::NextPowerOfTwo(textSurface->w) + pixelMargin,
+                            Math::NextPowerOfTwo(textSurface->h) + pixelMargin);
 
     FontTexture* fontTexture = GetOrCreateFontTexture(tileSize);
 
@@ -1075,7 +1077,6 @@ CharTexture CText::CreateCharTexture(UTF8Char ch, CachedFont* font)
         texture.id = fontTexture->id;
         texture.charPos = GetNextTilePos(*fontTexture);
         texture.charSize = Math::IntPoint(textSurface->w, textSurface->h);
-        texture.tileSize = tileSize;
 
         ImageData imageData;
         imageData.surface = textSurface;
diff --git a/src/graphics/engine/text.h b/src/graphics/engine/text.h
index 962c755..6ee0a86 100644
--- a/src/graphics/engine/text.h
+++ b/src/graphics/engine/text.h
@@ -193,7 +193,6 @@ struct CharTexture
     unsigned int id = 0;
     Math::IntPoint charPos;
     Math::IntPoint charSize;
-    Math::IntPoint tileSize;
 };
 
 // Definition is private - in text.cpp

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list