diff --git a/Aeon/Aeon.cpp b/Aeon/Aeon.cpp index 4260ffa..9178c52 100644 --- a/Aeon/Aeon.cpp +++ b/Aeon/Aeon.cpp @@ -9,11 +9,11 @@ using Core::App; using Core::Display; using Core::DisplayProperties; -using Input::Input; +using Input::InputController; App::App( const AppProperties& props, const DisplayProperties& dispProps ) : mDisplay() - , mInput() + , mInput(InputController::GetInstance()) { PushThisAsSink( "ENGINE_DISPLAY_CORE" ); diff --git a/Aeon/Aeon.hpp b/Aeon/Aeon.hpp index 0ae89d2..ab9073f 100644 --- a/Aeon/Aeon.hpp +++ b/Aeon/Aeon.hpp @@ -39,7 +39,7 @@ public: private: Display mDisplay; - Input mInput; + Input::InputController& mInput; // Game layers from z orderxko285132046 std::vector mGameLayers; diff --git a/Aeon/Core/Display.cpp b/Aeon/Core/Display.cpp index 0fcf906..4edd164 100644 --- a/Aeon/Core/Display.cpp +++ b/Aeon/Core/Display.cpp @@ -3,6 +3,7 @@ #include #include "Aeon/Assert.hpp" +#include "Aeon/Rendering/RenderMaster.hpp" #include "Aeon/Rendering/ImGui.hpp" using Core::Display; @@ -10,6 +11,7 @@ using Core::Display; Display::Display() : mWindow( nullptr ) , mContext( NULL ) + , mRenderer( Rendering::RenderMaster::GetInstance() ) , mClearColour{ 1.0f, 1.0f, 1.0f, 1.0f } { PushThisAsSink( "ENGINE_DISPLAY_CORE" ); diff --git a/Aeon/Core/Display.hpp b/Aeon/Core/Display.hpp index e6d8e93..a31d332 100644 --- a/Aeon/Core/Display.hpp +++ b/Aeon/Core/Display.hpp @@ -11,7 +11,8 @@ extern "C" { #include "Aeon/Core/EngineConfig.hpp" #include "Aeon/Core/Events.hpp" -class Rendering::Rendermaster; +namespace Rendering { class RenderMaster; } +using namespace Rendering; namespace Core { @@ -41,10 +42,10 @@ private: SDL_Window* mWindow; SDL_GLContext mContext; + RenderMaster& mRenderer; - - unsigned int mWidth, mHeight; - unsigned int mX, mY; + unsigned int mWidth, mHeight = 0; + unsigned int mX, mY = 0; float mClearColour[4]; private: diff --git a/Aeon/Core/Events.hpp b/Aeon/Core/Events.hpp index 394ba0d..6c1ab36 100644 --- a/Aeon/Core/Events.hpp +++ b/Aeon/Core/Events.hpp @@ -24,6 +24,9 @@ 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 diff --git a/Aeon/Input/Input.cpp b/Aeon/Input/Input.cpp index 23a4ea7..1603914 100644 --- a/Aeon/Input/Input.cpp +++ b/Aeon/Input/Input.cpp @@ -10,9 +10,9 @@ #include "Aeon/Input/InputMap.hpp" #include "Aeon/Rendering/ImGui.hpp" -using Input::Input; +using Input::InputController; -Input::Input() +InputController::InputController() : mEvent() , mDisplayEventDispatcher() , mKeyboardEventDispatcher() @@ -25,7 +25,7 @@ Input::Input() mKbdState = static_cast(SDL_GetKeyboardState( &mNumScancodes )); } -Input::~Input() +InputController::~InputController() { mDisplayEventDispatcher.DeRegisterAsSource( "ENGINE_DISPLAY_CORE" ); mMouseEventDispatcher.DeRegisterAsSource( "ENGINE_INPUT_MOUSE" ); @@ -34,7 +34,7 @@ Input::~Input() // Do not free mKbdState as that is done by SDL } -void Input::PollInput() +void InputController::PollInput() { //SDL_PumpEvents(); while ( SDL_PollEvent( &mEvent ) ) @@ -80,7 +80,7 @@ void Input::PollInput() mPollScanKeyboard(); } -void Input::mPollDisplay() +void InputController::mPollDisplay() { switch ( mEvent.window.event ) { @@ -150,7 +150,7 @@ void Input::mPollDisplay() } } -void Input::mPollMouse() +void InputController::mPollMouse() { Core::GenericEvent e; e.x = mEvent.motion.x; @@ -161,7 +161,7 @@ void Input::mPollMouse() mMouseEventDispatcher.Dispatch( e ); } -void Input::mPollScroll() +void InputController::mPollScroll() { Core::GenericEvent e; e.y = mEvent.wheel.y; @@ -169,7 +169,7 @@ void Input::mPollScroll() mMouseEventDispatcher.Dispatch( e ); } -void Input::mPollClick() +void InputController::mPollClick() { if ( mEvent.button.state == SDL_PRESSED ) { @@ -215,7 +215,7 @@ void Input::mPollClick() } } -void Input::mPollKeyboard() +void InputController::mPollKeyboard() { EKeyCode keycode = KeyCodeFromSDL( mEvent.key.keysym.sym ); Core::GenericEvent e; @@ -237,7 +237,7 @@ void Input::mPollKeyboard() mKeyboardEventDispatcher.Dispatch( e ); } -void Input::mPollScanKeyboard() +void InputController::mPollScanKeyboard() { //this is naive, can be optimised with double buffering for ( int i = 0; i < mNumScancodes; i++ ) diff --git a/Aeon/Input/Input.hpp b/Aeon/Input/Input.hpp index 4cfbba4..f19ce08 100644 --- a/Aeon/Input/Input.hpp +++ b/Aeon/Input/Input.hpp @@ -10,11 +10,11 @@ namespace Input { -class Input +class InputController : public Helpers::Singleton { public: - Input(); - ~Input(); + InputController(); + ~InputController(); void PollInput(); diff --git a/Aeon/Rendering/RenderMaster.cpp b/Aeon/Rendering/RenderMaster.cpp new file mode 100644 index 0000000..1f0de27 --- /dev/null +++ b/Aeon/Rendering/RenderMaster.cpp @@ -0,0 +1,13 @@ +#include "Aeon/Rendering/RenderMaster.hpp" + +using Rendering; + +RenderMaster::RenderMaster() +{ + +} + +void RenderMaster::QueueRenderable() +{ + +} diff --git a/Aeon/Rendering/RenderMaster.hpp b/Aeon/Rendering/RenderMaster.hpp index 3715193..431ed54 100644 --- a/Aeon/Rendering/RenderMaster.hpp +++ b/Aeon/Rendering/RenderMaster.hpp @@ -6,9 +6,13 @@ namespace Rendering { +class Renderable; + class RenderMaster : public Helpers::Singleton { + RenderMaster(); + void QueueRenderable( Renderable* renderable ); }; } diff --git a/Game/ExampleGame.cpp b/Game/ExampleGame.cpp index 1f16131..91f68f0 100644 --- a/Game/ExampleGame.cpp +++ b/Game/ExampleGame.cpp @@ -2,6 +2,7 @@ #include #include +#include class BackgroundLevel : public Core::GameLayer { @@ -23,6 +24,9 @@ public: void FrameTick() override { + + + } void TimeTick() override @@ -32,7 +36,44 @@ public: bool EventRecieved( Core::GenericEvent& e ) override { + return false; + } + void Detach() override + { + + } +}; + +class DebugLayer : public Core::GameLayer +{ +public: + DebugLayer() + { + + } + + void Attach() override + { + + } + + void FrameTick() override + { + + ImGui::Begin( "Debug" ); + + ImGui::End(); + + } + + void TimeTick() override + { + + } + + bool EventRecieved( Core::GenericEvent& e ) override + { return false; } @@ -50,6 +91,8 @@ public: { Level* level = new Level; PushLayer( (Core::GameLayer*)level ); + DebugLayer* debug = new DebugLayer; + PushDebugLayer( debug ); Run(); delete level; }