diff --git a/.cache/clangd/index/Aeon.cpp.486F3A6DD69928F6.idx b/.cache/clangd/index/Aeon.cpp.486F3A6DD69928F6.idx new file mode 100644 index 0000000..cb706ef Binary files /dev/null and b/.cache/clangd/index/Aeon.cpp.486F3A6DD69928F6.idx differ diff --git a/.cache/clangd/index/Aeon.hpp.A53F5D75FC880F09.idx b/.cache/clangd/index/Aeon.hpp.A53F5D75FC880F09.idx new file mode 100644 index 0000000..91d318a Binary files /dev/null and b/.cache/clangd/index/Aeon.hpp.A53F5D75FC880F09.idx differ diff --git a/.cache/clangd/index/Assert.hpp.FCC5E01277F7C7CE.idx b/.cache/clangd/index/Assert.hpp.FCC5E01277F7C7CE.idx new file mode 100644 index 0000000..486ed36 Binary files /dev/null and b/.cache/clangd/index/Assert.hpp.FCC5E01277F7C7CE.idx differ diff --git a/.cache/clangd/index/ComponentController.hpp.97C5D5015D936EAC.idx b/.cache/clangd/index/ComponentController.hpp.97C5D5015D936EAC.idx new file mode 100644 index 0000000..7178ced Binary files /dev/null and b/.cache/clangd/index/ComponentController.hpp.97C5D5015D936EAC.idx differ diff --git a/.cache/clangd/index/Display.cpp.D92635EEBD4AE5E7.idx b/.cache/clangd/index/Display.cpp.D92635EEBD4AE5E7.idx new file mode 100644 index 0000000..cab95d2 Binary files /dev/null and b/.cache/clangd/index/Display.cpp.D92635EEBD4AE5E7.idx differ diff --git a/.cache/clangd/index/Display.hpp.1F2BECCAA6FFFC93.idx b/.cache/clangd/index/Display.hpp.1F2BECCAA6FFFC93.idx new file mode 100644 index 0000000..1a0d251 Binary files /dev/null and b/.cache/clangd/index/Display.hpp.1F2BECCAA6FFFC93.idx differ diff --git a/.cache/clangd/index/EngineConfig.hpp.0EF2CD8B81B5CBC3.idx b/.cache/clangd/index/EngineConfig.hpp.0EF2CD8B81B5CBC3.idx new file mode 100644 index 0000000..83b51f5 Binary files /dev/null and b/.cache/clangd/index/EngineConfig.hpp.0EF2CD8B81B5CBC3.idx differ diff --git a/.cache/clangd/index/Entity.hpp.755C0D6DF9F32090.idx b/.cache/clangd/index/Entity.hpp.755C0D6DF9F32090.idx new file mode 100644 index 0000000..43e6d18 Binary files /dev/null and b/.cache/clangd/index/Entity.hpp.755C0D6DF9F32090.idx differ diff --git a/.cache/clangd/index/EntityController.cpp.15C613A4666FA9E9.idx b/.cache/clangd/index/EntityController.cpp.15C613A4666FA9E9.idx new file mode 100644 index 0000000..d4a7f37 Binary files /dev/null and b/.cache/clangd/index/EntityController.cpp.15C613A4666FA9E9.idx differ diff --git a/.cache/clangd/index/EntityController.hpp.A05C5AA2D5FDD335.idx b/.cache/clangd/index/EntityController.hpp.A05C5AA2D5FDD335.idx new file mode 100644 index 0000000..5f21da7 Binary files /dev/null and b/.cache/clangd/index/EntityController.hpp.A05C5AA2D5FDD335.idx differ diff --git a/.cache/clangd/index/Events.cpp.B4EE623917FA0DA2.idx b/.cache/clangd/index/Events.cpp.B4EE623917FA0DA2.idx new file mode 100644 index 0000000..7f82dd6 Binary files /dev/null and b/.cache/clangd/index/Events.cpp.B4EE623917FA0DA2.idx differ diff --git a/.cache/clangd/index/Events.hpp.A496277A6267D622.idx b/.cache/clangd/index/Events.hpp.A496277A6267D622.idx new file mode 100644 index 0000000..87d8b06 Binary files /dev/null and b/.cache/clangd/index/Events.hpp.A496277A6267D622.idx differ diff --git a/.cache/clangd/index/ExampleGame.cpp.9EC42D6E840C2507.idx b/.cache/clangd/index/ExampleGame.cpp.9EC42D6E840C2507.idx new file mode 100644 index 0000000..6eac052 Binary files /dev/null and b/.cache/clangd/index/ExampleGame.cpp.9EC42D6E840C2507.idx differ diff --git a/.cache/clangd/index/GameLayer.hpp.2FD71740EFD654A2.idx b/.cache/clangd/index/GameLayer.hpp.2FD71740EFD654A2.idx new file mode 100644 index 0000000..4302a26 Binary files /dev/null and b/.cache/clangd/index/GameLayer.hpp.2FD71740EFD654A2.idx differ diff --git a/.cache/clangd/index/ImGui.hpp.D9F0B3635FB5E102.idx b/.cache/clangd/index/ImGui.hpp.D9F0B3635FB5E102.idx new file mode 100644 index 0000000..25eccc0 Binary files /dev/null and b/.cache/clangd/index/ImGui.hpp.D9F0B3635FB5E102.idx differ diff --git a/.cache/clangd/index/Includes.hpp.F54D408F8139EA1E.idx b/.cache/clangd/index/Includes.hpp.F54D408F8139EA1E.idx new file mode 100644 index 0000000..34af2ed Binary files /dev/null and b/.cache/clangd/index/Includes.hpp.F54D408F8139EA1E.idx differ diff --git a/.cache/clangd/index/Input.cpp.43A863BDFFD32619.idx b/.cache/clangd/index/Input.cpp.43A863BDFFD32619.idx new file mode 100644 index 0000000..b1cedce Binary files /dev/null and b/.cache/clangd/index/Input.cpp.43A863BDFFD32619.idx differ diff --git a/.cache/clangd/index/Input.hpp.7A0BE460434DCB6B.idx b/.cache/clangd/index/Input.hpp.7A0BE460434DCB6B.idx new file mode 100644 index 0000000..9f85a4e Binary files /dev/null and b/.cache/clangd/index/Input.hpp.7A0BE460434DCB6B.idx differ diff --git a/.cache/clangd/index/InputMap.hpp.B92A15D4271A456C.idx b/.cache/clangd/index/InputMap.hpp.B92A15D4271A456C.idx new file mode 100644 index 0000000..9f5fa1e Binary files /dev/null and b/.cache/clangd/index/InputMap.hpp.B92A15D4271A456C.idx differ diff --git a/.cache/clangd/index/RenderMaster.cpp.FB2469C012B524DF.idx b/.cache/clangd/index/RenderMaster.cpp.FB2469C012B524DF.idx new file mode 100644 index 0000000..cafd4d9 Binary files /dev/null and b/.cache/clangd/index/RenderMaster.cpp.FB2469C012B524DF.idx differ diff --git a/.cache/clangd/index/RenderMaster.hpp.EDA52D09ADFC44AE.idx b/.cache/clangd/index/RenderMaster.hpp.EDA52D09ADFC44AE.idx new file mode 100644 index 0000000..c69c9ff Binary files /dev/null and b/.cache/clangd/index/RenderMaster.hpp.EDA52D09ADFC44AE.idx differ diff --git a/.cache/clangd/index/Singleton.hpp.29617A099D8E65EE.idx b/.cache/clangd/index/Singleton.hpp.29617A099D8E65EE.idx new file mode 100644 index 0000000..7960a09 Binary files /dev/null and b/.cache/clangd/index/Singleton.hpp.29617A099D8E65EE.idx differ diff --git a/.cache/clangd/index/glad.c.30975A047DE69F0C.idx b/.cache/clangd/index/glad.c.30975A047DE69F0C.idx new file mode 100644 index 0000000..303d99f Binary files /dev/null and b/.cache/clangd/index/glad.c.30975A047DE69F0C.idx differ diff --git a/.cache/clangd/index/glad.h.29D3E4FE97705D53.idx b/.cache/clangd/index/glad.h.29D3E4FE97705D53.idx new file mode 100644 index 0000000..a82c2e8 Binary files /dev/null and b/.cache/clangd/index/glad.h.29D3E4FE97705D53.idx differ diff --git a/.cache/clangd/index/imconfig.h.BC4D5FD8D2B2E2D9.idx b/.cache/clangd/index/imconfig.h.BC4D5FD8D2B2E2D9.idx new file mode 100644 index 0000000..9016683 Binary files /dev/null and b/.cache/clangd/index/imconfig.h.BC4D5FD8D2B2E2D9.idx differ diff --git a/.cache/clangd/index/imgui.cpp.22D74525CBA383BF.idx b/.cache/clangd/index/imgui.cpp.22D74525CBA383BF.idx new file mode 100644 index 0000000..bd81fbb Binary files /dev/null and b/.cache/clangd/index/imgui.cpp.22D74525CBA383BF.idx differ diff --git a/.cache/clangd/index/imgui.h.C72F17EDCE96FECB.idx b/.cache/clangd/index/imgui.h.C72F17EDCE96FECB.idx new file mode 100644 index 0000000..d9df451 Binary files /dev/null and b/.cache/clangd/index/imgui.h.C72F17EDCE96FECB.idx differ diff --git a/.cache/clangd/index/imgui_draw.cpp.568E5346954DA987.idx b/.cache/clangd/index/imgui_draw.cpp.568E5346954DA987.idx new file mode 100644 index 0000000..520639b Binary files /dev/null and b/.cache/clangd/index/imgui_draw.cpp.568E5346954DA987.idx differ diff --git a/.cache/clangd/index/imgui_impl_opengl2.cpp.B53B0289258249D9.idx b/.cache/clangd/index/imgui_impl_opengl2.cpp.B53B0289258249D9.idx new file mode 100644 index 0000000..00a06b7 Binary files /dev/null and b/.cache/clangd/index/imgui_impl_opengl2.cpp.B53B0289258249D9.idx differ diff --git a/.cache/clangd/index/imgui_impl_opengl2.h.760F23D44B19BEFF.idx b/.cache/clangd/index/imgui_impl_opengl2.h.760F23D44B19BEFF.idx new file mode 100644 index 0000000..960b942 Binary files /dev/null and b/.cache/clangd/index/imgui_impl_opengl2.h.760F23D44B19BEFF.idx differ diff --git a/.cache/clangd/index/imgui_impl_opengl3.cpp.2E5BE08BD904302C.idx b/.cache/clangd/index/imgui_impl_opengl3.cpp.2E5BE08BD904302C.idx new file mode 100644 index 0000000..959a04a Binary files /dev/null and b/.cache/clangd/index/imgui_impl_opengl3.cpp.2E5BE08BD904302C.idx differ diff --git a/.cache/clangd/index/imgui_impl_opengl3.h.721114A74EDC0BBC.idx b/.cache/clangd/index/imgui_impl_opengl3.h.721114A74EDC0BBC.idx new file mode 100644 index 0000000..0aa34fd Binary files /dev/null and b/.cache/clangd/index/imgui_impl_opengl3.h.721114A74EDC0BBC.idx differ diff --git a/.cache/clangd/index/imgui_impl_opengl3_loader.h.705CD6EED01BB796.idx b/.cache/clangd/index/imgui_impl_opengl3_loader.h.705CD6EED01BB796.idx new file mode 100644 index 0000000..742a94a Binary files /dev/null and b/.cache/clangd/index/imgui_impl_opengl3_loader.h.705CD6EED01BB796.idx differ diff --git a/.cache/clangd/index/imgui_impl_sdl.cpp.E3965EBA77FC9AB6.idx b/.cache/clangd/index/imgui_impl_sdl.cpp.E3965EBA77FC9AB6.idx new file mode 100644 index 0000000..81e6cc9 Binary files /dev/null and b/.cache/clangd/index/imgui_impl_sdl.cpp.E3965EBA77FC9AB6.idx differ diff --git a/.cache/clangd/index/imgui_impl_sdl.h.16F60CF22B0116EC.idx b/.cache/clangd/index/imgui_impl_sdl.h.16F60CF22B0116EC.idx new file mode 100644 index 0000000..582f3aa Binary files /dev/null and b/.cache/clangd/index/imgui_impl_sdl.h.16F60CF22B0116EC.idx differ diff --git a/.cache/clangd/index/imgui_internal.h.CE27FB5EA6D68FF8.idx b/.cache/clangd/index/imgui_internal.h.CE27FB5EA6D68FF8.idx new file mode 100644 index 0000000..ab0f3fb Binary files /dev/null and b/.cache/clangd/index/imgui_internal.h.CE27FB5EA6D68FF8.idx differ diff --git a/.cache/clangd/index/imgui_tables.cpp.7D674032578A9ACB.idx b/.cache/clangd/index/imgui_tables.cpp.7D674032578A9ACB.idx new file mode 100644 index 0000000..5a99e35 Binary files /dev/null and b/.cache/clangd/index/imgui_tables.cpp.7D674032578A9ACB.idx differ diff --git a/.cache/clangd/index/imgui_widgets.cpp.E3D2B0926EFE068D.idx b/.cache/clangd/index/imgui_widgets.cpp.E3D2B0926EFE068D.idx new file mode 100644 index 0000000..737552d Binary files /dev/null and b/.cache/clangd/index/imgui_widgets.cpp.E3D2B0926EFE068D.idx differ diff --git a/.cache/clangd/index/imstb_rectpack.h.54D9710AEC75A87D.idx b/.cache/clangd/index/imstb_rectpack.h.54D9710AEC75A87D.idx new file mode 100644 index 0000000..ffafbf1 Binary files /dev/null and b/.cache/clangd/index/imstb_rectpack.h.54D9710AEC75A87D.idx differ diff --git a/.cache/clangd/index/imstb_textedit.h.0234A9C40BC83F97.idx b/.cache/clangd/index/imstb_textedit.h.0234A9C40BC83F97.idx new file mode 100644 index 0000000..264fe25 Binary files /dev/null and b/.cache/clangd/index/imstb_textedit.h.0234A9C40BC83F97.idx differ diff --git a/.cache/clangd/index/imstb_truetype.h.BA0779D8E5C26FB2.idx b/.cache/clangd/index/imstb_truetype.h.BA0779D8E5C26FB2.idx new file mode 100644 index 0000000..12f6ba2 Binary files /dev/null and b/.cache/clangd/index/imstb_truetype.h.BA0779D8E5C26FB2.idx differ diff --git a/.cache/clangd/index/khrplatform.h.50BCDE84CFA5D07D.idx b/.cache/clangd/index/khrplatform.h.50BCDE84CFA5D07D.idx new file mode 100644 index 0000000..dfb8cd4 Binary files /dev/null and b/.cache/clangd/index/khrplatform.h.50BCDE84CFA5D07D.idx differ diff --git a/Aeon/Core/Display.cpp b/Aeon/Core/Display.cpp index 5264e67..0754185 100644 --- a/Aeon/Core/Display.cpp +++ b/Aeon/Core/Display.cpp @@ -1,143 +1,139 @@ #include "Display.hpp" -#include - #include -#include +#include #include using Core::Display; Display::Display() - : mWindow( nullptr ) - , mContext( NULL ) - , mRenderer( Rendering::RenderMaster::GetInstance() ) - , mClearColour{ 1.0f, 1.0f, 1.0f, 1.0f } + : mWindow(nullptr), mContext(NULL), mClearColour {1.0f, 1.0f, 1.0f, 1.0f} { - PushThisAsSink( "ENGINE_DISPLAY_CORE" ); + PushThisAsSink("ENGINE_DISPLAY_CORE"); } Display::~Display() { - } -bool Display::Create( const DisplayProperties& properties ) +bool Display::Create(const DisplayProperties& properties) { - SDL_Init( SDL_INIT_VIDEO ); + SDL_Init(SDL_INIT_VIDEO); - SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 32 ); - SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); - SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 ); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); - SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 ); - SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 5 ); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 5); - mWindow = SDL_CreateWindow( properties.Name.c_str(), - SDL_WINDOWPOS_CENTERED, - SDL_WINDOWPOS_CENTERED, properties.Width, properties.Height, - SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE ); + mWindow = SDL_CreateWindow(properties.Name.c_str(), + SDL_WINDOWPOS_CENTERED, + SDL_WINDOWPOS_CENTERED, + properties.Width, + properties.Height, + SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); - AEON_ASSERT( mWindow, "Can't initialise window" ); + AEON_ASSERT(mWindow, "Can't initialise window"); - mContext = SDL_GL_CreateContext( mWindow ); + mContext = SDL_GL_CreateContext(mWindow); - AEON_ASSERT( mContext, "Can't initialise context" ); + AEON_ASSERT(mContext, "Can't initialise context"); - SDL_GL_SetSwapInterval( static_cast(!properties.VSync) ); + SDL_GL_SetSwapInterval(static_cast(!properties.VSync)); - gladLoadGLLoader( SDL_GL_GetProcAddress ); - glEnable( GL_MULTISAMPLE ); - glCullFace( GL_BACK ); - glEnable( GL_DEPTH_TEST ); + gladLoadGLLoader(SDL_GL_GetProcAddress); + glEnable(GL_MULTISAMPLE); + glCullFace(GL_BACK); + glEnable(GL_DEPTH_TEST); - mWidth = properties.Width; - mHeight = properties.Height; + mWidth = properties.Width; + mHeight = properties.Height; - Rendering::SetupImGui( mWindow, mContext ); + Rendering::SetupImGui(mWindow, mContext); - // Make sure ImGUI is ready to be used on the first frame - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplSDL2_NewFrame(); - ImGui::NewFrame(); + // Make sure ImGUI is ready to be used on the first frame + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplSDL2_NewFrame(); + ImGui::NewFrame(); - return true; + return true; } const unsigned int Display::GetWidth() { - return mWidth; + return mWidth; } const unsigned int Display::GetHeight() { - return mHeight; + return mHeight; } const SDL_Window* Display::GetWindow() { - return mWindow; + return mWindow; } const SDL_GLContext& Display::GetContext() { - return mContext; + return mContext; } -void Display::SetClearColour( float r, float g, float b, float a ) +void Display::SetClearColour(float r, float g, float b, float a) { - mClearColour[0] = r * a; - mClearColour[1] = g * a; - mClearColour[2] = b * a; - mClearColour[3] = a; + mClearColour[0] = r * a; + mClearColour[1] = g * a; + mClearColour[2] = b * a; + mClearColour[3] = a; } void Display::EndFrame() { - ImGui::Render(); - ImGui_ImplOpenGL3_RenderDrawData( ImGui::GetDrawData() ); - - SDL_GL_SwapWindow( mWindow ); - - glClearColor( mClearColour[0], mClearColour[1], mClearColour[2], mClearColour[3] ); - glClear( GL_COLOR_BUFFER_BIT ); + ImGui::Render(); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplSDL2_NewFrame(); - ImGui::NewFrame(); + SDL_GL_SwapWindow(mWindow); + + glClearColor(mClearColour[0], mClearColour[1], mClearColour[2], mClearColour[3]); + glClear(GL_COLOR_BUFFER_BIT); + + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplSDL2_NewFrame(); + ImGui::NewFrame(); } void Display::Destroy() { - Rendering::CleanupImGui(); - SDL_DestroyWindow( mWindow ); - // dangly balls - mWindow = nullptr; - mWidth = 0; - mHeight = 0; + Rendering::CleanupImGui(); + SDL_DestroyWindow(mWindow); + // dangly balls + mWindow = nullptr; + mWidth = 0; + mHeight = 0; } -bool Display::EventRecieved( GenericEvent& e ) +bool Display::EventRecieved(GenericEvent& e) { - if ( e.Type == "DISPLAY_RESIZE" ) - { - mWidth = e.x; - mHeight = e.y; - return true; - } + if (e.Type == "DISPLAY_RESIZE") + { + mWidth = e.x; + mHeight = e.y; + return true; + } - if ( e.Type == "DISPLAY_MOVE" ) - { - mX = e.x; - mY = e.y; - return true; - } + if (e.Type == "DISPLAY_MOVE") + { + mX = e.x; + mY = e.y; + return true; + } - return false; + return false; } diff --git a/Aeon/Core/Display.hpp b/Aeon/Core/Display.hpp index f2183dd..a420ff1 100644 --- a/Aeon/Core/Display.hpp +++ b/Aeon/Core/Display.hpp @@ -37,8 +37,6 @@ private: SDL_Window* mWindow; SDL_GLContext mContext; - RenderMaster& mRenderer; - unsigned int mWidth, mHeight = 0; unsigned int mX, mY = 0; float mClearColour[4]; diff --git a/Aeon/Core/Events.cpp b/Aeon/Core/Events.cpp index b556970..eb935e4 100644 --- a/Aeon/Core/Events.cpp +++ b/Aeon/Core/Events.cpp @@ -2,262 +2,265 @@ #include -using Core::GenericEvent; -using Core::EventListener; using Core::EventDispatcher; +using Core::EventListener; using Core::EventManager; +using Core::GenericEvent; // TODO: Events should use pre-allocated memory ALWAYS! // TODO: Look into Bump Allocation EventListener::EventListener() { - } EventListener::~EventListener() { - } -void EventListener::PushThisAsSink( std::string system ) +void EventListener::PushThisAsSink(std::string system) { - mListenerID = EventManager::GetInstance().RegisterSinkPush( this, system ); - AEON_ASSERT( mListenerID != -1, "Cannot register event sink" ); + mListenerID = EventManager::GetInstance().RegisterSinkPush(this, system); + AEON_ASSERT(mListenerID != -1, "Cannot register event sink"); } -void EventListener::PushAndStickThisAsSink( std::string system ) +void EventListener::PushAndStickThisAsSink(std::string system) { - mListenerID = EventManager::GetInstance().RegisterSinkPushStick( this, system ); - AEON_ASSERT( mListenerID != -1, "Cannot register event sink" ); + mListenerID = EventManager::GetInstance().RegisterSinkPushStick(this, system); + AEON_ASSERT(mListenerID != -1, "Cannot register event sink"); } -void EventListener::UnshiftThisAsSink( std::string system ) +void EventListener::UnshiftThisAsSink(std::string system) { - mListenerID = EventManager::GetInstance().RegisterSinkUnshift( this, system ); - AEON_ASSERT( mListenerID != -1, "Cannot register event sink" ); + mListenerID = EventManager::GetInstance().RegisterSinkUnshift(this, system); + AEON_ASSERT(mListenerID != -1, "Cannot register event sink"); } -void EventListener::ShiftSinkLeft( std::string forSystem ) +void EventListener::ShiftSinkLeft(std::string forSystem) { - EventManager::GetInstance().MoveSinkLeft( this, forSystem ); + EventManager::GetInstance().MoveSinkLeft(this, forSystem); } -void EventListener::ShiftSinkRight( std::string forSystem ) +void EventListener::ShiftSinkRight(std::string forSystem) { - EventManager::GetInstance().MoveSinkRight( this, forSystem ); + EventManager::GetInstance().MoveSinkRight(this, forSystem); } -void EventListener::DeRegisterAsSink( std::string system ) +void EventListener::DeRegisterAsSink(std::string system) { - } - - EventDispatcher::EventDispatcher() { - } -EventDispatcher::EventDispatcher( std::string system ) +EventDispatcher::EventDispatcher(std::string system) { - RegisterAsSource( system ); + RegisterAsSource(system); } EventDispatcher::~EventDispatcher() { - } -void EventDispatcher::RegisterAsSource( std::string system ) +void EventDispatcher::RegisterAsSource(std::string system) { - mDispatcherID = EventManager::GetInstance().RegisterSource( this, system ); - AEON_ASSERT( mDispatcherID != -1, "Cannot register event source" ); - mSystem = system; + mDispatcherID = EventManager::GetInstance().RegisterSource(this, system); + AEON_ASSERT(mDispatcherID != -1, "Cannot register event source"); + mSystem = system; } -void EventDispatcher::DeRegisterAsSource( std::string system ) +void EventDispatcher::DeRegisterAsSource(std::string system) { - } -void EventDispatcher::Dispatch( GenericEvent e ) +void EventDispatcher::Dispatch(GenericEvent e) { - e.System = mSystem; - EventManager::GetInstance().Dispatch( mDispatcherID, e ); + e.System = mSystem; + EventManager::GetInstance().Dispatch(mDispatcherID, e); } -void EventDispatcher::Dispatch( std::string type ) +void EventDispatcher::Dispatch(std::string type) { - GenericEvent e; - e.Type = type; - e.System = mSystem; - EventManager::GetInstance().Dispatch( mDispatcherID, e ); + GenericEvent e; + e.Type = type; + e.System = mSystem; + EventManager::GetInstance().Dispatch(mDispatcherID, e); } - EventManager::EventManager() { - } EventManager::~EventManager() { - } -int EventManager::RegisterSource( EventDispatcher* source, std::string system ) +int EventManager::RegisterSource(EventDispatcher* source, std::string system) { - int id = mNextHeighest; - mSources[id] = system; - mNextHeighest++; - return id; + int id = mNextHeighest; + mSources[id] = system; + mNextHeighest++; + return id; } -int EventManager::RegisterSinkPush( EventListener* sink, std::string system ) +int EventManager::RegisterSinkPush(EventListener* sink, std::string system) { - int id = mNextHeighest; - mListeners[id] = sink; + int id = mNextHeighest; + mListeners[id] = sink; - auto& sinkVector = mSinks[system]; - sinkVector.push_back( { sink, id } ); + auto& sinkVector = mSinks[system]; + sinkVector.push_back({sink, id}); - mNextHeighest++; - return id; + mNextHeighest++; + return id; } -int EventManager::RegisterSinkPushStick( EventListener* sink, std::string system ) +int EventManager::RegisterSinkPushStick(EventListener* sink, std::string system) { - int id = mNextHeighest; - mListeners[id] = sink; + int id = mNextHeighest; + mListeners[id] = sink; - auto& sinkVector = mStickySinks[system]; - sinkVector.push_back( { sink, id } ); + auto& sinkVector = mStickySinks[system]; + sinkVector.push_back({sink, id}); - mNextHeighest++; - return id; + mNextHeighest++; + return id; } -int EventManager::RegisterSinkUnshift( EventListener* sink, std::string system ) +int EventManager::RegisterSinkUnshift(EventListener* sink, std::string system) { - int id = mNextHeighest; - mListeners[id] = sink; + int id = mNextHeighest; + mListeners[id] = sink; - if ( !mSinks.count( system ) ) - { - return RegisterSinkPush( sink, system ); - } + if (!mSinks.count(system)) + { + return RegisterSinkPush(sink, system); + } - auto& sinkVector = mSinks[system]; - sinkVector.insert( sinkVector.begin(), { sink, id } ); + auto& sinkVector = mSinks[system]; + sinkVector.insert(sinkVector.begin(), {sink, id}); - mNextHeighest++; - return id; + mNextHeighest++; + return id; } -void EventManager::MoveSinkLeft( EventListener* sink, std::string system ) +void EventManager::MoveSinkLeft(EventListener* sink, std::string system) { - } -void EventManager::MoveSinkRight( EventListener* sink, std::string system ) +void EventManager::MoveSinkRight(EventListener* sink, std::string system) { - } -void EventManager::RemoveSource( int dispatcherID, std::string system ) +void EventManager::RemoveSource(int dispatcherID, std::string system) { - } -void EventManager::RemoveSink( int listenerID, std::string system ) +void EventManager::RemoveSink(int listenerID, std::string system) { - } - // it is important to reverse the lists so that the dispatching is done correctly // this is more efficiently done at insert... lol template -struct reverse_wrapper { +struct reverse_wrapper +{ - C& c_; - reverse_wrapper(C& c) : c_(c) {} + C& c_; + reverse_wrapper(C& c) : c_(c) + {} - typename C::reverse_iterator begin() { return c_.rbegin(); } - typename C::reverse_iterator end() { return c_.rend(); } + typename C::reverse_iterator begin() + { + return c_.rbegin(); + } + typename C::reverse_iterator end() + { + return c_.rend(); + } }; template -struct reverse_wrapper< C[N] > { +struct reverse_wrapper +{ - C(&c_)[N]; - reverse_wrapper(C(&c)[N]) : c_(c) {} + C (&c_) + [N]; + reverse_wrapper(C (&c)[N]) : c_(c) + {} - typename std::reverse_iterator begin() { return std::rbegin(c_); } - typename std::reverse_iterator end() { return std::rend(c_); } + typename std::reverse_iterator begin() + { + return std::rbegin(c_); + } + typename std::reverse_iterator end() + { + return std::rend(c_); + } }; - template -reverse_wrapper r_wrap(C& c) { - return reverse_wrapper(c); +reverse_wrapper r_wrap(C& c) +{ + return reverse_wrapper(c); } -void EventManager::Dispatch( int dispatcherID, GenericEvent e ) +void EventManager::Dispatch(int dispatcherID, GenericEvent e) { - std::string targetSink = mSources[dispatcherID]; - auto stickySinks = mStickySinks[targetSink]; - auto sinks = mSinks[targetSink]; + std::string targetSink = mSources[dispatcherID]; + auto stickySinks = mStickySinks[targetSink]; + auto sinks = mSinks[targetSink]; - if ( !stickySinks.empty() ) - { - for ( auto& listenerPair : r_wrap(stickySinks)) - { - EventListener* listener = std::get<0>( listenerPair ); - bool handled = listener->EventRecieved( e ); - if ( handled ) e.Handled = handled; + if (!stickySinks.empty()) + { + for (auto& listenerPair : r_wrap(stickySinks)) + { + EventListener* listener = std::get<0>(listenerPair); + bool handled = listener->EventRecieved(e); + if (handled) + e.Handled = handled; - if ( e.Handled ) - { - // destroy event - return; - } - } - } + if (e.Handled) + { + // destroy event + return; + } + } + } - if (!sinks.empty()) - { - for (auto& listenerPair : r_wrap(sinks)) - { - EventListener* listener = std::get<0>(listenerPair); - bool handled = listener->EventRecieved(e); - if (handled) e.Handled = handled; + if (!sinks.empty()) + { + for (auto& listenerPair : r_wrap(sinks)) + { + EventListener* listener = std::get<0>(listenerPair); + bool handled = listener->EventRecieved(e); + if (handled) + e.Handled = handled; - if (e.Handled) - { - // destroy event - return; - } - } - } - + if (e.Handled) + { + // destroy event + return; + } + } + } } void EventManager::DebugPrint() { - std::cout << "----- BEGIN EVENTS DEBUG -----" << std::endl; - for (auto const& [dispatcher, targetSink] : mSources) - { - auto stickySinks = mStickySinks[targetSink]; - auto sinks = mSinks[targetSink]; + std::cout << "----- BEGIN EVENTS DEBUG -----" << std::endl; + for (auto const& [dispatcher, targetSink] : mSources) + { + auto stickySinks = mStickySinks[targetSink]; + auto sinks = mSinks[targetSink]; - int sourceCount = 0; - for (auto const& [id, source] : mSources) - if (source == targetSink) sourceCount++; + int sourceCount = 0; + for (auto const& [id, source] : mSources) + if (source == targetSink) + sourceCount++; - std::cout << targetSink << " has " << stickySinks.size() << " sticky and " << sinks.size() << " sink(s) and is being dispatched from " << sourceCount << " different source(s)" << std::endl; - } - std::cout << "----- END EVENTS DEBUG -----" << std::endl; + std::cout << targetSink << " has " << stickySinks.size() << " sticky and " << sinks.size() << " sink(s) and is being dispatched from " << sourceCount << " different source(s)" << std::endl; + } + std::cout << "----- END EVENTS DEBUG -----" << std::endl; } diff --git a/Aeon/Core/Events.hpp b/Aeon/Core/Events.hpp index 0101759..22cf73e 100644 --- a/Aeon/Core/Events.hpp +++ b/Aeon/Core/Events.hpp @@ -2,173 +2,173 @@ #define AEON_CORE_EVENTS_H_ /* - - Events have a source and a sink, where from and where too - - Event sinks are systems that events are dispatched to from - a source of the same system - - Event listeners are layered, 0 is front, larger is back so - events propogate from the front to the back, not going - further once handled - - Event sources can only dispatch events to a single system - - Systems can request to only receive events from a certain - "system" category, or multiple - - Events are blocking for now + - Events have a source and a sink, where from and where too + - Event sinks are systems that events are dispatched to from + a source of the same system + - Event listeners are layered, 0 is front, larger is back so + events propogate from the front to the back, not going + further once handled + - Event sources can only dispatch events to a single system + - Systems can request to only receive events from a certain + "system" category, or multiple + - Events are blocking for now */ #include - -#include #include +#include -namespace Core +namespace Core { // THis needs some redesigning so i can do this.AttachSpecificListener(Type, Action, [&] => {...}) // More specifically to support enumerator calling AND custom defined string calling // Maybe through a reserved enumeration map 0-100: system etc.. /* -* Engine event systems / type -* ENGINE_SYSTEM_CORE - start, stop, pause, etc -* ENGINE_START - starts game loop execution -* ENGINE_STOP -* ENGINE_PAUSE -* ENGINE_DISPLAY_CORE - window open, window close, etc -* DISPLAY_RESIZE (x, y) - rezise to x, y being new w, h -* DISPLAY_MOVE (x, y) - move to x, y -* DISPLAY_SHOW - no data -* DISPLAY_HIDE - no data -* DISPLAY_MINIMISED - no data -* DISPLAY_MAXIMISED - no data -* DISPLAY_CLOSED - no data -* DISPLAY_MOUSE_ENTER - no data -* DISPLAY_MOUSE_LEAVE - no data -* DISPLAY_FOCUS - no data -* DISPLAY_OUT_OF_FOCUS - no data -* ENGINE_INPUT_MOUSE -* MOUSE_LEFT_DOWN - no data -* MOUSE_LEFT_UP - no data -* MOUSE_RIGHT_DOWN - no data -* MOUSE_RIGHT_UP - no data -* MOUSE_MIDDLE_DOWN - no data -* MOUSE_MIDDLE_UP - no data -* MOUSE_SCROLL - y+- -* MOUSE_MOVE - move to x, y relative dx, dy -* ENGINE_INPUT_KEYBOARD -* KEYBOARD_KEYDOWN - keycode, keymod -* KEYBOARD_KEYUP - keycode, keymod -* KEYBOARD_KEYPRESS - keycode for continual pressing, keymod -*/ - + * Engine event systems / type + * ENGINE_SYSTEM_CORE - start, stop, pause, etc + * ENGINE_START - starts game loop execution + * ENGINE_STOP + * ENGINE_PAUSE + * ENGINE_DISPLAY_CORE - window open, window close, etc + * DISPLAY_RESIZE (x, y) - rezise to x, y being new w, h + * DISPLAY_MOVE (x, y) - move to x, y + * DISPLAY_SHOW - no data + * DISPLAY_HIDE - no data + * DISPLAY_MINIMISED - no data + * DISPLAY_MAXIMISED - no data + * DISPLAY_CLOSED - no data + * DISPLAY_MOUSE_ENTER - no data + * DISPLAY_MOUSE_LEAVE - no data + * DISPLAY_FOCUS - no data + * DISPLAY_OUT_OF_FOCUS - no data + * ENGINE_INPUT_MOUSE + * MOUSE_LEFT_DOWN - no data + * MOUSE_LEFT_UP - no data + * MOUSE_RIGHT_DOWN - no data + * MOUSE_RIGHT_UP - no data + * MOUSE_MIDDLE_DOWN - no data + * MOUSE_MIDDLE_UP - no data + * MOUSE_SCROLL - y+- + * MOUSE_MOVE - move to x, y relative dx, dy + * ENGINE_INPUT_KEYBOARD + * KEYBOARD_KEYDOWN - keycode, keymod + * KEYBOARD_KEYUP - keycode, keymod + * KEYBOARD_KEYPRESS - keycode for continual pressing, keymod + */ struct GenericEvent { - // always populated - std::string System; - std::string Type; - - // the rest can be empty - // user defined - std::string Data; + // always populated + std::string System; + std::string Type; - // DISPLAY_RESIZE DISPLAY_MOVE MOUSE_MOVE - int x, y; - // MOUSE_MOVE - int dx, dy; - - // KEYBOARD_KEYDOWN KEYBOARD_KEYUP KEYBOARD_PRESSED - Input::EKeyCode keyCode; - uint16_t keyMods; + // the rest can be empty + // user defined + std::string Data; - bool Handled = false; + // DISPLAY_RESIZE DISPLAY_MOVE MOUSE_MOVE + int x, y; + // MOUSE_MOVE + int dx, dy; + + // KEYBOARD_KEYDOWN KEYBOARD_KEYUP KEYBOARD_PRESSED + Input::EKeyCode keyCode; + uint16_t keyMods; + + // USER EVENTS + void* UserData = nullptr; + + bool Handled = false; }; class EventListener { public: - EventListener(); - virtual ~EventListener(); + EventListener(); + virtual ~EventListener(); - // Pushes sink to the top of the listener stack - // underneath the stuck listeners - void PushThisAsSink( std::string system ); - // Pushes sink to the top of the listener stack - // with all of the other "stuck" listeners - void PushAndStickThisAsSink( std::string system ); - // Pushes sink to the bottom of the listener stack - void UnshiftThisAsSink( std::string system ); + // Pushes sink to the top of the listener stack + // underneath the stuck listeners + void PushThisAsSink(std::string system); + // Pushes sink to the top of the listener stack + // with all of the other "stuck" listeners + void PushAndStickThisAsSink(std::string system); + // Pushes sink to the bottom of the listener stack + void UnshiftThisAsSink(std::string system); - void ShiftSinkLeft( std::string forSystem ); - void ShiftSinkRight( std::string forSystem ); + void ShiftSinkLeft(std::string forSystem); + void ShiftSinkRight(std::string forSystem); - void DeRegisterAsSink( std::string system ); + void DeRegisterAsSink(std::string system); - // return true = event handled and will not be further - // propogated - virtual bool EventRecieved( GenericEvent& e ) = 0; + // return true = event handled and will not be further + // propogated + virtual bool EventRecieved(GenericEvent& e) = 0; private: - int mListenerID = -1; + int mListenerID = -1; - friend class EventManager; + friend class EventManager; }; class EventDispatcher { public: - EventDispatcher(); - EventDispatcher( std::string system ); - ~EventDispatcher(); + EventDispatcher(); + EventDispatcher(std::string system); + ~EventDispatcher(); - void RegisterAsSource( std::string system ); - void DeRegisterAsSource( std::string system ); + void RegisterAsSource(std::string system); + void DeRegisterAsSource(std::string system); - void Dispatch( GenericEvent e ); - // no data needed, listeners act on the event happening - void Dispatch( std::string type ); + void Dispatch(GenericEvent e); + // no data needed, listeners act on the event happening + void Dispatch(std::string type); private: - std::string mSystem; - int mDispatcherID = -1; + std::string mSystem; + int mDispatcherID = -1; - friend class EventManager; + friend class EventManager; }; class EventManager : public Helpers::Singleton { public: - EventManager(); - ~EventManager(); + EventManager(); + ~EventManager(); - int RegisterSource( EventDispatcher* source, std::string system ); + int RegisterSource(EventDispatcher* source, std::string system); - int RegisterSinkPush( EventListener* sink, std::string system ); - int RegisterSinkPushStick( EventListener* sink, std::string system ); - int RegisterSinkUnshift( EventListener* sink, std::string system ); + int RegisterSinkPush(EventListener* sink, std::string system); + int RegisterSinkPushStick(EventListener* sink, std::string system); + int RegisterSinkUnshift(EventListener* sink, std::string system); - void MoveSinkLeft( EventListener* sink, std::string system ); - void MoveSinkRight( EventListener* sink, std::string system ); + void MoveSinkLeft(EventListener* sink, std::string system); + void MoveSinkRight(EventListener* sink, std::string system); - void RemoveSource( int dispatcherID, std::string system ); - - void RemoveSink( int listenerID, std::string system ); + void RemoveSource(int dispatcherID, std::string system); - void Dispatch( int dispatcherID, GenericEvent e ); + void RemoveSink(int listenerID, std::string system); - void DebugPrint(); + void Dispatch(int dispatcherID, GenericEvent e); + + void DebugPrint(); private: + // indexed by listener ID for quick lookup + std::map mListeners; + // indexed by dispatcher ID for itteration + std::map mSources; + // indexed by (sink) system ID (string) + // their position in the vector is their layer + std::map>> mStickySinks; + std::map>> mSinks; - // indexed by listener ID for quick lookup - std::map mListeners; - // indexed by dispatcher ID for itteration - std::map mSources; - // indexed by (sink) system ID (string) - // their position in the vector is their layer - std::map>> mStickySinks; - std::map>> mSinks; - - int mNextHeighest = 0; + int mNextHeighest = 0; }; -} +} // namespace Core #endif diff --git a/Aeon/Entity/EntityController.cpp b/Aeon/Entity/EntityController.cpp index e7c341e..eeac9d1 100644 --- a/Aeon/Entity/EntityController.cpp +++ b/Aeon/Entity/EntityController.cpp @@ -2,26 +2,23 @@ using namespace EC; - EntityRegistry::EntityRegistry() { - } EntityRegistry::~EntityRegistry() { - } Entity EntityRegistry::Create() { uint32_t entityId; - if ( mFreedEntities.empty() ) + if (mFreedEntities.empty()) { mEntityCeiling++; entityId = mEntityCeiling; - } - else + } + else { mFreedEntities.pop(); } @@ -30,22 +27,23 @@ Entity EntityRegistry::Create() return entityId; } -Entity Copy( const Entity& entity ) +Entity Copy(const Entity& entity) { // look up everything, create a new entity and populate // with the components in the og entity - return static_cast( 0 ); + return static_cast(0); } -void EntityRegistry::Destroy( Entity entity ) +void EntityRegistry::Destroy(Entity entity) { - if ( !this->Valid( entity ) ) return; + if (!this->Valid(entity)) + return; mFreedEntities.push(entity); mEntities.erase(entity); } -bool EntityRegistry::Valid( const Entity entity ) +bool EntityRegistry::Valid(const Entity entity) { return mEntities.find(entity) != mEntities.end(); } diff --git a/Aeon/Entity/EntityController.hpp b/Aeon/Entity/EntityController.hpp index bfb0328..956b978 100644 --- a/Aeon/Entity/EntityController.hpp +++ b/Aeon/Entity/EntityController.hpp @@ -1,9 +1,8 @@ #ifndef AEON_ENTITY_ENTITYCONTROLLER_H_ #define AEON_ENTITY_ENTITYCONTROLLER_H_ -#include - #include +#include namespace EC { @@ -17,9 +16,9 @@ public: ~EntityRegistry(); Entity Create(); - Entity Copy( const Entity entity ); - void Destroy( Entity entity ); - bool Valid( const Entity entity ); + Entity Copy(const Entity entity); + void Destroy(Entity entity); + bool Valid(const Entity entity); // add, replace components template @@ -27,7 +26,7 @@ public: template TComponent& Replace(const Entity entity); - + // replace in-place template TComponent& Patch(const Entity entity); @@ -35,7 +34,7 @@ public: // Get component from entity based on T template TComponent& Get(const Entity entity); - + // Get std::optional from entity based on T template std::optional Opt(const Entity entity); @@ -43,7 +42,7 @@ public: // TODO: Sort by component properties, for example list of // entities with the renderable components, sorted by Y pos // of position component - // template + // template // std::vector Sort(std::function<; private: @@ -58,7 +57,7 @@ private: // optimisations coming soon TM std::unordered_map> mEntities; }; - -} + +} // namespace EC #endif diff --git a/Aeon/Input/Input.cpp b/Aeon/Input/Input.cpp index 2a7eed9..f747a6d 100644 --- a/Aeon/Input/Input.cpp +++ b/Aeon/Input/Input.cpp @@ -1,76 +1,67 @@ #include "Input.hpp" -#include - #include +#include #include #include using Input::InputController; InputController::InputController() - : mEvent() - , mDisplayEventDispatcher() - , mKeyboardEventDispatcher() - , mMouseEventDispatcher() + : mEvent(), mDisplayEventDispatcher(), mKeyboardEventDispatcher(), mMouseEventDispatcher() { - mDisplayEventDispatcher.RegisterAsSource( "ENGINE_DISPLAY_CORE" ); - mMouseEventDispatcher.RegisterAsSource( "ENGINE_INPUT_MOUSE" ); - mKeyboardEventDispatcher.RegisterAsSource( "ENGINE_INPUT_KEYBOARD" ); + mDisplayEventDispatcher.RegisterAsSource("ENGINE_DISPLAY_CORE"); + mMouseEventDispatcher.RegisterAsSource("ENGINE_INPUT_MOUSE"); + mKeyboardEventDispatcher.RegisterAsSource("ENGINE_INPUT_KEYBOARD"); - mKbdState = static_cast(SDL_GetKeyboardState( &mNumScancodes )); + mKbdState = static_cast(SDL_GetKeyboardState(&mNumScancodes)); } InputController::~InputController() { - mDisplayEventDispatcher.DeRegisterAsSource( "ENGINE_DISPLAY_CORE" ); - mMouseEventDispatcher.DeRegisterAsSource( "ENGINE_INPUT_MOUSE" ); - mKeyboardEventDispatcher.DeRegisterAsSource( "ENGINE_INPUT_KEYBOARD" ); + mDisplayEventDispatcher.DeRegisterAsSource("ENGINE_DISPLAY_CORE"); + mMouseEventDispatcher.DeRegisterAsSource("ENGINE_INPUT_MOUSE"); + mKeyboardEventDispatcher.DeRegisterAsSource("ENGINE_INPUT_KEYBOARD"); // Do not free mKbdState as that is done by SDL } void InputController::PollInput() { - //SDL_PumpEvents(); - while ( SDL_PollEvent( &mEvent ) ) - { + // SDL_PumpEvents(); + while (SDL_PollEvent(&mEvent)) + { // Provide to non-event driven subsystem - ImGui_ImplSDL2_ProcessEvent( &mEvent ); + ImGui_ImplSDL2_ProcessEvent(&mEvent); - switch ( mEvent.type ) - { - case SDL_WINDOWEVENT: - { + switch (mEvent.type) + { + case SDL_WINDOWEVENT: { mPollDisplay(); break; - } - case SDL_MOUSEWHEEL: - { + } + case SDL_MOUSEWHEEL: { mPollScroll(); break; } case SDL_MOUSEBUTTONDOWN: - case SDL_MOUSEBUTTONUP: - { + case SDL_MOUSEBUTTONUP: { mPollClick(); break; } - case SDL_MOUSEMOTION: - { + case SDL_MOUSEMOTION: { mPollMouse(); break; } case SDL_KEYDOWN: - case SDL_KEYUP: - { + case SDL_KEYUP: { mPollKeyboard(); } - } - } + } + } // just in case - mKbdState = static_cast(SDL_GetKeyboardState( &mNumScancodes )); + mKbdState = static_cast(SDL_GetKeyboardState(&mNumScancodes)); // keyboard processing mPollScanKeyboard(); @@ -78,69 +69,58 @@ void InputController::PollInput() void InputController::mPollDisplay() { - switch ( mEvent.window.event ) + switch (mEvent.window.event) { - case SDL_WINDOWEVENT_SHOWN: - { - mDisplayEventDispatcher.Dispatch( "DISPLAY_SHOW" ); + case SDL_WINDOWEVENT_SHOWN: { + mDisplayEventDispatcher.Dispatch("DISPLAY_SHOW"); break; } - case SDL_WINDOWEVENT_HIDDEN: - { - mDisplayEventDispatcher.Dispatch( "DISPLAY_HIDE" ); + case SDL_WINDOWEVENT_HIDDEN: { + mDisplayEventDispatcher.Dispatch("DISPLAY_HIDE"); break; } - case SDL_WINDOWEVENT_MOVED: - { + case SDL_WINDOWEVENT_MOVED: { Core::GenericEvent e; e.x = mEvent.window.data1; e.y = mEvent.window.data2; e.Type = "DISPLAY_MOVE"; - mDisplayEventDispatcher.Dispatch( e ); + mDisplayEventDispatcher.Dispatch(e); break; } - case SDL_WINDOWEVENT_RESIZED: - { + case SDL_WINDOWEVENT_RESIZED: { Core::GenericEvent e; e.x = mEvent.window.data1; e.y = mEvent.window.data2; e.Type = "DISPLAY_RESIZE"; - mDisplayEventDispatcher.Dispatch( e ); + mDisplayEventDispatcher.Dispatch(e); break; } - case SDL_WINDOWEVENT_MINIMIZED: - { - mDisplayEventDispatcher.Dispatch( "DISPLAY_MINIMISED" ); + case SDL_WINDOWEVENT_MINIMIZED: { + mDisplayEventDispatcher.Dispatch("DISPLAY_MINIMISED"); break; } - case SDL_WINDOWEVENT_MAXIMIZED: - { - mDisplayEventDispatcher.Dispatch( "DISPLAY_MAXIMISED" ); + case SDL_WINDOWEVENT_MAXIMIZED: { + mDisplayEventDispatcher.Dispatch("DISPLAY_MAXIMISED"); break; } - case SDL_WINDOWEVENT_ENTER: - { - mDisplayEventDispatcher.Dispatch( "DISPLAY_MOUSE_ENTER" ); + case SDL_WINDOWEVENT_ENTER: { + mDisplayEventDispatcher.Dispatch("DISPLAY_MOUSE_ENTER"); break; } - case SDL_WINDOWEVENT_LEAVE: - { - mDisplayEventDispatcher.Dispatch( "DISPLAY_MOUSE_LEAVE" ); + case SDL_WINDOWEVENT_LEAVE: { + mDisplayEventDispatcher.Dispatch("DISPLAY_MOUSE_LEAVE"); break; } - case SDL_WINDOWEVENT_FOCUS_GAINED: - { - mDisplayEventDispatcher.Dispatch( "DISPLAY_FOCUS" ); + case SDL_WINDOWEVENT_FOCUS_GAINED: { + mDisplayEventDispatcher.Dispatch("DISPLAY_FOCUS"); break; } - case SDL_WINDOWEVENT_FOCUS_LOST: - { - mDisplayEventDispatcher.Dispatch( "DISPLAY_OUT_OF_FOCUS" ); + case SDL_WINDOWEVENT_FOCUS_LOST: { + mDisplayEventDispatcher.Dispatch("DISPLAY_OUT_OF_FOCUS"); break; } - case SDL_WINDOWEVENT_CLOSE: - { - mDisplayEventDispatcher.Dispatch( "DISPLAY_CLOSED" ); + case SDL_WINDOWEVENT_CLOSE: { + mDisplayEventDispatcher.Dispatch("DISPLAY_CLOSED"); break; } } @@ -154,7 +134,7 @@ void InputController::mPollMouse() e.dx = mEvent.motion.xrel; e.dy = mEvent.motion.yrel; e.Type = "MOUSE_MOVE"; - mMouseEventDispatcher.Dispatch( e ); + mMouseEventDispatcher.Dispatch(e); } void InputController::mPollScroll() @@ -162,49 +142,43 @@ void InputController::mPollScroll() Core::GenericEvent e; e.y = mEvent.wheel.y; e.Type = "MOUSE_SCROLL"; - mMouseEventDispatcher.Dispatch( e ); + mMouseEventDispatcher.Dispatch(e); } void InputController::mPollClick() { - if ( mEvent.button.state == SDL_PRESSED ) + if (mEvent.button.state == SDL_PRESSED) { - switch ( mEvent.button.button ) + switch (mEvent.button.button) { - case SDL_BUTTON_LEFT: - { - mDisplayEventDispatcher.Dispatch( "MOUSE_LEFT_DOWN" ); + case SDL_BUTTON_LEFT: { + mDisplayEventDispatcher.Dispatch("MOUSE_LEFT_DOWN"); break; } - case SDL_BUTTON_RIGHT: - { - mDisplayEventDispatcher.Dispatch( "MOUSE_RIGHT_DOWN" ); + case SDL_BUTTON_RIGHT: { + mDisplayEventDispatcher.Dispatch("MOUSE_RIGHT_DOWN"); break; } - case SDL_BUTTON_MIDDLE: - { - mDisplayEventDispatcher.Dispatch( "MOUSE_MIDDLE_DOWN" ); + case SDL_BUTTON_MIDDLE: { + mDisplayEventDispatcher.Dispatch("MOUSE_MIDDLE_DOWN"); break; } } } - else if ( mEvent.button.state == SDL_RELEASED ) + else if (mEvent.button.state == SDL_RELEASED) { - switch ( mEvent.button.button ) + switch (mEvent.button.button) { - case SDL_BUTTON_LEFT: - { - mDisplayEventDispatcher.Dispatch( "MOUSE_LEFT_UP" ); + case SDL_BUTTON_LEFT: { + mDisplayEventDispatcher.Dispatch("MOUSE_LEFT_UP"); break; } - case SDL_BUTTON_RIGHT: - { - mDisplayEventDispatcher.Dispatch( "MOUSE_RIGHT_UP" ); + case SDL_BUTTON_RIGHT: { + mDisplayEventDispatcher.Dispatch("MOUSE_RIGHT_UP"); break; } - case SDL_BUTTON_MIDDLE: - { - mDisplayEventDispatcher.Dispatch( "MOUSE_MIDDLE_UP" ); + case SDL_BUTTON_MIDDLE: { + mDisplayEventDispatcher.Dispatch("MOUSE_MIDDLE_UP"); break; } } @@ -213,41 +187,41 @@ void InputController::mPollClick() void InputController::mPollKeyboard() { - EKeyCode keycode = KeyCodeFromSDL( mEvent.key.keysym.sym ); + EKeyCode keycode = KeyCodeFromSDL(mEvent.key.keysym.sym); Core::GenericEvent e; e.keyCode = KeyCodeFromSDL(keycode); - if ( mEvent.key.state == SDL_PRESSED ) + if (mEvent.key.state == SDL_PRESSED) { e.Type = "KEYBOARD_KEYDOWN"; } - else if ( mEvent.key.state == SDL_RELEASED ) + else if (mEvent.key.state == SDL_RELEASED) { e.Type = "KEYBOARD_KEYUP"; } - + uint16_t mods = mEvent.key.keysym.mod; e.keyMods = mods; mModKeyState = mods; - mKeyboardEventDispatcher.Dispatch( e ); + mKeyboardEventDispatcher.Dispatch(e); } void InputController::mPollScanKeyboard() { - //this is naive, can be optimised with double buffering - for ( int i = 0; i < mNumScancodes; i++ ) + // this is naive, can be optimised with double buffering + for (int i = 0; i < mNumScancodes; i++) { bool isKeyPressed = (bool)mKbdState[i]; - if ( isKeyPressed ) + if (isKeyPressed) { - EKeyCode whatKeyPressed = KeyCodeFromScanCode( (SDL_Scancode)i ); + EKeyCode whatKeyPressed = KeyCodeFromScanCode((SDL_Scancode)i); Core::GenericEvent e; e.keyCode = whatKeyPressed; e.keyMods = mModKeyState; e.Type = "KEYBOARD_KEYPRESS"; - mKeyboardEventDispatcher.Dispatch( e ); + mKeyboardEventDispatcher.Dispatch(e); } } } diff --git a/Aeon/Rendering/Device/OpenGL/New File b/Aeon/Rendering/Device/OpenGL/.gitkeep similarity index 100% rename from Aeon/Rendering/Device/OpenGL/New File rename to Aeon/Rendering/Device/OpenGL/.gitkeep diff --git a/Aeon/Rendering/Material.cpp b/Aeon/Rendering/Material.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Aeon/Rendering/Material.hpp b/Aeon/Rendering/Material.hpp new file mode 100644 index 0000000..e69de29 diff --git a/Aeon/Rendering/Mesh.cpp b/Aeon/Rendering/Mesh.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Aeon/Rendering/Mesh.hpp b/Aeon/Rendering/Mesh.hpp new file mode 100644 index 0000000..e69de29 diff --git a/Aeon/Rendering/RenderMaster.hpp b/Aeon/Rendering/RenderMaster.hpp index 84108c3..30bce07 100644 --- a/Aeon/Rendering/RenderMaster.hpp +++ b/Aeon/Rendering/RenderMaster.hpp @@ -11,12 +11,13 @@ namespace Rendering class RenderMaster : public Helpers::Singleton { public: - RenderMaster(); + RenderMaster(); + + void QueueRenderable(Renderable* renderable); + - void QueueRenderable( Renderable* renderable ); }; - -} +} // namespace Rendering #endif diff --git a/Aeon/Rendering/Renderable.cpp b/Aeon/Rendering/Renderable.cpp new file mode 100644 index 0000000..e69de29 diff --git a/CMakeModules/FindSDL2.cmake b/CMakeModules/FindSDL2.cmake deleted file mode 100644 index 641d1f7..0000000 --- a/CMakeModules/FindSDL2.cmake +++ /dev/null @@ -1,197 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# FindSDL2 -# ------- -# -# Locate SDL2 library -# -# This module defines -# -# :: -# -# SDL2_LIBRARY, the name of the library to link against -# SDL2_FOUND, if false, do not try to link to SDL -# SDL2_INCLUDE_DIR, where to find SDL.h -# SDL2_VERSION_STRING, human-readable string containing the version of SDL -# -# -# -# This module responds to the flag: -# -# :: -# -# SDL2_BUILDING_LIBRARY -# If this is defined, then no SDL2_main will be linked in because -# only applications need main(). -# Otherwise, it is assumed you are building an application and this -# module will attempt to locate and set the proper link flags -# as part of the returned SDL2_LIBRARY variable. -# -# -# -# Don't forget to include SDLmain.h and SDLmain.m your project for the -# OS X framework based version. (Other versions link to -lSDLmain which -# this module will try to find on your behalf.) Also for OS X, this -# module will automatically add the -framework Cocoa on your behalf. -# -# -# -# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your -# configuration and no SDL2_LIBRARY, it means CMake did not find your SDL -# library (SDL.dll, libsdl.so, SDL.framework, etc). Set -# SDL2_LIBRARY_TEMP to point to your SDL library, and configure again. -# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this -# value as appropriate. These values are used to generate the final -# SDL2_LIBRARY variable, but when these values are unset, SDL2_LIBRARY -# does not get created. -# -# -# -# $SDL2DIR is an environment variable that would correspond to the -# ./configure --prefix=$SDL2DIR used in building SDL. l.e.galup 9-20-02 -# -# Modified by Eric Wing. Added code to assist with automated building -# by using environmental variables and providing a more -# controlled/consistent search behavior. Added new modifications to -# recognize OS X frameworks and additional Unix paths (FreeBSD, etc). -# Also corrected the header search path to follow "proper" SDL -# guidelines. Added a search for SDLmain which is needed by some -# platforms. Added a search for threads which is needed by some -# platforms. Added needed compile switches for MinGW. -# -# On OSX, this will prefer the Framework version (if found) over others. -# People will have to manually change the cache values of SDL2_LIBRARY to -# override this selection or set the CMake environment -# CMAKE_INCLUDE_PATH to modify the search paths. -# -# Note that the header path has changed from SDL/SDL.h to just SDL.h -# This needed to change because "proper" SDL convention is #include -# "SDL.h", not . This is done for portability reasons -# because not all systems place things in SDL/ (see FreeBSD). - -if(NOT SDL2_DIR) - set(SDL2_DIR "" CACHE PATH "SDL2 directory") -endif() - -find_path(SDL2_INCLUDE_DIR SDL.h - HINTS - ENV SDL2DIR - ${SDL2_DIR} - PATH_SUFFIXES SDL2 - # path suffixes to search inside ENV{SDL2DIR} - include/SDL2 include -) - -# AWLAYS 64 bit -set(VC_LIB_PATH_SUFFIX lib/x64) - -find_library(SDL2_LIBRARY_TEMP - NAMES SDL2 - HINTS - ENV SDL2DIR - ${SDL2_DIR} - PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} -) - -# Hide this cache variable from the user, it's an internal implementation -# detail. The documented library variable for the user is SDL2_LIBRARY -# which is derived from SDL2_LIBRARY_TEMP further below. -set_property(CACHE SDL2_LIBRARY_TEMP PROPERTY TYPE INTERNAL) - -if(NOT SDL2_BUILDING_LIBRARY) - if(NOT SDL2_INCLUDE_DIR MATCHES ".framework") - # Non-OS X framework versions expect you to also dynamically link to - # SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms - # seem to provide SDLmain for compatibility even though they don't - # necessarily need it. - find_library(SDL2MAIN_LIBRARY - NAMES SDL2main - HINTS - ENV SDL2DIR - ${SDL2_DIR} - PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} - PATHS - /sw - /opt/local - /opt/csw - /opt - ) - endif() -endif() - -# SDL may require threads on your system. -# The Apple build may not need an explicit flag because one of the -# frameworks may already provide it. -# But for non-OSX systems, I will use the CMake Threads package. -if(NOT APPLE) - find_package(Threads) -endif() - -# MinGW needs an additional link flag, -mwindows -# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -mwindows -if(MINGW) - set(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "link flags for MinGW") -endif() - -if(SDL2_LIBRARY_TEMP) - # For SDLmain - if(SDL2MAIN_LIBRARY AND NOT SDL2_BUILDING_LIBRARY) - list(FIND SDL2_LIBRARY_TEMP "${SDLMAIN_LIBRARY}" _SDL2_MAIN_INDEX) - if(_SDL2_MAIN_INDEX EQUAL -1) - set(SDL2_LIBRARY_TEMP "${SDLMAIN_LIBRARY}" ${SDL2_LIBRARY_TEMP}) - endif() - unset(_SDL2_MAIN_INDEX) - endif() - - # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa. - # CMake doesn't display the -framework Cocoa string in the UI even - # though it actually is there if I modify a pre-used variable. - # I think it has something to do with the CACHE STRING. - # So I use a temporary variable until the end so I can set the - # "real" variable in one-shot. - if(APPLE) - set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa") - endif() - - # For threads, as mentioned Apple doesn't need this. - # In fact, there seems to be a problem if I used the Threads package - # and try using this line, so I'm just skipping it entirely for OS X. - if(NOT APPLE) - set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) - endif() - - # For MinGW library - if(MINGW) - set(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP}) - endif() - - # Set the final string here so the GUI reflects the final state. - set(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found") -endif() - -if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL2_version.h") - file(STRINGS "${SDL2_INCLUDE_DIR}/SDL2_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL2_MAJOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_INCLUDE_DIR}/SDL2_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL2_MINOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_INCLUDE_DIR}/SDL2_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL2_PATCHLEVEL[ \t]+[0-9]+$") - string(REGEX REPLACE "^#define[ \t]+SDL2_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL2_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL2_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}") - set(SDL2_VERSION_STRING ${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH}) - unset(SDL2_VERSION_MAJOR_LINE) - unset(SDL2_VERSION_MINOR_LINE) - unset(SDL2_VERSION_PATCH_LINE) - unset(SDL2_VERSION_MAJOR) - unset(SDL2_VERSION_MINOR) - unset(SDL2_VERSION_PATCH) -endif() - -set(SDL2_LIBRARIES ${SDL2_LIBRARY} ${SDL2MAIN_LIBRARY}) -set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) - -include(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL - REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR - VERSION_VAR SDL2_VERSION_STRING) diff --git a/CMakeSettings.json b/CMakeSettings.json deleted file mode 100644 index 4bf8087..0000000 --- a/CMakeSettings.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "configurations": [ - { - "name": "x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "inheritEnvironments": [ "msvc_x64_x64" ], - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "-DSDL2_PATH=\"C:/Users/benja/Programming/lib/SDL2-2.0.16/\"", - "buildCommandArgs": "-v", - "ctestCommandArgs": "" - }, - { - "name": "x64-Release", - "generator": "Ninja", - "configurationType": "RelWithDebInfo", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "-DSDL2_DIR=\"C:/Users/benja/Programming/lib/SDL2-2.0.16/\"", - "buildCommandArgs": "-v", - "ctestCommandArgs": "", - "inheritEnvironments": [ "msvc_x64_x64" ] - } - ] -} \ No newline at end of file