From 8563ecb7e8695d50bb0e18750c9e37309af451c5 Mon Sep 17 00:00:00 2001 From: Xiao Qi Date: Thu, 8 Sep 2022 11:48:32 +0800 Subject: [PATCH 1/2] Imported Application, Engine, Scene Manager, Test Scene from 200 --- SHADE_Application/SHADE_Application.vcxproj | 4 + .../src/Application/SBApplication.cpp | 43 +++++ .../src/Application/SBApplication.h | 23 +++ SHADE_Application/src/Scenes/SBTestScene.cpp | 48 ++++++ SHADE_Application/src/Scenes/SBTestScene.h | 29 ++++ SHADE_Application/src/WinMain.cpp | 22 +++ SHADE_Engine/SHADE_Engine.vcxproj | 4 + SHADE_Engine/SHADE_Engine.vcxproj.filters | 95 ++++++++--- SHADE_Engine/src/Engine/SHEngine.cpp | 3 +- SHADE_Engine/src/Engine/SHEngine.h | 42 ++++- SHADE_Engine/src/Meta/SHIsDetected.h | 25 +++ SHADE_Engine/src/Scene/SHScene.h | 44 +++++ SHADE_Engine/src/Scene/SHSceneManager.cpp | 148 ++++++++++++++++ SHADE_Engine/src/Scene/SHSceneManager.h | 160 ++++++++++++++++++ 14 files changed, 663 insertions(+), 27 deletions(-) create mode 100644 SHADE_Application/src/Application/SBApplication.cpp create mode 100644 SHADE_Application/src/Application/SBApplication.h create mode 100644 SHADE_Application/src/Scenes/SBTestScene.cpp create mode 100644 SHADE_Application/src/Scenes/SBTestScene.h create mode 100644 SHADE_Engine/src/Meta/SHIsDetected.h create mode 100644 SHADE_Engine/src/Scene/SHScene.h create mode 100644 SHADE_Engine/src/Scene/SHSceneManager.cpp create mode 100644 SHADE_Engine/src/Scene/SHSceneManager.h 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..385d7b88 --- /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]]GLFWwindow* 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..22df2e4d --- /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(GLFWwindow* 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