assimp and ECS, also renderpass? not really tho

This commit is contained in:
Ben Kyd
2025-06-28 23:11:16 +01:00
parent 0db51249ea
commit 8e713e38e6
26 changed files with 160 additions and 93 deletions

6
.gitmodules vendored
View File

@@ -1,3 +1,9 @@
[submodule "Aeon/ThirdParty/entt"] [submodule "Aeon/ThirdParty/entt"]
path = Aeon/ThirdParty/entt path = Aeon/ThirdParty/entt
url = https://github.com/skypjack/entt url = https://github.com/skypjack/entt
[submodule "Aeon/ThirdParty/assimp"]
path = Aeon/ThirdParty/assimp
url = https://github.com/assimp/assimp
[submodule "Aeon/ThirdParty/Yolo"]
path = Aeon/ThirdParty/Yolo
url = git@github.com:benkyd/Yolo

View File

@@ -1,7 +1,6 @@
#include "Aeon.hpp" #include "Aeon.hpp"
#include <Aeon/Includes.hpp> #include <Aeon/Includes.hpp>
#include <Aeon/Rendering/ImGui.hpp> #include <Aeon/Rendering/ImGui.hpp>
using Core::App; using Core::App;
@@ -10,85 +9,87 @@ using Core::DisplayProperties;
using Input::InputController; using Input::InputController;
App::App( const AppProperties& props, const DisplayProperties& dispProps ) App::App(const AppProperties& props, const DisplayProperties& dispProps)
: mDisplay() : mDisplay(), mInput(InputController::GetInstance()), mEntityRegistry()
, mInput(InputController::GetInstance())
, mEntityController( )
{ {
PushThisAsSink( "ENGINE_DISPLAY_CORE" ); PushThisAsSink("ENGINE_DISPLAY_CORE");
mDisplay.Create( dispProps ); mDisplay.Create(dispProps);
} }
void App::Run() void App::Run()
{ {
while ( !mSIGTERM ) while (!mSIGTERM)
{ {
// Should do this ONLY on update (but needs to be on main thread) // Should do this ONLY on update (but needs to be on main thread)
mInput.PollInput(); mInput.PollInput();
// tick through game layers // tick through game layers
for ( const auto& layer : mGameLayers ) for (const auto& layer : mGameLayers)
{ {
layer->FrameTick(); layer->FrameTick();
} }
for ( const auto& layer : mTopLayers ) for (const auto& layer : mTopLayers)
{ {
layer->FrameTick(); layer->FrameTick();
} }
for ( const auto& layer : mDebugLayers ) for (const auto& layer : mDebugLayers)
{ {
layer->FrameTick(); layer->FrameTick();
} }
// tick through game layers *but timed* // tick through game layers *but timed*
// TODO: Timed event thread (won't allow rendering) // TODO: Timed event thread (won't allow rendering)
for ( const auto& layer : mGameLayers ) for (const auto& layer : mGameLayers)
{ {
layer->TimeTick(); layer->TimeTick();
} }
for ( const auto& layer : mTopLayers ) for (const auto& layer : mTopLayers)
{ {
layer->TimeTick(); layer->TimeTick();
} }
for ( const auto& layer : mDebugLayers ) for (const auto& layer : mDebugLayers)
{ {
layer->TimeTick(); layer->TimeTick();
} }
mDisplay.EndFrame(); mDisplay.EndFrame();
} }
mDisplay.Destroy(); mDisplay.Destroy();
} }
const Display& App::GetDisplay() const Display& App::GetDisplay()
{ {
return mDisplay; return mDisplay;
} }
void App::PushLayer( GameLayer* layer ) EC::Registry& App::GetEntityRegistry()
{ {
mGameLayers.push_back( layer ); return mEntityRegistry;
} }
void App::PushTopLayer( GameLayer* layer ) void App::PushLayer(GameLayer* layer)
{ {
mTopLayers.push_back( layer ); mGameLayers.push_back(layer);
} }
void App::PushDebugLayer( GameLayer* layer ) void App::PushTopLayer(GameLayer* layer)
{ {
mDebugLayers.push_back( layer ); mTopLayers.push_back(layer);
} }
void App::PushDebugLayer(GameLayer* layer)
bool App::EventRecieved( GenericEvent& e )
{ {
if ( e.Type == "DISPLAY_CLOSED" ) mDebugLayers.push_back(layer);
{ }
mSIGTERM = true;
} bool App::EventRecieved(GenericEvent& e)
{
return false; if (e.Type == "DISPLAY_CLOSED")
{
mSIGTERM = true;
}
return false;
} }

