Replaced some internal math functions with equivalents from the GLM library.

This commit is contained in:
Leon Styhre 2021-08-17 20:55:29 +02:00
parent 71d0e14a77
commit 74e21e8c03
28 changed files with 63 additions and 68 deletions

View file

@ -11,7 +11,6 @@
#include "FileData.h"
#include "Log.h"
#include "Settings.h"
#include "math/Misc.h"
#include "utils/StringUtil.h"
#include "views/UIModeController.h"

View file

@ -12,7 +12,6 @@
#include "Log.h"
#include "Settings.h"
#include "SystemData.h"
#include "math/Misc.h"
#include "utils/StringUtil.h"
#include <chrono>
@ -564,11 +563,11 @@ void MiximageGenerator::calculateMarqueeSize(const unsigned int& targetWidth,
// an approximately equivalent amount of space on the miximage.
float widthRatio = static_cast<float>(width) / static_cast<float>(height);
widthModifier = Math::clamp(widthModifier + widthRatio / 6.5f, 0.0f, 1.0f);
widthModifier = glm::clamp(widthModifier + widthRatio / 6.5f, 0.0f, 1.0f);
// Hack to increase the size slightly for wider and shorter images.
if (widthRatio >= 4)
widthModifier += Math::clamp(widthRatio / 40.0f, 0.0f, 0.3f);
widthModifier += glm::clamp(widthRatio / 40.0f, 0.0f, 0.3f);
adjustedTargetWidth =
static_cast<unsigned int>(static_cast<float>(targetWidth) * widthModifier);
@ -620,9 +619,9 @@ void MiximageGenerator::sampleFrameColor(CImg<unsigned char>& screenshotImage,
}
}
unsigned char redC = Math::clamp(static_cast<int>(redLine / 255), 0, 255);
unsigned char greenC = Math::clamp(static_cast<int>(greenLine / 255), 0, 255);
unsigned char blueC = Math::clamp(static_cast<int>(blueLine / 255), 0, 255);
unsigned char redC = glm::clamp(static_cast<int>(redLine / 255), 0, 255);
unsigned char greenC = glm::clamp(static_cast<int>(greenLine / 255), 0, 255);
unsigned char blueC = glm::clamp(static_cast<int>(blueLine / 255), 0, 255);
// Convert to the HSL color space to be able to modify saturation and lightness.
CImg<float> colorHSL = CImg<>(1, 1, 1, 3).fill(redC, greenC, blueC).RGBtoHSL();
@ -635,8 +634,8 @@ void MiximageGenerator::sampleFrameColor(CImg<unsigned char>& screenshotImage,
// makes the end result look better than the raw average pixel value. Also clamp
// the lightness to a low value so we don't get a frame that is nearly pitch black
// if the screenshot mostly contains blacks or dark colors.
colorHSL(0, 0, 0, 1) = Math::clamp(saturation * 0.9f, 0.0f, 1.0f);
colorHSL(0, 0, 0, 2) = Math::clamp(lightness * 1.25f, 0.10f, 1.0f);
colorHSL(0, 0, 0, 1) = glm::clamp(saturation * 0.9f, 0.0f, 1.0f);
colorHSL(0, 0, 0, 2) = glm::clamp(lightness * 1.25f, 0.10f, 1.0f);
const CImg<unsigned char> colorRGB = colorHSL.HSLtoRGB();

View file

@ -291,13 +291,13 @@ void SystemScreensaver::renderScreensaver()
0x00000000 | mRectangleFadeIn, 0x00000000 | mRectangleFadeIn);
}
mRectangleFadeIn =
Math::clamp(mRectangleFadeIn + 6 + mRectangleFadeIn / 20, 0, 170);
glm::clamp(mRectangleFadeIn + 6 + mRectangleFadeIn / 20, 0, 170);
mGameOverlay.get()->setColor(0xFFFFFF00 | mTextFadeIn);
if (mTextFadeIn > 50)
mGameOverlayFont.at(0)->renderTextCache(mGameOverlay.get());
if (mTextFadeIn < 255)
mTextFadeIn = Math::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255);
mTextFadeIn = glm::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255);
}
}
else {
@ -344,13 +344,13 @@ void SystemScreensaver::renderScreensaver()
0x00000000 | mRectangleFadeIn, 0x00000000 | mRectangleFadeIn);
}
mRectangleFadeIn =
Math::clamp(mRectangleFadeIn + 6 + mRectangleFadeIn / 20, 0, 170);
glm::clamp(mRectangleFadeIn + 6 + mRectangleFadeIn / 20, 0, 170);
mGameOverlay.get()->setColor(0xFFFFFF00 | mTextFadeIn);
if (mTextFadeIn > 50)
mGameOverlayFont.at(0)->renderTextCache(mGameOverlay.get());
if (mTextFadeIn < 255)
mTextFadeIn = Math::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255);
mTextFadeIn = glm::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255);
}
}
else {
@ -364,11 +364,11 @@ void SystemScreensaver::renderScreensaver()
dimParameters.fragmentDimValue = mDimValue;
Renderer::shaderPostprocessing(Renderer::SHADER_DIM, dimParameters);
if (mDimValue > 0.4)
mDimValue = Math::clamp(mDimValue - 0.021f, 0.4f, 1.0f);
mDimValue = glm::clamp(mDimValue - 0.021f, 0.4f, 1.0f);
dimParameters.fragmentSaturation = mSaturationAmount;
Renderer::shaderPostprocessing(Renderer::SHADER_DESATURATE, dimParameters);
if (mSaturationAmount > 0.0)
mSaturationAmount = Math::clamp(mSaturationAmount - 0.035f, 0.0f, 1.0f);
mSaturationAmount = glm::clamp(mSaturationAmount - 0.035f, 0.0f, 1.0f);
#else
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), Renderer::getScreenHeight(),
0x000000A0, 0x000000A0);
@ -380,7 +380,7 @@ void SystemScreensaver::renderScreensaver()
blackParameters.fragmentDimValue = mDimValue;
Renderer::shaderPostprocessing(Renderer::SHADER_DIM, blackParameters);
if (mDimValue > 0.0)
mDimValue = Math::clamp(mDimValue - 0.045f, 0.0f, 1.0f);
mDimValue = glm::clamp(mDimValue - 0.045f, 0.0f, 1.0f);
#else
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), Renderer::getScreenHeight(),
0x000000FF, 0x000000FF);

