mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 01:25:39 +00:00
This commit is contained in:
parent
22fa16be89
commit
2b3aeeb7ae
Binary file not shown.
Binary file not shown.
|
@ -1,4 +0,0 @@
|
|||
bin\Debug\DisplayLists.exe
|
||||
bin\Debug\DisplayLists.pdb
|
||||
bin\Debug\OpenGL.dll
|
||||
bin\Debug\OpenGL.pdb
|
|
@ -1,3 +0,0 @@
|
|||
obj\Debug\ResolveAssemblyReference.cache
|
||||
obj\Debug\OpenTK.OpenGL.Examples.DisplayLists.Properties.Resources.resources
|
||||
obj\Debug\OpenTK.OpenGL.DisplayLists.csproj.GenerateResource.Cache
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,4 +0,0 @@
|
|||
obj\Debug\ResolveAssemblyReference.cache
|
||||
obj\Debug\OpenTK.OpenGL.Examples.TwoContexts.Properties.Resources.resources
|
||||
obj\Debug\OpenTK.OpenGL.Test.TwoContexts.resources
|
||||
obj\Debug\OpenTK.OpenGL.TwoContexts.csproj.GenerateResource.Cache
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
obj\Debug\ResolveAssemblyReference.cache
|
||||
obj\Debug\OpenTK.OpenGL.Examples.Window.Properties.Resources.resources
|
||||
obj\Debug\OpenTK.OpenGL.Window.csproj.GenerateResource.Cache
|
Binary file not shown.
|
@ -1,6 +0,0 @@
|
|||
bin\Debug\Window.exe
|
||||
bin\Debug\Window.pdb
|
||||
bin\Debug\OpenGL.dll
|
||||
bin\Debug\OpenGL.pdb
|
||||
..\Binaries\Debug\Window.exe
|
||||
..\Binaries\Debug\Window.pdb
|
|
@ -1,91 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an opengl constant in C# format. Both the constant name and value
|
||||
/// can be retrieved or set. All opengl constants are translated to 'const uint'.
|
||||
/// </summary>
|
||||
public class Constant
|
||||
{
|
||||
#region Name
|
||||
|
||||
string _name;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the opengl constant (eg. GL_LINES).
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set
|
||||
{
|
||||
if (!String.IsNullOrEmpty(value))
|
||||
_name = value.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Value
|
||||
|
||||
string _value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the opengl constant (eg. 0x00000001).
|
||||
/// </summary>
|
||||
public string Value
|
||||
{
|
||||
get { return _value; }
|
||||
set
|
||||
{
|
||||
if (!String.IsNullOrEmpty(value))
|
||||
_value = value.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Creates an empty Constant.
|
||||
/// </summary>
|
||||
public Constant()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Constant with the given name and value.
|
||||
/// </summary>
|
||||
/// <param name="name">The Name of the Constant.</param>
|
||||
/// <param name="value">The Type of the Constant.</param>
|
||||
public Constant(string name, string value)
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper functions
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string that represents the full constant declaration without decorations
|
||||
/// (eg const uint GL_XXX_YYY = 0xDEADBEEF).
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
new public string ToString()
|
||||
{
|
||||
return "uint " + Name + " = " + Value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
public class Enum
|
||||
{
|
||||
public Enum()
|
||||
{
|
||||
}
|
||||
|
||||
string _name;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
|
||||
System.Collections.Hashtable _constant_collection = new System.Collections.Hashtable();
|
||||
|
||||
public System.Collections.Hashtable ConstantCollection
|
||||
{
|
||||
get { return _constant_collection; }
|
||||
set { _constant_collection = value; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine(" public enum " + Name + " : uint");
|
||||
sb.AppendLine(" {");
|
||||
foreach (Constant c in ConstantCollection.Values)
|
||||
{
|
||||
sb.AppendLine(" " + c.Name + " = " + c.Value + ",");
|
||||
}
|
||||
sb.AppendLine(" }");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an opengl function.
|
||||
/// The return value, function name, function parameters and opengl version can be retrieved or set.
|
||||
/// </summary>
|
||||
public class Function
|
||||
{
|
||||
#region Needs wrapper property
|
||||
|
||||
bool _needs_wrapper;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this function needs to be wrapped with a Marshaling function.
|
||||
/// This flag is set if a function contains an Array parameter, or returns
|
||||
/// an Array or string.
|
||||
/// </summary>
|
||||
public bool NeedsWrapper
|
||||
{
|
||||
get { return _needs_wrapper; }
|
||||
set { _needs_wrapper = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Return value property
|
||||
|
||||
string _return_value;
|
||||
/// <summary>
|
||||
/// Gets or sets the return value of the opengl function.
|
||||
/// </summary>
|
||||
public string ReturnValue
|
||||
{
|
||||
get { return _return_value; }
|
||||
set { _return_value = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Name property
|
||||
|
||||
string _name;
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the opengl function.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set
|
||||
{
|
||||
if (!String.IsNullOrEmpty(value))
|
||||
_name = value.Trim();
|
||||
else
|
||||
_name = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Parameter collection property
|
||||
|
||||
ParameterCollection _parameters = new ParameterCollection();
|
||||
|
||||
public ParameterCollection Parameters
|
||||
{
|
||||
get { return _parameters; }
|
||||
set { _parameters = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Version property
|
||||
|
||||
string _version;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the opengl version that introduced this function.
|
||||
/// </summary>
|
||||
public string Version
|
||||
{
|
||||
get { return _version; }
|
||||
set { _version = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Extension property
|
||||
|
||||
bool _extension = false;
|
||||
|
||||
public bool Extension
|
||||
{
|
||||
get { return _extension; }
|
||||
set { _extension = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public Function()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ToString function
|
||||
|
||||
/// <summary>
|
||||
/// Gets the string representing the full function declaration without decorations
|
||||
/// (ie "void glClearColor(float red, float green, float blue, float alpha)"
|
||||
/// </summary>
|
||||
override public string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(ReturnValue + " " + Name + Parameters.ToString());
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a single parameter of an opengl function.
|
||||
/// </summary>
|
||||
public class Parameter
|
||||
{
|
||||
#region Name property
|
||||
|
||||
string _name;
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the parameter.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MarshalAs property
|
||||
|
||||
UnmanagedType _unmanaged_type;
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the parameter.
|
||||
/// </summary>
|
||||
public UnmanagedType UnmanagedType
|
||||
{
|
||||
get { return _unmanaged_type; }
|
||||
set { _unmanaged_type = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Type property
|
||||
|
||||
string _type;
|
||||
/// <summary>
|
||||
/// Gets the type of the parameter.
|
||||
/// </summary>
|
||||
public string Type
|
||||
{
|
||||
get { return _type; }
|
||||
set { _type = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Flow property
|
||||
|
||||
/// <summary>
|
||||
/// Enumarates the possible flows of a parameter (ie. is this parameter
|
||||
/// used as input or as output?)
|
||||
/// </summary>
|
||||
public enum FlowDirection
|
||||
{
|
||||
Undefined = 0,
|
||||
In,
|
||||
Out
|
||||
}
|
||||
|
||||
FlowDirection _flow;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the flow of the parameter.
|
||||
/// </summary>
|
||||
public FlowDirection Flow
|
||||
{
|
||||
get { return _flow; }
|
||||
set { _flow = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Array property
|
||||
|
||||
bool _array = false;
|
||||
|
||||
public bool Array
|
||||
{
|
||||
get { return _array; }
|
||||
set { _array = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Parameter without type and name.
|
||||
/// </summary>
|
||||
public Parameter() { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ToString function
|
||||
|
||||
override public string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (UnmanagedType == UnmanagedType.AsAny && Flow == FlowDirection.In)
|
||||
sb.Append("[MarshalAs(UnmanagedType.AsAny)] ");
|
||||
|
||||
if (Flow == FlowDirection.Out)
|
||||
sb.Append("out ");
|
||||
sb.Append(Type);
|
||||
|
||||
sb.Append(" ");
|
||||
sb.Append(Name);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
public class ParameterCollection : List<Parameter>
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public ParameterCollection()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
override public string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("(");
|
||||
if (this.Count > 0)
|
||||
{
|
||||
foreach (Parameter p in this)
|
||||
{
|
||||
sb.Append(p.ToString());
|
||||
sb.Append(", ");
|
||||
}
|
||||
sb.Replace(", ", ")", sb.Length - 2, 2);
|
||||
}
|
||||
else
|
||||
sb.Append(")");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public bool ContainsType(string type)
|
||||
{
|
||||
foreach (Parameter p in this)
|
||||
if (p.Type == type)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
partial class Process
|
||||
{
|
||||
#region Enum collection property
|
||||
|
||||
System.Collections.Hashtable _enum_collection = new System.Collections.Hashtable();
|
||||
|
||||
public System.Collections.Hashtable EnumCollection
|
||||
{
|
||||
get { return _enum_collection; }
|
||||
set { _enum_collection = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Function collection property
|
||||
|
||||
List<Function> _function_collection = new List<Function>();
|
||||
|
||||
public List<Function> FunctionCollection
|
||||
{
|
||||
get { return _function_collection; }
|
||||
set { _function_collection = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Wrapper collection property
|
||||
|
||||
List<Function> _wrapper_collection = new List<Function>();
|
||||
|
||||
public List<Function> WrapperCollection
|
||||
{
|
||||
get { return _wrapper_collection; }
|
||||
set { _wrapper_collection = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Processes the file given in the input_file parameter and writes the output
|
||||
/// to the path sepcified by the Properties.Bind.Default.OutputPath parameter. The Block parameter
|
||||
/// contains the complete list of bindings for this class.
|
||||
/// </summary>
|
||||
/// <param name="Properties.Bind.Default.InputPath">A string containing the path to the input file.</param>
|
||||
/// <param name="Properties.Bind.Default.OutputPath">A string containing the path to the output directory.</param>
|
||||
/// <param name="complete_block">Contains the full list of constants and functions generated by this processor.</param>
|
||||
public Process()
|
||||
{
|
||||
long ticks = System.DateTime.Now.Ticks;
|
||||
|
||||
ReadSpecs("gl.spec");
|
||||
ReadSpecs("enum.spec");
|
||||
ReadSpecs("enumext.spec");
|
||||
|
||||
Translation.Translate(FunctionCollection, WrapperCollection);
|
||||
Translation.Translate(EnumCollection);
|
||||
|
||||
WriteFunctions(Properties.Bind.Default.OutputPath);
|
||||
WriteEnums(Properties.Bind.Default.OutputPath);
|
||||
WriteWrappers(Properties.Bind.Default.OutputPath);
|
||||
WritePerContextLoad(Properties.Bind.Default.OutputPath, "WindowsContext", "1.0", "1.1");
|
||||
WritePerContextLoad(Properties.Bind.Default.OutputPath, "WindowsVistaContext", "1.0", "1.1", "1.2", "1.3", "1.4");
|
||||
WritePerContextLoad(Properties.Bind.Default.OutputPath, "X11Context", "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "2.0");
|
||||
|
||||
ticks = System.DateTime.Now.Ticks - ticks;
|
||||
|
||||
Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0);
|
||||
Thread.Sleep(1000); // In order to allow new files to be copied to be parsed by the OpenTK build target.
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,205 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
/* There are several errors in the spec files.
|
||||
* enum.spec:
|
||||
* A missing "#" to comment out a constant for a commented-out SGI extension (inoffensive, but erroneous nonetheless).
|
||||
* Uses LightProperty instead of the correct LightParameter.
|
||||
* References the commented out SGIX_icc_texture enum.
|
||||
*
|
||||
* enumext.spec
|
||||
* The renaming scheme for the 2.0 version (e.g. SRC_ALPHA2 instead of SOURCE_ALPHA2) references the GL_* versions
|
||||
* instead of the * which will break when a generator does not add the GL_ prefix. Moreover these reside in different enums
|
||||
* so the reference will only work for the C preprocessor. As a workaround I added the missing constants outside of any enum.
|
||||
*/
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
public partial class Process
|
||||
{
|
||||
void ReadSpecs(string specfile)
|
||||
{
|
||||
string path = Path.Combine(Properties.Bind.Default.InputPath, specfile);
|
||||
StreamReader sr;
|
||||
try
|
||||
{
|
||||
sr = new StreamReader(path);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Console.WriteLine("Error opening spec file: {0}", path);
|
||||
return;
|
||||
}
|
||||
Console.WriteLine("Reading specs from: {0}", specfile);
|
||||
|
||||
do
|
||||
{
|
||||
string line = sr.ReadLine().Trim();
|
||||
|
||||
if (String.IsNullOrEmpty(line) ||
|
||||
line.StartsWith("#") || // Disregard comments.
|
||||
line.StartsWith("passthru") || // Disregard passthru statements.
|
||||
line.StartsWith("required-props:") ||
|
||||
line.StartsWith("param:") ||
|
||||
line.StartsWith("dlflags:") ||
|
||||
line.StartsWith("glxflags:") ||
|
||||
line.StartsWith("vectorequiv:") ||
|
||||
line.StartsWith("category:") ||
|
||||
line.StartsWith("version:") ||
|
||||
line.StartsWith("glxsingle:") ||
|
||||
line.StartsWith("glxropcode:") ||
|
||||
line.StartsWith("glxvendorpriv:") ||
|
||||
line.StartsWith("glsflags:") ||
|
||||
line.StartsWith("glsopcode:") ||
|
||||
line.StartsWith("glsalias:") ||
|
||||
line.StartsWith("wglflags:") ||
|
||||
line.StartsWith("extension:") ||
|
||||
line.StartsWith("alias:") ||
|
||||
line.StartsWith("offset:"))
|
||||
continue;
|
||||
|
||||
while (line.Contains("(") && !sr.EndOfStream)
|
||||
//complete_block.Functions.Add(ReadFunction(sr, line));
|
||||
FunctionCollection.Add(ReadFunction(sr, ref line));
|
||||
|
||||
while (line.Contains("enum") && !sr.EndOfStream)
|
||||
{
|
||||
Enum e = ReadEnum(sr, ref line);
|
||||
if (EnumCollection.ContainsKey(e.Name))
|
||||
{
|
||||
//Merge keys:
|
||||
foreach (Constant c in e.ConstantCollection.Values)
|
||||
{
|
||||
if (!((Enum)EnumCollection[e.Name]).ConstantCollection.ContainsKey(c.Name))
|
||||
((Enum)EnumCollection[e.Name]).ConstantCollection.Add(c.Name, c);
|
||||
}
|
||||
}
|
||||
else
|
||||
EnumCollection.Add(e.Name, e);
|
||||
}
|
||||
// EnumCollection.Add(ReadEnum(sr, ref line));
|
||||
|
||||
|
||||
}
|
||||
while (!sr.EndOfStream);
|
||||
}
|
||||
|
||||
#region Read enumeration function
|
||||
|
||||
private Enum ReadEnum(StreamReader sr, ref string line)
|
||||
{
|
||||
Enum e = new Enum();
|
||||
|
||||
e.Name = line.Split(Translation.Separators, StringSplitOptions.RemoveEmptyEntries)[0];
|
||||
|
||||
do
|
||||
{
|
||||
line = sr.ReadLine();
|
||||
|
||||
if (String.IsNullOrEmpty(line) || line.StartsWith("#"))
|
||||
continue;
|
||||
|
||||
if (line.Contains("enum:") || sr.EndOfStream)
|
||||
break;
|
||||
|
||||
line = line.Replace('\t', ' ');
|
||||
|
||||
string[] words = line.Split(Translation.Separators, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (words.Length == 0)
|
||||
continue;
|
||||
|
||||
Constant c = new Constant();
|
||||
if (words[0] == "use")
|
||||
{
|
||||
c.Name = words[2];
|
||||
c.Value = words[1] + "." + words[2];
|
||||
}
|
||||
|
||||
if (line.Contains("="))
|
||||
{
|
||||
c.Name = words[0];
|
||||
c.Value = words[2];
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(c.Name) && !e.ConstantCollection.ContainsKey(c.Name))
|
||||
e.ConstantCollection.Add(c.Name, c);
|
||||
}
|
||||
while (!sr.EndOfStream);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read function function
|
||||
|
||||
Function ReadFunction(StreamReader sr, ref string line)
|
||||
{
|
||||
Function f = new Function();
|
||||
|
||||
//string line = sr.ReadLine();
|
||||
f.Name = line.Split(Translation.Separators, StringSplitOptions.RemoveEmptyEntries)[0];
|
||||
if (f.Name.EndsWith("ARB") ||
|
||||
f.Name.EndsWith("EXT") ||
|
||||
f.Name.EndsWith("ATI") ||
|
||||
f.Name.EndsWith("NV") ||
|
||||
f.Name.EndsWith("SUN") ||
|
||||
f.Name.EndsWith("SUNX") ||
|
||||
f.Name.EndsWith("SGI") ||
|
||||
f.Name.EndsWith("SGIS") ||
|
||||
f.Name.EndsWith("SGIX") ||
|
||||
f.Name.EndsWith("MESA") ||
|
||||
f.Name.EndsWith("3DFX") ||
|
||||
f.Name.EndsWith("IBM") ||
|
||||
f.Name.EndsWith("GREMEDY") ||
|
||||
f.Name.EndsWith("HP") ||
|
||||
f.Name.EndsWith("INTEL") ||
|
||||
f.Name.EndsWith("PGI") ||
|
||||
f.Name.EndsWith("INGR") ||
|
||||
f.Name.EndsWith("APPLE"))
|
||||
f.Extension = true;
|
||||
|
||||
do
|
||||
{
|
||||
line = sr.ReadLine();
|
||||
line = line.Replace('\t', ' ');
|
||||
|
||||
string[] words = line.Split(Translation.Separators, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (String.IsNullOrEmpty(line) || words.Length == 0)
|
||||
break;
|
||||
|
||||
switch (words[0])
|
||||
{
|
||||
case "return":
|
||||
f.ReturnValue = words[1];
|
||||
break;
|
||||
case "param":
|
||||
Parameter p = new Parameter();
|
||||
p.Name = words[1];
|
||||
p.Flow = words[3] == "in" ? Parameter.FlowDirection.In : Parameter.FlowDirection.Out;
|
||||
p.Type = words[2];
|
||||
if (words[4] == "array")
|
||||
p.Array = true;
|
||||
f.Parameters.Add(p);
|
||||
break;
|
||||
case "version":
|
||||
f.Version = words[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (!sr.EndOfStream);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
partial class Process
|
||||
{
|
||||
#region Write the per-context load function
|
||||
|
||||
/// <summary>
|
||||
/// Write the platform specific Load() and LoadExtensions() functions.
|
||||
/// </summary>
|
||||
/// <param name="Properties.Bind.Default.OutputPath">The folder where the generated file will be saved.</param>
|
||||
/// <param name="class_name">The name of the partial class that contains the load functions.</param>
|
||||
/// <param name="core_blocks">The names of the function groups that are considered "core" for the specified platform. (e.g. GL_VERSION_1_1 for Windows prior to Vista)</param>
|
||||
void WritePerContextLoad(string output_path, string class_name, params string[] import_functions)
|
||||
{
|
||||
if (!Directory.Exists(output_path))
|
||||
Directory.CreateDirectory(output_path);
|
||||
|
||||
string filename = Path.Combine(output_path, class_name + "Load.cs");
|
||||
StreamWriter sw = new StreamWriter(filename, false);
|
||||
|
||||
Console.WriteLine("Writing {0} to {1}", class_name, output_path);
|
||||
|
||||
// Write using directives.
|
||||
sw.WriteLine("using System;");
|
||||
sw.WriteLine("using System.Runtime.InteropServices;");
|
||||
sw.WriteLine("using {0};", Properties.Bind.Default.OutputNamespace);
|
||||
sw.WriteLine();
|
||||
|
||||
// Open namespace and class.
|
||||
sw.WriteLine("namespace {0}.{1}", Properties.Bind.Default.OutputNamespace, Properties.Bind.Default.OutputPlatformNamespace);
|
||||
sw.WriteLine("{");
|
||||
sw.WriteLine(" public partial class {0}", class_name);
|
||||
sw.WriteLine(" {");
|
||||
|
||||
#region Write the DllImports
|
||||
|
||||
// Write the [DllImported] functions.
|
||||
sw.WriteLine(" #region DllImports");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine(" internal class Imports");
|
||||
sw.WriteLine(" {");
|
||||
|
||||
foreach (Function f in FunctionCollection)
|
||||
{
|
||||
if (IsImportFunction(f, import_functions))
|
||||
{
|
||||
sw.WriteLine(" [DllImport(_dll_name, EntryPoint = \"{0}\")]", "gl" + f.Name);
|
||||
sw.WriteLine(" public static extern {0};", f.ToString());
|
||||
sw.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine(" #endregion");
|
||||
sw.WriteLine();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Write the Load function for the opengl core.
|
||||
|
||||
// Write the Load function.
|
||||
sw.WriteLine(" #region Load core");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine(" /// <summary>");
|
||||
sw.WriteLine(" /// Loads the core opengl functions (versions 1.0-2.0).");
|
||||
sw.WriteLine(" /// </summary>");
|
||||
sw.WriteLine(" public override void Load()");
|
||||
sw.WriteLine(" {");
|
||||
sw.WriteLine(" if ({0}.CoreLoaded) return;", Properties.Bind.Default.OutputGLClass);
|
||||
sw.WriteLine(" if ({0}.ExtensionsLoaded) return;", Properties.Bind.Default.OutputGLClass);
|
||||
|
||||
foreach (Function f in FunctionCollection)
|
||||
{
|
||||
if (!f.Extension)
|
||||
{
|
||||
if (IsImportFunction(f, import_functions))
|
||||
sw.WriteLine(" {0}.{1} = new {0}.Delegates.{1}(Imports.{1});",
|
||||
Properties.Bind.Default.OutputGLClass,
|
||||
f.Name);
|
||||
else
|
||||
sw.WriteLine(" {0}.{1} = ({0}.Delegates.{1}) GetAddress(\"gl{1}\", typeof({0}.Delegates.{1}));",
|
||||
Properties.Bind.Default.OutputGLClass,
|
||||
f.Name);
|
||||
}
|
||||
}
|
||||
|
||||
sw.WriteLine(" CoreLoaded = true;");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine(" #endregion");
|
||||
sw.WriteLine();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Write the LoadExtensions function for the opengl extensions.
|
||||
|
||||
// Write the LoadExtensions function.
|
||||
sw.WriteLine(" #region Load extensions");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine(" /// <summary>");
|
||||
sw.WriteLine(" /// Loads the opengl extensions (e.g. ARB, EXT, vendor and platform specific functions).");
|
||||
sw.WriteLine(" /// </summary>");
|
||||
sw.WriteLine(" public override void LoadExtensions()");
|
||||
sw.WriteLine(" {");
|
||||
|
||||
foreach (Function f in FunctionCollection)
|
||||
{
|
||||
if (f.Extension)
|
||||
sw.WriteLine(" {0}.{1} = ({0}.Delegates.{1}) GetAddress(\"gl{1}\", typeof({0}.Delegates.{1}));",
|
||||
Properties.Bind.Default.OutputGLClass,
|
||||
f.Name);
|
||||
}
|
||||
|
||||
sw.WriteLine(" CoreLoaded = true;");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine(" #endregion");
|
||||
|
||||
#endregion
|
||||
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine("}");
|
||||
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
|
||||
private bool IsImportFunction(Function f, string[] import_functions)
|
||||
{
|
||||
if (f.Extension)
|
||||
return false;
|
||||
|
||||
foreach (string s in import_functions)
|
||||
if (f.Version == s)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
/*
|
||||
partial class Process
|
||||
{
|
||||
#region Write Delegates.
|
||||
|
||||
/// <summary>
|
||||
/// Writes the full list of delegates for opengl functions.
|
||||
/// </summary>
|
||||
/// <param name="output_path">The path where the GL class will be written to.</param>
|
||||
void WriteDelegates(string output_path, string class_name)
|
||||
{
|
||||
if (!Directory.Exists(output_path))
|
||||
Directory.CreateDirectory(output_path);
|
||||
|
||||
string delegates_path = Path.Combine(output_path, "GLFunctions.cs");
|
||||
StreamWriter sw = new StreamWriter(delegates_path, false);
|
||||
Console.WriteLine("Writing delegates to: {0}", delegates_path);
|
||||
|
||||
sw.WriteLine("using System;");
|
||||
sw.WriteLine("using System.Runtime.InteropServices;");
|
||||
sw.WriteLine("using {0};", _opengl_delegates_namespace);
|
||||
sw.WriteLine();
|
||||
sw.WriteLine("namespace {0}", _opengl_namespace);
|
||||
sw.WriteLine("{");
|
||||
sw.WriteLine(" public partial class {0}", class_name);
|
||||
sw.WriteLine(" {");
|
||||
sw.WriteLine(" #region OpenGL Function Declarations.");
|
||||
sw.WriteLine();
|
||||
|
||||
foreach (Block b in BlockList)
|
||||
{
|
||||
sw.WriteLine(" #region {0} Functions", b.Name);
|
||||
sw.WriteLine();
|
||||
|
||||
foreach (Function f in b.Functions)
|
||||
{
|
||||
//sw.WriteLine(" public static {0} {1};", f.Name, f.Name.TrimStart('g', 'l'));
|
||||
|
||||
if (!f.NeedsWrapper)
|
||||
sw.WriteLine(" public static {0} {1};", f.Name, f.Name.TrimStart('g', 'l'));
|
||||
else
|
||||
sw.WriteLine(" public static {0} _{1};", f.Name, f.Name.TrimStart('g', 'l'));
|
||||
}
|
||||
|
||||
sw.WriteLine();
|
||||
sw.WriteLine(" #endregion");
|
||||
sw.WriteLine();
|
||||
}
|
||||
|
||||
sw.WriteLine(" #endregion");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine("}");
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
partial class Process
|
||||
{
|
||||
public void WriteEnums(string output_path)
|
||||
{
|
||||
if (!Directory.Exists(output_path))
|
||||
Directory.CreateDirectory(output_path);
|
||||
|
||||
StreamWriter sw = new StreamWriter(Path.Combine(output_path, "GLConstants.cs"), false);
|
||||
|
||||
Console.WriteLine("Writing opengl constants to: {0}", output_path);
|
||||
|
||||
sw.WriteLine("using System;");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine("namespace {0}", Properties.Bind.Default.OutputNamespace);
|
||||
sw.WriteLine("{");
|
||||
sw.WriteLine(" public static class Enums");
|
||||
sw.WriteLine(" {");
|
||||
|
||||
WriteMissingConstants(sw);
|
||||
|
||||
sw.WriteLine(" #region OpenGL enums");
|
||||
sw.WriteLine();
|
||||
|
||||
foreach (Enum e in EnumCollection.Values)
|
||||
{
|
||||
sw.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
sw.WriteLine();
|
||||
sw.WriteLine(" #endregion");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine("}");
|
||||
sw.WriteLine();
|
||||
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
|
||||
private void WriteMissingConstants(StreamWriter sw)
|
||||
{
|
||||
sw.WriteLine(" #region Missing Constants");
|
||||
sw.WriteLine();
|
||||
|
||||
// Version 1.4 enum
|
||||
sw.WriteLine(" const uint GL_FOG_COORDINATE_SOURCE = 0x8450;");
|
||||
sw.WriteLine(" const uint GL_FOG_COORDINATE = 0x8451;");
|
||||
sw.WriteLine(" const uint GL_CURRENT_FOG_COORDINATE = 0x8453;");
|
||||
sw.WriteLine(" const uint GL_FOG_COORDINATE_ARRAY_TYPE = 0x8454;");
|
||||
sw.WriteLine(" const uint GL_FOG_COORDINATE_ARRAY_STRIDE = 0x8455;");
|
||||
sw.WriteLine(" const uint GL_FOG_COORDINATE_ARRAY_POINTER = 0x8456;");
|
||||
sw.WriteLine(" const uint GL_FOG_COORDINATE_ARRAY = 0x8457;");
|
||||
|
||||
// Version 1.5 enum
|
||||
sw.WriteLine(" const uint GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING = 0x889D;");
|
||||
|
||||
// Version 1.3 enum
|
||||
sw.WriteLine(" const uint GL_SOURCE0_RGB = 0x8580;");
|
||||
sw.WriteLine(" const uint GL_SOURCE1_RGB = 0x8581;");
|
||||
sw.WriteLine(" const uint GL_SOURCE2_RGB = 0x8582;");
|
||||
sw.WriteLine(" const uint GL_SOURCE0_ALPHA = 0x8588;");
|
||||
sw.WriteLine(" const uint GL_SOURCE1_ALPHA = 0x8589;");
|
||||
sw.WriteLine(" const uint GL_SOURCE2_ALPHA = 0x858A;");
|
||||
|
||||
// Version 2.0 enum
|
||||
sw.WriteLine(" const uint GL_BLEND_EQUATION = 0x8009;");
|
||||
|
||||
sw.WriteLine(" const uint GL_MODELVIEW_MATRIX = 0x0BA6;");
|
||||
sw.WriteLine(" const uint GL_MODELVIEW = 0x1700;");
|
||||
sw.WriteLine(" const uint GL_MODELVIEW_STACK_DEPTH = 0x0BA3;");
|
||||
|
||||
// NV_texture_shader enum
|
||||
sw.WriteLine(" const uint GL_OFFSET_TEXTURE_MATRIX_NV = 0x86E1;");
|
||||
sw.WriteLine(" const uint GL_OFFSET_TEXTURE_SCALE_NV = 0x86E2;");
|
||||
sw.WriteLine(" const uint GL_OFFSET_TEXTURE_BIAS_NV = 0x86E3;");
|
||||
|
||||
sw.WriteLine();
|
||||
sw.WriteLine(" #endregion");
|
||||
sw.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
public partial class Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes the Translated opengl functions and function prototypes to the static opengl class.
|
||||
/// </summary>
|
||||
/// <param name="output_path">The folder wherein the class will be written.</param>
|
||||
public void WriteFunctions(string output_path)
|
||||
{
|
||||
if (!Directory.Exists(output_path))
|
||||
Directory.CreateDirectory(output_path);
|
||||
|
||||
StreamWriter sw = new StreamWriter(Path.Combine(output_path, "GLFunctions.cs"), false);
|
||||
|
||||
Console.WriteLine("Writing opengl functions to: {0}", output_path);
|
||||
|
||||
sw.WriteLine("using System;");
|
||||
sw.WriteLine("using System.Runtime.InteropServices;");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine("namespace {0}", Properties.Bind.Default.OutputNamespace);
|
||||
sw.WriteLine("{");
|
||||
sw.WriteLine(" public static partial class {0}", Properties.Bind.Default.OutputGLClass);
|
||||
sw.WriteLine(" {");
|
||||
sw.WriteLine(" public static bool ExtensionsLoaded = false;");
|
||||
sw.WriteLine(" public static bool CoreLoaded = false;");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine(" #region OpenGL functions");
|
||||
sw.WriteLine();
|
||||
|
||||
foreach (Function f in FunctionCollection)
|
||||
{
|
||||
sw.WriteLine(" public static Delegates.{0} {0};", f.Name);
|
||||
}
|
||||
|
||||
sw.WriteLine();
|
||||
sw.WriteLine(" #endregion");
|
||||
sw.WriteLine();
|
||||
|
||||
sw.WriteLine(" #region OpenGL function prototypes");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine(" public static class Delegates");
|
||||
sw.WriteLine(" {");
|
||||
|
||||
foreach (Function f in FunctionCollection)
|
||||
{
|
||||
sw.WriteLine(" public delegate {0};", f.ToString());
|
||||
}
|
||||
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine(" #endregion");
|
||||
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine("}");
|
||||
sw.WriteLine();
|
||||
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,241 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
partial class Process
|
||||
{
|
||||
#region Write Wrappers
|
||||
|
||||
void WriteWrappers(string output_path)
|
||||
{
|
||||
if (!Directory.Exists(output_path))
|
||||
Directory.CreateDirectory(output_path);
|
||||
|
||||
output_path = Path.Combine(output_path, "GLWrappers.cs");
|
||||
StreamWriter sw = new StreamWriter(output_path, false);
|
||||
Console.WriteLine("Writing wrappers to {0}", output_path);
|
||||
|
||||
sw.WriteLine("using System;");
|
||||
sw.WriteLine("using System.Runtime.InteropServices;");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine("namespace {0}", Properties.Bind.Default.OutputNamespace);
|
||||
sw.WriteLine("{");
|
||||
sw.WriteLine(" public partial class {0}", Properties.Bind.Default.OutputGLClass);
|
||||
sw.WriteLine(" {");
|
||||
sw.WriteLine(" #region Wrappers");
|
||||
sw.WriteLine();
|
||||
|
||||
foreach (Function fw in WrapperCollection)
|
||||
{
|
||||
sw.WriteLine(" // Wrapper for function {0}", fw.Name);
|
||||
|
||||
if (fw.Parameters.ContainsType("object"))
|
||||
{
|
||||
Function f = WeakNameLookup(fw.Name, FunctionCollection);
|
||||
|
||||
sw.WriteLine(" public {0} {1}{2}", fw.ReturnValue, fw.Name, fw.Parameters.ToString());
|
||||
sw.WriteLine(" {");
|
||||
|
||||
int i = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("(");
|
||||
foreach (Parameter p in fw.Parameters)
|
||||
{
|
||||
if (p.Type == "object")
|
||||
{
|
||||
sw.WriteLine(" GCHandle h{0} = GCHandle.Alloc({1}, GCHandleType.Pinned);", i, p.Name);
|
||||
sb.Append("h" + i + ".AddrOfPinnedObject()" + ", ");
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(p.Name + ", ");
|
||||
}
|
||||
}
|
||||
sb.Replace(", ", ")", sb.Length - 2, 2);
|
||||
|
||||
sw.WriteLine(" try");
|
||||
sw.WriteLine(" {");
|
||||
if (fw.ReturnValue == "void")
|
||||
sw.WriteLine(" {0}{1};", f.Name, sb.ToString());
|
||||
else
|
||||
sw.WriteLine(" return {0}{1};", f.Name, sb.ToString());
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine(" finally");
|
||||
sw.WriteLine(" {");
|
||||
while (i > 0)
|
||||
{
|
||||
sw.WriteLine(" h{0}.Free();", --i);
|
||||
}
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
#region Commented out
|
||||
|
||||
/*
|
||||
foreach (Function f in FunctionCollection)
|
||||
{
|
||||
if (f.NeedsWrapper)
|
||||
{
|
||||
sw.WriteLine(" // Wrapper for function {0}", f.Name);
|
||||
|
||||
if (f.ReturnValue == "IntPtr")
|
||||
{
|
||||
sw.WriteLine(" public {0} {1}{2}", f.ReturnValue, f.Name.TrimEnd('_'), f.Parameters.ToString());
|
||||
sw.WriteLine(" {");
|
||||
// sw.WriteLine(" return Marshal.PtrToStructure(_{0}{1}, new byte[]);", f.Name.TrimStart('g', 'l'), f.Parameters.GetNameString());
|
||||
sw.WriteLine(" throw new NotImplementedException(\"Wrapper not implemented yet.\");");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
foreach (Block b in BlockCollection)
|
||||
{
|
||||
foreach (Function f in b.Functions)
|
||||
{
|
||||
if (f.NeedsWrapper)
|
||||
{
|
||||
sw.WriteLine(" // Wrapper for function _{0}", f.Name);
|
||||
|
||||
if (f.Name == "glGetString") // Wraps GLubyte* glGetString(GLenum name);
|
||||
{
|
||||
sw.WriteLine(" public {0} {1}{2}", "string", f.Name.TrimStart('g', 'l'), f.Parameters.ToString());
|
||||
sw.WriteLine(" {");
|
||||
sw.WriteLine(" return Marshal.PtrToStringAnsi(_{0}{1});", f.Name.TrimStart('g', 'l'), f.Parameters.GetNameString());
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine();
|
||||
}
|
||||
else if (f.ReturnValue == "Array") // For the 3 functions that return a GLvoid*.
|
||||
{
|
||||
sw.WriteLine(" public {0} {1}{2}", f.ReturnValue, f.Name.TrimStart('g', 'l'), f.Parameters.ToString());
|
||||
sw.WriteLine(" {");
|
||||
// sw.WriteLine(" return Marshal.PtrToStructure(_{0}{1}, new byte[]);", f.Name.TrimStart('g', 'l'), f.Parameters.GetNameString());
|
||||
sw.WriteLine(" throw new NotImplementedException(\"Wrapper not implemented yet.\");");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine();
|
||||
}
|
||||
else if (f.Parameters.ToString().Contains("out Object[]"))
|
||||
{
|
||||
sw.WriteLine(" public {0} {1}{2}", f.ReturnValue, f.Name.TrimStart('g', 'l'), f.Parameters.ToString());
|
||||
sw.WriteLine(" {");
|
||||
sw.WriteLine(" throw new NotImplementedException(\"Wrapper not implemented yet.\");");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine();
|
||||
}
|
||||
else if (f.Parameters.ToString().Contains("Object[]"))
|
||||
{
|
||||
sw.WriteLine(" public {0} {1}{2}", f.ReturnValue, f.Name.TrimStart('g', 'l'), f.Parameters.ToString());
|
||||
sw.WriteLine(" {");
|
||||
sw.WriteLine(" throw new NotImplementedException(\"Wrapper not implemented yet.\");");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine();
|
||||
}
|
||||
else if (f.Parameters.ToString().Contains("out Object")) // For those functions that have an Array 'out' parameter:
|
||||
{
|
||||
sw.WriteLine(" public {0} {1}{2}", f.ReturnValue, f.Name.TrimStart('g', 'l'), f.Parameters.ToString());
|
||||
sw.WriteLine(" {");
|
||||
sw.WriteLine(" throw new NotImplementedException(\"Wrapper not implemented yet.\");");
|
||||
// HACK: The Array parameter is always the last one (I think)
|
||||
// sw.WriteLine(" GCHandle h = GCHandle.Alloc({0}, GCHandleType.Pinned);", f.Parameters[f.Parameters.Count-1].Name);
|
||||
// sw.WriteLine(" try");
|
||||
// sw.WriteLine(" {");
|
||||
// sw.WriteLine(" _{0}{1};", f.Name, f.ParameterNamesWithArrayRenamingString);
|
||||
// sw.WriteLine(" }");
|
||||
// sw.WriteLine(" finally");
|
||||
// sw.WriteLine(" {");
|
||||
// sw.WriteLine(" h.Free();");
|
||||
// sw.WriteLine(" }");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine();
|
||||
}
|
||||
else if (f.Parameters.ToString().Contains("Object"))
|
||||
{
|
||||
sw.WriteLine(" public {0} {1}{2}", f.ReturnValue, f.Name.TrimStart('g', 'l'), f.Parameters.ToString());
|
||||
sw.WriteLine(" {");
|
||||
|
||||
int i = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("(");
|
||||
foreach (Parameter p in f.Parameters)
|
||||
{
|
||||
if (p.Type == "Object")
|
||||
{
|
||||
sw.WriteLine(" GCHandle h{0} = GCHandle.Alloc({1}, GCHandleType.Pinned);", i, p.Name);
|
||||
sb.Append("h" + i + ".AddrOfPinnedObject()" + ", ");
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(p.Name + ", ");
|
||||
}
|
||||
}
|
||||
sb.Replace(", ", ")", sb.Length - 2, 2);
|
||||
|
||||
sw.WriteLine(" try");
|
||||
sw.WriteLine(" {");
|
||||
if (f.ReturnValue == "void")
|
||||
sw.WriteLine(" _{0}{1};", f.Name.TrimStart('g', 'l'), sb.ToString());
|
||||
else
|
||||
sw.WriteLine(" return _{0}{1};", f.Name.TrimStart('g', 'l'), sb.ToString());
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine(" finally");
|
||||
sw.WriteLine(" {");
|
||||
while (i > 0)
|
||||
{
|
||||
sw.WriteLine(" h{0}.Free();", --i);
|
||||
}
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
sw.WriteLine(" public {0} {1}{2}", f.ReturnValue, f.Name.TrimStart('g', 'l'), f.Parameters.ToString());
|
||||
sw.WriteLine(" {");
|
||||
sw.WriteLine(" throw new NotImplementedException(\"Wrapper not implemented yet.\");");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine();
|
||||
}
|
||||
//sw.WriteLine(" public static extern {0} {1} {2};", f.ReturnValue, f.Name.TrimStart('g', 'l'), f.ParameterString);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
sw.WriteLine(" #endregion");
|
||||
sw.WriteLine(" }");
|
||||
sw.WriteLine("}");
|
||||
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Function WeakNameLookup(string name, List<Function> function_list)
|
||||
{
|
||||
foreach (Function f in FunctionCollection)
|
||||
{
|
||||
if (f.Name.Contains(name))
|
||||
return f;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,465 +0,0 @@
|
|||
/* Copyright (c) 2006 Stephen Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenTK.OpenGL.Bind
|
||||
{
|
||||
static class Translation
|
||||
{
|
||||
public static char[] Separators = { ' ', '\n', ',', '(', ')', ';', '#' };
|
||||
public static char[] Whitespace = { ' ' };
|
||||
public static char[] Braces = { '(', ')' };
|
||||
public static char[] Comma = { ',' };
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a possible translation for the parameter given.
|
||||
/// </summary>
|
||||
/// <param name="str">The parameter to be translated.</param>
|
||||
/// <returns>The translation of the parameter, or the parameter itself if no translation is found.</returns>
|
||||
public static string Get(string str)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> pair in translations)
|
||||
if (pair.Key == str)
|
||||
return pair.Value;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static Dictionary<string, string> parameter_names = new Dictionary<string, string>();
|
||||
static Dictionary<string, string> parameter_types = new Dictionary<string, string>();
|
||||
static Dictionary<string, string> old_dictionary = new Dictionary<string, string>();
|
||||
|
||||
#region Constructor
|
||||
|
||||
static Translation()
|
||||
{
|
||||
parameter_names.Add("base", "@base");
|
||||
parameter_names.Add("object", "@object");
|
||||
parameter_names.Add("string", "@string");
|
||||
parameter_names.Add("ref", "reference");
|
||||
parameter_names.Add("params", "parameters");
|
||||
parameter_names.Add("in", "@in");
|
||||
|
||||
parameter_types.Add("Boolean", "bool");
|
||||
parameter_types.Add("BooleanPointer", "bool[]");
|
||||
parameter_types.Add("Char", "char");
|
||||
parameter_types.Add("CharPointer", "string");
|
||||
|
||||
parameter_types.Add("CheckedFloat32", "float");
|
||||
parameter_types.Add("CheckedInt32", "int");
|
||||
|
||||
parameter_types.Add("ClampedColorF", "float");
|
||||
parameter_types.Add("ClampedFloat32", "float");
|
||||
parameter_types.Add("ClampedFloat64", "double");
|
||||
parameter_types.Add("ClampedStencilValue", "int");
|
||||
|
||||
parameter_types.Add("ColorB", "byte");
|
||||
parameter_types.Add("ColorS", "short");
|
||||
parameter_types.Add("ColorI", "int");
|
||||
parameter_types.Add("ColorUB", "byte");
|
||||
parameter_types.Add("ColorUS", "ushort");
|
||||
parameter_types.Add("ColorUI", "uint");
|
||||
parameter_types.Add("ColorF", "float");
|
||||
parameter_types.Add("ColorD", "double");
|
||||
|
||||
parameter_types.Add("ColorIndexValueD", "double");
|
||||
parameter_types.Add("ColorIndexValueF", "float");
|
||||
parameter_types.Add("ColorIndexValueI", "int");
|
||||
parameter_types.Add("ColorIndexValueS", "short");
|
||||
parameter_types.Add("ColorIndexValueUB", "byte");
|
||||
|
||||
parameter_types.Add("CompressedTextureARB", "void");
|
||||
parameter_types.Add("ControlPointNV", "void");
|
||||
|
||||
parameter_types.Add("CoordF", "float");
|
||||
parameter_types.Add("CoordD", "double");
|
||||
parameter_types.Add("CoordI", "int");
|
||||
parameter_types.Add("CoordS", "short");
|
||||
|
||||
parameter_types.Add("FeedbackElement", "float");
|
||||
parameter_types.Add("FenceNV", "uint");
|
||||
|
||||
/////////////////////////////////////
|
||||
parameter_types.Add("Int8", "byte");
|
||||
parameter_types.Add("Int16", "short");
|
||||
parameter_types.Add("Int32", "int");
|
||||
parameter_types.Add("UInt8", "byte");
|
||||
parameter_types.Add("UInt16", "ushort");
|
||||
parameter_types.Add("UInt32", "uint");
|
||||
parameter_types.Add("Float32", "float");
|
||||
parameter_types.Add("Float64", "double");
|
||||
|
||||
parameter_types.Add("ConstFloat32", "float");
|
||||
parameter_types.Add("ConstInt32", "double");
|
||||
parameter_types.Add("ConstUInt32", "uint");
|
||||
parameter_types.Add("ConstVoid", "object");
|
||||
parameter_types.Add("ConstVoidPointer", "object");
|
||||
|
||||
parameter_types.Add("String", "string");
|
||||
parameter_types.Add("Void", "object");
|
||||
parameter_types.Add("VoidPointer", "object");
|
||||
parameter_types.Add("void", "void");
|
||||
|
||||
parameter_types.Add("Float32Pointer", "float");
|
||||
parameter_types.Add("Float32Double", "double");
|
||||
///////////////////////////////////////
|
||||
|
||||
parameter_types.Add("List", "uint");
|
||||
parameter_types.Add("SizeI", "int");
|
||||
parameter_types.Add("LineStipple", "ushort");
|
||||
parameter_types.Add("WinCoord", "int");
|
||||
|
||||
parameter_types.Add("Texture", "uint");
|
||||
parameter_types.Add("TextureComponentCount", "int");
|
||||
|
||||
parameter_types.Add("SelectName", "uint");
|
||||
|
||||
parameter_types.Add("MaskedColorIndexValueF", "float");
|
||||
parameter_types.Add("MaskedColorIndexValueI", "uint");
|
||||
parameter_types.Add("MaskedStencilValue", "uint");
|
||||
parameter_types.Add("StencilValue", "int");
|
||||
|
||||
parameter_types.Add("DrawElementsType", "uint");
|
||||
|
||||
parameter_types.Add("BlendEquationMode", "Enums.BlendEquationModeEXT");
|
||||
|
||||
parameter_types.Add("ColorTableTarget", "Enums.ColorTableTargetSGI");
|
||||
parameter_types.Add("ColorTableParameterPName", "Enums.ColorTableParameterPNameSGI");
|
||||
parameter_types.Add("ConvolutionTarget", "Enums.ConvolutionTargetEXT");
|
||||
parameter_types.Add("ConvolutionParameter", "Enums.ConvolutionParameterEXT");
|
||||
parameter_types.Add("GetColorTableParameterPName", "Enums.GetColorTableParameterPNameSGI");
|
||||
parameter_types.Add("GetConvolutionParameterPName", "Enums.GetConvolutionParameter"); // May not be correct, but was the closest I could find.
|
||||
parameter_types.Add("SeparableTarget", "Enums.SeparableTargetEXT");
|
||||
parameter_types.Add("HistogramTarget", "Enums.HistogramTargetEXT");
|
||||
parameter_types.Add("GetHistogramParameterPName", "Enums.GetHistogramParameterPNameEXT");
|
||||
parameter_types.Add("MinmaxTarget", "Enums.MinmaxTargetEXT");
|
||||
parameter_types.Add("GetMinmaxParameterPName", "Enums.GetMinmaxParameterPNameEXT");
|
||||
|
||||
parameter_types.Add("TextureUnit", "uint");
|
||||
parameter_types.Add("BlendFuncSeparateParameterEXT", "uint");
|
||||
parameter_types.Add("FogPointerTypeEXT", "uint");
|
||||
parameter_types.Add("PointParameterNameARB", "Enums.PointParameterNameSGIS");
|
||||
parameter_types.Add("GLenum", "uint");
|
||||
|
||||
parameter_types.Add("VertexBufferTargetARB", "uint");
|
||||
parameter_types.Add("VertexBufferUsageARB", "uint");
|
||||
parameter_types.Add("VertexBufferSize", "IntPtr");
|
||||
parameter_types.Add("VertexBufferOffset", "IntPtr");
|
||||
parameter_types.Add("VertexBufferPNameARB", "uint");
|
||||
parameter_types.Add("VertexBufferAccessARB", "uint");
|
||||
parameter_types.Add("VertexBufferPointerNameARB", "uint");
|
||||
parameter_types.Add("VertexAttribPropertyARB", "uint");
|
||||
parameter_types.Add("VertexAttribPointerPropertyARB", "uint");
|
||||
parameter_types.Add("VertexAttribPointerTypeARB", "uint");
|
||||
parameter_types.Add("VertexBufferSizeARB", "IntPtr");
|
||||
parameter_types.Add("VertexBufferOffsetARB", "IntPtr");
|
||||
|
||||
parameter_types.Add("DrawBufferModeATI", "Enums.DrawBufferMode");
|
||||
|
||||
parameter_types.Add("StencilFaceDirection", "uint");
|
||||
parameter_types.Add("WeightPointerTypeARB", "uint");
|
||||
parameter_types.Add("MatrixIndexPointerTypeARB", "uint");
|
||||
parameter_types.Add("ProgramFormatARB", "uint");
|
||||
parameter_types.Add("ProgramPropertyARB", "uint");
|
||||
parameter_types.Add("ProgramTargetARB", "uint");
|
||||
parameter_types.Add("ProgramStringPropertyARB", "uint");
|
||||
|
||||
parameter_types.Add("handleARB", "uint");
|
||||
parameter_types.Add("charARB", "char"); // Maybe this should be byte?
|
||||
parameter_types.Add("charPointerARB", "string");
|
||||
|
||||
parameter_types.Add("ClampColorTargetARB", "uint");
|
||||
parameter_types.Add("ClampColorModeARB", "uint");
|
||||
parameter_types.Add("TextureFilterSGIS", "uint");
|
||||
parameter_types.Add("PixelTexGenModeSGIX", "uint");
|
||||
parameter_types.Add("SpriteParameterNameSGIX", "uint");
|
||||
parameter_types.Add("ImageTransformTargetHP", "uint");
|
||||
parameter_types.Add("ImageTransformPNameHP", "uint");
|
||||
parameter_types.Add("HintTargetPGI", "uint");
|
||||
parameter_types.Add("IndexMaterialParameterEXT", "uint");
|
||||
parameter_types.Add("IndexFunctionEXT", "uint");
|
||||
parameter_types.Add("CullParameterEXT", "uint");
|
||||
parameter_types.Add("FragmentLightParameterSGIX", "uint");
|
||||
parameter_types.Add("FragmentLightNameSGIX", "uint");
|
||||
parameter_types.Add("LightTextureModeEXT", "uint");
|
||||
parameter_types.Add("LightTexturePNameEXT", "uint");
|
||||
parameter_types.Add("PixelTransformTargetEXT", "uint");
|
||||
parameter_types.Add("PixelTransformPNameEXT", "uint");
|
||||
parameter_types.Add("TextureNormalModeEXT", "uint");
|
||||
parameter_types.Add("TangentPointerTypeEXT", "uint");
|
||||
parameter_types.Add("BinormalPointerTypeEXT", "uint");
|
||||
parameter_types.Add("ReplacementCodeTypeSUN", "uint");
|
||||
parameter_types.Add("ReplacementCodeSUN", "uint");
|
||||
parameter_types.Add("VertexWeightPointerTypeEXT", "uint");
|
||||
|
||||
parameter_types.Add("CombinerParameterNV", "uint");
|
||||
parameter_types.Add("CombinerMappingNV", "uint");
|
||||
parameter_types.Add("CombinerPortionNV", "uint");
|
||||
parameter_types.Add("CombinerRegisterNV", "uint");
|
||||
parameter_types.Add("CombinerStageNV", "uint");
|
||||
parameter_types.Add("CombinerVariableNV", "uint");
|
||||
parameter_types.Add("CombinerScaleNV", "uint");
|
||||
parameter_types.Add("CombinerBiasNV", "uint");
|
||||
parameter_types.Add("CombinerComponentUsageNV", "uint");
|
||||
|
||||
parameter_types.Add("SecondaryColorPointerTypeIBM", "uint");
|
||||
parameter_types.Add("FogPointerTypeIBM", "uint");
|
||||
parameter_types.Add("SamplePatternEXT", "uint");
|
||||
parameter_types.Add("IglooParameterSGIX", "object");
|
||||
parameter_types.Add("IglooFunctionSelectSGIX", "uint");
|
||||
parameter_types.Add("FenceParameterNameNV", "uint");
|
||||
parameter_types.Add("FenceConditionNV", "uint");
|
||||
parameter_types.Add("MapTypeNV", "uint");
|
||||
parameter_types.Add("EvalTargetNV", "uint");
|
||||
parameter_types.Add("MapParameterNV", "uint");
|
||||
parameter_types.Add("MapAttribParameterNV", "uint");
|
||||
parameter_types.Add("EvalMapsModeNV", "uint");
|
||||
parameter_types.Add("VertexAttribEnumNV", "uint");
|
||||
parameter_types.Add("ProgramCharacterNV", "uint");
|
||||
|
||||
parameter_types.Add("TexBumpParameterATI", "uint");
|
||||
parameter_types.Add("GetTexBumpParameterATI", "uint");
|
||||
parameter_types.Add("SwizzleOpATI", "uint");
|
||||
parameter_types.Add("FragmentOpATI", "uint");
|
||||
parameter_types.Add("PNTrianglesPNameATI", "uint");
|
||||
parameter_types.Add("ArrayObjectUsageATI", "uint");
|
||||
parameter_types.Add("PreserveModeATI", "uint");
|
||||
parameter_types.Add("ArrayObjectPNameATI", "uint");
|
||||
parameter_types.Add("ScalarType", "uint");
|
||||
|
||||
parameter_types.Add("VertexShaderOpEXT", "uint");
|
||||
parameter_types.Add("VertexShaderCoordOutEXT", "uint");
|
||||
parameter_types.Add("VertexShaderWriteMaskEXT", "uint");
|
||||
parameter_types.Add("ParameterRangeEXT", "uint");
|
||||
parameter_types.Add("DataTypeEXT", "uint");
|
||||
parameter_types.Add("VertexShaderStorageTypeEXT", "uint");
|
||||
parameter_types.Add("VertexShaderTextureUnitParameter", "uint");
|
||||
parameter_types.Add("VertexShaderParameterEXT", "uint");
|
||||
parameter_types.Add("VariantCapEXT", "uint");
|
||||
parameter_types.Add("GetVariantValueEXT", "uint");
|
||||
parameter_types.Add("VertexStreamATI", "uint");
|
||||
parameter_types.Add("ElementPointerTypeATI", "uint");
|
||||
parameter_types.Add("OcclusionQueryParameterNameNV", "uint");
|
||||
parameter_types.Add("ObjectTypeAPPLE", "uint");
|
||||
parameter_types.Add("VertexArrayPNameAPPLE", "uint");
|
||||
|
||||
parameter_types.Add("Half16NV", "ushort");
|
||||
parameter_types.Add("PixelDataRangeTargetNV", "uint");
|
||||
//parameter_types.Add("", "");
|
||||
//parameter_types.Add("", "");
|
||||
//parameter_types.Add("", "");
|
||||
//parameter_types.Add("", "");
|
||||
//parameter_types.Add("", "");
|
||||
//parameter_types.Add("", "");
|
||||
//parameter_types.Add("", "");
|
||||
//parameter_types.Add("", "");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Old key pairs
|
||||
|
||||
static KeyValuePair<string, string>[] translations = new KeyValuePair<string, string>[]
|
||||
{
|
||||
// Pointer types.
|
||||
//new KeyValuePair<string, string>("GLhandleARB*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLhalfARB*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLhalfNV*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLcharARB*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLenum*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLboolean*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLbitfield*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLvoid*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLchar*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLbyte*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLshort*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLint*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLubyte*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLushort*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLuint*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLsizei*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLfloat*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLclampf*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLdouble*", "IntPtr"),
|
||||
//new KeyValuePair<string, string>("GLclampd*", "IntPtr"),
|
||||
|
||||
new KeyValuePair<string, string>("GLvoid*", "Array"),
|
||||
|
||||
// ARB and NV types (these should come before normal types to guard against double translation).
|
||||
new KeyValuePair<string, string>("GLsizeiptrARB", "IntPtr"),
|
||||
new KeyValuePair<string, string>("GLintptrARB", "IntPtr"),
|
||||
new KeyValuePair<string, string>("GLhandleARB", "uint"),
|
||||
new KeyValuePair<string, string>("GLhalfARB", "ushort"),
|
||||
new KeyValuePair<string, string>("GLhalfNV", "ushort"),
|
||||
new KeyValuePair<string, string>("GLcharARB", "char"),
|
||||
|
||||
// Normal types.
|
||||
new KeyValuePair<string, string>("GLsizeiptr", "IntPtr"),
|
||||
new KeyValuePair<string, string>("GLintptr", "IntPtr"),
|
||||
new KeyValuePair<string, string>("GLenum", "uint"),
|
||||
new KeyValuePair<string, string>("GLboolean", "bool"),
|
||||
new KeyValuePair<string, string>("GLbitfield", "uint"),
|
||||
new KeyValuePair<string, string>("GLvoid", "void"),
|
||||
new KeyValuePair<string, string>("GLchar", "char"),
|
||||
new KeyValuePair<string, string>("GLbyte", "sbyte"),
|
||||
new KeyValuePair<string, string>("GLshort", "short"),
|
||||
new KeyValuePair<string, string>("GLint", "int"),
|
||||
new KeyValuePair<string, string>("GLubyte", "byte"),
|
||||
new KeyValuePair<string, string>("GLushort", "ushort"),
|
||||
new KeyValuePair<string, string>("GLuint", "uint"),
|
||||
new KeyValuePair<string, string>("GLsizei", "int"),
|
||||
new KeyValuePair<string, string>("GLfloat", "float"),
|
||||
new KeyValuePair<string, string>("GLclampf", "float"),
|
||||
new KeyValuePair<string, string>("GLdouble", "double"),
|
||||
new KeyValuePair<string, string>("GLclampd", "double"),
|
||||
|
||||
new KeyValuePair<string, string>("void", "void"), // For return parameters.
|
||||
|
||||
// Special.
|
||||
//new KeyValuePair<string, string>("*", "[]"),
|
||||
new KeyValuePair<string, string>("const", String.Empty),
|
||||
|
||||
// Since we cannot marshal nested arrays...
|
||||
//new KeyValuePair<string, string>("char[][]", "string[]"),
|
||||
|
||||
//new KeyValuePair<string, string>("#define", "const uint "),
|
||||
//new KeyValuePair<string, string>(" *", "[] "),
|
||||
//new KeyValuePair<string, string>("GLAPI", String.Empty),
|
||||
//new KeyValuePair<string, string>("APIENTRY", String.Empty),
|
||||
//new KeyValuePair<string, string>("APIENTRYP", String.Empty),
|
||||
//new KeyValuePair<string, string>("\n", ""),
|
||||
//new KeyValuePair<string, string>(" out", " output"),
|
||||
//new KeyValuePair<string, string>(" ", " "),
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region Translate function list
|
||||
|
||||
public static void Translate(List<Function> function_list, List<Function> wrapper_list)
|
||||
{
|
||||
string s;
|
||||
|
||||
foreach (Function f in function_list)
|
||||
{
|
||||
Function wf = new Function();
|
||||
wf.ReturnValue = f.ReturnValue;
|
||||
wf.Name = f.Name;
|
||||
|
||||
if (parameter_types.TryGetValue(f.ReturnValue, out s))
|
||||
f.ReturnValue = s;
|
||||
else
|
||||
f.ReturnValue = "Enums." + f.ReturnValue;
|
||||
|
||||
// You may not marshal by return type (the return type must be defined).
|
||||
if (f.ReturnValue == "object")
|
||||
{
|
||||
f.ReturnValue = "IntPtr";
|
||||
wf.ReturnValue = "object";
|
||||
|
||||
f.NeedsWrapper = true;
|
||||
}
|
||||
|
||||
foreach (Parameter p in f.Parameters)
|
||||
{
|
||||
Parameter wp = new Parameter();
|
||||
wp.Name = p.Name;
|
||||
wp.Type = p.Type;
|
||||
wp.Array = p.Array;
|
||||
wp.Flow = p.Flow;
|
||||
wf.Parameters.Add(wp);
|
||||
|
||||
if (parameter_names.TryGetValue(p.Name, out s))
|
||||
{
|
||||
p.Name = s;
|
||||
wp.Name = s;
|
||||
}
|
||||
|
||||
if (parameter_types.TryGetValue(p.Type, out s))
|
||||
{
|
||||
p.Type = s;
|
||||
wp.Type = s;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.Type = "Enums." + p.Type;
|
||||
wp.Type = p.Type;
|
||||
}
|
||||
|
||||
if (p.Type == "object")
|
||||
{
|
||||
p.Array = false;
|
||||
p.Type = "object";
|
||||
p.UnmanagedType = System.Runtime.InteropServices.UnmanagedType.AsAny;
|
||||
//p.Type = "IntPtr";
|
||||
//wp.Array = false;
|
||||
//f.NeedsWrapper = true;
|
||||
}
|
||||
|
||||
if (p.Type == "void" && p.Array)
|
||||
{
|
||||
p.Array = false;
|
||||
p.Type = "object";
|
||||
p.UnmanagedType = System.Runtime.InteropServices.UnmanagedType.AsAny;
|
||||
//p.Type = "IntPtr";
|
||||
//wp.Type = "object";
|
||||
//wp.Array = true;
|
||||
//f.NeedsWrapper = true;
|
||||
}
|
||||
|
||||
if (p.Array)
|
||||
{
|
||||
p.Type = p.Type + "[]";
|
||||
wp.Type = wp.Type + "[]";
|
||||
}
|
||||
|
||||
//if (p.Flow == Parameter.FlowDirection.Out && p.Type.Contains("string"))
|
||||
// p.Type.Replace("string", "StringBuilder");
|
||||
|
||||
if (p.Type.Contains("[][]"))
|
||||
{
|
||||
p.Type = "ref " + p.Type.Replace("[][]", "[]");
|
||||
wp.Type = "ref " + wp.Type.Replace("[][]", "[]");
|
||||
}
|
||||
}
|
||||
|
||||
if (f.NeedsWrapper)
|
||||
{
|
||||
f.Name = f.Name + "_";
|
||||
wrapper_list.Add(wf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Translate enum hashtable
|
||||
|
||||
public static void Translate(System.Collections.Hashtable e_table)
|
||||
{
|
||||
foreach (Enum e in e_table.Values)
|
||||
{
|
||||
if (Char.IsDigit(e.Name[0]))
|
||||
e.Name = e.Name.Insert(0, "_");
|
||||
|
||||
if (e.Name == "Boolean")
|
||||
continue;
|
||||
|
||||
foreach (Constant c in e.ConstantCollection.Values)
|
||||
{
|
||||
if (Char.IsDigit(c.Name[0]))
|
||||
c.Name = c.Name.Insert(0, "_");
|
||||
|
||||
if (c.Value.Contains(".") && Char.IsDigit(c.Value[c.Value.IndexOf('.') + 1]))
|
||||
c.Value = c.Value.Insert(c.Value.IndexOf('.') + 1, "_");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
..\Binaries\Debug\Bind.exe.config
|
||||
$(SolutionDir)Binaries\Debug\Bind.exe.config
|
||||
$(SolutionDir)Binaries\Debug\Bind.exe
|
||||
$(SolutionDir)Binaries\Debug\Bind.pdb
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
..\..\Binaries\Debug\OpenTK.OpenGL.Bind.exe.config
|
||||
..\..\Binaries\Debug\OpenTK.OpenGL.Bind.exe
|
||||
..\..\Binaries\Debug\OpenTK.OpenGL.Bind.pdb
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,15 +0,0 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenTK.OpenGL
|
||||
{
|
||||
public partial class GL
|
||||
{
|
||||
#region Wrappers
|
||||
|
||||
// Wrapper for function MapBuffer
|
||||
// Wrapper for function MapBufferARB
|
||||
// Wrapper for function MapObjectBufferATI
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
bin\Release\OpenGL.dll
|
||||
bin\Release\OpenGL.pdb
|
||||
bin\Debug\OpenGL.dll
|
||||
bin\Debug\OpenGL.pdb
|
||||
..\Binaries\Debug\OpenGL.dll
|
||||
..\Binaries\Debug\OpenGL.pdb
|
|
@ -1,5 +0,0 @@
|
|||
obj\Debug\OpenGL.dll
|
||||
obj\Debug\OpenGL.pdb
|
||||
..\..\Binaries\Debug\OpenGL.dll
|
||||
..\..\Binaries\Debug\OpenGL.pdb
|
||||
obj\Debug\ResolveAssemblyReference.cache
|
Loading…
Reference in a new issue