Graphics System called in application

This commit is contained in:
Brandon Mak 2022-09-09 11:20:38 +08:00
parent ae8e30f120
commit fe6c5be8c6
6 changed files with 54 additions and 15 deletions

View File

@ -59,8 +59,8 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>SBpch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\Dependencies\spdlog\include;..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NOMINMAX;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\Dependencies\spdlog\include;$(VULKAN_SDK)\include;..\Dependencies\VMA\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
@ -79,8 +79,8 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>SBpch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\Dependencies\spdlog\include;..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NOMINMAX;_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\Dependencies\spdlog\include;$(VULKAN_SDK)\include;..\Dependencies\VMA\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>

View File

@ -22,6 +22,9 @@ project "SHADE_Application"
includedirs
{
"%{IncludeDir.spdlog}/include",
"%{IncludeDir.VULKAN}/include",
"%{IncludeDir.VMA}/include",
"%{IncludeDir.VULKAN}/Source/SPIRV-Reflect",
"../SHADE_Engine/src",
"src"
}
@ -39,6 +42,11 @@ project "SHADE_Application"
postbuildcommands
{
}
defines
{
"NOMINMAX"
}
warnings 'Extra'

View File

@ -1,5 +1,6 @@
#include "SBpch.h"
#include "SBApplication.h"
#include "Engine/ECS_Base/System/SHSystemManager.h"
#ifdef SHEDITOR
#include "Editor/SHEditor.h"
@ -23,6 +24,11 @@ namespace Sandbox
{
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
SHADE::SHSystemManager::CreateSystem<SHADE::SHGraphicsSystem>("Graphics System");
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem("Graphics System"));
graphicsSystem->SetWindow(&window);
SHADE::SHSystemManager::Init();
#ifdef SHEDITOR
#else
@ -44,6 +50,8 @@ namespace Sandbox
void SBApplication::Exit(void)
{
SHADE::SHSystemManager::Exit();
#ifdef SHEDITOR
#else
#endif

View File

@ -1,6 +1,7 @@
#ifndef SB_APPLICATION_H
#define SB_APPLICATION_H
#include <Graphics/Windowing/SHWindow.h>
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
//using namespace SHADE;
namespace Sandbox

View File

@ -25,11 +25,8 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
/* Constructor/Destructors */
/*---------------------------------------------------------------------------------*/
SHGraphicsSystem::SHGraphicsSystem(SHWindow& window)
void SHGraphicsSystem::Init(void)
{
// Save the SHWindow
this->window = &window;
// Set Up Instance
SHVkInstance::Init(true, true, true);
@ -39,10 +36,10 @@ namespace SHADE
device = SHVkInstance::CreateLogicalDevice({ SHQueueParams(SH_Q_FAM::GRAPHICS, SH_QUEUE_SELECT::DEDICATED), SHQueueParams(SH_Q_FAM::TRANSFER, SH_QUEUE_SELECT::DEDICATED) }, physicalDevice);
// Construct surface
surface = device->CreateSurface(window.GetHWND());
surface = device->CreateSurface(window->GetHWND());
// Construct Swapchain
auto windowDims = window.GetWindowSize();
auto windowDims = window->GetWindowSize();
swapchain = device->CreateSwapchain(surface, windowDims.first, windowDims.second, SHSwapchainParams
{
.surfaceImageFormats {vk::Format::eB8G8R8A8Unorm, vk::Format::eR8G8B8A8Unorm, vk::Format::eB8G8R8Unorm, vk::Format::eR8G8B8Unorm},
@ -51,7 +48,7 @@ namespace SHADE
.vsyncOn = false, // TODO: Set to true when shipping game
});
window.RegisterWindowSizeCallback([&]([[maybe_unused]] uint32_t width, [[maybe_unused]] uint32_t height)
window->RegisterWindowSizeCallback([&]([[maybe_unused]] uint32_t width, [[maybe_unused]] uint32_t height)
{
renderContext.SetIsResized(true);
});
@ -127,7 +124,13 @@ namespace SHADE
/* RENDERGRAPH END TESTING */
/*-----------------------------------------------------------------------*/
}
SHGraphicsSystem::~SHGraphicsSystem()
void SHGraphicsSystem::Run(float dt)
{
}
void SHGraphicsSystem::Exit(void)
{
//renderPass.Free();
renderContext.Destroy();
@ -235,4 +238,10 @@ namespace SHADE
void SHGraphicsSystem::RemoveSegment(Handle<SHScreenSegment> segment)
{
}
void SHGraphicsSystem::SetWindow(SHWindow* wind) noexcept
{
window = wind;
}
}

View File

@ -21,6 +21,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/SHVulkanIncludes.h"
#include "Graphics/MiddleEnd/PerFrame/SHRenderContext.h"
#include "Graphics/RenderGraph/SHRenderGraph.h"
#include "Engine/ECS_Base/System/SHSystem.h"
namespace SHADE
{
@ -61,7 +62,7 @@ namespace SHADE
portions of the screen.
*/
/***********************************************************************************/
class SHGraphicsSystem
class SHGraphicsSystem : public SHSystem
{
public:
/*-----------------------------------------------------------------------------*/
@ -72,8 +73,15 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
/* Constructor/Destructors */
/*-----------------------------------------------------------------------------*/
SHGraphicsSystem(SHWindow& window);
~SHGraphicsSystem();
SHGraphicsSystem (void) = default;
~SHGraphicsSystem(void) noexcept = default;
/*-----------------------------------------------------------------------------*/
/* SHSystem overrides */
/*-----------------------------------------------------------------------------*/
virtual void Init(void) override;
virtual void Run (float dt) override;
virtual void Exit(void) override;
/*-----------------------------------------------------------------------------*/
/* Lifecycle Functions */
@ -93,6 +101,11 @@ namespace SHADE
Handle<SHScreenSegment> AddSegment(const VkViewport& viewport, Handle<SHVkImage> imageToUse);
void RemoveSegment(Handle<SHScreenSegment> segment);
/*-----------------------------------------------------------------------------*/
/* Setters */
/*-----------------------------------------------------------------------------*/
void SetWindow (SHWindow* wind) noexcept;
/*-----------------------------------------------------------------------------*/
/* Getters (Temporary) */
/*-----------------------------------------------------------------------------*/