Nerfed/Nerfed.Builder/Builder/Importers/ShaderImporter.cs

34 lines
920 B
C#
Raw Normal View History

2024-07-06 23:33:04 +02:00
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();
}
}
}