readding ShaderComponent.cpp/hpp

This commit is contained in:
Clément Le Bihan
2021-06-08 12:44:52 +02:00
parent 4ee45c9c28
commit d738848eb0
4 changed files with 183 additions and 54 deletions
+54 -54
View File
@@ -20,60 +20,60 @@ if (EMSCRIPTEN)
endif ()
set(SOURCES
sources/Models/GameState.hpp
sources/Runner/Runner.cpp
sources/Runner/Runner.hpp
sources/Map/Map.cpp
sources/Map/Map.hpp
sources/Component/Position/PositionComponent.cpp
sources/Component/Position/PositionComponent.hpp
sources/Component/Movable/MovableComponent.cpp
sources/Component/Movable/MovableComponent.hpp
sources/Component/Controllable/ControllableComponent.hpp
sources/Component/Controllable/ControllableComponent.cpp
sources/Component/Gamepad/GamepadComponent.cpp
sources/Component/Gamepad/GamepadComponent.hpp
sources/Component/Keyboard/KeyboardComponent.cpp
sources/Component/Keyboard/KeyboardComponent.hpp
sources/Component/Health/HealthComponent.cpp
sources/Component/Health/HealthComponent.hpp
sources/System/Movable/MovableSystem.hpp
sources/System/Movable/MovableSystem.cpp
sources/System/Controllable/ControllableSystem.cpp
sources/System/Controllable/ControllableSystem.hpp
sources/System/Gamepad/GamepadSystem.cpp
sources/System/Gamepad/GamepadSystem.hpp
sources/System/Health/HealthSystem.cpp
sources/System/Health/HealthSystem.hpp
sources/System/Keyboard/KeyboardSystem.cpp
sources/System/Keyboard/KeyboardSystem.hpp
sources/System/Movable/MovableSystem.cpp
sources/System/Movable/MovableSystem.hpp
sources/Models/Vector3.hpp
sources/Component/GridCentered/GridCenteredComponent.cpp
sources/Component/GridCentered/GridCenteredComponent.hpp
sources/System/GridCentered/GridCenteredSystem.cpp
sources/System/GridCentered/GridCenteredSystem.hpp
sources/Models/Vector2.hpp
sources/Component/Renderer/Drawable2DComponent.hpp
sources/Component/Renderer/Drawable3DComponent.hpp
sources/System/Renderer/RenderSystem.hpp
sources/System/Renderer/RenderSystem.cpp
sources/Component/Renderer/CameraComponent.cpp
sources/Component/Renderer/CameraComponent.hpp
sources/Component/Animation/AnimationsComponent.cpp
sources/Component/Animation/AnimationsComponent.hpp
sources/System/Animation/AnimationsSystem.cpp
sources/System/Animation/AnimationsSystem.hpp
sources/Component/Collision/CollisionComponent.cpp
sources/Component/Collision/CollisionComponent.hpp
sources/System/Collision/CollisionSystem.hpp
sources/System/Collision/CollisionSystem.cpp
sources/Component/Animator/AnimatorComponent.cpp
sources/Component/Animator/AnimatorComponent.hpp
sources/System/Animator/AnimatorSystem.cpp
sources/System/Animator/AnimatorSystem.hpp
)
sources/Models/GameState.hpp
sources/Runner/Runner.cpp
sources/Runner/Runner.hpp
sources/Map/Map.cpp
sources/Map/Map.hpp
sources/Component/Position/PositionComponent.cpp
sources/Component/Position/PositionComponent.hpp
sources/Component/Movable/MovableComponent.cpp
sources/Component/Movable/MovableComponent.hpp
sources/Component/Controllable/ControllableComponent.hpp
sources/Component/Controllable/ControllableComponent.cpp
sources/Component/Gamepad/GamepadComponent.cpp
sources/Component/Gamepad/GamepadComponent.hpp
sources/Component/Keyboard/KeyboardComponent.cpp
sources/Component/Keyboard/KeyboardComponent.hpp
sources/Component/Health/HealthComponent.cpp
sources/Component/Health/HealthComponent.hpp
sources/System/Movable/MovableSystem.hpp
sources/System/Movable/MovableSystem.cpp
sources/System/Controllable/ControllableSystem.cpp
sources/System/Controllable/ControllableSystem.hpp
sources/System/Gamepad/GamepadSystem.cpp
sources/System/Gamepad/GamepadSystem.hpp
sources/System/Health/HealthSystem.cpp
sources/System/Health/HealthSystem.hpp
sources/System/Keyboard/KeyboardSystem.cpp
sources/System/Keyboard/KeyboardSystem.hpp
sources/System/Movable/MovableSystem.cpp
sources/System/Movable/MovableSystem.hpp
sources/Models/Vector3.hpp
sources/Component/GridCentered/GridCenteredComponent.cpp
sources/Component/GridCentered/GridCenteredComponent.hpp
sources/System/GridCentered/GridCenteredSystem.cpp
sources/System/GridCentered/GridCenteredSystem.hpp
sources/Models/Vector2.hpp
sources/Component/Renderer/Drawable2DComponent.hpp
sources/Component/Renderer/Drawable3DComponent.hpp
sources/System/Renderer/RenderSystem.hpp
sources/System/Renderer/RenderSystem.cpp
sources/Component/Renderer/CameraComponent.cpp
sources/Component/Renderer/CameraComponent.hpp
sources/Component/Animation/AnimationsComponent.cpp
sources/Component/Animation/AnimationsComponent.hpp
sources/System/Animation/AnimationsSystem.cpp
sources/System/Animation/AnimationsSystem.hpp
sources/Component/Collision/CollisionComponent.cpp
sources/Component/Collision/CollisionComponent.hpp
sources/System/Collision/CollisionSystem.hpp
sources/System/Collision/CollisionSystem.cpp
sources/Component/Animator/AnimatorComponent.cpp
sources/Component/Animator/AnimatorComponent.hpp
sources/System/Animator/AnimatorSystem.cpp
sources/System/Animator/AnimatorSystem.hpp
sources/Component/Shaders/ShaderComponent.cpp sources/Component/Shaders/ShaderComponent.hpp)
add_executable(bomberman
sources/main.cpp
${SOURCES}
@@ -0,0 +1,49 @@
//
// Created by cbihan on 03/06/2021.
//
#include "ShaderComponent.hpp"
#include <utility>
namespace BBM
{
WAL::Component *ShaderComponent::clone(WAL::Entity &entity) const
{
return new ShaderComponent(*this);
}
RAY::Shader &ShaderComponent::getShader()
{
return this->_shader;
}
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)
{
}
std::string ShaderComponent::getFragmentFilePath() const
{
return this->_fragmentFilePath;
}
std::string ShaderComponent::getVertexFilePath() const
{
return this->_vertexFilePath;
}
ShaderComponentModel::ShaderComponentModel(WAL::Entity &entity, std::string fragmentFilePath, std::string vertexFilePath)
: ShaderComponent(entity, std::move(fragmentFilePath), std::move(vertexFilePath))
{
}
ShaderComponentDrawable::ShaderComponentDrawable(WAL::Entity &entity, std::string fragmentFilePath, std::string vertexFilePath)
: ShaderComponent(entity, std::move(fragmentFilePath), std::move(vertexFilePath))
{
}
}
@@ -0,0 +1,78 @@
//
// Created by cbihan on 03/06/2021.
//
#pragma once
#include <string>
#include <Component/Component.hpp>
#include <Entity/Entity.hpp>
#include <Shaders/Shaders.hpp>
namespace BBM
{
class ShaderComponent : public WAL::Component
{
private:
//! @brief efefefefez
WAL::Entity &_refEntity;
//! @brief The shader to be applied
RAY::Shader _shader;
//! @brief The path to the fragment file
std::string _fragmentFilePath;
//! @brief The path to the vertex file
std::string _vertexFilePath;
public:
//! @brief getter for _shader
RAY::Shader &getShader();
//! @inherit
WAL::Component *clone(WAL::Entity &entity) const override;
//! @brief get the fragment file path
std::string getFragmentFilePath() const;
//! @brief get the fragment file path
std::string getVertexFilePath() const;
//! @brief ctor
//! @note use empty string to omit a file
ShaderComponent(WAL::Entity &entity, const std::string& fragmentFilePath, const std::string& vertexFilePath = "");
//! @brief Default copy ctor
ShaderComponent(const ShaderComponent &) = default;
//! @brief Default dtor
~ShaderComponent() override = default;
//! @brief Default assignment operator
ShaderComponent &operator=(const ShaderComponent &) = delete;
};
class ShaderComponentModel : public ShaderComponent
{
public:
//! @brief ctor
//! @note use empty string to omit a file
ShaderComponentModel(WAL::Entity &entity, std::string fragmentFilePath, std::string vertexFilePath = "");
//! @brief Default copy ctor
ShaderComponentModel(const ShaderComponentModel &) = default;
//! @brief Default dtor
~ShaderComponentModel() override = default;
//! @brief Default assignment operator
ShaderComponentModel &operator=(const ShaderComponentModel &) = delete;
};
class ShaderComponentDrawable : public ShaderComponent
{
public:
//! @brief ctor
//! @note use empty string to omit a file
ShaderComponentDrawable(WAL::Entity &entity, std::string fragmentFilePath, std::string vertexFilePath = "");
//! @brief Default copy ctor
ShaderComponentDrawable(const ShaderComponentDrawable &) = default;
//! @brief Default dtor
~ShaderComponentDrawable() override = default;
//! @brief Default assignment operator
ShaderComponentDrawable &operator=(const ShaderComponentDrawable &) = delete;
};
}
+2
View File
@@ -26,6 +26,7 @@
#include <System/Animator/AnimatorSystem.hpp>
#include "Component/Animation/AnimationsComponent.hpp"
#include "System/Animation/AnimationsSystem.hpp"
#include "Component/Shaders/ShaderComponent.hpp"
#include "Map/Map.hpp"
namespace RAY3D = RAY::Drawables::Drawables3D;
@@ -69,6 +70,7 @@ namespace BBM
.addComponent<ControllableComponent>()
.addComponent<AnimatorComponent>()
.addComponent<KeyboardComponent>()
.addComponent<ShaderComponent>("assets/shaders/glsl330/predator.fs")
.addComponent<AnimationsComponent>(RAY::ModelAnimations("assets/player/player.iqm"), 3)
.addComponent<CollisionComponent>(1)
.addComponent<MovableComponent>()