Introduce is_render_primitive type_trait
This commit is contained in:
parent
ca1e937dae
commit
2b4256f4fb
|
@ -42,7 +42,7 @@ namespace JabyEngine {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LINE_F : public internal::IsPrimitive, public internal::LineCodeInterface<LINE_F> {
|
struct LINE_F : public internal::LineCodeInterface<LINE_F> {
|
||||||
struct Head {
|
struct Head {
|
||||||
static constexpr auto IdentityCode = Code().set(Code::FlatShading).set(Code::SingleLine).set(Code::NonTransparent);
|
static constexpr auto IdentityCode = Code().set(Code::FlatShading).set(Code::SingleLine).set(Code::NonTransparent);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace JabyEngine {
|
||||||
/ \
|
/ \
|
||||||
3 - 2
|
3 - 2
|
||||||
*/
|
*/
|
||||||
struct POLY_F3 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_F3> {
|
struct POLY_F3 : public internal::PolyCodeInterface<POLY_F3> {
|
||||||
static constexpr auto IdentityCode = Code().set(Code::FlatShading).set(Code::TriVertics).set(Code::Untextured).set(Code::NonTransparent);
|
static constexpr auto IdentityCode = Code().set(Code::FlatShading).set(Code::TriVertics).set(Code::Untextured).set(Code::NonTransparent);
|
||||||
|
|
||||||
Color24 color; // a
|
Color24 color; // a
|
||||||
|
@ -69,7 +69,7 @@ namespace JabyEngine {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct POLY_FT3 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_FT3> {
|
struct POLY_FT3 : public internal::PolyCodeInterface<POLY_FT3> {
|
||||||
struct VertexEx {
|
struct VertexEx {
|
||||||
Vertex position;
|
Vertex position;
|
||||||
PagePosition page;
|
PagePosition page;
|
||||||
|
@ -100,7 +100,7 @@ namespace JabyEngine {
|
||||||
vertex2(vertices_ex[2].position), page2(vertices_ex[2].page), padded2(0) {}
|
vertex2(vertices_ex[2].position), page2(vertices_ex[2].page), padded2(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct POLY_G3 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_G3> {
|
struct POLY_G3 : public internal::PolyCodeInterface<POLY_G3> {
|
||||||
struct VertexEx {
|
struct VertexEx {
|
||||||
Vertex position;
|
Vertex position;
|
||||||
Color24 color;
|
Color24 color;
|
||||||
|
@ -128,7 +128,7 @@ namespace JabyEngine {
|
||||||
color2(verticies_ex[2].color), pad2(0), vertex2(verticies_ex[2].position) {}
|
color2(verticies_ex[2].color), pad2(0), vertex2(verticies_ex[2].position) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct POLY_GT3 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_GT3> {
|
struct POLY_GT3 : public internal::PolyCodeInterface<POLY_GT3> {
|
||||||
struct VertexEx {
|
struct VertexEx {
|
||||||
Vertex position;
|
Vertex position;
|
||||||
PagePosition page;
|
PagePosition page;
|
||||||
|
@ -168,7 +168,7 @@ namespace JabyEngine {
|
||||||
| |
|
| |
|
||||||
3 - 4
|
3 - 4
|
||||||
*/
|
*/
|
||||||
struct POLY_F4 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_F4> {
|
struct POLY_F4 : public internal::PolyCodeInterface<POLY_F4> {
|
||||||
static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::QuadVertics);
|
static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::QuadVertics);
|
||||||
|
|
||||||
Color24 color; // a
|
Color24 color; // a
|
||||||
|
@ -193,7 +193,7 @@ namespace JabyEngine {
|
||||||
color) {}
|
color) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct POLY_FT4 : public internal::IsPrimitive, public internal::PolyCodeInterface<POLY_FT4> {
|
struct POLY_FT4 : public internal::PolyCodeInterface<POLY_FT4> {
|
||||||
typedef POLY_FT3::VertexEx VertexEx;
|
typedef POLY_FT3::VertexEx VertexEx;
|
||||||
static constexpr auto IdentityCode = Code(POLY_FT3::IdentityCode).set(Code::QuadVertics);
|
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::PolyCodeInterface<POLY_G4> {
|
struct POLY_G4 : public internal::PolyCodeInterface<POLY_G4> {
|
||||||
typedef POLY_G3::VertexEx VertexEx;
|
typedef POLY_G3::VertexEx VertexEx;
|
||||||
static constexpr auto IdentityCode = Code(POLY_G3::IdentityCode).set(Code::QuadVertics);
|
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::PolyCodeInterface<POLY_GT4> {
|
struct POLY_GT4 : public internal::PolyCodeInterface<POLY_GT4> {
|
||||||
typedef POLY_GT3::VertexEx VertexEx;
|
typedef POLY_GT3::VertexEx VertexEx;
|
||||||
static constexpr auto IdentityCode = Code(POLY_GT3::IdentityCode).set(Code::QuadVertics);
|
static constexpr auto IdentityCode = Code(POLY_GT3::IdentityCode).set(Code::QuadVertics);
|
||||||
|
|
||||||
|
@ -325,6 +325,18 @@ namespace JabyEngine {
|
||||||
typedef POLY_G4 GouraudRectangle;
|
typedef POLY_G4 GouraudRectangle;
|
||||||
typedef POLY_GT4 GouraudTexturedRectangle;
|
typedef POLY_GT4 GouraudTexturedRectangle;
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
__jaby_engine_declare_render_primitive(POLY_F3);
|
||||||
|
__jaby_engine_declare_render_primitive(POLY_FT3);
|
||||||
|
__jaby_engine_declare_render_primitive(POLY_G3);
|
||||||
|
__jaby_engine_declare_render_primitive(POLY_GT3);
|
||||||
|
|
||||||
|
__jaby_engine_declare_render_primitive(POLY_F4);
|
||||||
|
__jaby_engine_declare_render_primitive(POLY_FT4);
|
||||||
|
__jaby_engine_declare_render_primitive(POLY_G4);
|
||||||
|
__jaby_engine_declare_render_primitive(POLY_GT4);
|
||||||
|
}
|
||||||
|
|
||||||
static_assert(sizeof(POLY_F3) == 16);
|
static_assert(sizeof(POLY_F3) == 16);
|
||||||
static_assert(sizeof(POLY_FT3) == 28);
|
static_assert(sizeof(POLY_FT3) == 28);
|
||||||
static_assert(sizeof(POLY_G3) == 24);
|
static_assert(sizeof(POLY_G3) == 24);
|
||||||
|
|
|
@ -35,9 +35,16 @@ namespace JabyEngine {
|
||||||
T primitive;
|
T primitive;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IsPrimitive {
|
template<typename T>
|
||||||
static constexpr bool is_primitive = true;
|
struct is_render_primitive {
|
||||||
|
static constexpr bool value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define __jaby_engine_declare_render_primitive(type) \
|
||||||
|
template<> \
|
||||||
|
struct is_render_primitive<type> { \
|
||||||
|
static constexpr bool value = true; \
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reexport for easier use
|
// Reexport for easier use
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace JabyEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static enable_if<T::is_primitive>::type render(const T& primitive) {
|
static enable_if<internal::is_render_primitive<T>::value>::type render(const T& primitive) {
|
||||||
internal::render(reinterpret_cast<const uint32_t*>(&primitive), sizeof(T)/sizeof(uint32_t));
|
internal::render(reinterpret_cast<const uint32_t*>(&primitive), sizeof(T)/sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue