Browse Source

Direct3D font rendering fix for TurboBadger

Josh Engebretson 11 years ago
parent
commit
f7e19e3173

+ 6 - 3
Source/Atomic/UI/TBUI.cpp

@@ -190,10 +190,13 @@ bool TBUIBitmap::Init(int width, int height, tb::uint32 *data)
     height_ = height;
 
     texture_ = new Texture2D(renderer_->context_);
-    texture_->SetMipsToSkip(0, 0);
+    texture_->SetMipsToSkip(QUALITY_LOW, 0); // No quality reduction
     texture_->SetNumLevels(1);
+    texture_->SetAddressMode(COORD_U, ADDRESS_BORDER);
+    texture_->SetAddressMode(COORD_V, ADDRESS_BORDER),
+    texture_->SetBorderColor(Color(0.0f, 0.0f, 0.0f, 0.0f));
     texture_->SetSize(width_, height_,  Graphics::GetRGBAFormat(), TEXTURE_STATIC);
-    texture_->SetFilterMode(FILTER_NEAREST);
+
     SetData(data);
 
     return true;
@@ -261,7 +264,7 @@ void TBUI::Initialize()
     // Load the default skin, and override skin that contains the graphics specific to the demo.
     tb::g_tb_skin->Load("AtomicEditor/resources/default_skin/skin.tb.txt", "AtomicEditor/editor/skin/skin.tb.txt");
 
-    register_tbbf_font_renderer();
+    //register_tbbf_font_renderer();
     //register_stb_font_renderer();
     register_freetype_font_renderer();
 

+ 2 - 0
Source/ThirdParty/TurboBadger/CMakeLists.txt

@@ -10,6 +10,8 @@ endif(APPLE)
 
 add_definitions(-DTB_FONT_RENDERER_FREETYPE)
 
+#add_definitions(-DTB_FONT_RENDERER_STB)
+
 # Define source files
 file (GLOB C_FILES *.cpp image/*.cpp animation/*.cpp parser/*.cpp renderers/*.cpp utf8/*.cpp)
 file (GLOB H_FILES *.h image/*.h animation/*.h parser/*.h renderers/*.h utf8/*.h)

+ 20 - 12
Source/ThirdParty/TurboBadger/renderers/tb_renderer_batcher.cpp

@@ -235,35 +235,43 @@ void TBRendererBatcher::AddQuadInternal(const TBRect &dst_rect, const TBRect &sr
 		m_uu = (float)(src_rect.x + src_rect.w) / bitmap_w;
 		m_vv = (float)(src_rect.y + src_rect.h) / bitmap_h;
 	}
+
+#ifdef _MSC_VER
+       //Direct3D Adjustment
+       float posAdjust = 0.5f;
+#else
+       float posAdjust = 0.0f;
+#endif
+
 	Vertex *ver = batch.Reserve(this, 6);
-	ver[0].x = (float) dst_rect.x;
-	ver[0].y = (float) (dst_rect.y + dst_rect.h);
+    ver[0].x = (float) dst_rect.x + posAdjust;
+    ver[0].y = (float) (dst_rect.y + dst_rect.h) + posAdjust;
 	ver[0].u = m_u;
 	ver[0].v = m_vv;
 	ver[0].col = color;
-	ver[1].x = (float) (dst_rect.x + dst_rect.w);
-	ver[1].y = (float) (dst_rect.y + dst_rect.h);
+    ver[1].x = (float) (dst_rect.x + dst_rect.w) + posAdjust;
+    ver[1].y = (float) (dst_rect.y + dst_rect.h) + posAdjust;
 	ver[1].u = m_uu;
 	ver[1].v = m_vv;
 	ver[1].col = color;
-	ver[2].x = (float) dst_rect.x;
-	ver[2].y = (float) dst_rect.y;
+    ver[2].x = (float) dst_rect.x + posAdjust;
+    ver[2].y = (float) dst_rect.y + posAdjust;
 	ver[2].u = m_u;
 	ver[2].v = m_v;
 	ver[2].col = color;
 
-	ver[3].x = (float) dst_rect.x;
-	ver[3].y = (float) dst_rect.y;
+    ver[3].x = (float) dst_rect.x + posAdjust;
+    ver[3].y = (float) dst_rect.y + posAdjust;
 	ver[3].u = m_u;
 	ver[3].v = m_v;
 	ver[3].col = color;
-	ver[4].x = (float) (dst_rect.x + dst_rect.w);
-	ver[4].y = (float) (dst_rect.y + dst_rect.h);
+    ver[4].x = (float) (dst_rect.x + dst_rect.w) + posAdjust;
+    ver[4].y = (float) (dst_rect.y + dst_rect.h) + posAdjust;
 	ver[4].u = m_uu;
 	ver[4].v = m_vv;
 	ver[4].col = color;
-	ver[5].x = (float) (dst_rect.x + dst_rect.w);
-	ver[5].y = (float) dst_rect.y;
+    ver[5].x = (float) (dst_rect.x + dst_rect.w) + posAdjust;
+    ver[5].y = (float) dst_rect.y + posAdjust;
 	ver[5].u = m_uu;
 	ver[5].v = m_v;
 	ver[5].col = color;

+ 1 - 1
Source/ThirdParty/TurboBadger/tb_font_renderer_stb.cpp

@@ -12,7 +12,7 @@
 using namespace tb;
 
 #define STB_TRUETYPE_IMPLEMENTATION  // force following include to generate implementation
-#include "thirdparty/stb_truetype.h"
+#include "../../ThirdParty/STB/stb_truetype.h"
 
 /** STBFontRenderer renders fonts using stb_truetype.h (http://nothings.org/) */