diff --git a/Hazelnut/src/EditorLayer.cpp b/Hazelnut/src/EditorLayer.cpp index f2df1e74a..34bcdd947 100644 --- a/Hazelnut/src/EditorLayer.cpp +++ b/Hazelnut/src/EditorLayer.cpp @@ -40,6 +40,15 @@ namespace Hazel { { HZ_PROFILE_FUNCTION(); + // Resize + if (Hazel::FramebufferSpecification spec = m_Framebuffer->GetSpecification(); + m_ViewportSize.x > 0.0f && m_ViewportSize.y > 0.0f && // zero sized framebuffer is invalid + (spec.Width != m_ViewportSize.x || spec.Height != m_ViewportSize.y)) + { + m_Framebuffer->Resize((uint32_t)m_ViewportSize.x, (uint32_t)m_ViewportSize.y); + m_CameraController.OnResize(m_ViewportSize.x, m_ViewportSize.y); + } + // Update if (m_ViewportFocused) m_CameraController.OnUpdate(ts); @@ -146,13 +155,8 @@ namespace Hazel { Application::Get().GetImGuiLayer()->BlockEvents(!m_ViewportFocused || !m_ViewportHovered); ImVec2 viewportPanelSize = ImGui::GetContentRegionAvail(); - if (m_ViewportSize != *((glm::vec2*)&viewportPanelSize) && viewportPanelSize.x > 0 && viewportPanelSize.y > 0) - { - m_Framebuffer->Resize((uint32_t)viewportPanelSize.x, (uint32_t)viewportPanelSize.y); - m_ViewportSize = { viewportPanelSize.x, viewportPanelSize.y }; + m_ViewportSize = { viewportPanelSize.x, viewportPanelSize.y }; - m_CameraController.OnResize(viewportPanelSize.x, viewportPanelSize.y); - } uint32_t textureID = m_Framebuffer->GetColorAttachmentRendererID(); ImGui::Image((void*)textureID, ImVec2{ m_ViewportSize.x, m_ViewportSize.y }, ImVec2{ 0, 1 }, ImVec2{ 1, 0 }); ImGui::End(); @@ -166,4 +170,4 @@ namespace Hazel { m_CameraController.OnEvent(e); } -} \ No newline at end of file +}