feat: entt library
This commit is contained in:
6
include/components/camera.h
Normal file
6
include/components/camera.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef COMPONENTS_PLAYER_H_
|
||||
#define COMPONENTS_PLAYER_H_
|
||||
|
||||
struct camera {};
|
||||
|
||||
#endif // COMPONENTS_PLAYER_H_
|
6
include/components/light.h
Normal file
6
include/components/light.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef COMPONENTS_LIGHT_H_
|
||||
#define COMPONENTS_LIGHT_H_
|
||||
|
||||
struct light {};
|
||||
|
||||
#endif // COMPONENTS_LIGHT_H_
|
11
include/components/mesh.h
Normal file
11
include/components/mesh.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef COMPONENTS_MESH_H_
|
||||
#define COMPONENTS_MESH_H_
|
||||
|
||||
#include <memory>
|
||||
#include "renderer/wavefront.h"
|
||||
|
||||
struct mesh {
|
||||
std::unique_ptr<Object> object;
|
||||
};
|
||||
|
||||
#endif // COMPONENTS_MESH_H_
|
12
include/components/transform.h
Normal file
12
include/components/transform.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef COMPONENTS_TRANSFORM_H_
|
||||
#define COMPONENTS_TRANSFORM_H_
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
struct transform {
|
||||
glm::vec3 position;
|
||||
glm::vec3 rotation;
|
||||
glm::vec3 scale;
|
||||
};
|
||||
|
||||
#endif // COMPONENTS_TRANSFORM_H_
|
@ -1,14 +0,0 @@
|
||||
#ifndef ECS_ENTITY_CAMERA_H_
|
||||
#define ECS_ENTITY_CAMERA_H
|
||||
|
||||
#include "ecs/entity.h"
|
||||
|
||||
namespace ecs {
|
||||
class Camera : Entity {
|
||||
public:
|
||||
Camera() = default;
|
||||
~Camera() = default;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ECS_ENTITY_CAMERA_H_
|
@ -1,9 +0,0 @@
|
||||
#ifndef ECS_COMPONENT_H_
|
||||
#define ECS_COMPONENT_H_
|
||||
|
||||
namespace ecs {
|
||||
class Component {
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ECS_COMPONENT_H_
|
@ -1,16 +0,0 @@
|
||||
#ifndef ECS_COMP_MESH_H_
|
||||
#define ECS_COMP_MESH_H_
|
||||
|
||||
#include "renderer/wavefront.h"
|
||||
#include "ecs/component.h"
|
||||
|
||||
namespace ecs {
|
||||
class Mesh : Component {
|
||||
public:
|
||||
Object* object;
|
||||
|
||||
Mesh(Object* model) : object(model) {}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ECS_COMP_MESH_H_
|
@ -1,18 +0,0 @@
|
||||
#ifndef ECS_COMP_TRANSFORM_H_
|
||||
#define ECS_COMP_TRANSFORM_H_
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include "ecs/component.h"
|
||||
|
||||
namespace ecs {
|
||||
class Transform : Component {
|
||||
public:
|
||||
Transform() = default;
|
||||
public:
|
||||
glm::vec3 pos;
|
||||
glm::vec3 rot;
|
||||
glm::vec3 scale;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ECS_COMP_TRANSFORM_H_
|
@ -1,18 +0,0 @@
|
||||
#ifndef ECS_ENTITY_H_
|
||||
#define ECS_ENTITY_H_
|
||||
|
||||
#include "ecs/components/transform.h"
|
||||
#include "ecs/components/mesh.h"
|
||||
|
||||
namespace ecs {
|
||||
class Entity {
|
||||
public:
|
||||
Transform transform;
|
||||
Mesh mesh;
|
||||
|
||||
Entity(Mesh m) : mesh(m) {}
|
||||
~Entity() = default;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ECS_ENTITY_H_
|
@ -2,16 +2,16 @@
|
||||
#define RENDERER_H_
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <entt/entity/registry.hpp>
|
||||
|
||||
#include "renderer/shader.h"
|
||||
#include "ecs/entity.h"
|
||||
|
||||
// TODO: make static or singleton
|
||||
class Renderer {
|
||||
public:
|
||||
Renderer(ecs::Entity& light, ecs::Entity& camera);
|
||||
Renderer();
|
||||
|
||||
void RenderLight();
|
||||
void RenderEntity(const ecs::Entity& entity);
|
||||
void Render(entt::registry& registry);
|
||||
|
||||
void OnWindowResized(int w, int h);
|
||||
private:
|
||||
@ -20,9 +20,6 @@ private:
|
||||
glm::mat4 m_model;
|
||||
glm::mat4 m_proj;
|
||||
glm::mat4 m_view;
|
||||
|
||||
ecs::Entity& m_light;
|
||||
ecs::Entity& m_camera;
|
||||
};
|
||||
|
||||
#endif // RENDERER_H_
|
@ -35,6 +35,7 @@ private:
|
||||
void CreateNewMesh(const std::string& materialName);
|
||||
public:
|
||||
void Render(Shader& shader);
|
||||
[[nodiscard]] inline const std::string Name() const { return m_name; }
|
||||
private:
|
||||
std::string m_name;
|
||||
std::vector<glm::vec3> m_vertices;
|
||||
|
Reference in New Issue
Block a user