private static void Main(string[] args) { if (args.Length != 3) { Console.Error.WriteLine("Usage: cmdxenfx inputFile outputNamespace outputFile"); return; } string source = args[0]; string dest = args[2]; if (!File.Exists(source)) { Console.Error.WriteLine(@"FileNotFound: '{0}'", source); return; } if (File.Exists(dest)) { if (File.GetLastWriteTime(dest) > File.GetLastWriteTime(source) && File.GetLastWriteTime(dest) > File.GetLastWriteTime(typeof(ShaderCodeGenerator).Assembly.Location)) { Console.WriteLine("Skipping... (File has not changed)"); return; } } byte[] code = new ShaderCodeGenerator().GenerateCode(Path.GetFullPath(args[0]), File.ReadAllText(args[0]), args[1], new Microsoft.CSharp.CSharpCodeProvider()); using (Stream file = File.Create(args[2])) file.Write(code, 0, code.Length); }
private static void ConstructShader(FileInfo fileInfo, string sourceFile, string localNamespace) { if (codeGenerator == null) { codeGenerator = new ShaderCodeGenerator(); codeProvider = new Microsoft.CSharp.CSharpCodeProvider(); } byte[] shaderCode = codeGenerator.GenerateCode(sourceFile, File.ReadAllText(sourceFile), localNamespace, codeProvider); using (FileStream file = fileInfo.Create()) file.Write(shaderCode, 0, shaderCode.Length); //done! Console.WriteLine(string.Format("Updated: \"{0}\"", Trim(fileInfo.FullName))); }
private static void Main(string[] args) { ShaderCodeGenerator codeGenerator = new ShaderCodeGenerator(); codeGenerator.GenerateDebug(System.IO.File.ReadAllText("test.fx"), "test.fx"); }