View file

@ -212,13 +212,13 @@ int VolumeControl::getVolume() const
}
#endif
volume = Math::clamp(volume, 0, 100);
volume = glm::clamp(volume, 0, 100);
return volume;
}
void VolumeControl::setVolume(int volume)
{
volume = Math::clamp(volume, 0, 100);
volume = glm::clamp(volume, 0, 100);
#if defined(__linux__)
if (mixerElem != nullptr) {

View file

@ -27,9 +27,9 @@ public:
void apply(float t) override
{
t -= 1;
cameraPosition[3].x = -Math::lerp(-mCameraStart[3].x, mTarget.x, t * t * t + 1);
cameraPosition[3].y = -Math::lerp(-mCameraStart[3].y, mTarget.y, t * t * t + 1);
cameraPosition[3].z = -Math::lerp(-mCameraStart[3].z, mTarget.z, t * t * t + 1);
cameraPosition[3].x = -glm::mix(-mCameraStart[3].x, mTarget.x, t * t * t + 1);
cameraPosition[3].y = -glm::mix(-mCameraStart[3].y, mTarget.y, t * t * t + 1);
cameraPosition[3].z = -glm::mix(-mCameraStart[3].z, mTarget.z, t * t * t + 1);
}
private:

View file

@ -103,7 +103,7 @@ GuiGameScraper::GuiGameScraper(Window* window,
// Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is
// the 16:9 reference.
float aspectValue = 1.778f / Renderer::getScreenAspectRatio();
float width = Math::clamp(0.95f * aspectValue, 0.70f, 0.95f) * Renderer::getScreenWidth();
float width = glm::clamp(0.95f * aspectValue, 0.70f, 0.95f) * Renderer::getScreenWidth();
setSize(width, Renderer::getScreenHeight() * 0.747f);
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,

View file

@ -12,7 +12,6 @@
#include "SystemData.h"
#include "components/ComponentGrid.h"
#include "components/TextComponent.h"
#include "math/Misc.h"
#include "utils/StringUtil.h"
GuiLaunchScreen::GuiLaunchScreen(Window* window)
@ -104,8 +103,8 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
// reference.
float aspectValue = 1.778f / Renderer::getScreenAspectRatio();
float maxWidthModifier = Math::clamp(0.78f * aspectValue, 0.78f, 0.90f);
float minWidthModifier = Math::clamp(0.50f * aspectValue, 0.50f, 0.65f);
float maxWidthModifier = glm::clamp(0.78f * aspectValue, 0.78f, 0.90f);
float minWidthModifier = glm::clamp(0.50f * aspectValue, 0.50f, 0.65f);
float maxWidth = static_cast<float>(Renderer::getScreenWidth()) * maxWidthModifier;
float minWidth = static_cast<float>(Renderer::getScreenWidth()) * minWidthModifier;
@ -119,7 +118,7 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
// Add a bit of width to compensate for the left and right spacers.
fontWidth += static_cast<float>(Renderer::getScreenWidth()) * 0.05f;
float width = Math::clamp(fontWidth, minWidth, maxWidth);
float width = glm::clamp(fontWidth, minWidth, maxWidth);
if (mImagePath != "")
setSize(width, static_cast<float>(Renderer::getScreenHeight()) * 0.60f);
@ -219,7 +218,7 @@ void GuiLaunchScreen::update(int deltaTime)
if (Settings::getInstance()->getString("MenuOpeningEffect") == "none")
mScaleUp = 1.0f;
else if (mScaleUp < 1.0f)
mScaleUp = Math::clamp(mScaleUp + 0.07f, 0.0f, 1.0f);
mScaleUp = glm::clamp(mScaleUp + 0.07f, 0.0f, 1.0f);
}
void GuiLaunchScreen::render()

View file

@ -107,7 +107,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
// Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is
// the 16:9 reference.
float aspectValue = 1.778f / Renderer::getScreenAspectRatio();
float width = Math::clamp(0.95f * aspectValue, 0.70f, 0.95f) * Renderer::getScreenWidth();
float width = glm::clamp(0.95f * aspectValue, 0.70f, 0.95f) * Renderer::getScreenWidth();
setSize(width, Renderer::getScreenHeight() * 0.849f);
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,

View file

@ -14,7 +14,6 @@
#include "PlatformId.h"
#include "Settings.h"
#include "SystemData.h"
#include "math/Misc.h"
#include "utils/StringUtil.h"
#include "utils/TimeUtil.h"

View file

@ -315,7 +315,7 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
anim = new LambdaAnimation(
[this, startExtrasFade, startPos, endPos, posMax](float t) {
t -= 1;
float f = Math::lerp(startPos, endPos, t * t * t + 1);
float f = glm::mix(startPos, endPos, t * t * t + 1);
if (f < 0)
f += posMax;
if (f >= posMax)
@ -325,11 +325,13 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
t += 1;
if (t < 0.3f)
this->mExtrasFadeOpacity = Math::lerp(0.0f, 1.0f, t / 0.2f + startExtrasFade);
this->mExtrasFadeOpacity =
glm::mix(0.0f, 1.0f, glm::clamp(t / 0.2f + startExtrasFade, 0.0f, 1.0f));
else if (t < 0.7f)
this->mExtrasFadeOpacity = 1.0f;
else
this->mExtrasFadeOpacity = Math::lerp(1.0f, 0.0f, (t - 0.6f) / 0.3f);
this->mExtrasFadeOpacity =
glm::mix(1.0f, 0.0f, glm::clamp((t - 0.6f) / 0.3f, 0.0f, 1.0f));
if (t > 0.5f)
this->mExtrasCamOffset = endPos;
@ -345,7 +347,7 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
anim = new LambdaAnimation(
[this, startPos, endPos, posMax](float t) {
t -= 1;
float f = Math::lerp(startPos, endPos, t * t * t + 1);
float f = glm::mix(startPos, endPos, t * t * t + 1);
if (f < 0)
f += posMax;
if (f >= posMax)
@ -381,7 +383,7 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
anim = new LambdaAnimation(
[this, startPos, endPos, posMax](float t) {
t -= 1;
float f = Math::lerp(startPos, endPos, t * t * t + 1);
float f = glm::mix(startPos, endPos, t * t * t + 1);
if (f < 0)
f += posMax;
if (f >= posMax)

View file

@ -561,7 +561,7 @@ void ViewController::playViewTransition(bool instant)
// Without this, a (much shorter) fade transition would still play as
// finishedCallback is calling this function.
if (!mCancelledTransition)
mFadeOpacity = Math::lerp(0.0f, 1.0f, t);
mFadeOpacity = glm::mix(0.0f, 1.0f, t);
};
auto fadeCallback = [this]() {

View file

@ -384,7 +384,7 @@ void DetailedGameListView::updateInfoPanel()
// Fade in the game image.
auto func = [this](float t) {
mImage.setOpacity(static_cast<unsigned char>(
Math::lerp(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
glm::mix(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
};
mImage.setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false);
@ -432,7 +432,7 @@ void DetailedGameListView::updateInfoPanel()
if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) {
auto func = [comp](float t) {
comp->setOpacity(static_cast<unsigned char>(Math::lerp(0.0f, 1.0f, t) * 255));
comp->setOpacity(static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
};
comp->setAnimation(new LambdaAnimation(func, 150), 0, nullptr, fadingOut);
}

View file

@ -444,7 +444,7 @@ void GridGameListView::updateInfoPanel()
// Fade in the game image.
auto func = [this](float t) {
mImage.setOpacity(static_cast<unsigned char>(
Math::lerp(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
glm::mix(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
};
mImage.setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false);
@ -492,7 +492,7 @@ void GridGameListView::updateInfoPanel()
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) {
auto func = [comp](float t) {
// TEMPORARY - This does not seem to work, needs to be reviewed later.
// comp->setOpacity(static_cast<unsigned char>(Math::lerp(0.0f, 1.0f, t) * 255));
// comp->setOpacity(static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
};
comp->setAnimation(new LambdaAnimation(func, 150), 0, nullptr, fadingOut);
}

View file

@ -424,7 +424,7 @@ void VideoGameListView::updateInfoPanel()
// Fade in the game image.
auto func = [this](float t) {
mVideo->setOpacity(static_cast<unsigned char>(
Math::lerp(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
glm::mix(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
};
mVideo->setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false);
@ -472,7 +472,7 @@ void VideoGameListView::updateInfoPanel()
if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) {
auto func = [comp](float t) {
comp->setOpacity(static_cast<unsigned char>(Math::lerp(0.0f, 1.0f, t) * 255));
comp->setOpacity(static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
};
comp->setAnimation(new LambdaAnimation(func, 200), 0, nullptr, fadingOut);
}

View file

@ -13,7 +13,6 @@
#include "HelpStyle.h"
#include "InputConfig.h"
#include "animations/AnimationController.h"
#include "math/Misc.h"
#include <functional>
#include <memory>

View file

@ -18,7 +18,6 @@
#include "InputManager.h"
#include "Log.h"
#include "Sound.h"
#include "math/Misc.h"
#include "resources/Font.h"
#include <algorithm>
@ -465,7 +464,7 @@ void Window::render()
if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") {
mBackgroundOverlay->setOpacity(mBackgroundOverlayOpacity);
if (mBackgroundOverlayOpacity < 255)
mBackgroundOverlayOpacity = Math::clamp(mBackgroundOverlayOpacity + 30, 0, 255);
mBackgroundOverlayOpacity = glm::clamp(mBackgroundOverlayOpacity + 30, 0, 255);
}
#endif // USE_OPENGL_21
@ -474,7 +473,7 @@ void Window::render()
// Scale-up menu opening effect.
if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") {
if (mTopScale < 1.0f) {
mTopScale = Math::clamp(mTopScale + 0.07f, 0.0f, 1.0f);
mTopScale = glm::clamp(mTopScale + 0.07f, 0.0f, 1.0f);
glm::vec2 topCenter{top->getCenter()};
top->setOrigin({0.5f, 0.5f});
top->setPosition({topCenter.x, topCenter.y, 0.0f});

View file

@ -190,7 +190,7 @@ void GridTileComponent::setSelected(bool selected,
auto func = [this](float t) {
t -= 1;
float pct = Math::lerp(0, 1, t * t * t + 1);
float pct = glm::mix(0.0f, 1.0f, t * t * t + 1.0f);
this->setSelectedZoom(pct);
};
@ -216,7 +216,7 @@ void GridTileComponent::setSelected(bool selected,
auto func = [this](float t) {
t -= 1.0f;
float pct = Math::lerp(0, 1, t * t * t + 1.0f);
float pct = glm::mix(0.0f, 1.0f, t * t * t + 1.0f);
this->setSelectedZoom(1.0f - pct);
};

View file

@ -505,7 +505,7 @@ template <typename T> void ImageGridComponent<T>::onCursorChanged(const CursorSt
return;
t -= 1.0f;
float pct = Math::lerp(0, 1.0f, t * t * t + 1.0f);
float pct = glm::mix(0.0f, 1.0f, t * t * t + 1.0f);
t = startPos * (1.0f - pct) + endPos * pct;
mCamera = t;
};

View file

@ -55,9 +55,9 @@ void NinePatchComponent::buildVertices()
// (e.g. from 720p to 4K) will be within these boundaries though.
float scaleFactor;
if (Renderer::getScreenWidth() > Renderer::getScreenHeight())
scaleFactor = Math::clamp(Renderer::getScreenHeightModifier(), 0.4f, 3.0f);
scaleFactor = glm::clamp(Renderer::getScreenHeightModifier(), 0.4f, 3.0f);
else
scaleFactor = Math::clamp(Renderer::getScreenWidthModifier(), 0.4f, 3.0f);
scaleFactor = glm::clamp(Renderer::getScreenWidthModifier(), 0.4f, 3.0f);
mTexture = TextureResource::get(mPath, false, false, true, scaleFactor);
@ -79,6 +79,7 @@ void NinePatchComponent::buildVertices()
// The "1 +" in posY and "-" in sizeY is to deal with texture coordinates having a bottom
// left corner origin vs. verticies having a top left origin.
// clang-format off
const float texSizeX[3]{mCornerSize.x / texSize.x, (texSize.x - mCornerSize.x * 2.0f) / texSize.x, mCornerSize.x / texSize.x};
const float texSizeY[3]{-mCornerSize.y / texSize.y, -(texSize.y - mCornerSize.y * 2.0f) / texSize.y, -mCornerSize.y / texSize.y};
@ -150,8 +151,8 @@ void NinePatchComponent::fitTo(glm::vec2 size, glm::vec3 position, glm::vec2 pad
position[1] -= padding.y / 2.0f;
setSize(size + mCornerSize * 2.0f);
setPosition(position.x + Math::lerp(-mCornerSize.x, mCornerSize.x, mOrigin.x),
position.y + Math::lerp(-mCornerSize.y, mCornerSize.y, mOrigin.y));
setPosition(position.x + glm::mix(-mCornerSize.x, mCornerSize.x, mOrigin.x),
position.y + glm::mix(-mCornerSize.y, mCornerSize.y, mOrigin.y));
}
void NinePatchComponent::setImagePath(const std::string& path)

View file

@ -134,7 +134,7 @@ void ScrollableContainer::update(int deltaTime)
if (mAutoScrollResetAccumulator >= static_cast<int>(mAutoScrollResetDelayConstant)) {
// Fade in the text as it resets to the start position.
auto func = [this](float t) {
this->setOpacity(static_cast<unsigned char>(Math::lerp(0.0f, 1.0f, t) * 255));
this->setOpacity(static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
mScrollPos = glm::vec2{};
mAutoScrollResetAccumulator = 0;
mAutoScrollAccumulator = -mAutoScrollDelay + mAutoScrollSpeed;

View file

@ -12,7 +12,6 @@
#include "Log.h"
#include "Sound.h"
#include "components/IList.h"
#include "math/Misc.h"
#include "resources/Font.h"
#include "utils/StringUtil.h"

View file

@ -275,15 +275,15 @@ void VideoComponent::update(int deltaTime)
// Fade in videos, the time period is a bit different between the screensaver,
// media viewer and gamelist view.
if (mScreensaverMode && mFadeIn < 1.0f) {
mFadeIn = Math::clamp(mFadeIn + (deltaTime / static_cast<float>(SCREENSAVER_FADE_IN_TIME)),
0.0f, 1.0f);
mFadeIn = glm::clamp(mFadeIn + (deltaTime / static_cast<float>(SCREENSAVER_FADE_IN_TIME)),
0.0f, 1.0f);
}
else if (mMediaViewerMode && mFadeIn < 1.0f) {
mFadeIn = Math::clamp(mFadeIn + (deltaTime / static_cast<float>(MEDIA_VIEWER_FADE_IN_TIME)),
0.0f, 1.0f);
mFadeIn = glm::clamp(mFadeIn + (deltaTime / static_cast<float>(MEDIA_VIEWER_FADE_IN_TIME)),
0.0f, 1.0f);
}
else if (mFadeIn < 1.0f) {
mFadeIn = Math::clamp(mFadeIn + 0.01f, 0.0f, 1.0f);
mFadeIn = glm::clamp(mFadeIn + 0.01f, 0.0f, 1.0f);
}
GuiComponent::update(deltaTime);

View file

@ -91,8 +91,8 @@ GuiComplexTextEditPopup::GuiComplexTextEditPopup(
// Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent
// regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
float aspectValue = 1.778f / Renderer::getScreenAspectRatio();
float infoWidth = Math::clamp(0.70f * aspectValue, 0.60f, 0.85f) * Renderer::getScreenWidth();
float windowWidth = Math::clamp(0.75f * aspectValue, 0.65f, 0.90f) * Renderer::getScreenWidth();
float infoWidth = glm::clamp(0.70f * aspectValue, 0.60f, 0.85f) * Renderer::getScreenWidth();
float windowWidth = glm::clamp(0.75f * aspectValue, 0.65f, 0.90f) * Renderer::getScreenWidth();
mText->setSize(0, textHeight);
mInfoString2->setSize(infoWidth, mInfoString2->getFont()->getHeight());

View file

@ -85,7 +85,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window,
// Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent
// regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
float aspectValue = 1.778f / Renderer::getScreenAspectRatio();
float width = Math::clamp(0.60f * aspectValue, 0.50f, 0.80f) * Renderer::getScreenWidth();
float width = glm::clamp(0.60f * aspectValue, 0.50f, 0.80f) * Renderer::getScreenWidth();
setSize(width, Renderer::getScreenHeight() * 0.5f);
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,

View file

@ -189,7 +189,7 @@ GuiInputConfig::GuiInputConfig(Window* window,
// Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent
// regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
float aspectValue = 1.778f / Renderer::getScreenAspectRatio();
float width = Math::clamp(0.60f * aspectValue, 0.50f, 0.80f) * Renderer::getScreenWidth();
float width = glm::clamp(0.60f * aspectValue, 0.50f, 0.80f) * Renderer::getScreenWidth();
setSize(width, Renderer::getScreenHeight() * 0.75f);
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,

View file

@ -37,9 +37,9 @@ GuiMsgBox::GuiMsgBox(Window* window,
float aspectValue = 1.778f / Renderer::getScreenAspectRatio();
float width =
floorf(Math::clamp(0.60f * aspectValue, 0.60f, 0.80f) * Renderer::getScreenWidth());
floorf(glm::clamp(0.60f * aspectValue, 0.60f, 0.80f) * Renderer::getScreenWidth());
float minWidth =
floorf(Math::clamp(0.30f * aspectValue, 0.10f, 0.50f) * Renderer::getScreenWidth());
floorf(glm::clamp(0.30f * aspectValue, 0.10f, 0.50f) * Renderer::getScreenWidth());
mMsg = std::make_shared<TextComponent>(mWindow, text, Font::get(FONT_SIZE_MEDIUM), 0x777777FF,
ALIGN_CENTER);
@ -110,7 +110,7 @@ void GuiMsgBox::changeText(const std::string& newText)
float aspectValue = 1.778f / Renderer::getScreenAspectRatio();
float width =
floorf(Math::clamp(0.60f * aspectValue, 0.60f, 0.80f) * Renderer::getScreenWidth());
floorf(glm::clamp(0.60f * aspectValue, 0.60f, 0.80f) * Renderer::getScreenWidth());
float minWidth = Renderer::getScreenWidth() * 0.3f;
// Decide final width.

View file

@ -67,7 +67,7 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window,
// Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent
// regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
float aspectValue = 1.778f / Renderer::getScreenAspectRatio();
float width = Math::clamp(0.50f * aspectValue, 0.40f, 0.70f) * Renderer::getScreenWidth();
float width = glm::clamp(0.50f * aspectValue, 0.40f, 0.70f) * Renderer::getScreenWidth();
setSize(width, mTitle->getFont()->getHeight() + textHeight + mButtonGrid->getSize().y +
mButtonGrid->getSize().y / 2.0f);

View file

@ -13,7 +13,6 @@
#include "ImageIO.h"
#include "Log.h"
#include "math/Misc.h"
#include "renderers/Renderer.h"
#include "resources/ResourceManager.h"