Moved most love.math functions out of the Math class, since they're pure functions.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-03-28 19:46:29 -03:00
parent 734789eb93
commit cc1b9bc619
6 changed files with 162 additions and 182 deletions
+6 -6
View File
@@ -42,9 +42,9 @@ void gammaCorrectColor(Colorf &c)
{
if (isGammaCorrect())
{
c.r = math::Math::instance.gammaToLinear(c.r);
c.g = math::Math::instance.gammaToLinear(c.g);
c.b = math::Math::instance.gammaToLinear(c.b);
c.r = math::gammaToLinear(c.r);
c.g = math::gammaToLinear(c.g);
c.b = math::gammaToLinear(c.b);
}
}
@@ -52,9 +52,9 @@ void unGammaCorrectColor(Colorf &c)
{
if (isGammaCorrect())
{
c.r = math::Math::instance.linearToGamma(c.r);
c.g = math::Math::instance.linearToGamma(c.g);
c.b = math::Math::instance.linearToGamma(c.b);
c.r = math::linearToGamma(c.r);
c.g = math::linearToGamma(c.g);
c.b = math::linearToGamma(c.b);
}
}
+1 -1
View File
@@ -490,7 +490,7 @@ void Graphics::clear(const std::vector<OptionalColorf> &colors)
if (isGammaCorrect())
{
for (int i = 0; i < 3; i++)
c[i] = math::Math::instance.gammaToLinear(c[i]);
c[i] = math::gammaToLinear(c[i]);
}
if (GLAD_ES_VERSION_3_0 || GLAD_VERSION_3_0)
+1 -2
View File
@@ -159,12 +159,11 @@ static int w__Shader_sendFloat(lua_State *L, bool colors)
{
// the fourth component (alpha) is always already linear, if it exists.
int ncomponents = std::min((int) dimension, 3);
const auto &m = love::math::Math::instance;
for (int i = 0; i < count; i++)
{
for (int j = 0; j < ncomponents; j++)
values[i * dimension + j] = m.gammaToLinear(values[i * dimension + j]);
values[i * dimension + j] = math::gammaToLinear(values[i * dimension + j]);
}
}