restructure around entt

This commit is contained in:
Ben Kyd
2025-06-28 19:11:10 +01:00
parent a8b80e6013
commit 841631eb95
20 changed files with 140 additions and 129 deletions

View File

@@ -1,13 +1,12 @@
#ifndef AEON_AEON_H_
#define AEON_AEON_H_
#include <Aeon/Includes.hpp>
#include <Aeon/Core/Display.hpp>
#include <Aeon/Core/Events.hpp>
#include <Aeon/Core/GameLayer.hpp>
#include <Aeon/Entity/Entity.hpp>
#include <Aeon/Includes.hpp>
#include <Aeon/Input/Input.hpp>
#include <Aeon/Entity/EntityController.hpp>
namespace Core
{
@@ -22,41 +21,41 @@ namespace Core
class App : public EventListener
{
public:
App( const AppProperties& props, const DisplayProperties& dispProps );
App(const AppProperties& props, const DisplayProperties& dispProps);
void Run();
void Run();
const Display& GetDisplay();
const Display& GetDisplay();
const EC::
// Layers, once assigned, until poped are assumed to
// never change their spot in the layer hierarchy
void PushLayer( GameLayer* layer );
void PushTopLayer( GameLayer* layer );
void PushDebugLayer( GameLayer* layer );
// Layers, once assigned, until poped are assumed to
// never change their spot in the layer hierarchy
void PushLayer(GameLayer* layer);
void PushTopLayer(GameLayer* layer);
void PushDebugLayer(GameLayer* layer);
bool EventRecieved( GenericEvent& e ) override;
bool EventRecieved(GenericEvent& e) override;
public:
void PopLayer();
void PopTopLayer();
void PopDebugLayer();
void PopLayer();
void PopTopLayer();
void PopDebugLayer();
private:
Display mDisplay;
Display mDisplay;
EC::EntityRegistry mEntityController;
Input::InputController& mInput;
EC::registry mEntityRegistry;
Input::InputController& mInput;
// Game layers from z order
std::vector<GameLayer*> mGameLayers;
std::vector<GameLayer*> mTopLayers;
std::vector<GameLayer*> mDebugLayers;
// Game layers from z order
std::vector<GameLayer*> mGameLayers;
std::vector<GameLayer*> mTopLayers;
std::vector<GameLayer*> mDebugLayers;
private:
bool mSIGTERM = false;
bool mSIGTERM = false;
};
}
} // namespace Core
#endif

View File

@@ -1,15 +1,12 @@
#ifndef AEON_CORE_DISPLAY_H_
#define AEON_CORE_DISPLAY_H_
#include <Aeon/Includes.hpp>
#include <Aeon/Rendering/RenderMaster.hpp>
#include <Aeon/Core/EngineConfig.hpp>
#include <Aeon/Core/Events.hpp>
#include <Aeon/Includes.hpp>
using namespace Rendering;
namespace Core {
namespace Core
{
class Display : public EventListener
{
@@ -17,7 +14,7 @@ public:
Display();
~Display();
bool Create( const DisplayProperties& properties );
bool Create(const DisplayProperties& properties);
const unsigned int GetWidth();
const unsigned int GetHeight();
@@ -25,13 +22,13 @@ public:
const SDL_Window* GetWindow();
const SDL_GLContext& GetContext();
void SetClearColour( float r, float g, float b, float a = 1.0f );
void SetClearColour(float r, float g, float b, float a = 1.0f);
void EndFrame();
void Destroy();
bool EventRecieved( GenericEvent& e ) override;
bool EventRecieved(GenericEvent& e) override;
private:
SDL_Window* mWindow;
@@ -42,10 +39,10 @@ private:
float mClearColour[4];
private:
Display( Display const& ) = delete;
void operator=( Display const& ) = delete;
Display(Display const&) = delete;
void operator=(Display const&) = delete;
};
}
} // namespace Core
#endif

View File

@@ -2,6 +2,7 @@
#define AEON_CORE_GAMELAYER_H_
#include <Aeon/Core/Events.hpp>
#include <Aeon/Entity/Entity.hpp>
namespace Core
{
@@ -9,15 +10,12 @@ namespace Core
class GameLayer : public EventListener
{
public:
virtual void Attach() = 0;
virtual void FrameTick() = 0;
virtual void TimeTick() = 0;
virtual void Detach() = 0;
protected:
virtual void Attach() = 0;
virtual void FrameTick() = 0;
virtual void TimeTick() = 0;
virtual void Detach() = 0;
};
}
} // namespace Core
#endif

View File

View File

@@ -1,19 +0,0 @@
#ifndef AEON_ENTITY_CORECOMPONENTS_SIMPLECOMPONENTS_H_
#define AEON_ENTITY_CORECOMPONENTS_SIMPLECOMPONENTS_H_
namespace EC
{
struct Position
{
float x, y, z;
};
struct Velocity
{
float dx, dy, dz;
};
} // namespace EC
#endif

