Support LINE_F
This commit is contained in:
73
include/PSX/GPU/Primitives/primitive_line_types.hpp
Normal file
73
include/PSX/GPU/Primitives/primitive_line_types.hpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#ifndef __JABY_ENGINE_PRIMITIVE_LINE_TYPES_HPP__
|
||||
#define __JABY_ENGINE_PRIMITIVE_LINE_TYPES_HPP__
|
||||
#include "primitive_support_types.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace GPU {
|
||||
namespace internal {
|
||||
struct LineCode : public CodeBase<LineCode> {
|
||||
static constexpr uint8_t CmdValue = 0b010;
|
||||
|
||||
static constexpr auto GouraudShading = Bit(28 - BitCorrection);
|
||||
static constexpr auto FlatShading = !GouraudShading;
|
||||
static constexpr auto PolyLine = Bit(27 - BitCorrection);
|
||||
static constexpr auto SingleLine = !PolyLine;
|
||||
static constexpr auto SemiTransparent = Bit(25 - BitCorrection);
|
||||
static constexpr auto NonTransparent = !SemiTransparent;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct LineCodeInterface {
|
||||
typedef ::JabyEngine::GPU::internal::LineCode Code;
|
||||
|
||||
constexpr T& set_poly_line(bool set = true) {
|
||||
if(set) {
|
||||
static_cast<T*>(this)->head.code.set(Code::PolyLine);
|
||||
}
|
||||
else {
|
||||
static_cast<T*>(this)->head.code.set(Code::SingleLine);
|
||||
}
|
||||
return *static_cast<T*>(this);
|
||||
}
|
||||
|
||||
constexpr T& set_semi_transparent(bool set = true) {
|
||||
if(set) {
|
||||
static_cast<T*>(this)->head.code.set(Code::SemiTransparent);
|
||||
}
|
||||
else {
|
||||
static_cast<T*>(this)->head.code.set(Code::NonTransparent);
|
||||
}
|
||||
return *static_cast<T*>(this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
struct LINE_F : public internal::IsPrimitive, public internal::LineCodeInterface<LINE_F> {
|
||||
struct Head {
|
||||
static constexpr auto IdentityCode = Code().set(Code::FlatShading).set(Code::SingleLine).set(Code::NonTransparent);
|
||||
|
||||
Color24 color;
|
||||
Code code = IdentityCode;
|
||||
};
|
||||
|
||||
union {
|
||||
Head head;
|
||||
Vertex vertex;
|
||||
};
|
||||
|
||||
static constexpr LINE_F new_line(const Color24& color, bool is_poly) {
|
||||
return LINE_F{.head = {.color = color, .code = Head::IdentityCode}}.set_poly_line(is_poly);
|
||||
}
|
||||
|
||||
static constexpr LINE_F new_point(const Vertex& vertex) {
|
||||
return {.vertex = vertex};
|
||||
}
|
||||
|
||||
static constexpr LINE_F new_terminate() {
|
||||
return {.vertex = {static_cast<short>(0xF000), static_cast<short>(0xF000u)}};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //!__JABY_ENGINE_PRIMITIVE_LINE_TYPES_HPP__
|
@@ -5,7 +5,7 @@
|
||||
namespace JabyEngine {
|
||||
namespace GPU {
|
||||
namespace internal {
|
||||
struct Code : public CodeBase<Code> {
|
||||
struct PolyCode : public CodeBase<PolyCode> {
|
||||
static constexpr uint8_t CmdValue = 0b001;
|
||||
|
||||
static constexpr auto GouraudShading = Bit(28 - BitCorrection);
|
||||
@@ -21,8 +21,8 @@ namespace JabyEngine {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct CodeInterface {
|
||||
typedef ::JabyEngine::GPU::internal::Code Code;
|
||||
struct PolyCodeInterface {
|
||||
typedef ::JabyEngine::GPU::internal::PolyCode Code;
|
||||
|
||||
constexpr T& set_semi_transparent(bool set = true) {
|
||||
if(set) {
|
||||
@@ -51,7 +51,7 @@ namespace JabyEngine {
|
||||
/ \
|
||||
3 - 2
|
||||
*/
|
||||
struct POLY_F3 : public internal::IsPrimitive, public internal::CodeInterface<POLY_F3> {
|
||||
struct POLY_F3 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_F3> {
|
||||
static constexpr auto IdentityCode = Code().set(Code::FlatShading).set(Code::TriVertics).set(Code::Untextured).set(Code::NonTransparent);
|
||||
|
||||
Color24 color; // a
|
||||
@@ -69,7 +69,7 @@ namespace JabyEngine {
|
||||
}
|
||||
};
|
||||
|
||||
struct POLY_FT3 : public internal::IsPrimitive, public internal::CodeInterface<POLY_FT3> {
|
||||
struct POLY_FT3 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_FT3> {
|
||||
struct VertexEx {
|
||||
Vertex position;
|
||||
PagePosition page;
|
||||
@@ -100,7 +100,7 @@ namespace JabyEngine {
|
||||
vertex2(vertices_ex[2].position), page2(vertices_ex[2].page), padded2(0) {}
|
||||
};
|
||||
|
||||
struct POLY_G3 : public internal::IsPrimitive, public internal::CodeInterface<POLY_G3> {
|
||||
struct POLY_G3 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_G3> {
|
||||
struct VertexEx {
|
||||
Vertex position;
|
||||
Color24 color;
|
||||
@@ -128,7 +128,7 @@ namespace JabyEngine {
|
||||
color2(verticies_ex[2].color), pad2(0), vertex2(verticies_ex[2].position) {}
|
||||
};
|
||||
|
||||
struct POLY_GT3 : public internal::IsPrimitive, public internal::CodeInterface<POLY_GT3> {
|
||||
struct POLY_GT3 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_GT3> {
|
||||
struct VertexEx {
|
||||
Vertex position;
|
||||
PagePosition page;
|
||||
@@ -168,7 +168,7 @@ namespace JabyEngine {
|
||||
| |
|
||||
3 - 4
|
||||
*/
|
||||
struct POLY_F4 : public internal::IsPrimitive, public internal::CodeInterface<POLY_F4> {
|
||||
struct POLY_F4 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_F4> {
|
||||
static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
Color24 color; // a
|
||||
@@ -193,7 +193,7 @@ namespace JabyEngine {
|
||||
color) {}
|
||||
};
|
||||
|
||||
struct POLY_FT4 : public internal::IsPrimitive, public internal::CodeInterface<POLY_FT4> {
|
||||
struct POLY_FT4 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_FT4> {
|
||||
typedef POLY_FT3::VertexEx VertexEx;
|
||||
static constexpr auto IdentityCode = Code(POLY_FT3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace JabyEngine {
|
||||
) {}
|
||||
};
|
||||
|
||||
struct POLY_G4 : public internal::IsPrimitive, public internal::CodeInterface<POLY_G4> {
|
||||
struct POLY_G4 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_G4> {
|
||||
typedef POLY_G3::VertexEx VertexEx;
|
||||
static constexpr auto IdentityCode = Code(POLY_G3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace JabyEngine {
|
||||
) {}
|
||||
};
|
||||
|
||||
struct POLY_GT4 : public internal::IsPrimitive, public internal::CodeInterface<POLY_GT4> {
|
||||
struct POLY_GT4 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_GT4> {
|
||||
typedef POLY_GT3::VertexEx VertexEx;
|
||||
static constexpr auto IdentityCode = Code(POLY_GT3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
|
Reference in New Issue
Block a user