View File

@@ -26,7 +26,7 @@ public:
void Run(); void Run();
const Display& GetDisplay(); const Display& GetDisplay();
const EC:: EC::Registry& GetEntityRegistry();
// Layers, once assigned, until poped are assumed to // Layers, once assigned, until poped are assumed to
// never change their spot in the layer hierarchy // never change their spot in the layer hierarchy
@@ -44,7 +44,7 @@ public:
private: private:
Display mDisplay; Display mDisplay;
EC::registry mEntityRegistry; EC::Registry mEntityRegistry;
Input::InputController& mInput; Input::InputController& mInput;
// Game layers from z order // Game layers from z order

0
Aeon/Assets.cpp Normal file
View File

0
Aeon/Assets.hpp Normal file
View File

View File

@@ -1,6 +1,8 @@
#ifndef AEON_CORE_ENGINECONFIG_H_ #ifndef AEON_CORE_ENGINECONFIG_H_
#define AEON_CORE_ENGINECONFIG_H_ #define AEON_CORE_ENGINECONFIG_H_
#include <Aeon/Includes.hpp>
namespace Core namespace Core
{ {

View File

@@ -0,0 +1,16 @@
#ifndef AEON_ENTITY_CORECOMPONENTS_MESH_H_
#define AEON_ENTITY_CORECOMPONENTS_MESH_H_
#include <Aeon/Rendering/Material.hpp>
namespace EC
{
struct Material
{
MaterialHandle Handle;
};
} // namespace EC
#endif

View File

@@ -0,0 +1,16 @@
#ifndef AEON_ENTITY_CORECOMPONENTS_MESH_H_
#define AEON_ENTITY_CORECOMPONENTS_MESH_H_
#include <Aeon/Rendering/Mesh.hpp>
namespace EC
{
struct Mesh
{
MeshHandle Handle;
};
} // namespace EC
#endif

View File

@@ -9,15 +9,15 @@ namespace EC
struct Transform struct Transform
{ {
Transform(glm::vec3 position) : position(position) Transform(glm::vec3 position) : Position(position)
{ {
} }
glm::vec3 position; glm::vec3 Position;
glm::quat rotation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f); glm::quat Rotation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f);
float scale = 1.0f; float Scale = 1.0f;
glm::mat4 model; glm::mat4 Model;
}; };
} // namespace EC } // namespace EC

View File

@@ -1,6 +1,8 @@
#ifndef AEON_ENTITY_ENTITY_H_ #ifndef AEON_ENTITY_ENTITY_H_
#define AEON_ENTITY_ENTITY_H_ #define AEON_ENTITY_ENTITY_H_
#include <Aeon/Entity/CoreComponents/Material.hpp>
#include <Aeon/Entity/CoreComponents/Mesh.hpp>
#include <Aeon/Entity/CoreComponents/Transform.hpp> #include <Aeon/Entity/CoreComponents/Transform.hpp>
#include <entt/entity/registry.hpp> #include <entt/entity/registry.hpp>
#include <entt/entt.hpp> #include <entt/entt.hpp>
@@ -14,13 +16,9 @@ using Handle = entt::handle;
template <typename... Components> template <typename... Components>
using View = entt::basic_view<entt::entity, entt::exclude_t<>, 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; using Dispatcher = entt::dispatcher;
static constexpr auto null = entt::null; static constexpr auto null = entt::null;
} // namespace EC } // namespace EC
#endif #endif

View File

