Minimize is now working

This commit is contained in:
Brandon Mak 2022-10-02 00:47:26 +08:00
parent 32a3cc0674
commit 64d1c2ab2e
7 changed files with 42 additions and 4 deletions

View File

@ -156,8 +156,8 @@ project "SHADE_Engine"
links{"assimp-vc142-mt.lib", "librttr_core.lib", "spdlog.lib"} links{"assimp-vc142-mt.lib", "librttr_core.lib", "spdlog.lib"}
excludes excludes
{ {
"%{prj.location}/src/Editor/**.cpp", -- "%{prj.location}/src/Editor/**.cpp",
"%{prj.location}/src/Editor/**.h", -- "%{prj.location}/src/Editor/**.h",
"%{prj.location}/src/Editor/**.hpp", -- "%{prj.location}/src/Editor/**.hpp",
} }
links{"fmodstudio_vc.lib", "fmod_vc.lib"} links{"fmodstudio_vc.lib", "fmod_vc.lib"}

View File

@ -213,6 +213,15 @@ namespace SHADE
/***************************************************************************/ /***************************************************************************/
void SHGraphicsSystem::Run(double) noexcept void SHGraphicsSystem::Run(double) noexcept
{ {
if (window->IsMinimized())
return;
if (renderContext.GetResized())
{
return;
}
// Frame data for the current frame // Frame data for the current frame
auto const& frameData = renderContext.GetCurrentFrameData(); auto const& frameData = renderContext.GetCurrentFrameData();
uint32_t frameIndex = renderContext.GetCurrentFrame(); uint32_t frameIndex = renderContext.GetCurrentFrame();
@ -335,6 +344,9 @@ namespace SHADE
/***************************************************************************/ /***************************************************************************/
void SHGraphicsSystem::BeginRender() void SHGraphicsSystem::BeginRender()
{ {
if (window->IsMinimized())
return;
// Finalise all batches // Finalise all batches
for (auto vp : viewports) for (auto vp : viewports)
for (auto renderer : vp->GetRenderers()) for (auto renderer : vp->GetRenderers())
@ -381,6 +393,16 @@ namespace SHADE
/***************************************************************************/ /***************************************************************************/
void SHGraphicsSystem::EndRender() void SHGraphicsSystem::EndRender()
{ {
if (window->IsMinimized())
return;
if (renderContext.GetResized())
{
return;
}
const uint32_t CURR_FRAME_IDX = renderContext.GetCurrentFrame(); const uint32_t CURR_FRAME_IDX = renderContext.GetCurrentFrame();
auto& currFrameData = renderContext.GetCurrentFrameData(); auto& currFrameData = renderContext.GetCurrentFrameData();
@ -513,6 +535,9 @@ namespace SHADE
void SHGraphicsSystem::HandleResize(void) noexcept void SHGraphicsSystem::HandleResize(void) noexcept
{ {
if (window->IsMinimized())
return;
auto windowDims = window->GetWindowSize(); auto windowDims = window->GetWindowSize();
// Resize the swapchain // Resize the swapchain

View File

@ -197,6 +197,11 @@ namespace SHADE
return currentFrame; return currentFrame;
} }
bool SHRenderContext::GetResized(void) noexcept
{
return isResized;
}
bool SHRenderContext::GetResizeAndReset(void) noexcept bool SHRenderContext::GetResizeAndReset(void) noexcept
{ {
bool b = isResized; bool b = isResized;

View File

@ -56,6 +56,7 @@ namespace SHADE
SHPerFrameData& GetCurrentFrameData(void) noexcept; SHPerFrameData& GetCurrentFrameData(void) noexcept;
SHPerFrameData& GetFrameData (uint32_t index) noexcept; SHPerFrameData& GetFrameData (uint32_t index) noexcept;
uint32_t GetCurrentFrame (void) const noexcept; uint32_t GetCurrentFrame (void) const noexcept;
bool GetResized(void) noexcept;
bool GetResizeAndReset (void) noexcept; bool GetResizeAndReset (void) noexcept;
}; };

View File

@ -383,6 +383,8 @@ namespace SHADE
{ {
wndData.isMinimised = true; wndData.isMinimised = true;
} }
else
wndData.isMinimised = false;
for (auto const& entry : windowResizeCallbacks) for (auto const& entry : windowResizeCallbacks)
{ {

View File

@ -125,6 +125,7 @@ namespace SHADE
CALLBACKID RegisterWindowSizeCallback(WindowResizeCallbackFn); CALLBACKID RegisterWindowSizeCallback(WindowResizeCallbackFn);
void UnregisterWindowSizeCallback(CALLBACKID const& callbackid); void UnregisterWindowSizeCallback(CALLBACKID const& callbackid);
bool IsMinimized() const { return wndData.isMinimised; }
protected: protected:
static LRESULT CALLBACK WndProcStatic(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); static LRESULT CALLBACK WndProcStatic(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
@ -165,7 +166,6 @@ namespace SHADE
void OnSize(UINT msg, UINT type, SIZE size); void OnSize(UINT msg, UINT type, SIZE size);
void OnPosChange(LPWINDOWPOS pos); void OnPosChange(LPWINDOWPOS pos);
void OnPaint(HDC hdc, LPPAINTSTRUCT paint); void OnPaint(HDC hdc, LPPAINTSTRUCT paint);
bool IsMinimized() const { return wndData.isMinimised; }
}; };
static SHWindowMap windowMap; static SHWindowMap windowMap;
static SHWindow* windowBeingCreated = nullptr; static SHWindow* windowBeingCreated = nullptr;

View File

@ -79,3 +79,8 @@ project "SHADE_Managed"
optimize "On" optimize "On"
defines{"_RELEASE"} defines{"_RELEASE"}
links{"librttr_core.lib"} links{"librttr_core.lib"}
filter "configurations:Publish"
optimize "On"
defines{"_RELEASE"}
links{"librttr_core.lib"}