40 lines
664 B
C++
40 lines
664 B
C++
/*
|
|
* 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)
|
|
{}
|
|
};
|
|
} |