diff --git a/openVulkanoCpp/Math/RGBA5551.hpp b/openVulkanoCpp/Math/RGBA5551.hpp new file mode 100644 index 0000000..d3f698f --- /dev/null +++ b/openVulkanoCpp/Math/RGBA5551.hpp @@ -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) + {} + }; +} \ No newline at end of file