Improved the renderer scaling accuracy.

This commit is contained in:
Leon Styhre 2022-09-04 22:01:59 +02:00
parent d242c84ea8
commit dda63403fa
3 changed files with 6 additions and 5 deletions

View file

@ -206,7 +206,7 @@ void GuiComponent::setDimming(float dimming)
const glm::mat4& GuiComponent::getTransform()
{
mTransform = Renderer::getIdentity();
mTransform = glm::translate(mTransform, mPosition);
mTransform = glm::translate(mTransform, glm::round(mPosition));
if (mScale != 1.0f)
mTransform = glm::scale(mTransform, glm::vec3 {mScale});
@ -228,8 +228,10 @@ const glm::mat4& GuiComponent::getTransform()
if (xOff != 0.0f || yOff != 0.0f)
mTransform = glm::translate(mTransform, glm::vec3 {xOff, yOff, 0.0f});
}
mTransform = glm::translate(
mTransform, glm::vec3 {mOrigin.x * mSize.x * -1.0f, mOrigin.y * mSize.y * -1.0f, 0.0f});
mTransform =
glm::translate(mTransform, glm::vec3 {std::round(mOrigin.x * mSize.x * -1.0f),
std::round(mOrigin.y * mSize.y * -1.0f), 0.0f});
return mTransform;
}

View file

@ -204,7 +204,7 @@ void TextComponent::render(const glm::mat4& parentTrans)
mRenderer->drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0x0000FF33, 0x0000FF33);
}
trans = glm::translate(trans, glm::vec3 {0.0f, yOff, 0.0f});
trans = glm::translate(trans, glm::vec3 {0.0f, std::round(yOff), 0.0f});
mRenderer->setMatrix(trans);
// Draw the text area, where the text actually is located.

View file

@ -278,7 +278,6 @@ void RendererOpenGL::destroyContext()
void RendererOpenGL::setMatrix(const glm::mat4& matrix)
{
mTrans = matrix;
mTrans[3] = glm::round(mTrans[3]);
mTrans = getProjectionMatrix() * mTrans;
}