@@ -1,42 +1,43 @@
#ifndef AEON_INPUT_INPUT_H_ #ifndef AEON_INPUT_INPUT_H_
#define AEON_INPUT_INPUT_H_ #define AEON_INPUT_INPUT_H_
#include <Aeon/Includes.hpp>
#include <Aeon/Singleton.hpp>
#include <Aeon/Core/Events.hpp> #include <Aeon/Core/Events.hpp>
#include <Aeon/Includes.hpp>
#include <Aeon/Singleton.hpp>
namespace Input namespace Input
{ {
// confusing name, not part of the ecs
// could be tho
class InputController : public Helpers::Singleton<InputController> class InputController : public Helpers::Singleton<InputController>
{ {
public: public:
InputController(); InputController();
~InputController(); ~InputController();
void PollInput(); void PollInput();
private: private:
void mPollDisplay(); void mPollDisplay();
void mPollMouse(); void mPollMouse();
void mPollScroll(); void mPollScroll();
void mPollClick(); void mPollClick();
void mPollKeyboard(); void mPollKeyboard();
void mPollScanKeyboard(); void mPollScanKeyboard();
private: private:
SDL_Event mEvent; SDL_Event mEvent;
int mNumScancodes = 242; int mNumScancodes = 242;
const uint8_t* mKbdState; const uint8_t* mKbdState;
uint16_t mModKeyState = 0x0; uint16_t mModKeyState = 0x0;
Core::EventDispatcher mDisplayEventDispatcher; Core::EventDispatcher mDisplayEventDispatcher;
Core::EventDispatcher mKeyboardEventDispatcher; Core::EventDispatcher mKeyboardEventDispatcher;
Core::EventDispatcher mMouseEventDispatcher; Core::EventDispatcher mMouseEventDispatcher;
}; };
} } // namespace Input
#endif #endif

View File

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

View File

@@ -0,0 +1,4 @@
#ifndef AEON_RENDERING_MESH_H_
#define AEON_RENDERING_MESH_H_
#endif

1
Aeon/ThirdParty/Yolo vendored Submodule

Submodule Aeon/ThirdParty/Yolo added at 8ea86d52d2

1
Aeon/ThirdParty/assimp vendored Submodule

Submodule Aeon/ThirdParty/assimp added at b447485c06

View File

@@ -15,6 +15,8 @@ set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
add_subdirectory("Aeon/ThirdParty/assimp")
# Adds RESOURCES constant in C++ # Adds RESOURCES constant in C++
add_definitions(-DRESOURCES="${CMAKE_SOURCE_DIR}/resources/") add_definitions(-DRESOURCES="${CMAKE_SOURCE_DIR}/resources/")
message(${CMAKE_SOURCE_DIR}/resources) message(${CMAKE_SOURCE_DIR}/resources)
@@ -45,12 +47,14 @@ include_directories(${Aeon}
"Aeon/ThirdParty/" "Aeon/ThirdParty/"
"Aeon/ThirdParty/glm/" "Aeon/ThirdParty/glm/"
"Aeon/ThirdParty/entt/src/" "Aeon/ThirdParty/entt/src/"
"Aeon/ThirdParty/assimp/"
"Aeon/ThirdParty/yolo/"
${WinSDK} ${WinSDK}
${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}
) )
add_executable(${Aeon} add_executable(${Aeon}
${EngineSource} ${EngineSource}
${GameSource} ${GameSource}
) )
@@ -59,4 +63,5 @@ target_link_libraries(${Aeon}
${SDL2_LIBRARIES} ${SDL2_LIBRARIES}
Threads::Threads Threads::Threads
OpenGL::GL OpenGL::GL
assimp
) )

View File

@@ -76,16 +76,17 @@ public:
ExampleGame() ExampleGame()
: App({"Example"}, {"Game with AEON!"}) : App({"Example"}, {"Game with AEON!"})
{ {
const auto entity = this->mEntityRegistry.create(); const auto entity = GetEntityRegistry().create();
entity.emplace<EC::Transform>(); GetEntityRegistry().emplace<EC::Transform>(entity, EC::Transform({0.0f, 0.0f, 0.0f}));
Level* level = new Level; Level* level = new Level;
PushLayer((Core::GameLayer*)level); PushLayer((Core::GameLayer*)level);
PushDebugLayer(&debug);
DebugLayer debug; DebugLayer debug;
PushDebugLayer(&debug);
Run(); Run();
delete level;
} }
~ExampleGame() ~ExampleGame()