Added Application class equivalent to SHADE_Managed
This commit is contained in:
parent
5eaf2b55aa
commit
66529474cd
|
@ -15,7 +15,7 @@
|
||||||
#include "ECS_Base/System/SHSystemRoutine.h"
|
#include "ECS_Base/System/SHSystemRoutine.h"
|
||||||
#include "Resource/SHHandle.h"
|
#include "Resource/SHHandle.h"
|
||||||
#include "EditorWindow/SHEditorWindow.h"
|
#include "EditorWindow/SHEditorWindow.h"
|
||||||
#include "Tools/SHLogger.h"
|
#include "Tools/SHLog.h"
|
||||||
#include "Gizmos/SHTransformGizmo.h"
|
#include "Gizmos/SHTransformGizmo.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SHLOG_WARNING("Attempt to create duplicate of Editor window type")
|
SHLog::Warning("Attempt to create duplicate of Editor window type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file SHGraphicsSystemInterface.cpp
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Oct 31, 2022
|
||||||
|
\brief Contains the definitions of the functions of the static
|
||||||
|
SHGraphicsSystemInterface class.
|
||||||
|
|
||||||
|
Copyright (C) 2022 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.
|
||||||
|
*//*************************************************************************************/
|
||||||
|
// Precompiled Headers
|
||||||
|
#include "SHpch.h"
|
||||||
|
// Primary Header
|
||||||
|
#include "SHGraphicsSystemInterface.h"
|
||||||
|
// Project Includes
|
||||||
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
|
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
||||||
|
#include "Graphics/Windowing/SHWindow.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/* Static Usage Functions */
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
uint32_t SHGraphicsSystemInterface::GetWindowWidth()
|
||||||
|
{
|
||||||
|
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
|
if (gfxSystem)
|
||||||
|
{
|
||||||
|
const auto WND = gfxSystem->GetWindow();
|
||||||
|
return WND->GetWindowSize().first;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHLOG_WARNING("[SHGraphicsSystemInterface] Failed to get window width. Value of 0 returned instead.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t SHGraphicsSystemInterface::GetWindowHeight()
|
||||||
|
{
|
||||||
|
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
|
if (gfxSystem)
|
||||||
|
{
|
||||||
|
const auto WND = gfxSystem->GetWindow();
|
||||||
|
return WND->GetWindowSize().second;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHLOG_WARNING("[SHGraphicsSystemInterface] Failed to get window height. Value of 0 returned instead.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SHGraphicsSystemInterface::IsFullscreen()
|
||||||
|
{
|
||||||
|
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
|
if (gfxSystem)
|
||||||
|
{
|
||||||
|
const auto WND = gfxSystem->GetWindow();
|
||||||
|
return WND->GetWindowData().isFullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHLOG_WARNING("[SHGraphicsSystemInterface] Failed to get window fullscreen status. Value of false returned instead.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsSystemInterface::CloseWindow()
|
||||||
|
{
|
||||||
|
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
|
if (gfxSystem)
|
||||||
|
{
|
||||||
|
auto WND = gfxSystem->GetWindow();
|
||||||
|
return WND->Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
SHLOG_WARNING("[SHGraphicsSystemInterface] Failed to close window.");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file SHGraphicsSystemInterface.h
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Oct 31, 2022
|
||||||
|
\brief Contains the definition of the SHGraphicsSystemInterface static class.
|
||||||
|
|
||||||
|
Copyright (C) 2022 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.
|
||||||
|
*//*************************************************************************************/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Static class that wraps up certain functions in the SHGraphicsSystem so that
|
||||||
|
/// accessing it from SHADE_Managed would not cause issues due to C++20 features.
|
||||||
|
/// </summary>
|
||||||
|
class SH_API SHGraphicsSystemInterface final
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Constructor */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
SHGraphicsSystemInterface() = delete;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Static Usage Functions */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the current window width.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The current window width.</returns>
|
||||||
|
static uint32_t GetWindowWidth();
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the current window height.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The current window height.</returns>
|
||||||
|
static uint32_t GetWindowHeight();
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the current window fullscreen status.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The current window fullscreen status..</returns>
|
||||||
|
static bool IsFullscreen();
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the current window, and depending on the implementation, should also
|
||||||
|
/// close the application.
|
||||||
|
/// </summary>
|
||||||
|
static void CloseWindow();
|
||||||
|
};
|
||||||
|
}
|
|
@ -9,7 +9,7 @@ Copyright (C) 2022 DigiPen Institute of Technology.
|
||||||
Reproduction or disclosure of this file or its contents without the prior written consent
|
Reproduction or disclosure of this file or its contents without the prior written consent
|
||||||
of DigiPen Institute of Technology is prohibited.
|
of DigiPen Institute of Technology is prohibited.
|
||||||
*//*************************************************************************************/
|
*//*************************************************************************************/
|
||||||
|
#pragma once
|
||||||
// Standard Library
|
// Standard Library
|
||||||
#include <string>
|
#include <string>
|
||||||
// Project Headers
|
// Project Headers
|
||||||
|
|
|
@ -25,11 +25,16 @@ project "SHADE_Managed"
|
||||||
includedirs
|
includedirs
|
||||||
{
|
{
|
||||||
"%{prj.location}/src",
|
"%{prj.location}/src",
|
||||||
|
}
|
||||||
|
|
||||||
|
externalincludedirs
|
||||||
|
{
|
||||||
"%{IncludeDir.spdlog}/include",
|
"%{IncludeDir.spdlog}/include",
|
||||||
"%{IncludeDir.imgui}",
|
"%{IncludeDir.imgui}",
|
||||||
"%{IncludeDir.imguizmo}",
|
"%{IncludeDir.imguizmo}",
|
||||||
"%{IncludeDir.imnodes}",
|
"%{IncludeDir.imnodes}",
|
||||||
"%{IncludeDir.yamlcpp}",
|
"%{IncludeDir.yamlcpp}",
|
||||||
|
"%{IncludeDir.SDL}\\include",
|
||||||
"%{IncludeDir.RTTR}/include",
|
"%{IncludeDir.RTTR}/include",
|
||||||
"%{IncludeDir.dotnet}\\include",
|
"%{IncludeDir.dotnet}\\include",
|
||||||
"%{IncludeDir.reactphysics3d}\\include",
|
"%{IncludeDir.reactphysics3d}\\include",
|
||||||
|
@ -38,13 +43,16 @@ project "SHADE_Managed"
|
||||||
|
|
||||||
libdirs
|
libdirs
|
||||||
{
|
{
|
||||||
"%{IncludeDir.RTTR}/lib"
|
"%{IncludeDir.RTTR}/lib",
|
||||||
|
"%{IncludeDir.SDL}/lib"
|
||||||
}
|
}
|
||||||
|
|
||||||
links
|
links
|
||||||
{
|
{
|
||||||
"yaml-cpp",
|
"yaml-cpp",
|
||||||
"imgui",
|
"imgui",
|
||||||
|
"SDL2.lib",
|
||||||
|
"SDL2main.lib",
|
||||||
"SHADE_Engine",
|
"SHADE_Engine",
|
||||||
"SHADE_CSharp"
|
"SHADE_CSharp"
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
// External Dependencies
|
// External Dependencies
|
||||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
#include "Editor/SHEditor.h"
|
#include "Editor/SHEditor.h"
|
||||||
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystemInterface.h"
|
||||||
#include "Graphics/Windowing/SHWindow.h"
|
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -47,40 +46,19 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
int Application::WindowWidth::get()
|
int Application::WindowWidth::get()
|
||||||
{
|
{
|
||||||
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
return SHGraphicsSystemInterface::GetWindowWidth();
|
||||||
if (gfxSystem)
|
|
||||||
{
|
|
||||||
const auto WND = gfxSystem->GetWindow();
|
|
||||||
return WND->GetWindowSize().first;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw gcnew System::InvalidOperationException("Unable to get current window width!");
|
|
||||||
}
|
}
|
||||||
int Application::WindowHeight::get()
|
int Application::WindowHeight::get()
|
||||||
{
|
{
|
||||||
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
return SHGraphicsSystemInterface::GetWindowWidth();
|
||||||
if (gfxSystem)
|
|
||||||
{
|
|
||||||
const auto WND = gfxSystem->GetWindow();
|
|
||||||
return WND->GetWindowSize().second;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw gcnew System::InvalidOperationException("Unable to get current window height!");
|
|
||||||
}
|
}
|
||||||
bool Application::IsFullscreen::get()
|
bool Application::IsFullscreen::get()
|
||||||
{
|
{
|
||||||
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
return SHGraphicsSystemInterface::IsFullscreen();
|
||||||
if (gfxSystem)
|
|
||||||
{
|
|
||||||
const auto WND = gfxSystem->GetWindow();
|
|
||||||
return WND->GetWindowData().isFullscreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw gcnew System::InvalidOperationException("Unable to get current window height!");
|
|
||||||
}
|
}
|
||||||
/*void Application::IsFullscreen::set(bool value)
|
/*void Application::IsFullscreen::set(bool value)
|
||||||
{
|
{
|
||||||
return Pls::Window::SetFullScreen(value);
|
return SHGraphicsSystemInterface::SetFullscreen(value);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -88,13 +66,6 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
void Application::Quit()
|
void Application::Quit()
|
||||||
{
|
{
|
||||||
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
SHGraphicsSystemInterface::CloseWindow();
|
||||||
if (gfxSystem)
|
|
||||||
{
|
|
||||||
auto WND = gfxSystem->GetWindow();
|
|
||||||
return WND->Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
throw gcnew System::InvalidOperationException("Unable to quit!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue