Fixed a font rendering issue in TextListComponent.

This commit is contained in:
Leon Styhre 2022-09-04 23:48:27 +02:00
parent b9a2031cf6
commit 77a2383683

View file

@ -460,11 +460,14 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
glm::mat4 drawTrans {trans}; glm::mat4 drawTrans {trans};
// Currently selected item text might be looping. // Currently selected item text might be looping.
if (mCursor == i && mLoopOffset > 0) if (mCursor == i && mLoopOffset > 0) {
drawTrans = glm::translate( drawTrans = glm::translate(
drawTrans, offset - glm::vec3 {static_cast<float>(mLoopOffset), 0.0f, 0.0f}); drawTrans,
else glm::round(offset - glm::vec3 {static_cast<float>(mLoopOffset), 0.0f, 0.0f}));
drawTrans = glm::translate(drawTrans, offset); }
else {
drawTrans = glm::translate(drawTrans, glm::round(offset));
}
// Needed to avoid flickering when returning to the start position. // Needed to avoid flickering when returning to the start position.
if (mLoopOffset == 0 && mLoopOffset2 == 0) if (mLoopOffset == 0 && mLoopOffset2 == 0)
@ -478,7 +481,8 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
mLoopScroll = true; mLoopScroll = true;
drawTrans = trans; drawTrans = trans;
drawTrans = glm::translate( drawTrans = glm::translate(
drawTrans, offset - glm::vec3 {static_cast<float>(mLoopOffset2), 0.0f, 0.0f}); drawTrans,
glm::round(offset - glm::vec3 {static_cast<float>(mLoopOffset2), 0.0f, 0.0f}));
mRenderer->setMatrix(drawTrans); mRenderer->setMatrix(drawTrans);
font->renderTextCache(entry.data.textCache.get()); font->renderTextCache(entry.data.textCache.get());
} }