From a9515e8f0969e6f44b5be7975a67e6b099ad64d4 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Mon, 23 Sep 2024 14:05:18 +0200 Subject: [PATCH] Add first draft for RGBA5551 --- openVulkanoCpp/Math/RGBA5551.hpp | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 openVulkanoCpp/Math/RGBA5551.hpp 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