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"}
excludes
{
"%{prj.location}/src/Editor/**.cpp",
"%{prj.location}/src/Editor/**.h",
"%{prj.location}/src/Editor/**.hpp",
-- "%{prj.location}/src/Editor/**.cpp",
-- "%{prj.location}/src/Editor/**.h",
-- "%{prj.location}/src/Editor/**.hpp",
}
links{"fmodstudio_vc.lib", "fmod_vc.lib"}

View File

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

View File

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

View File

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

View File

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

View File

@ -125,6 +125,7 @@ namespace SHADE
CALLBACKID RegisterWindowSizeCallback(WindowResizeCallbackFn);
void UnregisterWindowSizeCallback(CALLBACKID const& callbackid);
bool IsMinimized() const { return wndData.isMinimised; }
protected:
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 OnPosChange(LPWINDOWPOS pos);
void OnPaint(HDC hdc, LPPAINTSTRUCT paint);
bool IsMinimized() const { return wndData.isMinimised; }
};
static SHWindowMap windowMap;
static SHWindow* windowBeingCreated = nullptr;

View File

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