Use absolute dimensions of viewport to calculate aspect ratio. Refs #856

* On vulkan the viewport height could be negative to flip the NDC, but
  we don't care about its sign only its magnitude to calculate the
  aspect ratio.
This commit is contained in:
baldurk
2018-02-02 22:07:31 +00:00
parent 022d46ab7d
commit 477d5b6557
+6 -1
View File
@@ -3131,8 +3131,13 @@ namespace renderdocui.Windows
m_MeshDisplay.aspect = 1.0f;
Viewport vp = m_Core.CurPipelineState.GetViewport(0);
float vpWidth = Math.Abs(vp.width);
float vpHeight = Math.Abs(vp.height);
// take a guess for the aspect ratio, for if the user hasn't overridden it
m_MeshDisplay.aspect = m_Core.CurPipelineState.GetViewport(0).width / m_Core.CurPipelineState.GetViewport(0).height;
m_MeshDisplay.aspect = (vpWidth > 0.0f && vpHeight > 0.0f) ? (vpWidth / vpHeight) : 1.0f;
if (aspectGuess.Text.Length > 0 && float.TryParse(aspectGuess.Text, out m_MeshDisplay.aspect))
aspectGuess.Text = m_MeshDisplay.aspect.ToString("G");