Support basic linked elements

This commit is contained in:
2023-06-12 21:47:56 +02:00
parent fd9e352355
commit 04fa09e7e7
8 changed files with 97 additions and 12 deletions

View File

@@ -0,0 +1,56 @@
#ifndef __JABYENGINE_LINKED_ELEMENTS_HPP__
#define __JABYENGINE_LINKED_ELEMENTS_HPP__
#include "../../Auxiliary/bits.hpp"
namespace JabyEngine {
namespace GPU {
struct Link {
static constexpr auto AdrRange = BitRange::from_to(0, 23);
static constexpr auto SizeRange = BitRange::from_to(24, 31);
static constexpr uint32_t TerminationValue = 0x00FFFFFF;
uint32_t value = TerminationValue;
constexpr Link() = default;
constexpr Link(size_t size) : value(SizeRange.as_value(size >> 2) | TerminationValue) {
}
//void add
constexpr void terminate() {
this->value |= TerminationValue;
}
};
template<typename T>
struct LinkedElement : public Link {
T element;
constexpr LinkedElement() : Link(sizeof(T)), element() {
}
constexpr LinkedElement(const T& element) : Link(sizeof(T)), element(element) {
}
constexpr const T* operator->() const {
return &this->element;
}
constexpr T* operator->() {
return &this->element;
}
};
namespace internal {
template<typename T>
struct LinkedElementCreator {
constexpr LinkedElement<T> linked() {
return LinkedElement<T>(*static_cast<T*>(this));
}
};
}
}
}
#endif // !__JABYENGINE_LINKED_ELEMENTS_HPP__

View File

@@ -1,5 +1,6 @@
#ifndef __JABYENGINE_PRIMITIVE_RECTANGLE_TYPES_HPP__
#define __JABYENGINE_PRIMITIVE_RECTANGLE_TYPES_HPP__
#include "linked_elements.hpp"
#include "primitive_support_types.hpp"
namespace JabyEngine {
@@ -67,21 +68,21 @@ namespace JabyEngine {
typedef internal::RECT_F<internal::RectCode::Size::Sprite8x8> TILE_8;
typedef internal::RECT_F<internal::RectCode::Size::Sprite16x16> TILE_16;
struct TILE : public internal::RECT_F<internal::RectCode::Size::Variable> {
Vertex position_bottom_right;
SizeI16 size;
constexpr TILE() = default;
constexpr TILE(const AreaI16& area, const Color24& color) : RECT_F(area.position, color), position_bottom_right(area.get_bottom_left()) {
constexpr TILE(const AreaI16& area, const Color24& color) : RECT_F(area.position, color), size(area.size) {
}
};
typedef internal::RECT_T<internal::RectCode::Size::Pixel1x1> SPRT_1;
typedef internal::RECT_T<internal::RectCode::Size::Sprite8x8> SPRT_8;
typedef internal::RECT_T<internal::RectCode::Size::Sprite16x16> SPRT_16;
struct SPRT : public internal::RECT_T<internal::RectCode::Size::Variable> {
Vertex position_bottom_right;
struct SPRT : public internal::RECT_T<internal::RectCode::Size::Variable>, public internal::LinkedElementCreator<SPRT> {
SizeI16 size;
constexpr SPRT() = default;
constexpr SPRT(const AreaI16& area, const PagePositionClut& page, const Color24& color = Color24::Grey()) : RECT_T(area.position, page, color), position_bottom_right(area.get_bottom_left()) {
constexpr SPRT(const AreaI16& area, const PagePositionClut& page, const Color24& color = Color24::Grey()) : RECT_T(area.position, page, color), size(area.size) {
}
};

View File

@@ -52,13 +52,6 @@ namespace JabyEngine {
}
};
// Concept for now
template<typename T>
struct Hooked {
uint32_t hook;
T primitive;
};
template<typename T>
struct is_render_primitive {
static constexpr bool value = false;