compiling with templated component

This commit is contained in:
Clément Le Bihan
2021-05-25 17:43:48 +02:00
parent 95b1b2ebb7
commit e5e2739d73
3 changed files with 14 additions and 7 deletions
@@ -10,18 +10,21 @@
namespace BBM
{
template <class T>
class Drawable2DComponent : public WAL::Component, public T
class Drawable2DComponent : public WAL::Component
{
public:
explicit Drawable2DComponent(WAL::Entity &entity)
: WAL::Component(entity)
T member;
explicit Drawable2DComponent(WAL::Entity &entity, T member)
: WAL::Component(entity),
member(std::move(member))
{
}
WAL::Component *clone(WAL::Entity &entity) const override
{
return new Drawable2DComponent(entity);
return new Drawable2DComponent(entity, this->member);
}
@@ -15,8 +15,9 @@ namespace BBM
public:
T member;
explicit Drawable3DComponent(WAL::Entity &entity)
: WAL::Component(entity)
explicit Drawable3DComponent(WAL::Entity &entity, T member)
: WAL::Component(entity),
member(std::move(member))
{
}
+4 -1
View File
@@ -36,7 +36,10 @@ int main()
RAY::Vector3(0.0f, 1.0f, 0.0f),
45.0f, CAMERA_PERSPECTIVE
);
BBM::Renderer2DSystem<RAY::Drawables::Drawables2D::Text> textSystem(window);
RAY::Drawables::Drawables2D::Circle circle{10, 10, 10, 0};
WAL::Entity myEntity{"myEntity"};
BBM::Drawable2DComponent<RAY::Drawables::Drawables2D::Circle> circleComponent(myEntity, circle);
//BBM::Renderer2DSystem<RAY::Drawables::Drawables2D::Circle> textSystem(window);
RAY::Model model("assets/guy.iqm");
RAY::Texture texture("assets/guytex.png");
RAY::ModelAnimations animations("assets/guy.iqm");