Removed some projection matrix and vertices roundings which caused multiple pixel alignment issues.

This commit is contained in:
Leon Styhre 2022-09-02 21:01:31 +02:00
parent 4ade04d760
commit a1027c2580
6 changed files with 8 additions and 18 deletions

View file

@ -430,7 +430,7 @@ void ImageComponent::render(const glm::mat4& parentTrans)
return;
glm::mat4 trans {parentTrans * getTransform()};
mRenderer->setMatrix(trans, false);
mRenderer->setMatrix(trans);
if (mTexture && mOpacity > 0.0f) {
if (Settings::getInstance()->getBool("DebugImage")) {

View file

@ -204,13 +204,8 @@ 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, std::round(yOff), 0.0f});
// Don't round vertices if scaled as it may lead to single-pixel alignment issues.
if (mScale == 1.0f)
mRenderer->setMatrix(trans, true);
else
mRenderer->setMatrix(trans, false);
trans = glm::translate(trans, glm::vec3 {0.0f, yOff, 0.0f});
mRenderer->setMatrix(trans);
// Draw the text area, where the text actually is located.
if (Settings::getInstance()->getBool("DebugText")) {

View file

@ -615,9 +615,6 @@ template <typename T> void CarouselComponent<T>::render(const glm::mat4& parentT
yOff += mSize.y * mVerticalOffset;
}
xOff = std::round(xOff);
yOff = std::round(yOff);
int center {static_cast<int>(mEntryCamOffset)};
int itemInclusion {static_cast<int>(std::ceil(mMaxItemCount / 2.0f))};
bool singleEntry {numEntries == 1};

View file

@ -202,7 +202,7 @@ public:
const unsigned int numVertices,
const BlendFactor srcBlendFactor = BlendFactor::SRC_ALPHA,
const BlendFactor dstBlendFactor = BlendFactor::ONE_MINUS_SRC_ALPHA) = 0;
virtual void setMatrix(const glm::mat4& matrix, bool roundVertices = true) = 0;
virtual void setMatrix(const glm::mat4& matrix) = 0;
virtual void setScissor(const Rect& scissor) = 0;
virtual void setSwapInterval() = 0;
virtual void swapBuffers() = 0;

View file

@ -275,12 +275,10 @@ void RendererOpenGL::destroyContext()
mSDLContext = nullptr;
}
void RendererOpenGL::setMatrix(const glm::mat4& matrix, bool roundVertices)
void RendererOpenGL::setMatrix(const glm::mat4& matrix)
{
mTrans = matrix;
if (roundVertices)
mTrans[3] = glm::round(mTrans[3]);
mTrans = getProjectionMatrix() * mTrans;
// Calculate the project matrix.
mTrans = getProjectionMatrix() * matrix;
}
void RendererOpenGL::setScissor(const Rect& scissor)

View file

@ -38,7 +38,7 @@ public:
bool createContext() override;
void destroyContext() override;
void setMatrix(const glm::mat4& matrix, bool roundVertices = true) override;
void setMatrix(const glm::mat4& matrix) override;
void setScissor(const Rect& scissor) override;
void setSwapInterval() override;
void swapBuffers() override;