mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-27 10:45:32 +00:00
174 lines
6.7 KiB
C#
174 lines
6.7 KiB
C#
#region License
|
|
/*
|
|
MIT License
|
|
Copyright ©2003-2006 Tao Framework Team
|
|
http://www.taoframework.com
|
|
All rights reserved.
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
*/
|
|
#endregion License
|
|
|
|
using System;
|
|
using System.Text;
|
|
using System.IO;
|
|
using System.Security;
|
|
using System.Security.Permissions;
|
|
using System.Threading;
|
|
using System.Collections.Generic;
|
|
using System.CodeDom;
|
|
using System.Diagnostics;
|
|
|
|
namespace Bind
|
|
{
|
|
enum GeneratorMode
|
|
{
|
|
GL2,
|
|
GL3,
|
|
Wgl,
|
|
Glx,
|
|
Glu
|
|
}
|
|
|
|
static class MainClass
|
|
{
|
|
static GeneratorMode mode;
|
|
|
|
static void Main(string[] arguments)
|
|
{
|
|
Debug.Listeners.Clear();
|
|
Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
|
|
Debug.AutoFlush = true;
|
|
Trace.Listeners.Clear();
|
|
Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
|
|
Trace.AutoFlush = true;
|
|
|
|
Console.WriteLine("OpenGL binding generator {0} for OpenTK.",
|
|
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
|
|
Console.WriteLine("For comments, bugs and suggestions visit http://opentk.sourceforge.net");
|
|
//Console.WriteLine(" - the OpenTK team ;-)");
|
|
Console.WriteLine();
|
|
|
|
IBind bind;
|
|
|
|
#region Handle Arguments
|
|
|
|
try
|
|
{
|
|
foreach (string a in arguments)
|
|
{
|
|
if (a.StartsWith("--") || a.StartsWith("-") || a.StartsWith("/"))
|
|
{
|
|
string[] b = a.Split(new char[] { '-', '/', ':', '=' }, StringSplitOptions.RemoveEmptyEntries);
|
|
switch (b[0])
|
|
{
|
|
case "?":
|
|
case "help":
|
|
Console.WriteLine("Help not implemented yet.");
|
|
return;
|
|
case "in":
|
|
case "input":
|
|
Settings.InputPath = b[1];
|
|
break;
|
|
case "out":
|
|
case "output":
|
|
Settings.OutputPath = b[1];
|
|
break;
|
|
case "mode":
|
|
mode =
|
|
b[1].ToLower() == "gl2" ? GeneratorMode.GL2 :
|
|
b[1].ToLower() == "gl3" ? GeneratorMode.GL3 : GeneratorMode.GL2;
|
|
break;
|
|
case "namespace":
|
|
case "ns":
|
|
Settings.OutputNamespace = b[1];
|
|
break;
|
|
case "gl":
|
|
Settings.GLClass = b[1];
|
|
break;
|
|
case "glu":
|
|
Settings.GluClass = b[1];
|
|
break;
|
|
case "legacy":
|
|
Settings.Compatibility = b[1].ToLower() == "tao" ? Settings.Legacy.Tao : Settings.Legacy.None;
|
|
Settings.OutputNamespace = "Tao.OpenGl";
|
|
Settings.GLClass = "Gl";
|
|
break;
|
|
case "class":
|
|
Settings.GLClass = b[1];
|
|
break;
|
|
default:
|
|
throw new ArgumentException(
|
|
String.Format("Argument {0} not recognized. Use the '/?' switch for help.", a)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (NullReferenceException e)
|
|
{
|
|
Console.WriteLine("Argument error ({0}). Please use the '/?' switch for help.", e.ToString());
|
|
return;
|
|
}
|
|
catch (ArgumentException e)
|
|
{
|
|
Console.WriteLine("Argument error ({0}). Please use the '/?' switch for help.", e.ToString());
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
long ticks = System.DateTime.Now.Ticks;
|
|
|
|
switch (mode)
|
|
{
|
|
case GeneratorMode.GL2:
|
|
bind = new Bind.GL2.Generator(Settings.InputPath);
|
|
break;
|
|
|
|
default:
|
|
throw new NotImplementedException(String.Format("Mode {0} not implemented.", mode));
|
|
}
|
|
|
|
bind.Process();
|
|
|
|
ticks = System.DateTime.Now.Ticks - ticks;
|
|
|
|
Console.WriteLine();
|
|
Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0);
|
|
Console.WriteLine();
|
|
Console.WriteLine("Press any key to continue...");
|
|
Console.ReadKey(true);
|
|
}
|
|
catch (SecurityException e)
|
|
{
|
|
Console.WriteLine("Security violation \"{0}\" in method \"{1}\".", e.Message, e.Method);
|
|
Console.WriteLine("This application does not have permission to take the requested actions.");
|
|
}
|
|
catch (NotImplementedException e)
|
|
{
|
|
Console.WriteLine(e.Message);
|
|
Console.WriteLine("The requested functionality is not implemented yet.");
|
|
}
|
|
}
|
|
}
|
|
}
|