Making ComplexBitMap a POD part 1

This commit is contained in:
Jaby
2022-09-11 11:36:51 +02:00
parent db3196b290
commit 28122a8e1c
9 changed files with 386 additions and 238 deletions

View File

@@ -1,39 +1,73 @@
#ifndef __JABYENGINE_GPU_TYPES_HPP__
#define __JABYENGINE_GPU_TYPES_HPP__
#include "../jabyengine_defines.h"
#include "../Auxiliary/complex_bitmap.hpp"
namespace GPU {
struct Color {
struct Color24 {
uint8_t red = 0;
uint8_t green = 0;
uint8_t blue = 0;
constexpr Color() = default;
constexpr Color(uint8_t r, uint8_t g, uint8_t b) : blue(b), green(g), red(r) {
constexpr Color24() = default;
constexpr Color24(uint8_t r, uint8_t g, uint8_t b) : blue(b), green(g), red(r) {
}
constexpr uint32_t raw() const {
return ((this->blue << 16) | (this->green << 8) | this->red);
}
static constexpr Color Black() {
return Color(0, 0, 0);
static constexpr Color24 Black() {
return Color24(0, 0, 0);
}
static constexpr Color White() {
return Color(0xFF, 0xFF, 0xFF);
static constexpr Color24 White() {
return Color24(0xFF, 0xFF, 0xFF);
}
static constexpr Color Red() {
return Color(0xFF, 0x0, 0x0);
static constexpr Color24 Red() {
return Color24(0xFF, 0x0, 0x0);
}
static constexpr Color Green() {
return Color(0x0, 0x0, 0xFF);
static constexpr Color24 Green() {
return Color24(0x0, 0x0, 0xFF);
}
static constexpr Color Blue() {
return Color(0x0, 0x0, 0xFF);
static constexpr Color24 Blue() {
return Color24(0x0, 0x0, 0xFF);
}
};
class Color16 {
private:
static constexpr auto RedRange = BitRange<uint16_t>::from_to(0, 4);
static constexpr auto BlueRange = BitRange<uint16_t>::from_to(5, 9);
static constexpr auto GreenRange = BitRange<uint16_t>::from_to(10, 14);
static constexpr auto SemiTransperancyBit = Bit<uint16_t>(15);
ComplexBitMap<uint16_t> value = {0};
public:
constexpr Color16() = default;
constexpr Color16(uint8_t r, uint8_t g, uint8_t b) {
Color16::set_red(r);
Color16::set_green(g);
Color16::set_blue(b);
}
constexpr Color16(const Color24& color) : Color16(color.red, color.green, color.blue) {
}
constexpr void set_red(uint8_t red) {
this->value.set_value(static_cast<uint16_t>(red), RedRange);
}
constexpr void set_green(uint8_t green) {
this->value.set_value(static_cast<uint16_t>(green), GreenRange);
}
constexpr void set_blue(uint8_t blue) {
this->value.set_value(static_cast<uint16_t>(blue), BlueRange);
}
};