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