KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
Karma::Application Class Reference

The class for Game + Editor in application form. More...

#include <Application.h>

Inheritance diagram for Karma::Application:

Public Member Functions

 Application ()
 A constructor for Application.
 
 ~Application ()
 Destructor.
 
void Run ()
 Routine containing the main application loop.
 
void OnEvent (Event &e)
 For dispatching events and trickling down the call to Layer stack.
 
void PushLayer (Layer *layer)
 Places the Layer in the stack of layers and sends a notification.
 
void PushOverlay (Layer *layer)
 Places the Layer at the front most position, in the sense, after the last inserted layer.
 
void PrepareApplicationForRun ()
 Do the preliminaries before the main loop run.
 
void HookInputSystem (std::shared_ptr< Input > input)
 Set an event callback to the given input system.
 
void PrepareMemorySoftBed ()
 All the bulk memory allocation is done to prevent frequent calls to context switching new/delete operators.
 
void InitializeApplicationEngine ()
 Instantiate the instance of KEngine.
 
void DecommisionApplicationEngine ()
 Clean up all the KEngine relevant mess.
 
WindowGetWindow () const
 Getter for the Window handle.
 
void CloseApplication ()
 Closing of the Application and do the relevant processing for clean up.
 

Static Public Member Functions

static ApplicationGet ()
 Getter for the instance (s_Instance) of the Application.
 

Detailed Description

The class for Game + Editor in application form.

Constructor & Destructor Documentation

◆ Application()

Karma::Application::Application ( )

A constructor for Application.

Does the following steps

  • A check for ensuring only one instance is present
  • Creation of a Window (depending upon the platform)
  • Declaration of Layer stack
  • Creation of KarmaGui Layer and a push into the stack
Since
Karma 1.0.0

◆ ~Application()

Karma::Application::~Application ( )

Destructor.

  • Clearence of the memory (and relevant) resources
  • Clearence of rendering data
  • Deletion of Layer stack
  • Deletion of Application window
Since
Karma 1.0.0

Member Function Documentation

◆ CloseApplication()

void Karma::Application::CloseApplication ( )

Closing of the Application and do the relevant processing for clean up.

Since
Karma 1.0.0

◆ DecommisionApplicationEngine()

void Karma::Application::DecommisionApplicationEngine ( )

Clean up all the KEngine relevant mess.

Todo
Need to think how this should be written with GC in mind
Since
Karma 1.0.0

◆ Get()

static Application & Karma::Application::Get ( )
inlinestatic

Getter for the instance (s_Instance) of the Application.

Since
Karma 1.0.0

◆ GetWindow()

Window & Karma::Application::GetWindow ( ) const
inline

Getter for the Window handle.

Since
Karma 1.0.0

◆ HookInputSystem()

void Karma::Application::HookInputSystem ( std::shared_ptr< Input > input)

Set an event callback to the given input system.

Todo
Think about the need to uplift to more abstract implementation
Since
Karma 1.0.0

◆ InitializeApplicationEngine()

void Karma::Application::InitializeApplicationEngine ( )

Instantiate the instance of KEngine.

Todo
Ponder over the usage of KEngine type instances for Editor and Game
Since
Karma 1.0.0

◆ OnEvent()

void Karma::Application::OnEvent ( Event & e)

For dispatching events and trickling down the call to Layer stack.

The OnEvent call is basically made by the glfw library via m_Data.EventCallback. The registration is done like so

m_Window->SetEventCallback(KR_BIND_EVENT_FN(Application::OnEvent)); // Setting the listener
#define KR_BIND_EVENT_FN(fn)
Macro for std::bind routine. See https://en.cppreference.com/w/cpp/utility/functional/bind.
Definition Core.h:112
void OnEvent(Event &e)
For dispatching events and trickling down the call to Layer stack.
Definition Application.cpp:169

whilst, the EventCallback is called in the lambdas of (Linux/Mac/Windows)Window::SetGLFWCallbacks()

Since
Karma 1.0.0

◆ PrepareApplicationForRun()

void Karma::Application::PrepareApplicationForRun ( )

Do the preliminaries before the main loop run.

The following steps are taken

  • Input system is initialized
  • Memory system is initialized
  • Prepare an outer for KEngine instance
  • Initialize KEngine
Since
Karma 1.0.0

◆ PrepareMemorySoftBed()

void Karma::Application::PrepareMemorySoftBed ( )

All the bulk memory allocation is done to prevent frequent calls to context switching new/delete operators.

Note
See KarmaSmriti for understanding the workings of Karma's memory management
Since
Karma 1.0.0

◆ PushLayer()

void Karma::Application::PushLayer ( Layer * layer)

Places the Layer in the stack of layers and sends a notification.

LayerStack::m_Layers.emplace() is used to place the supplied layer at an index in ascending order. For instance the layer inserted first has least index and subsequent layers have higher indices ordered accordingly.

Parameters
layerThe Layer to be placed
See also
LayerStack::PushLayer
Since
Karma 1.0.0

◆ PushOverlay()

void Karma::Application::PushOverlay ( Layer * layer)

Places the Layer at the front most position, in the sense, after the last inserted layer.

Parameters
layerThe Layer to be pushed as overlay
See also
PushLayer
Since
Karma 1.0.0

◆ Run()

void Karma::Application::Run ( )

Routine containing the main application loop.

The purpose of the loop is multifold

  • Tracking the clock time gap between consecutive loop iterations (thus compute the deltatime)
  • Make GEngine (instance of KEngine class) tick
  • Update all the layers of stack
  • Update all the layers' UI rendering (KarmaGui's sequence)
  • Window update
Since
Karma 1.0.0

The documentation for this class was generated from the following files: