diff --git a/src/kiwano/platform/win32/WindowImpl.cpp b/src/kiwano/platform/win32/WindowImpl.cpp index f6fe696f..be5ae065 100644 --- a/src/kiwano/platform/win32/WindowImpl.cpp +++ b/src/kiwano/platform/win32/WindowImpl.cpp @@ -668,7 +668,7 @@ LRESULT WindowWin32Impl::MessageProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA if (is_fullscreen_) { // TODO restore to fullscreen mode - // Renderer::GetInstance().SetResolution(); + // SetResolution(); } } break; @@ -705,7 +705,17 @@ LRESULT WindowWin32Impl::MessageProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA { KGE_SYS_LOG("The display resolution has changed"); - ::InvalidateRect(hwnd, NULL, FALSE); + // Check fullscreen state + auto d3d_res = graphics::directx::GetD3DDeviceResources(); + auto swap_chain = d3d_res->GetDXGISwapChain(); + if (swap_chain) + { + BOOL is_fullscreen = FALSE; + if (SUCCEEDED(swap_chain->GetFullscreenState(&is_fullscreen, nullptr))) + { + is_fullscreen_ = !!is_fullscreen; + } + } } break; diff --git a/src/kiwano/render/Renderer.cpp b/src/kiwano/render/Renderer.cpp index be2226b2..a95d65d4 100644 --- a/src/kiwano/render/Renderer.cpp +++ b/src/kiwano/render/Renderer.cpp @@ -44,11 +44,7 @@ void Renderer::DestroyModule() void Renderer::HandleEvent(Event* evt) { - if (evt->IsType()) - { - auto window_evt = dynamic_cast(evt); - Resize(window_evt->width, window_evt->height); - } + // DO NOTHING } void Renderer::BeginDraw() diff --git a/src/kiwano/render/Renderer.h b/src/kiwano/render/Renderer.h index 68077fa1..a42b3c7c 100644 --- a/src/kiwano/render/Renderer.h +++ b/src/kiwano/render/Renderer.h @@ -55,6 +55,18 @@ public: /// @brief 获取清屏颜色 virtual Color GetClearColor() const; + /// \~chinese + /// @brief 获取渲染输出大小 + Size GetOutputSize() const; + + /// \~chinese + /// @brief 获取渲染上下文 + RenderContext& GetContext(); + + /// \~chinese + /// @brief 重设渲染输出大小 + virtual void Resize(uint32_t width, uint32_t height) = 0; + /// \~chinese /// @brief 设置清屏颜色 virtual void SetClearColor(const Color& clear_color); @@ -206,14 +218,6 @@ public: virtual RenderContextPtr CreateTextureRenderContext(Texture& texture, const Size* desired_size = nullptr) = 0; public: - /// \~chinese - /// @brief 获取渲染上下文 - RenderContext& GetContext(); - - /// \~chinese - /// @brief 获取渲染输出大小 - Size GetOutputSize() const; - /// \~chinese /// @brief 开始渲染 virtual void BeginDraw(); @@ -231,10 +235,6 @@ public: /// @throw kiwano::SystemError 呈现失败时抛出 virtual void Present() = 0; - /// \~chinese - /// @brief 重设渲染输出大小 - virtual void Resize(uint32_t width, uint32_t height) = 0; - public: void SetupModule() override;