1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 15:37:46 +00:00

LibGL: Implement glLightModel integer normalization

For the ambient light model, integers need to be remapped to a range of
`-1.` through `1.`. Add the `+` and `-` operators to `VectorN` to make
it a bit easier to normalize 4 values at once.
This commit is contained in:
Jelle Raaijmakers 2022-12-12 00:32:11 +01:00 committed by Andreas Kling
parent a074b7e871
commit 8c094699db
2 changed files with 36 additions and 19 deletions

View file

@ -158,6 +158,26 @@ public:
return result;
}
template<typename U>
[[nodiscard]] constexpr VectorN operator+(U f) const
{
VectorN result;
UNROLL_LOOP
for (auto i = 0u; i < N; ++i)
result.m_data[i] = m_data[i] + f;
return result;
}
template<typename U>
[[nodiscard]] constexpr VectorN operator-(U f) const
{
VectorN result;
UNROLL_LOOP
for (auto i = 0u; i < N; ++i)
result.m_data[i] = m_data[i] - f;
return result;
}
template<typename U>
[[nodiscard]] constexpr VectorN operator*(U f) const
{