Color values in love's APIs are now in the range of [0, 1] rather than [0, 255].

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-01-31 10:49:29 -04:00
parent 50087bd60e
commit ed933847f8
19 changed files with 126 additions and 144 deletions
+5 -10
View File
@@ -174,21 +174,16 @@ static int w__Shader_sendFloat(lua_State *L, bool colors)
if (!values)
return luaL_error(L, "Error in arguments.");
if (colors)
if (colors && love::graphics::isGammaCorrect())
{
bool gammacorrect = love::graphics::isGammaCorrect();
// 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 < (int) dimension; j++)
{
// the fourth component (alpha) is always already linear, if it exists.
if (gammacorrect && j < 3)
values[i * dimension + j] = m.gammaToLinear(values[i * dimension + j] / 255.0f);
else
values[i * dimension + j] /= 255.0f;
}
for (int j = 0; j < ncomponents; j++)
values[i * dimension + j] = m.gammaToLinear(values[i * dimension + j]);
}
}