View File

@@ -0,0 +1,25 @@
#ifndef AEON_ENTITY_CORECOMPONENTS_TRANSFORM_H_
#define AEON_ENTITY_CORECOMPONENTS_TRANSFORM_H_
#include <glm/glm.hpp>
#include <glm/gtx/quaternion.hpp>
namespace EC
{
struct Transform
{
Transform(glm::vec3 position) : position(position)
{
}
glm::vec3 position;
glm::quat rotation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f);
float scale = 1.0f;
glm::mat4 model;
};
} // namespace EC
#endif

View File

@@ -1,11 +1,25 @@
#ifndef AEON_ENTITY_ENTITY_H_
#define AEON_ENTITY_ENTITY_H_
#include <Aeon/Entity/CoreComponents/Transform.hpp>
#include <entt/entity/registry.hpp>
#include <entt/entt.hpp>
namespace EC
{
using Entity = entt::entity;
using Registry = entt::registry;
using Handle = entt::handle;
template <typename... Components>
using View = entt::basic_view<entt::entity, entt::exclude_t<>, Components...>;
template <typename... Include, typename... Exclude>
using View = entt::basic_view<entt::entity, entt::exclude_t<Exclude...>, Include...>;
using Dispatcher = entt::dispatcher;
static constexpr auto null = entt::null;
} // namespace EC

11
Aeon/Handle.hpp Normal file
View File

@@ -0,0 +1,11 @@
#ifndef AEON_RENDERING_HANDLE_H_
#define AEON_RENDERING_HANDLE_H_
#include <Aeon/Includes.hpp>
constexpr uint32_t InvalidID = UINT32_MAX;
typedef uint32_t Handle;
#endif

View File

@@ -0,0 +1,15 @@
#ifndef AEON_RENDERING_MESH_H_
#define AEON_RENDERING_MESH_H_
#include <Aeon/Includes.hpp>
#include <Aeon/Handle.hpp>
struct Mesh
{
};
typedef Handle MeshHandle;
#endif

View File

@@ -1,13 +0,0 @@
#include "RenderMaster.hpp"
using namespace Rendering;
RenderMaster::RenderMaster()
{
}
void RenderMaster::QueueRenderable( Renderable* renderable )
{
}

View File

@@ -1,23 +0,0 @@
#ifndef AEON_RENDERING_RENDERMASTER_H_
#define AEON_RENDERING_RENDERMASTER_H_
#include <Aeon/Singleton.hpp>
class Renderable;
namespace Rendering
{
class RenderMaster : public Helpers::Singleton<Rendering::RenderMaster>
{
public:
RenderMaster();
void QueueRenderable(Renderable* renderable);
};
} // namespace Rendering
#endif

View File

View File

View File

View File

View File

@@ -0,0 +1,28 @@
#ifndef AEON_RENDERING_TEXTURE_H_
#define AEON_RENDERING_TEXTURE_H_
#include <Aeon/Includes.hpp>
#include <Aeon/Handle.hpp>
enum class TextureType {
Albedo,
Normal,
Metallic,
Roughness,
AO,
Emissive,
Custom
};
struct TextureDesc
{
};
struct Texture
{
Handle handle;
};
#endif

View File

View File

0
Aeon/ResoucePool.hpp Normal file
View File

View File

@@ -1,6 +1,6 @@
#include <Aeon/Aeon.hpp>
#include <Aeon/Core/Events.hpp>
#include <Aeon/Entity/ComponentController.hpp>
#include <Aeon/Entity/Entity.hpp>
#include <Aeon/Rendering/ImGui.hpp>
#include <iostream>
@@ -51,7 +51,6 @@ public:
void FrameTick() override
{
ImGui::Begin("Debug");
ImGui::End();
@@ -77,34 +76,14 @@ public:
ExampleGame()
: App({"Example"}, {"Game with AEON!"})
{
// EC::EntityRegistry registry;
//
// EC::Entity entity1 = registry.Create();
//
// std::cout << "1: " << entity1 << std::endl;
//
// std::vector<EC::Entity> entities;
//
// for (int i = 0; i < 100; i++)
// {
// entities.push_back(registry.Create());
// }
//
// std::cout << entities[entities.size()] << std::endl;
//
// for (int i = 0; i < 100; i++)
// {
// std::cout << "ENtity in vector pos " << i << " " << entities[i] << std::endl;
// registry.Destroy(entities[i]);
// }
//
// EC::Entity entity2 = registry.Create();
// std::cout << "2: " << entity2 << std::endl;
const auto entity = this->mEntityRegistry.create();
entity.emplace<EC::Transform>();
Level* level = new Level;
PushLayer((Core::GameLayer*)level);
DebugLayer* debug = new DebugLayer;
PushDebugLayer(debug);
PushDebugLayer(&debug);
DebugLayer debug;
Run();
delete level;
}