From bb6aa99b9e0b419540fd1f1d76616b05c65eca5a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 17 Feb 2019 08:10:14 -0800 Subject: [PATCH] Qt: Correct text bind on first draw of string. Previously, the first frame we drew a new string was using the UI texture, typically. --- ext/native/gfx_es2/draw_text_qt.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/native/gfx_es2/draw_text_qt.cpp b/ext/native/gfx_es2/draw_text_qt.cpp index a2fae32f39..a29b363397 100644 --- a/ext/native/gfx_es2/draw_text_qt.cpp +++ b/ext/native/gfx_es2/draw_text_qt.cpp @@ -81,8 +81,6 @@ void TextDrawerQt::DrawString(DrawBuffer &target, const char *str, float x, floa auto iter = cache_.find(entryHash); if (iter != cache_.end()) { entry = iter->second.get(); - entry->lastUsedFrame = frameCount_; - draw_->BindTexture(0, entry->texture); } else { QFont *font = fontMap_.find(fontHash_)->second; QFontMetrics fm(*font); @@ -104,7 +102,6 @@ void TextDrawerQt::DrawString(DrawBuffer &target, const char *str, float x, floa entry = new TextStringEntry(); entry->bmWidth = entry->width = image.width(); entry->bmHeight = entry->height = image.height(); - entry->lastUsedFrame = frameCount_; TextureDesc desc{}; desc.type = TextureType::LINEAR2D; @@ -126,8 +123,11 @@ void TextDrawerQt::DrawString(DrawBuffer &target, const char *str, float x, floa delete[] bitmapData; cache_[entryHash] = std::unique_ptr(entry); } + float w = entry->bmWidth * fontScaleX_; float h = entry->bmHeight * fontScaleY_; + entry->lastUsedFrame = frameCount_; + draw_->BindTexture(0, entry->texture); DrawBuffer::DoAlign(align, &x, &y, &w, &h); target.DrawTexRect(x, y, x + w, y + h, 0.0f, 0.0f, 1.0f, 1.0f, color); target.Flush(true);