From d16a8024d53b86a618db0feaa4369b8a82be0549 Mon Sep 17 00:00:00 2001 From: baldurk Date: Sat, 12 Sep 2015 17:30:35 +0200 Subject: [PATCH] Make sure we have some fallback for locating position element. Refs #149 * If no position element is selected at all that's really confusing, so worst case we just pick the first attribute. * Making it intuitive/obvious that you can change which attribute is displayed as mesh - that's a different problem. --- renderdocui/Windows/BufferViewer.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/renderdocui/Windows/BufferViewer.cs b/renderdocui/Windows/BufferViewer.cs index 46cd4f59b..3d3a4aecb 100644 --- a/renderdocui/Windows/BufferViewer.cs +++ b/renderdocui/Windows/BufferViewer.cs @@ -2365,6 +2365,7 @@ namespace renderdocui.Windows break; } } + // look for an exact match for (int i = 0; posEl == -1 && i < ui.m_Input.BufferFormats.Length; i++) { FormatElement el = ui.m_Input.BufferFormats[i]; @@ -2378,6 +2379,33 @@ namespace renderdocui.Windows break; } } + // try anything containing position + for (int i = 0; posEl == -1 && i < ui.m_Input.BufferFormats.Length; i++) + { + FormatElement el = ui.m_Input.BufferFormats[i]; + + if (el.name.ToUpperInvariant().Contains("POSITION")) + { + posEl = i; + break; + } + } + // OK last resort, just look for 'pos' + for (int i = 0; posEl == -1 && i < ui.m_Input.BufferFormats.Length; i++) + { + FormatElement el = ui.m_Input.BufferFormats[i]; + + if (el.name.ToUpperInvariant().Contains("POS")) + { + posEl = i; + break; + } + } + // if we still have absolutely nothing, just use the first available element + if (posEl == -1 && ui.m_Input.BufferFormats.Length > 0) + { + posEl = 0; + } } m_PosElement[(int)stage] = posEl;