mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Fixed some MSVC compiler warnings.
This commit is contained in:
parent
e6847a09c7
commit
0365e9c572
|
@ -256,8 +256,8 @@ void SystemScreensaver::renderScreensaver()
|
|||
if (mVideoScreensaver && screensaverType == "video") {
|
||||
// Render a black background below the video.
|
||||
Renderer::setMatrix(Transform4x4f::Identity());
|
||||
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(),
|
||||
Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
||||
|
||||
// Only render the video if the state requires it.
|
||||
if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
|
||||
|
@ -268,8 +268,8 @@ void SystemScreensaver::renderScreensaver()
|
|||
else if (mImageScreensaver && screensaverType == "slideshow") {
|
||||
// Render a black background below the image.
|
||||
Renderer::setMatrix(Transform4x4f::Identity());
|
||||
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(),
|
||||
Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
||||
|
||||
// Only render the image if the state requires it.
|
||||
if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
|
||||
|
@ -319,7 +319,7 @@ void SystemScreensaver::renderScreensaver()
|
|||
Renderer::getScreenHeight(), 0x000000FF, 0x000000FF, mDimValue);
|
||||
#endif
|
||||
if (mDimValue > 0.0)
|
||||
mDimValue = Math::clamp(mDimValue-0.045, 0.0, 1.0);
|
||||
mDimValue = Math::clamp(mDimValue - 0.045f, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
if (Settings::getInstance()->getString("ScreensaverType") == "video") {
|
||||
|
@ -361,7 +361,7 @@ void SystemScreensaver::renderScreensaver()
|
|||
Renderer::getScreenHeight(), 0x000000FF, 0x000000FF, mDimValue);
|
||||
#endif
|
||||
if (mDimValue > 0.0)
|
||||
mDimValue = Math::clamp(mDimValue-0.045, 0.0, 1.0);
|
||||
mDimValue = Math::clamp(mDimValue - 0.045f, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,11 +371,11 @@ void SystemScreensaver::renderScreensaver()
|
|||
dimParameters.fragmentDimValue = mDimValue;
|
||||
Renderer::shaderPostprocessing(Renderer::SHADER_DIM, dimParameters);
|
||||
if (mDimValue > 0.4)
|
||||
mDimValue = Math::clamp(mDimValue-0.021, 0.4, 1.0);
|
||||
mDimValue = Math::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.035, 0.0, 1.0);
|
||||
mSaturationAmount = Math::clamp(mSaturationAmount - 0.035f, 0.0f, 1.0f);
|
||||
#else
|
||||
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(),
|
||||
Renderer::getScreenHeight(), 0x000000A0, 0x000000A0);
|
||||
|
@ -387,7 +387,7 @@ void SystemScreensaver::renderScreensaver()
|
|||
blackParameters.fragmentDimValue = mDimValue;
|
||||
Renderer::shaderPostprocessing(Renderer::SHADER_DIM, blackParameters);
|
||||
if (mDimValue > 0.0)
|
||||
mDimValue = Math::clamp(mDimValue-0.045, 0.0, 1.0);
|
||||
mDimValue = Math::clamp(mDimValue - 0.045f, 0.0f, 1.0f);
|
||||
#else
|
||||
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(),
|
||||
Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
|
@ -515,7 +515,8 @@ void SystemScreensaver::pickRandomImage(std::string& path)
|
|||
std::random_device randDev;
|
||||
// Mersenne Twister pseudorandom number generator.
|
||||
std::mt19937 engine{randDev()};
|
||||
std::uniform_int_distribution<int> uniform_dist(0, mImageFiles.size() - 1);
|
||||
std::uniform_int_distribution<int>
|
||||
uniform_dist(0, static_cast<int>(mImageFiles.size()) - 1);
|
||||
index = uniform_dist(engine);
|
||||
}
|
||||
while (mPreviousGame && mImageFiles.at(index) == mPreviousGame);
|
||||
|
@ -546,7 +547,8 @@ void SystemScreensaver::pickRandomVideo(std::string& path)
|
|||
std::random_device randDev;
|
||||
// Mersenne Twister pseudorandom number generator.
|
||||
std::mt19937 engine{randDev()};
|
||||
std::uniform_int_distribution<int> uniform_dist(0, mVideoFiles.size() - 1);
|
||||
std::uniform_int_distribution<int>
|
||||
uniform_dist(0, static_cast<int>(mVideoFiles.size()) - 1);
|
||||
index = uniform_dist(engine);
|
||||
}
|
||||
while (mPreviousGame && mVideoFiles.at(index) == mPreviousGame);
|
||||
|
@ -574,7 +576,8 @@ void SystemScreensaver::pickRandomCustomImage(std::string& path)
|
|||
std::random_device randDev;
|
||||
// Mersenne Twister pseudorandom number generator.
|
||||
std::mt19937 engine{randDev()};
|
||||
std::uniform_int_distribution<int> uniform_dist(0, mImageCustomFiles.size() - 1);
|
||||
std::uniform_int_distribution<int>
|
||||
uniform_dist(0, static_cast<int>(mImageCustomFiles.size()) - 1);
|
||||
index = uniform_dist(engine);
|
||||
}
|
||||
while (mPreviousCustomImage != "" && mImageCustomFiles.at(index) == mPreviousCustomImage);
|
||||
|
@ -590,8 +593,8 @@ void SystemScreensaver::generateOverlayInfo()
|
|||
if (mGameName == "" || mSystemName == "")
|
||||
return;
|
||||
|
||||
float posX = static_cast<float>(Renderer::getWindowWidth()) * 0.023;
|
||||
float posY = static_cast<float>(Renderer::getWindowHeight()) * 0.02;
|
||||
float posX = static_cast<float>(Renderer::getWindowWidth()) * 0.023f;
|
||||
float posY = static_cast<float>(Renderer::getWindowHeight()) * 0.02f;
|
||||
|
||||
std::string favoriteChar;
|
||||
if (mCurrentGame->getFavorite())
|
||||
|
@ -618,7 +621,7 @@ void SystemScreensaver::generateOverlayInfo()
|
|||
else
|
||||
textSizeX = mGameOverlayFont[0].get()->sizeText(systemName).x();
|
||||
|
||||
float marginX = Renderer::getWindowWidth() * 0.01;
|
||||
float marginX = Renderer::getWindowWidth() * 0.01f;
|
||||
|
||||
mGameOverlayRectangleCoords.clear();
|
||||
mGameOverlayRectangleCoords.push_back(posX - marginX);
|
||||
|
|
|
@ -152,7 +152,7 @@ void AudioManager::mixAudio(void* /*unused*/, Uint8* stream, int len)
|
|||
// Mix sample into stream.
|
||||
SDL_MixAudioFormat(stream, &(sound->getData()[sound->getPosition()]),
|
||||
sAudioFormat.format, restLength,
|
||||
Settings::getInstance()->getInt("SoundVolumeNavigation") * 1.28);
|
||||
Settings::getInstance()->getInt("SoundVolumeNavigation") * 1.28f);
|
||||
if (sound->getPosition() + restLength < sound->getLength()) {
|
||||
// Sample hasn't ended yet.
|
||||
stillPlaying = true;
|
||||
|
|
|
@ -245,7 +245,7 @@ int GuiComponent::getChildIndex() const
|
|||
std::find(getParent()->mChildren.begin(), getParent()->mChildren.end(), this);
|
||||
|
||||
if (it != getParent()->mChildren.end())
|
||||
return std::distance(getParent()->mChildren.begin(), it);
|
||||
return static_cast<int>(std::distance(getParent()->mChildren.begin(), it));
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ void GuiComponent::setColor(unsigned int color)
|
|||
|
||||
float GuiComponent::getSaturation() const
|
||||
{
|
||||
return mColor;
|
||||
return static_cast<float>(mColor);
|
||||
}
|
||||
|
||||
void GuiComponent::setSaturation(float saturation)
|
||||
|
|
|
@ -32,7 +32,7 @@ std::string HttpReq::urlEncode(const std::string &s)
|
|||
else {
|
||||
escaped.append("%");
|
||||
char buf[3];
|
||||
sprintf(buf, "%.2X", static_cast<unsigned char>(s[i]));
|
||||
snprintf(buf, 3, "%.2X", static_cast<unsigned char>(s[i]));
|
||||
escaped.append(buf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ void Window::update(int deltaTime)
|
|||
textureTotalUsageMiB << " MiB";
|
||||
mFrameDataText = std::unique_ptr<TextCache>
|
||||
(mDefaultFonts.at(0)->buildTextCache(ss.str(), Renderer::getScreenWidth() *
|
||||
0.02 , Renderer::getScreenHeight() * 0.02, 0xFF00FFFF, 1.3));
|
||||
0.02f, Renderer::getScreenHeight() * 0.02f, 0xFF00FFFF, 1.3f));
|
||||
}
|
||||
|
||||
mFrameTimeElapsed = 0;
|
||||
|
@ -341,7 +341,7 @@ void Window::render()
|
|||
// it with the blurring leads to very strange and severe artifacts.
|
||||
// This is for sure a bug that needs to be resolved at some later date.
|
||||
Renderer::shaderParameters blackParameters;
|
||||
blackParameters.fragmentDimValue = 0.6;
|
||||
blackParameters.fragmentDimValue = 0.6f;
|
||||
Renderer::shaderPostprocessing(Renderer::SHADER_DIM,
|
||||
blackParameters, processedTexture);
|
||||
|
||||
|
@ -375,7 +375,7 @@ void Window::render()
|
|||
// Menu opening effects (scale-up and fade-in).
|
||||
if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") {
|
||||
if (mTopScale < 1.0)
|
||||
mTopScale = Math::clamp(mTopScale+0.07, 0, 1.0);
|
||||
mTopScale = Math::clamp(mTopScale + 0.07f, 0.0f, 1.0f);
|
||||
Vector2f topCenter = top->getCenter();
|
||||
top->setOrigin({0.5, 0.5});
|
||||
top->setPosition({topCenter.x(), topCenter.y(), 0});
|
||||
|
@ -458,8 +458,8 @@ void Window::renderLoadingScreen(std::string text)
|
|||
{
|
||||
Transform4x4f trans = Transform4x4f::Identity();
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(),
|
||||
Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
||||
|
||||
ImageComponent splash(this, true);
|
||||
splash.setResize(Renderer::getScreenWidth() * 0.6f, 0.0f);
|
||||
|
|
|
@ -292,9 +292,9 @@ void VideoComponent::update(int deltaTime)
|
|||
// video screensaver that is running, or if it's the video in the gamelist.
|
||||
if (mScreensaverMode && mFadeIn < 1.0f)
|
||||
mFadeIn = Math::clamp(mFadeIn + (deltaTime /
|
||||
static_cast<float>(SCREENSAVER_FADE_IN_TIME)), 0.0, 1.0);
|
||||
static_cast<float>(SCREENSAVER_FADE_IN_TIME)), 0.0f, 1.0f);
|
||||
else if (mFadeIn < 1.0f)
|
||||
mFadeIn = Math::clamp(mFadeIn + 0.01, 0.0f, 1.0f);
|
||||
mFadeIn = Math::clamp(mFadeIn + 0.01f, 0.0f, 1.0f);
|
||||
|
||||
GuiComponent::update(deltaTime);
|
||||
}
|
||||
|
|
|
@ -8,29 +8,24 @@
|
|||
|
||||
#include "math/Misc.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Math
|
||||
{
|
||||
float clamp(const float _num, const float _min, const float _max)
|
||||
{
|
||||
return std::fmax(std::fmin(_num, _max), _min);
|
||||
}
|
||||
|
||||
float lerp(const float _start, const float _end, const float _fraction)
|
||||
{
|
||||
return (_start + ((_end - _start) * clamp(_fraction, 0, 1)));
|
||||
return (_start + ((_end - _start) * clamp(_fraction, 0.0f, 1.0f)));
|
||||
}
|
||||
|
||||
float smoothStep(const float _left, const float _right, const float _x)
|
||||
{
|
||||
const float x = clamp((_x - _left)/(_right - _left), 0, 1);
|
||||
const float x = clamp((_x - _left)/(_right - _left), 0.0f, 1.0f);
|
||||
return x * x * (3 - (2 * x));
|
||||
}
|
||||
|
||||
float smootherStep(const float _left, const float _right, const float _x)
|
||||
{
|
||||
const float x = clamp((_x - _left)/(_right - _left), 0, 1);
|
||||
const float x = clamp((_x - _left)/(_right - _left), 0.0f, 1.0f);
|
||||
return x * x * x * (x * ((x * 6) - 15) + 10);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,12 @@
|
|||
namespace Math
|
||||
{
|
||||
// When moving to the C++20 standard these functions are no longer required.
|
||||
float clamp(const float _num, const float _min, const float _max);
|
||||
template<typename T>
|
||||
T const& clamp(const T& _num, const T& _min, const T& _max)
|
||||
{
|
||||
T newVal = std::max(std::min(_num, _max), _min);
|
||||
return std::max(std::min(_num, _max), _min);
|
||||
}
|
||||
float lerp(const float _start, const float _end, const float _fraction);
|
||||
|
||||
float smoothStep(const float _left, const float _right, const float _x);
|
||||
|
|
|
@ -39,11 +39,11 @@ namespace Renderer
|
|||
unsigned int shaderPasses;
|
||||
|
||||
shaderParameters()
|
||||
: textureSize({0.0, 0.0}),
|
||||
textureCoordinates({0.0, 0.0, 0.0, 0.0}),
|
||||
fragmentSaturation(1.0),
|
||||
fragmentDimValue(0.4),
|
||||
fragmentOpacity(1.0),
|
||||
: textureSize({0.0f, 0.0f}),
|
||||
textureCoordinates({0.0f, 0.0f, 0.0f, 0.0f}),
|
||||
fragmentSaturation(1.0f),
|
||||
fragmentDimValue(0.4f),
|
||||
fragmentOpacity(1.0f),
|
||||
shaderPasses(1)
|
||||
{};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue