2007-07-23 00:15:18 +00:00
|
|
|
|
#region License
|
|
|
|
|
/*
|
|
|
|
|
MIT License
|
|
|
|
|
Copyright <EFBFBD>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;
|
2007-08-01 09:27:57 +00:00
|
|
|
|
using System.Diagnostics;
|
2007-07-23 00:15:18 +00:00
|
|
|
|
|
2007-08-01 09:27:57 +00:00
|
|
|
|
namespace Bind
|
2007-07-23 00:15:18 +00:00
|
|
|
|
{
|
2007-08-01 09:27:57 +00:00
|
|
|
|
enum GeneratorMode
|
|
|
|
|
{
|
|
|
|
|
GL2,
|
|
|
|
|
GL3,
|
|
|
|
|
Wgl,
|
|
|
|
|
Glx,
|
|
|
|
|
Glu
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-23 00:15:18 +00:00
|
|
|
|
static class MainClass
|
|
|
|
|
{
|
2007-08-01 09:27:57 +00:00
|
|
|
|
static GeneratorMode mode;
|
|
|
|
|
|
2007-08-01 21:14:39 +00:00
|
|
|
|
static internal IBind Generator;
|
|
|
|
|
|
2007-07-23 00:15:18 +00:00
|
|
|
|
static void Main(string[] arguments)
|
|
|
|
|
{
|
2007-08-01 09:27:57 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2007-07-23 00:15:18 +00:00
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
#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":
|
2007-08-01 09:27:57 +00:00
|
|
|
|
case "output":
|
2007-07-23 00:15:18 +00:00
|
|
|
|
Settings.OutputPath = b[1];
|
|
|
|
|
break;
|
2007-08-01 09:27:57 +00:00
|
|
|
|
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;
|
2007-07-23 00:15:18 +00:00
|
|
|
|
case "class":
|
|
|
|
|
Settings.GLClass = b[1];
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2007-08-01 09:27:57 +00:00
|
|
|
|
throw new ArgumentException(
|
|
|
|
|
String.Format("Argument {0} not recognized. Use the '/?' switch for help.", a)
|
|
|
|
|
);
|
2007-07-23 00:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
2007-08-01 09:27:57 +00:00
|
|
|
|
switch (mode)
|
|
|
|
|
{
|
|
|
|
|
case GeneratorMode.GL2:
|
2007-08-01 21:14:39 +00:00
|
|
|
|
Generator = new Bind.GL2.Generator(Settings.InputPath);
|
2007-08-01 09:27:57 +00:00
|
|
|
|
break;
|
2007-07-23 00:15:18 +00:00
|
|
|
|
|
2007-08-01 09:27:57 +00:00
|
|
|
|
default:
|
|
|
|
|
throw new NotImplementedException(String.Format("Mode {0} not implemented.", mode));
|
|
|
|
|
}
|
2007-07-23 00:15:18 +00:00
|
|
|
|
|
2007-08-01 21:14:39 +00:00
|
|
|
|
Generator.Process();
|
2007-07-23 00:15:18 +00:00
|
|
|
|
|
|
|
|
|
ticks = System.DateTime.Now.Ticks - ticks;
|
|
|
|
|
|
2007-08-01 09:27:57 +00:00
|
|
|
|
Console.WriteLine();
|
2007-07-23 00:15:18 +00:00
|
|
|
|
Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0);
|
|
|
|
|
Console.WriteLine();
|
2007-08-01 09:27:57 +00:00
|
|
|
|
Console.WriteLine("Press any key to continue...");
|
|
|
|
|
Console.ReadKey(true);
|
2007-07-23 00:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
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.");
|
|
|
|
|
}
|
2007-08-01 09:27:57 +00:00
|
|
|
|
catch (NotImplementedException e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(e.Message);
|
|
|
|
|
Console.WriteLine("The requested functionality is not implemented yet.");
|
|
|
|
|
}
|
2007-07-23 00:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|