Clamped the scale factor in NinePatchComponent to avoid artifacts for extreme screen resolutions.

This commit is contained in:
Leon Styhre 2021-01-16 20:53:09 +01:00
parent 0b259dc47a
commit a3c2f831c8

View file

@ -51,8 +51,11 @@ void NinePatchComponent::buildVertices()
if (mVertices != nullptr) if (mVertices != nullptr)
delete[] mVertices; delete[] mVertices;
// Scale the corner size relative to the screen resolution. // Scale the corner size relative to the screen resolution, but keep the scale factor
mTexture = TextureResource::get(mPath, false, false, true, Renderer::getScreenWidthModifier()); // within reason as extreme resolutions may cause artifacts. Any "normal" resolution
// (e.g. from 720p to 4K) will be within these boundaries though.
float scaleFactor = Math::clamp(Renderer::getScreenWidthModifier(), 0.4f, 3.0f);
mTexture = TextureResource::get(mPath, false, false, true, scaleFactor);
if (mTexture->getSize() == Vector2i::Zero()) { if (mTexture->getSize() == Vector2i::Zero()) {
mVertices = nullptr; mVertices = nullptr;