Adding a onStart onStop

This commit is contained in:
Zoe Roux
2021-06-09 16:00:06 +02:00
parent c544a83ee8
commit c94237dedc
13 changed files with 79 additions and 38 deletions
@@ -5,6 +5,7 @@
#include "ShaderComponent.hpp"
#include <utility>
#include <Component/Renderer/Drawable3DComponent.hpp>
namespace BBM
{
@@ -20,7 +21,6 @@ namespace BBM
ShaderComponent::ShaderComponent(WAL::Entity &entity, const std::string &fragmentFilePath, const std::string &vertexFilePath)
: WAL::Component(entity),
_refEntity(entity),
_shader(vertexFilePath, fragmentFilePath),
_fragmentFilePath(fragmentFilePath),
_vertexFilePath(vertexFilePath)
@@ -42,6 +42,14 @@ namespace BBM
{
}
void ShaderComponentModel::onStart()
{
auto &drawable = this->_entity.getComponent<Drawable3DComponent>();
this->model = dynamic_cast<RAY::Drawables::Drawables3D::Model *>(drawable.drawable.get());
if (!this->model)
throw std::runtime_error("No model available with a shader model component. This is unsupported.");
}
ShaderComponentDrawable2D::ShaderComponentDrawable2D(WAL::Entity &entity, std::string fragmentFilePath, std::string vertexFilePath)
: ShaderComponent(entity, std::move(fragmentFilePath), std::move(vertexFilePath))
{