diff --git a/SHADE_Engine/src/Editor/SHEditor.h b/SHADE_Engine/src/Editor/SHEditor.h index 34405390..624069db 100644 --- a/SHADE_Engine/src/Editor/SHEditor.h +++ b/SHADE_Engine/src/Editor/SHEditor.h @@ -15,7 +15,7 @@ #include "ECS_Base/System/SHSystemRoutine.h" #include "Resource/SHHandle.h" #include "EditorWindow/SHEditorWindow.h" -#include "Tools/SHLogger.h" +#include "Tools/SHLog.h" #include "Gizmos/SHTransformGizmo.h" @@ -76,7 +76,7 @@ namespace SHADE } else { - SHLOG_WARNING("Attempt to create duplicate of Editor window type") + SHLog::Warning("Attempt to create duplicate of Editor window type"); } } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystemInterface.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystemInterface.cpp new file mode 100644 index 00000000..1ad46e04 --- /dev/null +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystemInterface.cpp @@ -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(); + 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(); + 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(); + 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(); + if (gfxSystem) + { + auto WND = gfxSystem->GetWindow(); + return WND->Close(); + } + + SHLOG_WARNING("[SHGraphicsSystemInterface] Failed to close window."); + } +} diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystemInterface.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystemInterface.h new file mode 100644 index 00000000..5bc77ed9 --- /dev/null +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystemInterface.h @@ -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 +{ + /// + /// 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. + /// + class SH_API SHGraphicsSystemInterface final + { + public: + /*---------------------------------------------------------------------------------*/ + /* Constructor */ + /*---------------------------------------------------------------------------------*/ + SHGraphicsSystemInterface() = delete; + + /*---------------------------------------------------------------------------------*/ + /* Static Usage Functions */ + /*---------------------------------------------------------------------------------*/ + /// + /// Retrieves the current window width. + /// + /// The current window width. + static uint32_t GetWindowWidth(); + /// + /// Retrieves the current window height. + /// + /// The current window height. + static uint32_t GetWindowHeight(); + /// + /// Retrieves the current window fullscreen status. + /// + /// The current window fullscreen status.. + static bool IsFullscreen(); + /// + /// Closes the current window, and depending on the implementation, should also + /// close the application. + /// + static void CloseWindow(); + }; +} diff --git a/SHADE_Engine/src/Tools/SHLog.h b/SHADE_Engine/src/Tools/SHLog.h index 89dd9206..91117da6 100644 --- a/SHADE_Engine/src/Tools/SHLog.h +++ b/SHADE_Engine/src/Tools/SHLog.h @@ -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 of DigiPen Institute of Technology is prohibited. *//*************************************************************************************/ - +#pragma once // Standard Library #include // Project Headers diff --git a/SHADE_Managed/premake5.lua b/SHADE_Managed/premake5.lua index 906511c1..b383f002 100644 --- a/SHADE_Managed/premake5.lua +++ b/SHADE_Managed/premake5.lua @@ -25,11 +25,16 @@ project "SHADE_Managed" includedirs { "%{prj.location}/src", + } + + externalincludedirs + { "%{IncludeDir.spdlog}/include", "%{IncludeDir.imgui}", "%{IncludeDir.imguizmo}", "%{IncludeDir.imnodes}", "%{IncludeDir.yamlcpp}", + "%{IncludeDir.SDL}\\include", "%{IncludeDir.RTTR}/include", "%{IncludeDir.dotnet}\\include", "%{IncludeDir.reactphysics3d}\\include", @@ -38,13 +43,16 @@ project "SHADE_Managed" libdirs { - "%{IncludeDir.RTTR}/lib" + "%{IncludeDir.RTTR}/lib", + "%{IncludeDir.SDL}/lib" } links { "yaml-cpp", "imgui", + "SDL2.lib", + "SDL2main.lib", "SHADE_Engine", "SHADE_CSharp" } diff --git a/SHADE_Managed/src/Engine/Application.cxx b/SHADE_Managed/src/Engine/Application.cxx index c4bce19f..c19bafa6 100644 --- a/SHADE_Managed/src/Engine/Application.cxx +++ b/SHADE_Managed/src/Engine/Application.cxx @@ -19,8 +19,7 @@ of DigiPen Institute of Technology is prohibited. // External Dependencies #include "ECS_Base/Managers/SHSystemManager.h" #include "Editor/SHEditor.h" -#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h" -#include "Graphics/Windowing/SHWindow.h" +#include "Graphics/MiddleEnd/Interface/SHGraphicsSystemInterface.h" namespace SHADE { @@ -47,40 +46,19 @@ namespace SHADE } int Application::WindowWidth::get() { - auto gfxSystem = SHSystemManager::GetSystem(); - if (gfxSystem) - { - const auto WND = gfxSystem->GetWindow(); - return WND->GetWindowSize().first; - } - - throw gcnew System::InvalidOperationException("Unable to get current window width!"); + return SHGraphicsSystemInterface::GetWindowWidth(); } int Application::WindowHeight::get() { - auto gfxSystem = SHSystemManager::GetSystem(); - if (gfxSystem) - { - const auto WND = gfxSystem->GetWindow(); - return WND->GetWindowSize().second; - } - - throw gcnew System::InvalidOperationException("Unable to get current window height!"); + return SHGraphicsSystemInterface::GetWindowWidth(); } bool Application::IsFullscreen::get() { - auto gfxSystem = SHSystemManager::GetSystem(); - if (gfxSystem) - { - const auto WND = gfxSystem->GetWindow(); - return WND->GetWindowData().isFullscreen; - } - - throw gcnew System::InvalidOperationException("Unable to get current window height!"); + return SHGraphicsSystemInterface::IsFullscreen(); } /*void Application::IsFullscreen::set(bool value) { - return Pls::Window::SetFullScreen(value); + return SHGraphicsSystemInterface::SetFullscreen(value); }*/ /*---------------------------------------------------------------------------------*/ @@ -88,13 +66,6 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ void Application::Quit() { - auto gfxSystem = SHSystemManager::GetSystem(); - if (gfxSystem) - { - auto WND = gfxSystem->GetWindow(); - return WND->Close(); - } - - throw gcnew System::InvalidOperationException("Unable to quit!"); + SHGraphicsSystemInterface::CloseWindow(); } }