Add first draft for RGBA5551

This commit is contained in:
Georg Hagen
2024-09-23 14:05:18 +02:00
committed by ohyzha
parent 01921cc3bc
commit a9515e8f09

View File

@@ -0,0 +1,40 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "Math/Math.hpp"
namespace OpenVulkano::Math
{
class RGBA5551
{
uint16_t Make5(uint8_t val)
{
return val * 31.0f / 255.0f;
}
public:
union
{
uint16_t value;
struct
{
uint16_t b : 5;
uint16_t g : 5;
uint16_t r : 5;
uint16_t a : 1;
};
};
RGBA5551(Math::Vector4uc color = {0, 0, 0, 1})
: b(Make5(color.b))
, g(Make5(color.g))
, r(Make5(color.r))
, a(color.a > 128)
{}
};
}