diff --git a/SHADE_Application/SHADE_Application.vcxproj b/SHADE_Application/SHADE_Application.vcxproj
index 3d9cfd1a..37c97b1c 100644
--- a/SHADE_Application/SHADE_Application.vcxproj
+++ b/SHADE_Application/SHADE_Application.vcxproj
@@ -98,12 +98,16 @@
+
+
+
Create
+
diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp
new file mode 100644
index 00000000..58aded2b
--- /dev/null
+++ b/SHADE_Application/src/Application/SBApplication.cpp
@@ -0,0 +1,43 @@
+#include "SBpch.h"
+#include "SBApplication.h"
+
+#ifdef SHEDITOR
+#include "Editor/SHEditor.h"
+#include "Scenes/SBEditorScene.h"
+#endif // SHEDITOR
+
+#include
+#include
+#include
+
+namespace Sandbox
+{
+ bool paused = false;
+ void SBApplication::Initialize(void)
+ {
+ #ifdef SHEDITOR
+ #else
+ #endif
+
+ }
+
+ void SBApplication::Update(void)
+ {
+ //TODO: Change true to window is open
+ while(true)
+ {
+ #ifdef SHEDITOR
+ #else
+ #endif
+ }
+ }
+
+
+ void SBApplication::Exit(void)
+ {
+ #ifdef SHEDITOR
+ #else
+ #endif
+ }
+}
+
diff --git a/SHADE_Application/src/Application/SBApplication.h b/SHADE_Application/src/Application/SBApplication.h
new file mode 100644
index 00000000..c8e02863
--- /dev/null
+++ b/SHADE_Application/src/Application/SBApplication.h
@@ -0,0 +1,23 @@
+#ifndef SB_APPLICATION_H
+#define SB_APPLICATION_H
+
+//using namespace SHADE;
+
+namespace Sandbox
+{
+ class SBApplication
+ {
+ private:
+ //SHAppConfig config;
+ public:
+ SBApplication() = default;
+ void Initialize(void);
+ void Update(void);
+ void Exit(void);
+ private:
+ //std::common_type_t collisionSystemTime, physicsSystemTime, transformSystemTime, audioSystemTime, renderSystemTime, gameTime;
+ //std::chrono::high_resolution_clock::time_point audioStart, audioEnd, transformStart, transformEnd, physicsStart, physicsEnd, collisionStart, collisionEnd, renderStart, renderEnd, gameStart, gameEnd;
+ };
+}
+
+#endif
diff --git a/SHADE_Application/src/Scenes/SBTestScene.cpp b/SHADE_Application/src/Scenes/SBTestScene.cpp
new file mode 100644
index 00000000..46b1bb84
--- /dev/null
+++ b/SHADE_Application/src/Scenes/SBTestScene.cpp
@@ -0,0 +1,48 @@
+#include "SBpch.h"
+#include "SBTestScene.h"
+
+using namespace SHADE;
+
+namespace Sandbox
+{
+
+ void SBTestScene::WindowFocusFunc([[maybe_unused]]void* window, int focused)
+ {
+ if(focused)
+ {
+ }
+ else
+ {
+ }
+ }
+
+ void SBTestScene::Load()
+ {
+ }
+ void SBTestScene::Init()
+ {
+
+ }
+ void SBTestScene::Update(float dt)
+ {
+ (void)dt;
+
+ }
+
+ void SBTestScene::Render()
+ {
+ }
+
+ void SBTestScene::Unload()
+ {
+ }
+
+ void SBTestScene::Free()
+ {
+ //SHSerialization::SerializeScene("resources/scenes/Scene01.SHADE");
+ }
+
+}
+
+
+
diff --git a/SHADE_Application/src/Scenes/SBTestScene.h b/SHADE_Application/src/Scenes/SBTestScene.h
new file mode 100644
index 00000000..6776c671
--- /dev/null
+++ b/SHADE_Application/src/Scenes/SBTestScene.h
@@ -0,0 +1,29 @@
+#pragma once
+
+#include "Scene/SHScene.h"
+#include "Scene/SHSceneManager.h"
+
+namespace Sandbox
+{
+ class SBTestScene : public SHADE::SHScene
+ {
+ private:
+ EntityID camera;
+
+
+ public:
+ virtual void Load();
+ virtual void Init();
+ virtual void Update(float dt);
+ virtual void Render();
+ virtual void Free();
+ virtual void Unload();
+
+ //TODO: Change to new window DO IT IN CPP TOO
+ void WindowFocusFunc(void* window, int focused);
+
+ SBTestScene(void) = default;
+ };
+
+}
+
diff --git a/SHADE_Application/src/WinMain.cpp b/SHADE_Application/src/WinMain.cpp
index 21fb268a..89005432 100644
--- a/SHADE_Application/src/WinMain.cpp
+++ b/SHADE_Application/src/WinMain.cpp
@@ -1,7 +1,29 @@
#include "SBpch.h"
+#include
+#include "Application/SBApplication.h"
+
+
+#define _CRTDBG_MAP_ALLOC
+#include
+#include
+
+#ifdef _DEBUG
+#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
+// Replace _NORMAL_BLOCK with _CLIENT_BLOCK if you want the
+// allocations to be of _CLIENT_BLOCK type
+#else
+#define DBG_NEW new
+#endif
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR lpCmdLine, INT nCmdShow)
{
+ #ifndef SHEDITOR
+ ShowWindow(::GetConsoleWindow(), SW_HIDE);
+ #endif
+
+ SHADE::SHEngine::Run();
+ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+
return 0;
}
\ No newline at end of file
diff --git a/SHADE_Engine/SHADE_Engine.vcxproj b/SHADE_Engine/SHADE_Engine.vcxproj
index f10ed0e7..15d38e26 100644
--- a/SHADE_Engine/SHADE_Engine.vcxproj
+++ b/SHADE_Engine/SHADE_Engine.vcxproj
@@ -116,6 +116,9 @@
+
+
+
@@ -126,6 +129,7 @@
+
Create
diff --git a/SHADE_Engine/SHADE_Engine.vcxproj.filters b/SHADE_Engine/SHADE_Engine.vcxproj.filters
index b4a61bae..02a36cbf 100644
--- a/SHADE_Engine/SHADE_Engine.vcxproj.filters
+++ b/SHADE_Engine/SHADE_Engine.vcxproj.filters
@@ -4,36 +4,93 @@
{DBC7D3B0-C769-FE86-B024-12DB9C6585D7}
+
+ {7FF59BF8-EB80-09BD-F491-8CB1609C65BD}
+
+
+ {340D0110-201D-ADE0-89D6-11FF75059C79}
+
+
+ {EBFC8BDC-D7F6-B42E-C063-4B3FACFC1A9B}
+
+
+ {6CD692F2-D80D-DB89-E117-3FAD4DCE0183}
+
+
+ {B3E3FAFD-9FDD-2350-884A-BA6074E389BC}
+
+
+ Engine\ECS_Base\Components
+
+
+ Engine\ECS_Base\Components
+
+
+ Engine\ECS_Base\Entity
+
+
+ Engine\ECS_Base\General
+
+
+ Engine\ECS_Base\General
+
+
+ Engine\ECS_Base\General
+
+
+ Engine\ECS_Base\General
+
+
+ Engine\ECS_Base\General
+
+
+ Engine\ECS_Base
+
+
+ Engine\ECS_Base\System
+
+
+ Engine\ECS_Base\System
+
+
+ Engine\ECS_Base\System
+
+
+ Engine\ECS_Base\System
+
Engine
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Engine\ECS_Base\Components
+
+
+ Engine\ECS_Base\Components
+
+
+ Engine\ECS_Base\Entity
+
+
+ Engine\ECS_Base\System
+
+
+ Engine\ECS_Base\System
+
+
+ Engine\ECS_Base\System
+
Engine
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/SHADE_Engine/src/Engine/SHEngine.cpp b/SHADE_Engine/src/Engine/SHEngine.cpp
index f65a5402..a7fec85b 100644
--- a/SHADE_Engine/src/Engine/SHEngine.cpp
+++ b/SHADE_Engine/src/Engine/SHEngine.cpp
@@ -1,2 +1 @@
-#include "SHpch.h"
-#include "SHEngine.h"
\ No newline at end of file
+#include "SHpch.h"
\ No newline at end of file
diff --git a/SHADE_Engine/src/Engine/SHEngine.h b/SHADE_Engine/src/Engine/SHEngine.h
index 7d723425..87e1e28d 100644
--- a/SHADE_Engine/src/Engine/SHEngine.h
+++ b/SHADE_Engine/src/Engine/SHEngine.h
@@ -1,9 +1,39 @@
-#pragma once
+#ifndef SH_ENGINE_H
+#define SH_ENGINE_H
+
+#include
+#include "Meta/SHIsDetected.h"
namespace SHADE
{
- class SHEngine
- {
-
- };
-}
\ No newline at end of file
+ template
+ using GetInit_t = decltype (std::declval().Initialize());
+
+ template
+ using GetUpdate_t = decltype (std::declval().Update());
+
+ template
+ using GetExit_t = decltype (std::declval().Exit());
+
+
+ class SHEngine
+ {
+
+ public:
+ template
+ static void Run(void)
+ {
+ static_assert(SHIsDetected::value, "Init Not Detected");
+ static_assert(SHIsDetected::value, "Update Not Detected");
+ static_assert(SHIsDetected::value, "Exit Not Detected");
+
+ static Application application;
+
+ application.Initialize();
+ application.Update();
+ application.Exit();
+ };
+ };
+};
+
+#endif
diff --git a/SHADE_Engine/src/Meta/SHIsDetected.h b/SHADE_Engine/src/Meta/SHIsDetected.h
new file mode 100644
index 00000000..2e945786
--- /dev/null
+++ b/SHADE_Engine/src/Meta/SHIsDetected.h
@@ -0,0 +1,25 @@
+#ifndef SH_HAS_MEMBER_H
+#define SH_HAS_MEMBER_H
+
+#include
+
+namespace SHADE
+{
+ template typename InvocationCheckAlias, typename EvaluatedVoid, typename... ICAArgs>
+ struct IsDetected : std::false_type
+ {
+ using value = std::false_type;
+ };
+
+ template typename InvocationCheckAlias, typename... ICAArgs>
+ struct IsDetected>, ICAArgs...> : std::true_type
+ {
+ using value = std::true_type;
+ };
+
+ template typename InvocationCheckAlias, typename... ICAArgs>
+ using SHIsDetected = typename IsDetected ::value;
+
+}
+
+#endif
diff --git a/SHADE_Engine/src/Scene/SHScene.h b/SHADE_Engine/src/Scene/SHScene.h
new file mode 100644
index 00000000..18aeffdc
--- /dev/null
+++ b/SHADE_Engine/src/Scene/SHScene.h
@@ -0,0 +1,44 @@
+/*********************************************************************
+ * \file SHScene.h
+ * \author Daniel Chua Yee Chen
+ * \brief Declaration for the SHScene abstract base class
+ *
+ * \copyright Copyright (c) 2021 DigiPen Institute of Technology. Reproduction
+ or disclosure of this file or its contents without the prior written
+ consent of DigiPen Institute of Technology is prohibited.
+ *********************************************************************/
+
+#ifndef SH_SCENE_H
+#define SH_SCENE_H
+
+#include
+
+namespace SHADE
+{
+
+ class SHScene
+ {
+ private:
+
+ protected:
+
+ SHScene() = default;
+
+ public:
+ std::string sceneName;
+
+ virtual ~SHScene() = default;
+
+ virtual void Load() = 0;
+ virtual void Init() = 0;
+ virtual void Update(float dt) = 0;
+ virtual void Render() = 0;
+ virtual void Free() = 0;
+ virtual void Unload() = 0;
+ };
+
+
+}
+
+
+#endif
diff --git a/SHADE_Engine/src/Scene/SHSceneManager.cpp b/SHADE_Engine/src/Scene/SHSceneManager.cpp
new file mode 100644
index 00000000..ba2eafc2
--- /dev/null
+++ b/SHADE_Engine/src/Scene/SHSceneManager.cpp
@@ -0,0 +1,148 @@
+/*********************************************************************
+ * \file SHSceneManager.cpp
+ * \author Daniel Chua Yee Chen
+ * \brief Definition of functions for the SHSceneManager class
+ * This class handles the changing of game scenes.
+ *
+ * \copyright Copyright (c) 2021 DigiPen Institute of Technology. Reproduction
+ or disclosure of this file or its contents without the prior written
+ consent of DigiPen Institute of Technology is prohibited.
+ *********************************************************************/
+#include "SHpch.h"
+#include "SHSceneManager.h"
+#include "Engine/ECS_Base/System/SHComponentManager.h"
+//#include "Input/SHInputManager.h"
+//#include "Engine/Rendering/Window/SHRenderingWindow.h"
+#include "Engine/ECS_Base/System/SHEntityManager.h"
+#include "Engine/ECS_Base/System/SHSystemManager.h"
+//#include "FRC/SHFrameRateController.h"
+//#include "ECS_Base/System/SHApplication.h"
+
+
+#include
+namespace SHADE
+{
+ bool SHSceneManager::quit = false;
+ bool SHSceneManager::sceneChanged = false;
+ bool SHSceneManager::prevSceneReload = false;
+ bool SHSceneManager::cleanReload = false;
+ std::string SHSceneManager::newSceneName{};
+ uint32_t SHSceneManager::currentSceneID = UINT32_MAX;
+ uint32_t SHSceneManager::nextSceneID = UINT32_MAX;
+
+
+ SHScene* SHSceneManager::currentScene = nullptr;
+ //SHScene* SHSceneManager::nextScene = nullptr;
+
+ std::function SHSceneManager::newScene = []() {};
+ //void (*SHSceneManager::prevSceneCreate)() = []() {};
+
+ void SHSceneManager::UpdateSceneManager() noexcept
+ {
+ if (sceneChanged == false)
+ {
+ return;
+ }
+ sceneChanged = false;
+ if (nextSceneID != currentSceneID)
+ {
+ if (currentScene)
+ {
+ currentScene->Free();
+ currentScene->Unload();
+ SHEntityManager::DestroyAllEntity();
+ delete currentScene;
+
+ }
+ if (!prevSceneReload)
+ {
+ newScene();
+ }
+ else
+ {
+ //prevSceneCreate();
+
+ void (*temp)();
+ //temp = prevSceneCreate;
+ //prevSceneCreate = newScene;
+ newScene = temp;
+ prevSceneReload = false;
+ }
+
+
+ //prevSceneID = currentSceneID;
+ currentSceneID = nextSceneID;
+
+ nextSceneID = UINT32_MAX;
+ if (currentScene != nullptr)
+ {
+ currentScene->Load();
+ currentScene->Init();
+ }
+
+ }
+ else // restarting scene
+ {
+ nextSceneID = UINT32_MAX;
+
+ currentScene->Free();
+ if (cleanReload == true)
+ {
+ cleanReload = false;
+ currentScene->Unload();
+ SHEntityManager::DestroyAllEntity();
+ currentScene->sceneName = newSceneName;
+ currentScene->Load();
+ }
+ else
+ SHEntityManager::DestroyAllEntity();
+
+ currentScene->Init();
+ }
+ }
+
+ void SHSceneManager::RestartScene(std::string const& sceneName) noexcept
+ {
+ if (currentScene->sceneName != sceneName)
+ {
+ cleanReload = true;
+ newSceneName = sceneName;
+ }
+ else
+ cleanReload = false;
+
+ nextSceneID = currentSceneID;
+ sceneChanged = true;
+ }
+
+ void SHSceneManager::RestartScene() noexcept
+ {
+ cleanReload = false;
+ nextSceneID = currentSceneID;
+ sceneChanged = true;
+ }
+
+ void SHSceneManager::SceneUpdate(float dt) noexcept
+ {
+ currentScene->Update(dt);
+ //currentScene->Update(0.016);
+ }
+
+ void SHSceneManager::SceneRender() noexcept
+ {
+ currentScene->Render();
+ }
+
+ void SHSceneManager::Exit() noexcept
+ {
+ currentScene->Free();
+ currentScene->Unload();
+ SHEntityManager::DestroyAllEntity();
+ delete currentScene;
+ }
+
+ std::string SHSceneManager::GetSceneName() noexcept
+ {
+ return currentScene->sceneName;
+ }
+}
diff --git a/SHADE_Engine/src/Scene/SHSceneManager.h b/SHADE_Engine/src/Scene/SHSceneManager.h
new file mode 100644
index 00000000..6e5caa37
--- /dev/null
+++ b/SHADE_Engine/src/Scene/SHSceneManager.h
@@ -0,0 +1,160 @@
+/*********************************************************************
+ * \file SHSceneManager.h
+ * \author Daniel Chua Yee Chen
+ * \brief Declaration for the SHSceneManager class
+ * This class handles the changing of game scenes.
+ *
+ * \copyright Copyright (c) 2021 DigiPen Institute of Technology. Reproduction
+ or disclosure of this file or its contents without the prior written
+ consent of DigiPen Institute of Technology is prohibited.
+ *********************************************************************/
+
+#ifndef SH_SCENE_MANAGER_H
+#define SH_SCENE_MANAGER_H
+
+
+#include "Engine/ECS_Base/General/SHFamily.h"
+#include "SHScene.h"
+#include
+
+namespace SHADE
+{
+
+ class SHSceneManager
+ {
+ private:
+ //boolean to check if the scene has been changed
+ static bool sceneChanged;
+
+ //boolean to toggle to reload scene previous scene
+ static bool prevSceneReload;
+
+ //boolean to toggle reload scene while calling Load and Unload.
+ static bool cleanReload;
+
+ //The sceneID of the current scene
+ static uint32_t currentSceneID;
+ //The sceneID of the next scene
+ static uint32_t nextSceneID;
+
+ //The sceneID of the previous scene(DISABLED)
+ //static uint32_t prevSceneID;
+
+ //pointer to the current scene
+ static SHScene* currentScene;
+
+ //Used in reloading scene.
+ static std::string newSceneName;
+
+ //function pointer to store the new scene creation
+ static std::functionnewScene;
+
+ //function pointer that stores the creation of the previous scene. (DISABLED)
+ //static void(*prevSceneCreate)();
+ protected:
+
+ public:
+ //boolean to check if the programme has been terminated.
+ static bool quit;
+
+ /*!*************************************************************************
+ * \brief
+ * Initialize scene manager and loads a default scene
+ * @tparam T
+ * The type of the default scene
+ *
+ * \return
+ * None.
+ ***************************************************************************/
+ template
+ static std::enable_if_t, void> InitSceneManager(std::string const& sceneName) noexcept
+ {
+ //prevSceneCreate = newScene;
+ newScene = [sceneName]() { currentScene = new T(); currentScene->sceneName = sceneName; };
+ nextSceneID = SHFamilyID::template GetID();
+
+ sceneChanged = true;
+ }
+
+ /*!*************************************************************************
+ * \brief
+ * Change the next scene to a specified scene
+ * @tparam T
+ * The type of the next scene.
+ * \return
+ * None.
+ ***************************************************************************/
+ template
+ static std::enable_if_t, void> ChangeScene(std::string const& sceneName) noexcept
+ {
+ //check if this new Scene is current Scene (Use RestartScene instead)
+ if (currentSceneID == SHFamilyID::template GetID())
+ {
+ return;
+ }
+ //prevSceneCreate = newScene;
+ newScene = [sceneName]() { currentScene = new T(); currentScene->sceneName; };
+ nextSceneID = SHFamilyID::template GetID();
+ sceneChanged = true;
+ }
+
+
+ /*!*************************************************************************
+ * \brief
+ * Checks if the scene has to be change and Updates the
+ * scenemanager accordingly
+ ***************************************************************************/
+ static void UpdateSceneManager() noexcept;
+
+ /*!*************************************************************************
+ * \brief
+ * Calls the cuurrent scene to run the Update function
+ ***************************************************************************/
+ static void SceneUpdate(float dt) noexcept;
+
+ /*!*************************************************************************
+ * \brief
+ * Calls the current scene to run the Render function
+ ***************************************************************************/
+ static void SceneRender() noexcept;
+
+ /*!*************************************************************************
+ * \brief
+ * Restarts current scene. Only Scene::Init() and Scene::Free()
+ * Scene::Load() and Scene::Unload() will not be called.
+ * Edit: allows for RestartScene to restart the scene with a different
+ * scene name.
+ * If a sceneName is different from the current one, Load and Unload will
+ * run.
+ ***************************************************************************/
+ static void RestartScene(std::string const& sceneName ) noexcept;
+
+ /*!*************************************************************************
+ * \brief
+ * Restarts current scene. Only Scene::Init() and Scene::Free()
+ * Scene::Load() and Scene::Unload() will not be called.
+ * Reuse current scene name and Unload and Load will not run.
+ ***************************************************************************/
+ static void RestartScene() noexcept;
+
+ /*!*************************************************************************
+ * \brief
+ * Change the scene to the previous scene (DISABLED)
+ ***************************************************************************/
+ //static void ReloadPrevScene() noexcept;
+
+ /*!*************************************************************************
+ * \brief
+ * Cleans up memory usued by the SceneManager.
+ ***************************************************************************/
+ static void Exit() noexcept;
+
+ static std::string GetSceneName() noexcept;
+
+ };
+
+
+}
+
+
+#endif