mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
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:
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user