Re: cindy - [0-255] color range in LÖVE 11
Posted: Wed Nov 22, 2023 7:01 pm
Just recently I noticed that the 0..1 floating point color range doesn't work so well in one specific area of LÖVE: vertex colors.
Consider the following code snippet:
getVertexAttribute does not return the values that were originally passed to setVertexAttribute. This is because each color component of a vertex is represented by a single byte internally. So setVertexAttribute crams the floating point values into a 0..255 value range and getVertexAttribute converts them back into floating point numbers, leading to some loss in precision.
But this can't be fixed by cindy or any other library. I consider it a small flaw in how this specific part of the API was designed.
Best regards
Consider the following code snippet:
Code: Select all
local COLOR_INDEX = 3
local mesh = love.graphics.newMesh(3)
mesh:setVertexAttribute(1, COLOR_INDEX, 0.1, 0.2, 0.3, 0.4)
print(mesh:getVertexAttribute(1, COLOR_INDEX))
But this can't be fixed by cindy or any other library. I consider it a small flaw in how this specific part of the API was designed.
![Monocle :monocle:](./images/smilies/ms-monocle.png)
Best regards