#ifndef __JABYENGINE_GPU_PRIMITIVES_HPP__ #define __JABYENGINE_GPU_PRIMITIVES_HPP__ #include "gpu_types.hpp" namespace JabyEngine { namespace GPU { namespace internal { struct Code { static constexpr uint8_t CmdValue = 0b001; static constexpr auto BitCorrection = 24; static constexpr auto CmdID = BitRange::from_to(29 - BitCorrection, 31 - BitCorrection); static constexpr auto GouraudShading = Bit(28 - BitCorrection); static constexpr auto FlatShading = !GouraudShading; static constexpr auto QuardVertics = Bit(27 - BitCorrection); static constexpr auto TriVertics = !QuardVertics; static constexpr auto Textured = Bit(26 - BitCorrection); static constexpr auto Untextured = !Textured; static constexpr auto SemiTransparent = Bit(25 - BitCorrection); static constexpr auto NonTransparent = !SemiTransparent; static constexpr auto BlendTexture = Bit(24 - BitCorrection); static constexpr auto NoBlendTexture = !BlendTexture; uint8_t value = bit::value::set_normalized(0u, CmdID.with(CmdValue)); constexpr Code() = default; constexpr Code& set(Bit bit) { this->value = bit::set(this->value, bit); return *this; } constexpr Code& set(ClearBit bit) { this->value = bit::set(this->value, bit); return *this; } }; struct IsPrimitive { static constexpr bool is_primitive = true; }; template struct CodeInterface { constexpr T& set_semi_transparent() { static_cast(this)->code.set(Code::SemiTransparent); return *static_cast(this); } constexpr T& set_non_transparent() { static_cast(this)->code.set(Code::NonTransparent); return *static_cast(this); } constexpr T& set_texture_blending() { static_cast(this)->code.set(Code::BlendTexture); return *static_cast(this); } constexpr T& set_non_texture_blening() { static_cast(this)->code.set(Code::NoBlendTexture); return *static_cast(this); } }; // Concept for now template struct Hooked { uint32_t hook; T primitive; }; } struct POLY_F3 : public internal::IsPrimitive, public internal::CodeInterface { static constexpr auto IdentityCode = internal::Code().set(internal::Code::FlatShading).set(internal::Code::TriVertics).set(internal::Code::Untextured).set(internal::Code::NonTransparent).set(internal::Code::NoBlendTexture); Color24 color; internal::Code code = IdentityCode; PositionI16 vertex[3]; constexpr POLY_F3() = default; constexpr POLY_F3(Color24 color, const PositionI16 (&verticies)[3]) : color(color), code(IdentityCode), vertex{verticies[0], verticies[1], verticies[2]} { } }; static_assert(sizeof(POLY_F3) == 16); } } #endif // !__JABYENGINE_GPU_PRIMITIVES_HPP__