Nerfed/Nerfed.Builder/Builder/Importers/ShaderImporter.cs
robert 97c2b308f1 Added builder
Added shader importer
2024-07-06 23:33:04 +02:00

34 lines
920 B
C#

using System.Diagnostics;
namespace Nerfed.Builder;
public class ShaderImporter : IImporter
{
public void Import(string inFile, string outFile)
{
using (Process proc = new Process())
{
string glslc;
if (OperatingSystem.IsWindows())
{
glslc = "Win64/glslc.exe";
}
else if (OperatingSystem.IsLinux())
{
glslc = "Linux/glslc";
}
else
{
throw new PlatformNotSupportedException("No shader compiler found for current platform");
}
proc.StartInfo.FileName = glslc;
proc.StartInfo.Arguments = @$"""{inFile}"" -o ""{outFile}"" -c";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.Start();
proc.WaitForExit();
}
}
}