From e5e2739d73b4703cd54cc6360d3890fdd4d3e372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Tue, 25 May 2021 17:43:48 +0200 Subject: [PATCH] compiling with templated component --- sources/Component/Drawable/Drawable2DComponent.hpp | 11 +++++++---- sources/Component/Drawable/Drawable3DComponent.hpp | 5 +++-- sources/main.cpp | 5 ++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sources/Component/Drawable/Drawable2DComponent.hpp b/sources/Component/Drawable/Drawable2DComponent.hpp index cefb2c62..c59e3c0c 100644 --- a/sources/Component/Drawable/Drawable2DComponent.hpp +++ b/sources/Component/Drawable/Drawable2DComponent.hpp @@ -10,18 +10,21 @@ namespace BBM { template - 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); } diff --git a/sources/Component/Drawable/Drawable3DComponent.hpp b/sources/Component/Drawable/Drawable3DComponent.hpp index bfe631db..8807d76a 100644 --- a/sources/Component/Drawable/Drawable3DComponent.hpp +++ b/sources/Component/Drawable/Drawable3DComponent.hpp @@ -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)) { } diff --git a/sources/main.cpp b/sources/main.cpp index 5429c90e..c6552263 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -36,7 +36,10 @@ int main() RAY::Vector3(0.0f, 1.0f, 0.0f), 45.0f, CAMERA_PERSPECTIVE ); - BBM::Renderer2DSystem textSystem(window); + RAY::Drawables::Drawables2D::Circle circle{10, 10, 10, 0}; + WAL::Entity myEntity{"myEntity"}; + BBM::Drawable2DComponent circleComponent(myEntity, circle); + //BBM::Renderer2DSystem textSystem(window); RAY::Model model("assets/guy.iqm"); RAY::Texture texture("assets/guytex.png"); RAY::ModelAnimations animations("assets/guy.iqm");