what the fuck is a renderable

This commit is contained in:
Benjamin Kyd
2022-05-20 01:36:53 +01:00
parent 411200ddaa
commit fe3fb0101a
10 changed files with 86 additions and 20 deletions

View File

@@ -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" );

View File

@@ -39,7 +39,7 @@ public:
private:
Display mDisplay;
Input mInput;
Input::InputController& mInput;
// Game layers from z orderxko285132046
std::vector<GameLayer*> mGameLayers;

View File

@@ -3,6 +3,7 @@
#include <iostream>
#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" );

View File

@@ -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:

View File

@@ -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

View File

@@ -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<const uint8_t*>(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++ )

View File

@@ -10,11 +10,11 @@
namespace Input {
class Input
class InputController : public Helpers::Singleton<InputController>
{
public:
Input();
~Input();
InputController();
~InputController();
void PollInput();

View File

@@ -0,0 +1,13 @@
#include "Aeon/Rendering/RenderMaster.hpp"
using Rendering;
RenderMaster::RenderMaster()
{
}
void RenderMaster::QueueRenderable()
{
}

View File

@@ -6,9 +6,13 @@
namespace Rendering
{
class Renderable;
class RenderMaster : public Helpers::Singleton<RenderMaster>
{
RenderMaster();
void QueueRenderable( Renderable* renderable );
};
}

View File

@@ -2,6 +2,7 @@
#include <Aeon/Aeon.hpp>
#include <Aeon/Core/Events.hpp>
#include <Aeon/Rendering/ImGui.hpp>
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;
}