diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-25 08:29:53 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-26 07:30:39 +0000 |
commit | da7a32c6ea92242c99412c2702ad59df36007de4 (patch) | |
tree | 79bea6d27c808d4fe5ac63941f8cbb52afb34552 /src/openglgraphics.cpp | |
parent | 4091bd9568e5aff4a1f24416d26da567a2c076ad (diff) | |
download | mana-da7a32c6ea92242c99412c2702ad59df36007de4.tar.gz mana-da7a32c6ea92242c99412c2702ad59df36007de4.tar.bz2 mana-da7a32c6ea92242c99412c2702ad59df36007de4.tar.xz mana-da7a32c6ea92242c99412c2702ad59df36007de4.zip |
Added support for HiDPI fonts
* TrueTypeFont class now takes into account the graphics scale, in order
to render an appropriate higher-resolution texture.
* Removed TrueTypeFont::fontCounter, since TTF_Init/TTF_Quit already
keep a counter.
* Avoid copying the rendered string needlessly, when it already exists
in the cache. Avoid another copy, when inserting a new chunk into the
cache.
Diffstat (limited to 'src/openglgraphics.cpp')
-rw-r--r-- | src/openglgraphics.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index 9e77e5f7..56c16586 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -131,7 +131,7 @@ void OpenGLGraphics::setReduceInputLag(bool reduceInputLag) void OpenGLGraphics::updateSize(int windowWidth, int windowHeight, float scale) { - mScale = scale; + mUserScale = scale; int drawableWidth; int drawableHeight; @@ -142,11 +142,12 @@ void OpenGLGraphics::updateSize(int windowWidth, int windowHeight, float scale) float displayScaleX = windowWidth > 0 ? static_cast<float>(drawableWidth) / windowWidth : 1.0f; float displayScaleY = windowHeight > 0 ? static_cast<float>(drawableHeight) / windowHeight : 1.0f; - mScaleX = mScale * displayScaleX; - mScaleY = mScale * displayScaleY; + mScaleX = mUserScale * displayScaleX; + mScaleY = mUserScale * displayScaleY; mWidth = std::ceil(drawableWidth / mScaleX); mHeight = std::ceil(drawableHeight / mScaleY); + mScale = mScaleX; glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -557,8 +558,8 @@ void OpenGLGraphics::updateScreen() void OpenGLGraphics::windowToLogical(int windowX, int windowY, float &logicalX, float &logicalY) const { - logicalX = windowX / mScale; - logicalY = windowY / mScale; + logicalX = windowX / mUserScale; + logicalY = windowY / mUserScale; } SDL_Surface *OpenGLGraphics::getScreenshot() |