Skip to content

Commit

Permalink
Merge pull request #11808 from unknownbrackets/qt-textdrawer
Browse files Browse the repository at this point in the history
Qt: Correct text bind on first draw of string
  • Loading branch information
hrydgard authored Feb 17, 2019
2 parents f955cc0 + bb6aa99 commit 8090c3d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ext/native/gfx_es2/draw_text_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -126,8 +123,11 @@ void TextDrawerQt::DrawString(DrawBuffer &target, const char *str, float x, floa
delete[] bitmapData;
cache_[entryHash] = std::unique_ptr<TextStringEntry>(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);
Expand Down

0 comments on commit 8090c3d

Please sign in to comment.