Implement rounding on DrawString input coordinates (Crisp text rendering even when users pass in non-integer values, however, still need to account for non-integer scaling).
This commit is contained in:
1
main.cpp
1
main.cpp
@@ -1,4 +1,3 @@
|
||||
|
||||
#include <JGL/JGL.h>
|
||||
#include <rewindow/types/window.h>
|
||||
#include <Colors.hpp>
|
||||
|
@@ -95,6 +95,15 @@ namespace JGL {
|
||||
// Offset by height to render at "correct" location.
|
||||
y += size;
|
||||
|
||||
bool round_text_coords_for_crisp_rendering = true;
|
||||
|
||||
// TODO: This currently does not account for non-integer scale factors.
|
||||
if (round_text_coords_for_crisp_rendering)
|
||||
{
|
||||
x = J3ML::Math::Floor(x);
|
||||
y = J3ML::Math::Floor(y);
|
||||
}
|
||||
|
||||
CachedFont* cachedFont = fontCache.getFont(size, font.index);
|
||||
|
||||
if (font.face == nullptr)
|
||||
@@ -153,6 +162,17 @@ namespace JGL {
|
||||
float y = pos.y;
|
||||
float z = pos.z;
|
||||
|
||||
|
||||
bool round_text_coords_for_crisp_rendering = true;
|
||||
|
||||
// TODO: This currently does not account for non-integer scale factors.
|
||||
if (round_text_coords_for_crisp_rendering)
|
||||
{
|
||||
x = J3ML::Math::Floor(x);
|
||||
y = J3ML::Math::Floor(y);
|
||||
z = J3ML::Math::Floor(z);
|
||||
}
|
||||
|
||||
CachedFont* cachedFont = fontCache.getFont(size, font.index);
|
||||
if (font.face == nullptr)
|
||||
jlog::Fatal("Drawing a string with an uninitialized font?");
|
||||
|
Reference in New Issue
Block a user