From ef25c675f7b9e067bf87bce5f994d1083039fefe Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 16 Jan 2021 22:55:38 +0100 Subject: [PATCH] Fixed an issue where separator lines would not get rendered on lower resolutions. --- es-core/src/components/ComponentGrid.cpp | 4 ++-- es-core/src/renderers/Renderer.cpp | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/es-core/src/components/ComponentGrid.cpp b/es-core/src/components/ComponentGrid.cpp index 7965df043..3b2ca1bc3 100644 --- a/es-core/src/components/ComponentGrid.cpp +++ b/es-core/src/components/ComponentGrid.cpp @@ -208,7 +208,7 @@ void ComponentGrid::updateSeparators() std::vector coordVector; coordVector.push_back(pos.x()); coordVector.push_back(pos.y()); - coordVector.push_back(1.0f * Renderer::getScreenHeightModifier()); + coordVector.push_back(1.0f * Renderer::getScreenWidthModifier()); coordVector.push_back(size.y()); mSeparators.push_back(coordVector); } @@ -216,7 +216,7 @@ void ComponentGrid::updateSeparators() std::vector coordVector; coordVector.push_back(pos.x() + size.x()); coordVector.push_back(pos.y()); - coordVector.push_back(1.0f * Renderer::getScreenHeightModifier()); + coordVector.push_back(1.0f * Renderer::getScreenWidthModifier()); coordVector.push_back(size.y()); mSeparators.push_back(coordVector); } diff --git a/es-core/src/renderers/Renderer.cpp b/es-core/src/renderers/Renderer.cpp index c03267710..dba1278dd 100644 --- a/es-core/src/renderers/Renderer.cpp +++ b/es-core/src/renderers/Renderer.cpp @@ -364,10 +364,20 @@ namespace Renderer const unsigned int colorEnd = convertRGBAToABGR(_colorEnd); Vertex vertices[4]; - vertices[0] = { { _x ,_y }, { 0.0f, 0.0f }, color }; - vertices[1] = { { _x ,_y + _h }, { 0.0f, 0.0f }, horizontalGradient ? colorEnd : color }; - vertices[2] = { { _x + _w,_y }, { 0.0f, 0.0f }, horizontalGradient ? color : colorEnd }; - vertices[3] = { { _x + _w,_y + _h }, { 0.0f, 0.0f }, colorEnd }; + float _wL = _w; + float _hL = _h; + + // If the width or height was scaled down to less than 1 pixel, then set it to + // 1 pixel so that it will still render on lower resolutions. + if (_wL > 0 && _wL < 1) + _wL = 1; + if (_hL > 0 && _hL < 1) + _hL = 1; + + vertices[0] = { { _x , _y }, { 0.0f, 0.0f }, color }; + vertices[1] = { { _x , _y + _hL }, { 0.0f, 0.0f }, horizontalGradient ? colorEnd : color }; + vertices[2] = { { _x + _wL, _y }, { 0.0f, 0.0f }, horizontalGradient ? color : colorEnd }; + vertices[3] = { { _x + _wL, _y + _hL }, { 0.0f, 0.0f }, colorEnd }; // Round vertices. for (int i = 0; i < 4; ++i)