Add Poly specific functions
This commit is contained in:
parent
617e8c2090
commit
22a8f9f4ac
|
@ -32,6 +32,35 @@ namespace JabyEngine {
|
|||
return *static_cast<T*>(this);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct Poly3Interface {};
|
||||
|
||||
template<typename T>
|
||||
struct Poly4Interface {
|
||||
constexpr T& set_rect_size(const SizeI16& size) {
|
||||
static_cast<T*>(this)->vertex1 = static_cast<const T*>(this)->vertex0.add(size.width, 0);
|
||||
static_cast<T*>(this)->vertex2 = static_cast<const T*>(this)->vertex0.add(0, size.height);
|
||||
static_cast<T*>(this)->vertex3 = static_cast<const T*>(this)->vertex0.add(size.width, size.height);
|
||||
|
||||
return *static_cast<T*>(this);
|
||||
}
|
||||
|
||||
constexpr T& set_rect_size_fast(const SizeI16& size) {
|
||||
static_cast<T*>(this)->vertex1.x = static_cast<const T*>(this)->vertex0.x + size.width;
|
||||
static_cast<T*>(this)->vertex2.y = static_cast<const T*>(this)->vertex0.y + size.height;
|
||||
static_cast<T*>(this)->vertex3 = static_cast<const T*>(this)->vertex0.add(size.width, size.height);
|
||||
|
||||
return *static_cast<T*>(this);
|
||||
}
|
||||
|
||||
constexpr SizeI16 get_rect_size() const {
|
||||
return SizeI16::create(
|
||||
static_cast<const T*>(this)->vertex1.x - static_cast<const T*>(this)->vertex0.x,
|
||||
static_cast<const T*>(this)->vertex2.y - static_cast<const T*>(this)->vertex0.y
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -39,9 +68,9 @@ namespace JabyEngine {
|
|||
/ \
|
||||
3 - 2
|
||||
*/
|
||||
struct POLY_F3 : public internal::RenderPrimitive<POLY_F3>, public internal::PolyCodeInterface<POLY_F3>, public internal::LinkedElementCreator<POLY_F3> {
|
||||
struct POLY_F3 : public internal::RenderPrimitive<POLY_F3>, public internal::PolyCodeInterface<POLY_F3>, public internal::Poly3Interface<POLY_F3>, public internal::LinkedElementCreator<POLY_F3> {
|
||||
static constexpr auto IdentityCode = Code::create().set(Code::FlatShading).set(Code::TriVertics).set(Code::Untextured).set(Code::NonTransparent);
|
||||
|
||||
|
||||
Color24 color; // a
|
||||
Code code; // a
|
||||
Vertex vertex0; // b
|
||||
|
@ -58,7 +87,7 @@ namespace JabyEngine {
|
|||
}
|
||||
};
|
||||
|
||||
struct POLY_FT3 : public internal::RenderPrimitive<POLY_FT3>, public internal::PolyCodeInterface<POLY_FT3>, public internal::LinkedElementCreator<POLY_FT3> {
|
||||
struct POLY_FT3 : public internal::RenderPrimitive<POLY_FT3>, public internal::PolyCodeInterface<POLY_FT3>, public internal::Poly3Interface<POLY_FT3>, public internal::LinkedElementCreator<POLY_FT3> {
|
||||
struct VertexEx {
|
||||
Vertex position;
|
||||
PageOffset tex_offset;
|
||||
|
@ -94,7 +123,7 @@ namespace JabyEngine {
|
|||
}
|
||||
};
|
||||
|
||||
struct POLY_G3 : public internal::RenderPrimitive<POLY_G3>, public internal::PolyCodeInterface<POLY_G3>, public internal::LinkedElementCreator<POLY_G3> {
|
||||
struct POLY_G3 : public internal::RenderPrimitive<POLY_G3>, public internal::PolyCodeInterface<POLY_G3>, public internal::Poly3Interface<POLY_G3>, public internal::LinkedElementCreator<POLY_G3> {
|
||||
static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::GouraudShading);
|
||||
|
||||
Color24 color0; // a
|
||||
|
@ -124,7 +153,7 @@ namespace JabyEngine {
|
|||
}
|
||||
};
|
||||
|
||||
struct POLY_GT3 : public internal::RenderPrimitive<POLY_GT3>, public internal::PolyCodeInterface<POLY_GT3>, public internal::LinkedElementCreator<POLY_GT3> {
|
||||
struct POLY_GT3 : public internal::RenderPrimitive<POLY_GT3>, public internal::PolyCodeInterface<POLY_GT3>, public internal::Poly3Interface<POLY_GT3>, public internal::LinkedElementCreator<POLY_GT3> {
|
||||
struct VertexEx {
|
||||
Vertex position;
|
||||
PageOffset tex_offset;
|
||||
|
@ -170,7 +199,7 @@ namespace JabyEngine {
|
|||
| |
|
||||
3 - 4
|
||||
*/
|
||||
struct POLY_F4 : public internal::RenderPrimitive<POLY_F4>, public internal::PolyCodeInterface<POLY_F4>, public internal::LinkedElementCreator<POLY_F4> {
|
||||
struct POLY_F4 : public internal::RenderPrimitive<POLY_F4>, public internal::PolyCodeInterface<POLY_F4>, public internal::Poly4Interface<POLY_F4>, public internal::LinkedElementCreator<POLY_F4> {
|
||||
static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
Color24 color; // a
|
||||
|
@ -200,7 +229,7 @@ namespace JabyEngine {
|
|||
}
|
||||
};
|
||||
|
||||
struct POLY_FT4 : public internal::RenderPrimitive<POLY_FT4>, public internal::PolyCodeInterface<POLY_FT4>, public internal::LinkedElementCreator<POLY_FT4> {
|
||||
struct POLY_FT4 : public internal::RenderPrimitive<POLY_FT4>, public internal::PolyCodeInterface<POLY_FT4>, public internal::Poly4Interface<POLY_FT4>, public internal::LinkedElementCreator<POLY_FT4> {
|
||||
typedef POLY_FT3::VertexEx VertexEx;
|
||||
static constexpr auto IdentityCode = Code(POLY_FT3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
|
@ -248,7 +277,7 @@ namespace JabyEngine {
|
|||
}
|
||||
};
|
||||
|
||||
struct POLY_G4 : public internal::RenderPrimitive<POLY_G4>, public internal::PolyCodeInterface<POLY_G4>, public internal::LinkedElementCreator<POLY_G4> {
|
||||
struct POLY_G4 : public internal::RenderPrimitive<POLY_G4>, public internal::PolyCodeInterface<POLY_G4>, public internal::Poly4Interface<POLY_G4>, public internal::LinkedElementCreator<POLY_G4> {
|
||||
static constexpr auto IdentityCode = Code(POLY_G3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
Color24 color0; // a
|
||||
|
@ -292,7 +321,7 @@ namespace JabyEngine {
|
|||
}
|
||||
};
|
||||
|
||||
struct POLY_GT4 : public internal::RenderPrimitive<POLY_GT4>, public internal::PolyCodeInterface<POLY_GT4>, public internal::LinkedElementCreator<POLY_GT4> {
|
||||
struct POLY_GT4 : public internal::RenderPrimitive<POLY_GT4>, public internal::PolyCodeInterface<POLY_GT4>, public internal::Poly4Interface<POLY_GT4>, public internal::LinkedElementCreator<POLY_GT4> {
|
||||
typedef POLY_GT3::VertexEx VertexEx;
|
||||
static constexpr auto IdentityCode = Code(POLY_GT3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
|
|
Loading…
Reference in New Issue