Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	Hazelnut/src/EditorLayer.cpp
  • Loading branch information
TheCherno committed Jul 21, 2020
2 parents c8a8651 + 3d3537d commit 5aff96f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Hazelnut/src/EditorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -166,4 +170,4 @@ namespace Hazel {
m_CameraController.OnEvent(e);
}

}
}

0 comments on commit 5aff96f

Please sign in to comment.