diff --git a/BizHawk.Client.EmuHawk/DisplayManager/Filters/Retro.cs b/BizHawk.Client.EmuHawk/DisplayManager/Filters/Retro.cs index a7c2b8903d..86f560c475 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/Filters/Retro.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/Filters/Retro.cs @@ -142,6 +142,20 @@ namespace BizHawk.Client.EmuHawk.Filters public List Passes = new List(); + /// + /// Indicates whether any of the passes contain GLSL filenames (these are invalid now) + /// + public bool ContainsGLSL + { + get + { + foreach (var pass in Passes) + if (Path.GetExtension(pass.ShaderPath).ToLowerInvariant() == ".glsl") + return true; + return false; + } + } + public enum ScaleType { NotSet, Source, Viewport, Absolute diff --git a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs index 20eb6de13c..8d1bce3ed0 100644 --- a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs +++ b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs @@ -176,7 +176,34 @@ namespace BizHawk.Client.EmuHawk.config if (ofd.ShowDialog() == DialogResult.OK) { rbUser.Checked = true; - PathSelection = Path.GetFullPath(ofd.FileName); + var choice = Path.GetFullPath(ofd.FileName); + + //test the preset + using (var stream = File.OpenRead(choice)) + { + var cgp = new BizHawk.Client.EmuHawk.Filters.RetroShaderPreset(stream); + if (cgp.ContainsGLSL) + { + MessageBox.Show("Specified CGP contains references to .glsl files. This is illegal. Use .cg"); + return; + } + + //try compiling it + bool ok = false; + try + { + var filter = new BizHawk.Client.EmuHawk.Filters.RetroShaderChain(GlobalWin.IGL_GL, cgp, Path.GetDirectoryName(choice)); + ok = filter.Available; + } + catch {} + if (!ok) + { + MessageBox.Show("Selected filter could not be compiled."); + return; + } + } + + PathSelection = choice; RefreshState(); } }