mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 06:25:32 +00:00
Sycned with gl3 branch.
This commit is contained in:
parent
de43ff5f1f
commit
00da3bf3f4
|
@ -1,3 +1,21 @@
|
|||
OpenTK 0.3.8 -> 0.3.9
|
||||
|
||||
+ Bind
|
||||
+ Rewrote almost everything. Does not rely on CodeDOM anymore (wasn't flexible enough).
|
||||
+ Initial work for gl3, wgl, glx, glu compatibility.
|
||||
+ Implemented almost all pending features:
|
||||
+ Extensions in different classes (e.g. GL.ARB.ActiveTexture)
|
||||
+ Fixed statement instead of GCHandle for improved performance
|
||||
+ Real pointers instead of IntPtrs
|
||||
+ CLS-Compliant and non CLS-Compliant overloads (e.g. functions with unsigned parameters).
|
||||
+ Overloads over the 'basic' function (e.g. GL.Vertex3fv -> GL.Vertex3)
|
||||
+ Enums now in the GL class.
|
||||
+ New commandline options
|
||||
+ 'legacy': defines compatibility with Tao ('-legacy:tao')
|
||||
+ 'mode': defines translation mode (e.g. gl2, gl3, wgl etc)
|
||||
+ 4 files are now generated: GL.cs, GLCore.cs, GLDelegates.cs, GLEnums.cs
|
||||
|
||||
|
||||
OpenTK 0.3.7 -> 0.3.8
|
||||
|
||||
+ New project layout. Only four projects remain under the 'Source' directory: Bind, Build, Examples, OpenTK
|
||||
|
|
|
@ -9,69 +9,32 @@ namespace Bind.GL2
|
|||
{
|
||||
class Generator : IBind
|
||||
{
|
||||
private SpecReader specReader = new SpecReader();
|
||||
private SpecWriter specWriter = new SpecWriter();
|
||||
DelegateCollection delegates = new DelegateCollection();
|
||||
FunctionCollection wrappers = new FunctionCollection();
|
||||
//List<Bind.Structures.Enum> enums = new List<Bind.Structures.Enum>();
|
||||
EnumCollection enums = new EnumCollection();
|
||||
EnumCollection extEnums = new EnumCollection();
|
||||
Dictionary<string, string> GLTypes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> CSTypes = new Dictionary<string, string>();
|
||||
internal static SpecReader specReader;
|
||||
internal static SpecWriter specWriter;
|
||||
|
||||
string specFolder;
|
||||
|
||||
public Generator(string folder)
|
||||
{
|
||||
specFolder = folder;
|
||||
specReader = new GL2.SpecReader();
|
||||
specWriter = new GL2.SpecWriter();
|
||||
}
|
||||
|
||||
#region IBind Members
|
||||
|
||||
/*
|
||||
public ISpecReader SpecReader
|
||||
{
|
||||
get { return specReader; }
|
||||
}
|
||||
*/
|
||||
|
||||
#region public void Process()
|
||||
|
||||
public void Process()
|
||||
{
|
||||
// Read
|
||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\gl.tm"))
|
||||
{
|
||||
GLTypes = specReader.ReadTypeMap(sr);
|
||||
}
|
||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\csharp.tm"))
|
||||
{
|
||||
CSTypes = specReader.ReadCSTypeMap(sr);
|
||||
}
|
||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\gl.spec"))
|
||||
{
|
||||
delegates = specReader.ReadDelegates(sr);
|
||||
}
|
||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\enum.spec"))
|
||||
{
|
||||
enums = specReader.ReadEnums(sr);
|
||||
}
|
||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\enumext.spec"))
|
||||
{
|
||||
extEnums = specReader.ReadEnums(sr);
|
||||
}
|
||||
|
||||
// Merge all opengl enumerants in enums
|
||||
foreach (Bind.Structures.Enum e in extEnums.Values)
|
||||
{
|
||||
//enums.Add(e.Name, e);
|
||||
Utilities.Merge(enums, e);
|
||||
}
|
||||
Bind.Structures.Type.Initialize();
|
||||
Bind.Structures.Enum.Initialize();
|
||||
Bind.Structures.Function.Initialize();
|
||||
Bind.Structures.Delegate.Initialize();
|
||||
|
||||
// Process enums and delegates - create wrappers.
|
||||
this.Translate();
|
||||
|
||||
|
||||
// Write
|
||||
using (BindStreamWriter sw = new BindStreamWriter(Path.Combine(Settings.OutputPath, "GLEnums.cs")))
|
||||
{
|
||||
|
@ -83,7 +46,7 @@ namespace Bind.GL2
|
|||
sw.WriteLine("{");
|
||||
|
||||
sw.Indent();
|
||||
specWriter.WriteEnums(sw, enums);
|
||||
specWriter.WriteEnums(sw, Bind.Structures.Enum.GLEnums);
|
||||
sw.Unindent();
|
||||
|
||||
sw.WriteLine("}");
|
||||
|
@ -97,8 +60,10 @@ namespace Bind.GL2
|
|||
sw.WriteLine("{");
|
||||
|
||||
sw.Indent();
|
||||
specWriter.WriteTypes(sw, CSTypes);
|
||||
specWriter.WriteDelegates(sw, delegates);
|
||||
//specWriter.WriteTypes(sw, Bind.Structures.Type.CSTypes);
|
||||
sw.WriteLine("using System;");
|
||||
sw.WriteLine("using System.Runtime.InteropServices;");
|
||||
specWriter.WriteDelegates(sw, Bind.Structures.Delegate.Delegates);
|
||||
sw.Unindent();
|
||||
|
||||
sw.WriteLine("}");
|
||||
|
@ -109,8 +74,10 @@ namespace Bind.GL2
|
|||
sw.WriteLine("{");
|
||||
|
||||
sw.Indent();
|
||||
specWriter.WriteTypes(sw, CSTypes);
|
||||
specWriter.WriteImports(sw, delegates);
|
||||
//specWriter.WriteTypes(sw, Bind.Structures.Type.CSTypes);
|
||||
sw.WriteLine("using System;");
|
||||
sw.WriteLine("using System.Runtime.InteropServices;");
|
||||
specWriter.WriteImports(sw, Bind.Structures.Delegate.Delegates);
|
||||
sw.Unindent();
|
||||
|
||||
sw.WriteLine("}");
|
||||
|
@ -121,8 +88,10 @@ namespace Bind.GL2
|
|||
sw.WriteLine("{");
|
||||
|
||||
sw.Indent();
|
||||
specWriter.WriteTypes(sw, CSTypes);
|
||||
specWriter.WriteWrappers(sw, wrappers, CSTypes);
|
||||
//specWriter.WriteTypes(sw, Bind.Structures.Type.CSTypes);
|
||||
sw.WriteLine("using System;");
|
||||
sw.WriteLine("using System.Runtime.InteropServices;");
|
||||
specWriter.WriteWrappers(sw, Bind.Structures.Function.Wrappers, Bind.Structures.Type.CSTypes);
|
||||
sw.Unindent();
|
||||
|
||||
sw.WriteLine("}");
|
||||
|
@ -137,184 +106,15 @@ namespace Bind.GL2
|
|||
|
||||
private void Translate()
|
||||
{
|
||||
foreach (Bind.Structures.Enum e in enums.Values)
|
||||
foreach (Bind.Structures.Enum e in Bind.Structures.Enum.GLEnums.Values)
|
||||
{
|
||||
TranslateEnum(e);
|
||||
}
|
||||
|
||||
foreach (Bind.Structures.Delegate d in delegates.Values)
|
||||
foreach (Bind.Structures.Delegate d in Bind.Structures.Delegate.Delegates.Values)
|
||||
{
|
||||
TranslateReturnType(d);
|
||||
TranslateParameters(d);
|
||||
//wrappers.AddRange(d.CreateWrappers());
|
||||
foreach (Function f in d.CreateWrappers(CSTypes))
|
||||
{
|
||||
if (!f.CLSCompliant)
|
||||
{
|
||||
Function clsFunction = f.GetCLSCompliantFunction(CSTypes);
|
||||
if (clsFunction.Parameters.ToString(true) != f.Parameters.ToString(true))
|
||||
wrappers.Add(clsFunction);
|
||||
}
|
||||
wrappers.Add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private void TranslateReturnType(Bind.Structures.Delegate d)
|
||||
|
||||
/// <summary>
|
||||
/// Translates the opengl return type to the equivalent C# type.
|
||||
/// </summary>
|
||||
/// <param name="d">The opengl function to translate.</param>
|
||||
/// <remarks>
|
||||
/// First, we use the official typemap (gl.tm) to get the correct type.
|
||||
/// Then we override this, when it is:
|
||||
/// 1) A string (we have to use Marshal.PtrToStringAnsi, to avoid heap corruption)
|
||||
/// 2) An array (translates to IntPtr)
|
||||
/// 3) A generic object or void* (translates to IntPtr)
|
||||
/// 4) A GLenum (translates to int on Legacy.Tao or GL.Enums.GLenum otherwise).
|
||||
/// Return types must always be CLS-compliant, because .Net does not support overloading on return types.
|
||||
/// </remarks>
|
||||
private void TranslateReturnType(Bind.Structures.Delegate d)
|
||||
{
|
||||
if (GLTypes.ContainsKey(d.ReturnType.Type))
|
||||
{
|
||||
d.ReturnType.Type = GLTypes[d.ReturnType.Type];
|
||||
}
|
||||
|
||||
if (d.ReturnType.Type.ToLower().Contains("void") && d.ReturnType.Pointer)
|
||||
{
|
||||
d.ReturnType.WrapperType = WrapperTypes.GenericReturnType;
|
||||
}
|
||||
|
||||
if (d.ReturnType.Type == "GLstring")
|
||||
{
|
||||
d.ReturnType.Type = "System.IntPtr";
|
||||
d.ReturnType.WrapperType = WrapperTypes.StringReturnType;
|
||||
}
|
||||
|
||||
if (d.ReturnType.Type.ToLower().Contains("object"))
|
||||
{
|
||||
d.ReturnType.Type = "System.IntPtr";
|
||||
d.ReturnType.WrapperType |= WrapperTypes.GenericReturnType;
|
||||
}
|
||||
|
||||
if (d.ReturnType.Type == "GLenum")
|
||||
{
|
||||
if (Settings.Compatibility == Settings.Legacy.None)
|
||||
d.ReturnType.Type = Settings.GLClass + ".Enums.GLenum";
|
||||
else
|
||||
d.ReturnType.Type = "int";
|
||||
}
|
||||
|
||||
if (d.ReturnType.Type.ToLower().Contains("bool") && Settings.Compatibility == Settings.Legacy.Tao)
|
||||
{
|
||||
d.ReturnType.Type = "int";
|
||||
}
|
||||
|
||||
if (d.ReturnType.WrapperType != WrapperTypes.None)
|
||||
{
|
||||
d.NeedsWrapper = true;
|
||||
}
|
||||
|
||||
d.ReturnType.Type = d.ReturnType.GetCLSCompliantType(CSTypes);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private void TranslateParameters(Bind.Structures.Delegate d)
|
||||
|
||||
private void TranslateParameters(Bind.Structures.Delegate d)
|
||||
{
|
||||
string s;
|
||||
Bind.Structures.Enum @enum;
|
||||
|
||||
foreach (Parameter p in d.Parameters)
|
||||
{
|
||||
// Translate enum parameters
|
||||
if (enums.TryGetValue(p.Type, out @enum) && @enum.Name != "GLenum")
|
||||
{
|
||||
if (Settings.Compatibility == Settings.Legacy.None)
|
||||
p.Type = p.Type.Insert(0, Settings.GLClass + ".Enums.");
|
||||
else
|
||||
p.Type = "int";
|
||||
}
|
||||
else if (GLTypes.TryGetValue(p.Type, out s))
|
||||
{
|
||||
// Check if the parameter is a generic GLenum. If yes,
|
||||
// check if a better match exists:
|
||||
if (s.Contains("GLenum") && !String.IsNullOrEmpty(d.Category))
|
||||
{
|
||||
if (Settings.Compatibility == Settings.Legacy.None)
|
||||
{
|
||||
// Better match: enum.Name == function.Category (e.g. GL_VERSION_1_1 etc)
|
||||
if (enums.ContainsKey(d.Category))
|
||||
{
|
||||
p.Type = Settings.GLClass + ".Enums." + d.Category;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.Type = Settings.GLClass + ".Enums.GLenum";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p.Type = "int";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is not enum, default translation:
|
||||
p.Type = s;
|
||||
}
|
||||
}
|
||||
|
||||
// Translate pointer parameters
|
||||
if (p.Pointer)
|
||||
{
|
||||
p.WrapperType = WrapperTypes.ArrayParameter;
|
||||
|
||||
if (p.Type.ToLower().Contains("char") || p.Type.ToLower().Contains("string"))
|
||||
{
|
||||
// char* or string -> [In] String or [Out] StringBuilder
|
||||
p.Type =
|
||||
p.Flow == Parameter.FlowDirection.Out ?
|
||||
"System.Text.StringBuilder" :
|
||||
"System.String";
|
||||
|
||||
if (d.Name.Contains("ShaderSource"))
|
||||
{
|
||||
// Special case: these functions take a string[]
|
||||
//p.IsPointer = true;
|
||||
p.Array = 1;
|
||||
}
|
||||
|
||||
p.Pointer = false;
|
||||
p.WrapperType = WrapperTypes.None;
|
||||
}
|
||||
else if (p.Type.ToLower().Contains("void"))
|
||||
{
|
||||
p.WrapperType = WrapperTypes.GenericParameter;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for LineStipple (should be unchecked)
|
||||
if (p.Type.ToLower().Contains("ushort") && d.Name.Contains("LineStipple"))
|
||||
{
|
||||
p.WrapperType = WrapperTypes.UncheckedParameter;
|
||||
}
|
||||
|
||||
if (p.Type.ToLower().Contains("bool"))
|
||||
{
|
||||
p.WrapperType = WrapperTypes.BoolParameter;
|
||||
}
|
||||
|
||||
if (p.WrapperType != WrapperTypes.None)
|
||||
{
|
||||
d.NeedsWrapper = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,7 +124,6 @@ namespace Bind.GL2
|
|||
|
||||
private void TranslateEnum(Bind.Structures.Enum e)
|
||||
{
|
||||
|
||||
foreach (Constant c in e.ConstantCollection.Values)
|
||||
{
|
||||
// There are cases when a value is an aliased constant, with no enum specified.
|
||||
|
@ -332,7 +131,7 @@ namespace Bind.GL2
|
|||
// In this case try searching all enums for the correct constant to alias (stupid opengl specs).
|
||||
if (String.IsNullOrEmpty(c.Reference) && !Char.IsDigit(c.Value[0]))
|
||||
{
|
||||
foreach (Bind.Structures.Enum @enum in enums.Values)
|
||||
foreach (Bind.Structures.Enum @enum in Bind.Structures.Enum.GLEnums.Values)
|
||||
{
|
||||
// Skip generic GLenum
|
||||
if (@enum.Name == "GLenum")
|
||||
|
@ -348,5 +147,53 @@ namespace Bind.GL2
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISpecReader Members
|
||||
|
||||
public DelegateCollection ReadDelegates(StreamReader specFile)
|
||||
{
|
||||
return specReader.ReadDelegates(specFile);
|
||||
}
|
||||
|
||||
public EnumCollection ReadEnums(StreamReader specFile)
|
||||
{
|
||||
return specReader.ReadEnums(specFile);
|
||||
}
|
||||
|
||||
public Dictionary<string, string> ReadTypeMap(StreamReader specFile)
|
||||
{
|
||||
return specReader.ReadTypeMap(specFile);
|
||||
}
|
||||
|
||||
public Dictionary<string, string> ReadCSTypeMap(StreamReader specFile)
|
||||
{
|
||||
return specReader.ReadCSTypeMap(specFile);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISpecWriter Members
|
||||
|
||||
public void WriteDelegates(BindStreamWriter sw, DelegateCollection delegates)
|
||||
{
|
||||
specWriter.WriteDelegates(sw, delegates);
|
||||
}
|
||||
|
||||
public void WriteWrappers(BindStreamWriter sw, FunctionCollection wrappers, Dictionary<string, string> CSTypes)
|
||||
{
|
||||
specWriter.WriteWrappers(sw, wrappers, CSTypes);
|
||||
}
|
||||
|
||||
public void WriteEnums(BindStreamWriter sw, EnumCollection enums)
|
||||
{
|
||||
specWriter.WriteEnums(sw, enums);
|
||||
}
|
||||
|
||||
public void WriteTypes(BindStreamWriter sw, Dictionary<string, string> CSTypes)
|
||||
{
|
||||
specWriter.WriteTypes(sw, CSTypes);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Bind.GL2
|
|||
// Get function name:
|
||||
d.Name = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries)[0];
|
||||
|
||||
if (d.Name == "CallLists")
|
||||
if (d.Name.Contains("MultiTexCoord1"))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -54,19 +54,17 @@ namespace Bind.GL2
|
|||
switch (words[0])
|
||||
{
|
||||
case "return": // Line denotes return value
|
||||
d.ReturnType.Type = words[1];
|
||||
d.ReturnType.CurrentType = words[1];
|
||||
break;
|
||||
|
||||
case "param": // Line denotes parameter
|
||||
Parameter p = new Parameter();
|
||||
WrapperTypes wrapper;
|
||||
string type;
|
||||
|
||||
p.Name = Utilities.Keywords.Contains(words[1]) ? "@" + words[1] : words[1];
|
||||
p.Type = words[2];
|
||||
p.CurrentType = words[2];
|
||||
p.Pointer = words[4] == "array" ? true : false;
|
||||
p.Flow = words[3] == "in" ? Parameter.FlowDirection.In : Parameter.FlowDirection.Out;
|
||||
|
||||
|
||||
d.Parameters.Add(p);
|
||||
break;
|
||||
|
||||
|
@ -82,6 +80,8 @@ namespace Bind.GL2
|
|||
}
|
||||
while (!specFile.EndOfStream);
|
||||
|
||||
d.Translate();
|
||||
|
||||
delegates.Add(d);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,13 +114,6 @@ namespace Bind.GL2
|
|||
|
||||
foreach (Function f in wrappers[key])
|
||||
{
|
||||
if (Settings.Compatibility != Settings.Legacy.Tao)
|
||||
Utilities.StripGL2Extension(f);
|
||||
|
||||
if (f.Name == "ActiveTexture")
|
||||
{
|
||||
}
|
||||
|
||||
if (!f.CLSCompliant)
|
||||
{
|
||||
sw.WriteLine("[System.CLSCompliant(false)]");
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Text;
|
|||
|
||||
namespace Bind
|
||||
{
|
||||
interface IBind
|
||||
interface IBind : ISpecReader, ISpecWriter
|
||||
{
|
||||
//ISpecReader SpecReader { get; }
|
||||
void Process();
|
||||
|
|
|
@ -50,6 +50,8 @@ namespace Bind
|
|||
{
|
||||
static GeneratorMode mode;
|
||||
|
||||
static internal IBind Generator;
|
||||
|
||||
static void Main(string[] arguments)
|
||||
{
|
||||
Debug.Listeners.Clear();
|
||||
|
@ -65,8 +67,6 @@ namespace Bind
|
|||
//Console.WriteLine(" - the OpenTK team ;-)");
|
||||
Console.WriteLine();
|
||||
|
||||
IBind bind;
|
||||
|
||||
#region Handle Arguments
|
||||
|
||||
try
|
||||
|
@ -141,14 +141,14 @@ namespace Bind
|
|||
switch (mode)
|
||||
{
|
||||
case GeneratorMode.GL2:
|
||||
bind = new Bind.GL2.Generator(Settings.InputPath);
|
||||
Generator = new Bind.GL2.Generator(Settings.InputPath);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException(String.Format("Mode {0} not implemented.", mode));
|
||||
}
|
||||
|
||||
bind.Process();
|
||||
Generator.Process();
|
||||
|
||||
ticks = System.DateTime.Now.Ticks - ticks;
|
||||
|
||||
|
|
|
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.9.5.1")]
|
||||
[assembly: AssemblyFileVersion("0.9.5.1")]
|
||||
[assembly: AssemblyVersion("0.9.7.1")]
|
||||
[assembly: AssemblyFileVersion("0.9.7.1")]
|
||||
|
|
|
@ -15,6 +15,13 @@ namespace Bind
|
|||
public static string OutputPath = "..\\..\\..\\Source\\OpenTK\\OpenGL\\Bindings";
|
||||
public static string OutputNamespace = "OpenTK.OpenGL";
|
||||
public static string GLClass = "GL";
|
||||
private static string enumsClass = "Enums";
|
||||
public static string GLEnumsClass
|
||||
{
|
||||
get { return GLClass + "." + enumsClass; }
|
||||
set { enumsClass = value; }
|
||||
|
||||
}
|
||||
public static string DelegatesClass = "Delegates";
|
||||
public static string ImportsClass = "Imports";
|
||||
public static string WglClass = "Wgl";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#region License
|
||||
//Copyright (c) 2006 Stefanos Apostolopoulos
|
||||
//See license.txt for license info
|
||||
#region --- License ---
|
||||
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
@ -8,6 +9,7 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace Bind.Structures
|
||||
{
|
||||
|
@ -17,6 +19,22 @@ namespace Bind.Structures
|
|||
/// </summary>
|
||||
public class Delegate
|
||||
{
|
||||
internal static DelegateCollection Delegates;
|
||||
|
||||
private static bool delegatesLoaded;
|
||||
internal static void Initialize()
|
||||
{
|
||||
if (!delegatesLoaded)
|
||||
{
|
||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\gl.spec"))
|
||||
{
|
||||
Delegates = Bind.MainClass.Generator.ReadDelegates(sr);
|
||||
}
|
||||
|
||||
delegatesLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
#region --- Constructors ---
|
||||
|
||||
public Delegate()
|
||||
|
@ -29,9 +47,9 @@ namespace Bind.Structures
|
|||
this.Category = new string(d.Category.ToCharArray());
|
||||
//this.Extension = !String.IsNullOrEmpty(d.Extension) ? new string(d.Extension.ToCharArray()) : "";
|
||||
this.Name = new string(d.Name.ToCharArray());
|
||||
this.NeedsWrapper = d.NeedsWrapper;
|
||||
//this.NeedsWrapper = d.NeedsWrapper;
|
||||
this.Parameters = new ParameterCollection(d.Parameters);
|
||||
this.ReturnType = new Parameter(d.ReturnType);
|
||||
this.ReturnType = new Type(d.ReturnType);
|
||||
this.Version = !String.IsNullOrEmpty(d.Version) ? new string(d.Version.ToCharArray()) : "";
|
||||
//this.Unsafe = d.Unsafe;
|
||||
}
|
||||
|
@ -89,8 +107,24 @@ namespace Bind.Structures
|
|||
/// </summary>
|
||||
public bool NeedsWrapper
|
||||
{
|
||||
get { return _needs_wrapper; }
|
||||
set { _needs_wrapper = value; }
|
||||
//get { return _needs_wrapper; }
|
||||
//set { _needs_wrapper = value; }
|
||||
|
||||
get
|
||||
{
|
||||
// TODO: Add special cases for (Get)ShaderSource.
|
||||
|
||||
if (ReturnType.WrapperType != WrapperTypes.None)
|
||||
return true;
|
||||
|
||||
foreach (Parameter p in Parameters)
|
||||
{
|
||||
if (p.WrapperType != WrapperTypes.None)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -125,28 +159,28 @@ namespace Bind.Structures
|
|||
|
||||
#region public Parameter ReturnType
|
||||
|
||||
Parameter _return_type = new Parameter();
|
||||
Type _return_type = new Type();
|
||||
/// <summary>
|
||||
/// Gets or sets the return value of the opengl function.
|
||||
/// </summary>
|
||||
public Parameter ReturnType
|
||||
public Type ReturnType
|
||||
{
|
||||
get { return _return_type; }
|
||||
set
|
||||
{
|
||||
_return_type = value;
|
||||
_return_type = Type.Translate(value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public string Name
|
||||
#region public virtual string Name
|
||||
|
||||
string _name;
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the opengl function.
|
||||
/// </summary>
|
||||
public string Name
|
||||
public virtual string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set
|
||||
|
@ -165,7 +199,7 @@ namespace Bind.Structures
|
|||
public ParameterCollection Parameters
|
||||
{
|
||||
get { return _parameters; }
|
||||
set { _parameters = value; }
|
||||
protected set { _parameters = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -222,51 +256,7 @@ namespace Bind.Structures
|
|||
sb.Append(Settings.DelegatesClass);
|
||||
sb.Append(".gl");
|
||||
sb.Append(Name);
|
||||
sb.Append("(");
|
||||
if (this.Name == "CallLists")
|
||||
{
|
||||
}
|
||||
if (Parameters.Count > 0)
|
||||
{
|
||||
foreach (Parameter p in Parameters)
|
||||
{
|
||||
if (p.Unchecked)
|
||||
sb.Append("unchecked((" + p.Type + ")");
|
||||
|
||||
if (p.Type != "object")
|
||||
{
|
||||
if (p.Type.ToLower().Contains("string"))
|
||||
{
|
||||
sb.Append(String.Format(
|
||||
"({0}{1})",
|
||||
p.Type,
|
||||
(p.Array > 0) ? "[]" : ""));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(String.Format(
|
||||
"({0}{1})",
|
||||
p.Type,
|
||||
(p.Pointer || p.Array > 0 || p.Reference) ? "*" : ""));
|
||||
}
|
||||
}
|
||||
|
||||
sb.Append(
|
||||
Utilities.Keywords.Contains(p.Name) ? "@" + p.Name : p.Name
|
||||
);
|
||||
|
||||
if (p.Unchecked)
|
||||
sb.Append(")");
|
||||
|
||||
sb.Append(", ");
|
||||
}
|
||||
sb.Replace(", ", ")", sb.Length - 2, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(")");
|
||||
}
|
||||
sb.Append(Parameters.CallString());
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -312,16 +302,16 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
public Delegate GetCLSCompliantDelegate(Dictionary<string, string> CSTypes)
|
||||
public Delegate GetCLSCompliantDelegate()
|
||||
{
|
||||
Delegate f = new Delegate(this);
|
||||
|
||||
for (int i = 0; i < f.Parameters.Count; i++)
|
||||
{
|
||||
f.Parameters[i].Type = f.Parameters[i].GetCLSCompliantType(CSTypes);
|
||||
f.Parameters[i].CurrentType = f.Parameters[i].GetCLSCompliantType();
|
||||
}
|
||||
|
||||
f.ReturnType.Type = f.ReturnType.GetCLSCompliantType(CSTypes);
|
||||
f.ReturnType.CurrentType = f.ReturnType.GetCLSCompliantType();
|
||||
|
||||
return f;
|
||||
}
|
||||
|
@ -330,11 +320,11 @@ namespace Bind.Structures
|
|||
|
||||
#region --- Wrapper Creation ---
|
||||
|
||||
#region public List<Function> CreateWrappers(Dictionary<string, string> CSTypes)
|
||||
#region public IEnumerable<Function> CreateWrappers()
|
||||
|
||||
public List<Function> CreateWrappers(Dictionary<string, string> CSTypes)
|
||||
public IEnumerable<Function> CreateWrappers()
|
||||
{
|
||||
if (this.Name == "MapBuffer")
|
||||
if (this.Name.Contains("GetString"))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -344,7 +334,7 @@ namespace Bind.Structures
|
|||
// No special wrapper needed - just call this delegate:
|
||||
Function f = new Function(this);
|
||||
|
||||
if (f.ReturnType.Type.ToLower().Contains("void"))
|
||||
if (f.ReturnType.CurrentType.ToLower().Contains("void"))
|
||||
f.Body.Add(String.Format("{0};", f.CallString()));
|
||||
else
|
||||
f.Body.Add(String.Format("return {0};", f.CallString()));
|
||||
|
@ -353,57 +343,10 @@ namespace Bind.Structures
|
|||
}
|
||||
else
|
||||
{
|
||||
// We have to add wrappers for all possible WrapperTypes.
|
||||
Function f;
|
||||
Function f = WrapReturnType();
|
||||
|
||||
// First, check if the return type needs wrapping:
|
||||
switch (this.ReturnType.WrapperType)
|
||||
{
|
||||
// If the function returns a string (glGetString) we must manually marshal it
|
||||
// using Marshal.PtrToStringXXX. Otherwise, the GC will try to free the memory
|
||||
// used by the string, resulting in corruption (the memory belongs to the
|
||||
// unmanaged boundary).
|
||||
case WrapperTypes.StringReturnType:
|
||||
f = new Function(this);
|
||||
f.ReturnType.Type = "System.String";
|
||||
|
||||
f.Body.Add(
|
||||
String.Format(
|
||||
"return System.Runtime.InteropServices.Marshal.PtrToStringAnsi({0});",
|
||||
this.CallString()
|
||||
)
|
||||
);
|
||||
|
||||
wrappers.Add(f);
|
||||
return wrappers; // Only occurs in glGetString, there's no need to check parameters.
|
||||
|
||||
// If the function returns a void* (GenericReturnValue), we'll have to return an IntPtr.
|
||||
// The user will unfortunately need to marshal this IntPtr to a data type manually.
|
||||
case WrapperTypes.GenericReturnType:
|
||||
ReturnType.Type = "IntPtr";
|
||||
ReturnType.Pointer = false;
|
||||
/*
|
||||
f = new Function(this);
|
||||
f.ReturnType.Type = "IntPtr";
|
||||
f.ReturnType.Pointer = false;
|
||||
|
||||
if (f.ReturnType.Type.ToLower().Contains("void"))
|
||||
f.Body.Add(String.Format("{0};", f.CallString()));
|
||||
else
|
||||
f.Body.Add(String.Format("return {0};", f.CallString()));
|
||||
|
||||
wrappers.Add(f);
|
||||
*/
|
||||
break;
|
||||
|
||||
case WrapperTypes.None:
|
||||
default:
|
||||
// No return wrapper needed
|
||||
break;
|
||||
}
|
||||
|
||||
// Then, create wrappers for each parameter:
|
||||
WrapParameters(new Function(this), wrappers, CSTypes);
|
||||
WrapParameters(new Function((Function)f ?? this), wrappers);
|
||||
}
|
||||
|
||||
return wrappers;
|
||||
|
@ -411,6 +354,52 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
#region protected Function WrapReturnType()
|
||||
|
||||
protected Function WrapReturnType()
|
||||
{
|
||||
// We have to add wrappers for all possible WrapperTypes.
|
||||
Function f;
|
||||
|
||||
// First, check if the return type needs wrapping:
|
||||
switch (this.ReturnType.WrapperType)
|
||||
{
|
||||
// If the function returns a string (glGetString) we must manually marshal it
|
||||
// using Marshal.PtrToStringXXX. Otherwise, the GC will try to free the memory
|
||||
// used by the string, resulting in corruption (the memory belongs to the
|
||||
// unmanaged boundary).
|
||||
case WrapperTypes.StringReturnType:
|
||||
f = new Function(this);
|
||||
f.ReturnType.CurrentType = "System.String";
|
||||
|
||||
f.Body.Add(
|
||||
String.Format(
|
||||
"return System.Runtime.InteropServices.Marshal.PtrToStringAnsi({0});",
|
||||
this.CallString()
|
||||
)
|
||||
);
|
||||
|
||||
return f; // Only occurs in glGetString, there's no need to check parameters.
|
||||
|
||||
// If the function returns a void* (GenericReturnValue), we'll have to return an IntPtr.
|
||||
// The user will unfortunately need to marshal this IntPtr to a data type manually.
|
||||
case WrapperTypes.GenericReturnType:
|
||||
ReturnType.CurrentType = "IntPtr";
|
||||
ReturnType.Pointer = false;
|
||||
|
||||
break;
|
||||
|
||||
case WrapperTypes.None:
|
||||
default:
|
||||
// No return wrapper needed
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region protected void WrapParameters(Function function, List<Function> wrappers)
|
||||
|
||||
protected static int index = 0;
|
||||
|
@ -425,9 +414,9 @@ namespace Bind.Structures
|
|||
/// "void f(object p, IntPtr q)"
|
||||
/// "void f(object p, object q)"
|
||||
/// </summary>
|
||||
protected void WrapParameters(Function function, List<Function> wrappers, Dictionary<string, string> CSTypes)
|
||||
protected void WrapParameters(Function function, List<Function> wrappers)
|
||||
{
|
||||
if (function.Name == "LineStipple")
|
||||
if (function.Name == "GetString")
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -451,7 +440,10 @@ namespace Bind.Structures
|
|||
}
|
||||
else
|
||||
{
|
||||
wrappers.Add(DefaultWrapper(function));
|
||||
if (function.Body.Count == 0)
|
||||
wrappers.Add(DefaultWrapper(function));
|
||||
else
|
||||
wrappers.Add(function);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -464,7 +456,7 @@ namespace Bind.Structures
|
|||
{
|
||||
// No wrapper needed, visit the next parameter
|
||||
++index;
|
||||
WrapParameters(function, wrappers, CSTypes);
|
||||
WrapParameters(function, wrappers);
|
||||
--index;
|
||||
}
|
||||
else
|
||||
|
@ -474,25 +466,25 @@ namespace Bind.Structures
|
|||
case WrapperTypes.ArrayParameter:
|
||||
// Recurse to the last parameter
|
||||
++index;
|
||||
WrapParameters(function, wrappers, CSTypes);
|
||||
WrapParameters(function, wrappers);
|
||||
--index;
|
||||
|
||||
// On stack rewind, create array wrappers
|
||||
f = ArrayWrapper(new Function(function), index, CSTypes);
|
||||
f = ArrayWrapper(new Function(function), index);
|
||||
wrappers.Add(f);
|
||||
|
||||
// Recurse to the last parameter again, keeping the Array wrappers
|
||||
++index;
|
||||
WrapParameters(f, wrappers, CSTypes);
|
||||
WrapParameters(f, wrappers);
|
||||
--index;
|
||||
|
||||
// On stack rewind, create Ref wrappers.
|
||||
f = ReferenceWrapper(new Function(function), index, CSTypes);
|
||||
f = ReferenceWrapper(new Function(function), index);
|
||||
wrappers.Add(f);
|
||||
|
||||
// Keeping the current Ref wrapper, visit all other parameters once more
|
||||
++index;
|
||||
WrapParameters(f, wrappers, CSTypes);
|
||||
WrapParameters(f, wrappers);
|
||||
--index;
|
||||
|
||||
break;
|
||||
|
@ -500,16 +492,16 @@ namespace Bind.Structures
|
|||
case WrapperTypes.GenericParameter:
|
||||
// Recurse to the last parameter
|
||||
++index;
|
||||
WrapParameters(function, wrappers, CSTypes);
|
||||
WrapParameters(function, wrappers);
|
||||
--index;
|
||||
|
||||
// On stack rewind, create array wrappers
|
||||
f = GenericWrapper(new Function(function), index, CSTypes);
|
||||
f = GenericWrapper(new Function(function), index);
|
||||
wrappers.Add(f);
|
||||
|
||||
// Keeping the current Object wrapper, visit all other parameters once more
|
||||
++index;
|
||||
WrapParameters(f, wrappers, CSTypes);
|
||||
WrapParameters(f, wrappers);
|
||||
--index;
|
||||
|
||||
break;
|
||||
|
@ -520,31 +512,31 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
#region protected Function GenericWrapper(Function function, int index, Dictionary<string, string> CSTypes)
|
||||
#region protected Function GenericWrapper(Function function, int index)
|
||||
|
||||
protected Function GenericWrapper(Function function, int index, Dictionary<string, string> CSTypes)
|
||||
protected Function GenericWrapper(Function function, int index)
|
||||
{
|
||||
// Search and replace IntPtr parameters with the known parameter types:
|
||||
function.Parameters[index].Reference = false;
|
||||
function.Parameters[index].Array = 0;
|
||||
function.Parameters[index].Pointer = false;
|
||||
function.Parameters[index].Type = "object";
|
||||
function.Parameters[index].CurrentType = "object";
|
||||
function.Parameters[index].Flow = Parameter.FlowDirection.Undefined;
|
||||
|
||||
// In the function body we should pin all objects in memory before calling the
|
||||
// low-level function.
|
||||
function.Body.Clear();
|
||||
//function.Body.AddRange(GetBodyWithFixedPins(function));
|
||||
function.Body.AddRange(GetBodyWithPins(function, CSTypes, false));
|
||||
function.Body.AddRange(function.GetBodyWithPins(false));
|
||||
|
||||
return function;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region protected Function ReferenceWrapper(Function function, int index, Dictionary<string, string> CSTypes)
|
||||
#region protected Function ReferenceWrapper(Function function, int index)
|
||||
|
||||
protected Function ReferenceWrapper(Function function, int index, Dictionary<string, string> CSTypes)
|
||||
protected Function ReferenceWrapper(Function function, int index)
|
||||
{
|
||||
// Search and replace IntPtr parameters with the known parameter types:
|
||||
function.Parameters[index].Reference = true;
|
||||
|
@ -554,16 +546,16 @@ namespace Bind.Structures
|
|||
// In the function body we should pin all objects in memory before calling the
|
||||
// low-level function.
|
||||
function.Body.Clear();
|
||||
function.Body.AddRange(GetBodyWithPins(function, CSTypes, false));
|
||||
function.Body.AddRange(function.GetBodyWithPins(false));
|
||||
|
||||
return function;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region protected Function ArrayWrapper(Function function, int index, Dictionary<string, string> CSTypes)
|
||||
#region protected Function ArrayWrapper(Function function, int index)
|
||||
|
||||
protected Function ArrayWrapper(Function function, int index, Dictionary<string, string> CSTypes)
|
||||
protected Function ArrayWrapper(Function function, int index)
|
||||
{
|
||||
// Search and replace IntPtr parameters with the known parameter types:
|
||||
function.Parameters[index].Array = 1;
|
||||
|
@ -573,7 +565,7 @@ namespace Bind.Structures
|
|||
// In the function body we should pin all objects in memory before calling the
|
||||
// low-level function.
|
||||
function.Body.Clear();
|
||||
function.Body.AddRange(GetBodyWithPins(function, CSTypes, false));
|
||||
function.Body.AddRange(function.GetBodyWithPins(false));
|
||||
|
||||
return function;
|
||||
}
|
||||
|
@ -584,12 +576,12 @@ namespace Bind.Structures
|
|||
|
||||
protected Function DefaultWrapper(Function f)
|
||||
{
|
||||
bool returns = f.ReturnType.Type.ToLower().Contains("void") && !f.ReturnType.Pointer;
|
||||
bool returns = f.ReturnType.CurrentType.ToLower().Contains("void") && !f.ReturnType.Pointer;
|
||||
string callString = String.Format(
|
||||
"{0} {1}{2}; {3}",
|
||||
Unsafe ? "unsafe {" : "",
|
||||
returns ? "" : "return ",
|
||||
f.CallString(),
|
||||
this.CallString(),
|
||||
Unsafe ? "}" : "");
|
||||
|
||||
f.Body.Add(callString);
|
||||
|
@ -599,22 +591,24 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
#region protected static FunctionBody GetBodyWithPins(Function function, Dictionary<string, string> CSTypes, bool wantCLSCompliance)
|
||||
#region protected FunctionBody GetBodyWithPins(bool wantCLSCompliance)
|
||||
|
||||
/// <summary>
|
||||
/// Generates a body which calls the specified function, pinning all needed parameters.
|
||||
/// </summary>
|
||||
/// <param name="function"></param>
|
||||
protected static FunctionBody GetBodyWithPins(Function function, Dictionary<string, string> CSTypes, bool wantCLSCompliance)
|
||||
protected FunctionBody GetBodyWithPins(bool wantCLSCompliance)
|
||||
{
|
||||
// We'll make changes, but we want the original intact.
|
||||
Function f = new Function(function);
|
||||
//Function function = this as Function ?? new Function(this);
|
||||
//Function f = new Function(function);
|
||||
Function f = new Function(this);
|
||||
f.Body.Clear();
|
||||
// Unsafe only if
|
||||
//function.Unsafe = false;
|
||||
|
||||
// Add default initliazers for out parameters:
|
||||
foreach (Parameter p in function.Parameters)
|
||||
foreach (Parameter p in this.Parameters)
|
||||
{
|
||||
if (p.Flow == Parameter.FlowDirection.Out)
|
||||
{
|
||||
|
@ -622,7 +616,7 @@ namespace Bind.Structures
|
|||
String.Format(
|
||||
"{0} = default({1});",
|
||||
p.Name,
|
||||
p.GetFullType(CSTypes, wantCLSCompliance)
|
||||
p.GetFullType(Bind.Structures.Type.CSTypes, wantCLSCompliance)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -673,7 +667,9 @@ namespace Bind.Structures
|
|||
f.Body.Add(
|
||||
String.Format(
|
||||
" fixed ({0}* {1} = {2})",
|
||||
wantCLSCompliance && !p.CLSCompliant ? p.GetCLSCompliantType(CSTypes) : p.Type,
|
||||
wantCLSCompliance && !p.CLSCompliant ?
|
||||
p.GetCLSCompliantType() :
|
||||
p.CurrentType,
|
||||
p.Name + "_ptr",
|
||||
p.Array > 0 ? p.Name : "&" + p.Name
|
||||
)
|
||||
|
@ -685,7 +681,7 @@ namespace Bind.Structures
|
|||
}
|
||||
}
|
||||
|
||||
if (!function.Unsafe)
|
||||
if (!this.Unsafe)
|
||||
{
|
||||
f.Body.Insert(handleEnd, "unsafe");
|
||||
f.Body.Insert(handleEnd + 1, "{");
|
||||
|
@ -698,13 +694,13 @@ namespace Bind.Structures
|
|||
|
||||
f.Body.Add(" {");
|
||||
// Add delegate call:
|
||||
if (f.ReturnType.Type.ToLower().Contains("void"))
|
||||
if (f.ReturnType.CurrentType.ToLower().Contains("void"))
|
||||
f.Body.Add(String.Format(" {0};", f.CallString()));
|
||||
else
|
||||
f.Body.Add(String.Format(" {0} {1} = {2};", f.ReturnType.Type, "retval", f.CallString()));
|
||||
f.Body.Add(String.Format(" {0} {1} = {2};", f.ReturnType.CurrentType, "retval", f.CallString()));
|
||||
|
||||
// Assign out parameters:
|
||||
foreach (Parameter p in function.Parameters)
|
||||
foreach (Parameter p in this.Parameters)
|
||||
{
|
||||
if (p.Flow == Parameter.FlowDirection.Out)
|
||||
{
|
||||
|
@ -718,7 +714,7 @@ namespace Bind.Structures
|
|||
String.Format(
|
||||
" {0} = ({1}){2}.Target;",
|
||||
p.Name,
|
||||
p.Type,
|
||||
p.CurrentType,
|
||||
p.Name + "_ptr"
|
||||
)
|
||||
);
|
||||
|
@ -737,7 +733,7 @@ namespace Bind.Structures
|
|||
}
|
||||
|
||||
// Return:
|
||||
if (!f.ReturnType.Type.ToLower().Contains("void"))
|
||||
if (!f.ReturnType.CurrentType.ToLower().Contains("void"))
|
||||
{
|
||||
f.Body.Add(" return retval;");
|
||||
}
|
||||
|
@ -747,7 +743,7 @@ namespace Bind.Structures
|
|||
f.Body.Add(" }");
|
||||
f.Body.Add(" finally");
|
||||
f.Body.Add(" {");
|
||||
foreach (Parameter p in function.Parameters)
|
||||
foreach (Parameter p in this.Parameters)
|
||||
{
|
||||
// Free all allocated GCHandles
|
||||
if (p.NeedsPin)
|
||||
|
@ -761,7 +757,7 @@ namespace Bind.Structures
|
|||
}
|
||||
f.Body.Add(" }");
|
||||
|
||||
if (!function.Unsafe)
|
||||
if (!this.Unsafe)
|
||||
{
|
||||
f.Body.Add("}");
|
||||
}
|
||||
|
@ -772,8 +768,146 @@ namespace Bind.Structures
|
|||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Translates the opengl return type to the equivalent C# type.
|
||||
/// </summary>
|
||||
/// <param name="d">The opengl function to translate.</param>
|
||||
/// <remarks>
|
||||
/// First, we use the official typemap (gl.tm) to get the correct type.
|
||||
/// Then we override this, when it is:
|
||||
/// 1) A string (we have to use Marshal.PtrToStringAnsi, to avoid heap corruption)
|
||||
/// 2) An array (translates to IntPtr)
|
||||
/// 3) A generic object or void* (translates to IntPtr)
|
||||
/// 4) A GLenum (translates to int on Legacy.Tao or GL.Enums.GLenum otherwise).
|
||||
/// Return types must always be CLS-compliant, because .Net does not support overloading on return types.
|
||||
/// </remarks>
|
||||
protected virtual void TranslateReturnType()
|
||||
{
|
||||
if (Bind.Structures.Type.GLTypes.ContainsKey(ReturnType.CurrentType))
|
||||
ReturnType.CurrentType = Bind.Structures.Type.GLTypes[ReturnType.CurrentType];
|
||||
|
||||
if (Bind.Structures.Type.CSTypes.ContainsKey(ReturnType.CurrentType))
|
||||
ReturnType.CurrentType = Bind.Structures.Type.CSTypes[ReturnType.CurrentType];
|
||||
|
||||
if (ReturnType.CurrentType.ToLower().Contains("void") && ReturnType.Pointer)
|
||||
{
|
||||
ReturnType.WrapperType = WrapperTypes.GenericReturnType;
|
||||
}
|
||||
|
||||
if (ReturnType.CurrentType.ToLower().Contains("string"))
|
||||
{
|
||||
ReturnType.CurrentType = "IntPtr";
|
||||
ReturnType.WrapperType = WrapperTypes.StringReturnType;
|
||||
}
|
||||
|
||||
if (ReturnType.CurrentType.ToLower().Contains("object"))
|
||||
{
|
||||
ReturnType.CurrentType = "IntPtr";
|
||||
ReturnType.WrapperType |= WrapperTypes.GenericReturnType;
|
||||
}
|
||||
|
||||
if (ReturnType.CurrentType.Contains("GLenum"))
|
||||
{
|
||||
if (Settings.Compatibility == Settings.Legacy.None)
|
||||
ReturnType.CurrentType = ReturnType.CurrentType.Insert(0, Settings.GLEnumsClass + ".");
|
||||
else
|
||||
ReturnType.CurrentType = "int";
|
||||
}
|
||||
|
||||
if (ReturnType.CurrentType.ToLower().Contains("bool"))
|
||||
{
|
||||
if (Settings.Compatibility == Settings.Legacy.Tao)
|
||||
ReturnType.CurrentType = "int";
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
//ReturnType.WrapperType = WrapperTypes.ReturnsBool;
|
||||
}
|
||||
|
||||
ReturnType.CurrentType = ReturnType.GetCLSCompliantType();
|
||||
}
|
||||
|
||||
protected virtual void TranslateParameters()
|
||||
{
|
||||
if (this.Name.Contains("MultiTexCoord1"))
|
||||
{
|
||||
}
|
||||
for (int i = 0; i < Parameters.Count; i++)
|
||||
{
|
||||
Parameters[i] = Parameter.Translate(Parameters[i], this.Category);
|
||||
|
||||
// Special cases: glLineStipple and gl(Get)ShaderSource:
|
||||
// Check for LineStipple (should be unchecked)
|
||||
if (Parameters[i].CurrentType == "UInt16" && Name.Contains("LineStipple"))
|
||||
{
|
||||
Parameters[i].WrapperType = WrapperTypes.UncheckedParameter;
|
||||
}
|
||||
|
||||
if (Name.Contains("ShaderSource") && Parameters[i].CurrentType.ToLower().Contains("string"))
|
||||
{
|
||||
// Special case: these functions take a string[]
|
||||
//IsPointer = true;
|
||||
Parameters[i].Array = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void Translate()
|
||||
{
|
||||
TranslateReturnType();
|
||||
TranslateParameters();
|
||||
|
||||
List<Function> wrappers = (List<Function>)CreateWrappers();
|
||||
|
||||
// If the function is not CLS-compliant (e.g. it contains unsigned parameters)
|
||||
// we need to create a CLS-Compliant overload. However, we should only do this
|
||||
// iff the opengl function does not contain unsigned/signed overloads itself
|
||||
// to avoid redefinitions.
|
||||
foreach (Function f in wrappers)
|
||||
{
|
||||
if (this.Name.Contains("Weightub"))
|
||||
{
|
||||
}
|
||||
|
||||
bool createCLS = !f.CLSCompliant;
|
||||
//createCLS &= String.IsNullOrEmpty(f.TrimmedName);
|
||||
string nameWithoutExtension = Utilities.StripGL2Extension(f.Name).TrimEnd('v');
|
||||
createCLS &=
|
||||
String.IsNullOrEmpty(f.TrimmedName) ||
|
||||
nameWithoutExtension.EndsWith("u") &&
|
||||
!nameWithoutExtension.EndsWith("b");
|
||||
|
||||
if (createCLS)
|
||||
{
|
||||
Function clsFunction = f.GetCLSCompliantFunction(Bind.Structures.Type.CSTypes);
|
||||
// avoid redefinitions
|
||||
if (clsFunction.Parameters.ToString(true) != f.Parameters.ToString(true))
|
||||
{
|
||||
bool defined = false;
|
||||
if (Bind.Structures.Function.Wrappers.ContainsKey(f.Extension))
|
||||
{
|
||||
foreach (Function fun in Bind.Structures.Function.Wrappers[clsFunction.Extension])
|
||||
{
|
||||
if (clsFunction.Name == fun.Name &&
|
||||
clsFunction.Parameters.ToString() == fun.Parameters.ToString())
|
||||
defined = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined)
|
||||
Bind.Structures.Function.Wrappers.Add(clsFunction);
|
||||
//wrappers.Add(f);
|
||||
}
|
||||
}
|
||||
Bind.Structures.Function.Wrappers.Add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region class DelegateCollection : Dictionary<string, Delegate>
|
||||
|
||||
class DelegateCollection : Dictionary<string, Delegate>
|
||||
{
|
||||
public void Add(Delegate d)
|
||||
|
@ -790,4 +924,6 @@ namespace Bind.Structures
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Bind.Structures
|
||||
{
|
||||
|
@ -13,6 +14,33 @@ namespace Bind.Structures
|
|||
|
||||
public class Enum
|
||||
{
|
||||
internal static EnumCollection GLEnums;
|
||||
|
||||
private static bool enumsLoaded;
|
||||
|
||||
internal static void Initialize()
|
||||
{
|
||||
if (!enumsLoaded)
|
||||
{
|
||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\enum.spec"))
|
||||
{
|
||||
GLEnums = Bind.MainClass.Generator.ReadEnums(sr);
|
||||
}
|
||||
|
||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\enumext.spec"))
|
||||
{
|
||||
foreach (Bind.Structures.Enum e in Bind.MainClass.Generator.ReadEnums(sr).Values)
|
||||
{
|
||||
//enums.Add(e.Name, e);
|
||||
Utilities.Merge(GLEnums, e);
|
||||
}
|
||||
}
|
||||
|
||||
enumsLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Enum()
|
||||
{ }
|
||||
|
||||
|
@ -61,19 +89,40 @@ namespace Bind.Structures
|
|||
|
||||
class EnumCollection : Dictionary<string, Enum>
|
||||
{
|
||||
/*
|
||||
public override string ToString()
|
||||
internal void AddRange(EnumCollection enums)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
foreach (Bind.Structures.Enum e in this.Values)
|
||||
foreach (Enum e in enums.Values)
|
||||
{
|
||||
sb.AppendLine(e.ToString());
|
||||
Utilities.Merge(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
internal void Translate()
|
||||
{
|
||||
foreach (Enum e in this.Values)
|
||||
{
|
||||
foreach (Constant c in e.ConstantCollection.Values)
|
||||
{
|
||||
// There are cases when a value is an aliased constant, with no enum specified.
|
||||
// (e.g. FOG_COORD_ARRAY_TYPE = GL_FOG_COORDINATE_ARRAY_TYPE)
|
||||
// In this case try searching all enums for the correct constant to alias (stupid opengl specs).
|
||||
if (String.IsNullOrEmpty(c.Reference) && !Char.IsDigit(c.Value[0]))
|
||||
{
|
||||
foreach (Enum @enum in this.Values)
|
||||
{
|
||||
// Skip generic GLenum
|
||||
if (@enum.Name == "GLenum")
|
||||
continue;
|
||||
|
||||
if (@enum.ConstantCollection.ContainsKey(c.Value))
|
||||
{
|
||||
c.Reference = @enum.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1,11 +1,51 @@
|
|||
using System;
|
||||
#region --- License ---
|
||||
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Bind.Structures
|
||||
{
|
||||
public class Function : Delegate
|
||||
{
|
||||
internal static FunctionCollection Wrappers;
|
||||
|
||||
private static bool loaded;
|
||||
internal static void Initialize()
|
||||
{
|
||||
if (!loaded)
|
||||
{
|
||||
Wrappers = new FunctionCollection();
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<string> endings = new List<string>(
|
||||
new string[]
|
||||
{
|
||||
"fv",
|
||||
"f",
|
||||
"dv",
|
||||
"d",
|
||||
"i",
|
||||
"iv",
|
||||
"s",
|
||||
"sv",
|
||||
"b",
|
||||
"bv",
|
||||
"ui",
|
||||
"uiv",
|
||||
"us",
|
||||
"usv",
|
||||
"ub",
|
||||
"ubv"
|
||||
});
|
||||
|
||||
#region --- Constructors ---
|
||||
|
||||
public Function()
|
||||
|
@ -13,21 +53,28 @@ namespace Bind.Structures
|
|||
{
|
||||
Body = new FunctionBody();
|
||||
}
|
||||
|
||||
/*
|
||||
public Function(Function f)
|
||||
: base(f)
|
||||
{
|
||||
this.Body = new FunctionBody(f.Body);
|
||||
this.Name = f.Name;
|
||||
}
|
||||
|
||||
*/
|
||||
public Function(Delegate d)
|
||||
: base(d)
|
||||
{
|
||||
this.Body = new FunctionBody();
|
||||
if (d is Function)
|
||||
this.Body = new FunctionBody((d as Function).Body);
|
||||
else
|
||||
this.Body = new FunctionBody();
|
||||
this.Name = d.Name;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public override bool Unsafe
|
||||
|
||||
public override bool Unsafe
|
||||
{
|
||||
get
|
||||
|
@ -39,7 +86,9 @@ namespace Bind.Structures
|
|||
}
|
||||
}
|
||||
|
||||
#region Function body
|
||||
#endregion
|
||||
|
||||
#region public FunctionBody Body
|
||||
|
||||
FunctionBody _body;
|
||||
|
||||
|
@ -51,6 +100,82 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
#region public string TrimmedName
|
||||
|
||||
string trimmedName;
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the opengl function, trimming the excess 234dfubsiv endings..
|
||||
/// </summary>
|
||||
public string TrimmedName
|
||||
{
|
||||
get { return trimmedName; }
|
||||
set
|
||||
{
|
||||
if (!String.IsNullOrEmpty(value))
|
||||
trimmedName = value.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public override string Name
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the opengl function.
|
||||
/// If no Tao compatibility is set, set TrimmedName to Name, after removing
|
||||
/// [u][bsifd][v].
|
||||
/// </summary>
|
||||
public override string Name
|
||||
{
|
||||
get { return base.Name; }
|
||||
set
|
||||
{
|
||||
base.Name = value;
|
||||
|
||||
// If we don't need compatibility with Tao,
|
||||
// remove the Extension and the overload information from the name
|
||||
// (Extension == "ARB", "EXT", etc, overload == [u][bsidf][v])
|
||||
// TODO: Use some regex's here, to reduce clutter.
|
||||
if (Settings.Compatibility != Settings.Legacy.Tao)
|
||||
{
|
||||
string ext = Utilities.GetGL2Extension(value);
|
||||
string trimmedName = value;
|
||||
|
||||
// Remove extension
|
||||
if (!String.IsNullOrEmpty(ext))
|
||||
{
|
||||
trimmedName = trimmedName.Substring(0, trimmedName.Length - ext.Length);
|
||||
}
|
||||
|
||||
// Remove overload
|
||||
if (endings.Contains(trimmedName.Substring(trimmedName.Length - 3)))
|
||||
{
|
||||
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 3);
|
||||
return;
|
||||
}
|
||||
|
||||
if (endings.Contains(trimmedName.Substring(trimmedName.Length - 2)))
|
||||
{
|
||||
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (endings.Contains(trimmedName.Substring(trimmedName.Length - 1)))
|
||||
{
|
||||
// An ending 's' may be either a plural form (glCallLists), which we
|
||||
// do not want to change, or an actual overload (glColor3s). We assume
|
||||
// (perhaps incorrectly), that an 's' preceeded be a digit indicates an
|
||||
// overload. If there is no digit, we assume a plural form (no change).
|
||||
if (Char.IsDigit(trimmedName[trimmedName.Length - 2]))
|
||||
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public override string ToString()
|
||||
|
||||
public override string ToString()
|
||||
|
@ -64,7 +189,7 @@ namespace Bind.Structures
|
|||
{
|
||||
sb.Append("gl");
|
||||
}
|
||||
sb.Append(Name);
|
||||
sb.Append(!String.IsNullOrEmpty(TrimmedName) ? TrimmedName : Name);
|
||||
sb.Append(Parameters.ToString(true));
|
||||
if (Body.Count > 0)
|
||||
{
|
||||
|
@ -85,17 +210,17 @@ namespace Bind.Structures
|
|||
|
||||
for (int i = 0; i < f.Parameters.Count; i++)
|
||||
{
|
||||
f.Parameters[i].Type = f.Parameters[i].GetCLSCompliantType(CSTypes);
|
||||
f.Parameters[i].CurrentType = f.Parameters[i].GetCLSCompliantType();
|
||||
}
|
||||
|
||||
f.Body.Clear();
|
||||
if (!f.NeedsWrapper)
|
||||
{
|
||||
f.Body.Add((f.ReturnType.Type != "void" ? "return " + this.CallString() : this.CallString()) + ";");
|
||||
f.Body.Add((f.ReturnType.CurrentType != "void" ? "return " + this.CallString() : this.CallString()) + ";");
|
||||
}
|
||||
else
|
||||
{
|
||||
f.Body.AddRange(Function.GetBodyWithPins(this, CSTypes, true));
|
||||
f.Body.AddRange(this.GetBodyWithPins(true));
|
||||
}
|
||||
|
||||
// The type system cannot differentiate between functions with the same parameters
|
||||
|
@ -144,6 +269,8 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
#region class FunctionCollection : Dictionary<string, List<Function>>
|
||||
|
||||
class FunctionCollection : Dictionary<string, List<Function>>
|
||||
{
|
||||
public void Add(Function f)
|
||||
|
@ -167,4 +294,6 @@ namespace Bind.Structures
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Bind.Structures
|
|||
/// <summary>
|
||||
/// Represents a single parameter of an opengl function.
|
||||
/// </summary>
|
||||
public class Parameter
|
||||
public class Parameter : Type
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
|
@ -23,6 +23,7 @@ namespace Bind.Structures
|
|||
/// Creates a new Parameter without type and name.
|
||||
/// </summary>
|
||||
public Parameter()
|
||||
:base()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -31,28 +32,20 @@ namespace Bind.Structures
|
|||
/// </summary>
|
||||
/// <param name="p">The parameter to copy from.</param>
|
||||
public Parameter(Parameter p)
|
||||
: base(p)
|
||||
{
|
||||
if (p == null)
|
||||
return;
|
||||
|
||||
this.Name = !String.IsNullOrEmpty(p.Name) ? new string(p.Name.ToCharArray()) : "";
|
||||
//this.NeedsWrapper = p.NeedsWrapper;
|
||||
this.PreviousType = !String.IsNullOrEmpty(p.PreviousType) ? new string(p.PreviousType.ToCharArray()) : "";
|
||||
this.Unchecked = p.Unchecked;
|
||||
this.UnmanagedType = p.UnmanagedType;
|
||||
this.WrapperType = p.WrapperType;
|
||||
|
||||
this.Type = new string(p.Type.ToCharArray());
|
||||
this.Flow = p.Flow;
|
||||
this.Array = p.Array;
|
||||
this.Pointer = p.Pointer;
|
||||
this.Reference = p.Reference;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Name property
|
||||
#region public string Name
|
||||
|
||||
string _name;
|
||||
/// <summary>
|
||||
|
@ -72,7 +65,7 @@ namespace Bind.Structures
|
|||
/// <summary>
|
||||
/// Gets or sets the name of the parameter.
|
||||
/// </summary>
|
||||
public UnmanagedType UnmanagedType
|
||||
private UnmanagedType UnmanagedType
|
||||
{
|
||||
get { return _unmanaged_type; }
|
||||
set { _unmanaged_type = value; }
|
||||
|
@ -80,61 +73,7 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
#region Type property
|
||||
|
||||
string _type;
|
||||
/// <summary>
|
||||
/// Gets the type of the parameter.
|
||||
/// </summary>
|
||||
public string Type
|
||||
{
|
||||
//get { return _type; }
|
||||
get
|
||||
{
|
||||
//if (Pointer && Settings.Compatibility == Settings.Legacy.Tao)
|
||||
// return "IntPtr";
|
||||
|
||||
return _type;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!String.IsNullOrEmpty(_type))
|
||||
PreviousType = _type;
|
||||
if (!String.IsNullOrEmpty(value))
|
||||
_type = value.Trim();
|
||||
if (_type.EndsWith("*"))
|
||||
{
|
||||
_type = _type.TrimEnd('*');
|
||||
Pointer = true;
|
||||
}
|
||||
|
||||
clsCompliant =
|
||||
!(
|
||||
(Pointer && (Settings.Compatibility != Settings.Legacy.Tao)) ||
|
||||
(Type.Contains("GLu") && !Type.Contains("GLubyte")) ||
|
||||
Type == "GLbitfield" ||
|
||||
Type.Contains("GLhandle") ||
|
||||
Type.Contains("GLhalf") ||
|
||||
Type == "GLbyte");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Previous type property
|
||||
|
||||
private string _previous_type;
|
||||
|
||||
public string PreviousType
|
||||
{
|
||||
get { return _previous_type; }
|
||||
set { _previous_type = value; }
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Flow property
|
||||
#region public FlowDirection Flow
|
||||
|
||||
/// <summary>
|
||||
/// Enumarates the possible flows of a parameter (ie. is this parameter
|
||||
|
@ -160,49 +99,14 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
#region public bool Reference
|
||||
|
||||
bool reference;
|
||||
|
||||
public bool Reference
|
||||
{
|
||||
get { return reference; }
|
||||
set { reference = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public bool Array
|
||||
|
||||
int array;
|
||||
|
||||
public int Array
|
||||
{
|
||||
get { return array; }
|
||||
set { array = value > 0 ? value : 0; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public bool Pointer
|
||||
|
||||
bool pointer = false;
|
||||
|
||||
public bool Pointer
|
||||
{
|
||||
get { return pointer; }
|
||||
set { pointer = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public bool NeedsPin
|
||||
|
||||
public bool NeedsPin
|
||||
{
|
||||
get { return
|
||||
(Array > 0 || Reference || Type == "object") &&
|
||||
!Type.ToLower().Contains("string"); }
|
||||
(Array > 0 || Reference || CurrentType == "object") &&
|
||||
!CurrentType.ToLower().Contains("string");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -219,33 +123,6 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
#region WrapperType property
|
||||
|
||||
private WrapperTypes _wrapper_type = WrapperTypes.None;
|
||||
|
||||
public WrapperTypes WrapperType
|
||||
{
|
||||
get { return _wrapper_type; }
|
||||
set { _wrapper_type = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public bool CLSCompliant
|
||||
|
||||
private bool clsCompliant;
|
||||
|
||||
public bool CLSCompliant
|
||||
{
|
||||
get
|
||||
{
|
||||
// Checked when setting the Type property.
|
||||
return clsCompliant || (Pointer && Settings.Compatibility == Settings.Legacy.Tao);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public string GetFullType()
|
||||
|
||||
public string GetFullType(Dictionary<string, string> CSTypes, bool compliant)
|
||||
|
@ -256,13 +133,13 @@ namespace Bind.Structures
|
|||
if (!compliant)
|
||||
{
|
||||
return
|
||||
Type +
|
||||
CurrentType +
|
||||
(Pointer ? "*" : "") +
|
||||
(Array > 0 ? "[]" : "");
|
||||
}
|
||||
|
||||
return
|
||||
GetCLSCompliantType(CSTypes) +
|
||||
GetCLSCompliantType() +
|
||||
(Pointer ? "*" : "") +
|
||||
(Array > 0 ? "[]" : "");
|
||||
|
||||
|
@ -270,36 +147,6 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
#region public string GetCLSCompliantType(Dictionary<string, string> CSTypes)
|
||||
|
||||
public string GetCLSCompliantType(Dictionary<string, string> CSTypes)
|
||||
{
|
||||
if (!CLSCompliant)
|
||||
{
|
||||
if (Pointer && Settings.Compatibility == Settings.Legacy.Tao)
|
||||
return "IntPtr";
|
||||
|
||||
if (CSTypes.ContainsKey(Type))
|
||||
{
|
||||
switch (CSTypes[Type])
|
||||
{
|
||||
case "UInt16":
|
||||
return "Int16";
|
||||
case "UInt32":
|
||||
return "Int32";
|
||||
case "UInt64":
|
||||
return "Int64";
|
||||
case "SByte":
|
||||
return "Byte";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Type;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region override public string ToString()
|
||||
|
||||
override public string ToString()
|
||||
|
@ -324,6 +171,11 @@ namespace Bind.Structures
|
|||
//if (Flow == FlowDirection.Out && !Array && !(Type == "IntPtr"))
|
||||
// sb.Append("out ");
|
||||
|
||||
if (Flow == FlowDirection.Out)
|
||||
sb.Append("[Out] ");
|
||||
else if (Flow == FlowDirection.Undefined)
|
||||
sb.Append("[In, Out] ");
|
||||
|
||||
if (Reference)
|
||||
{
|
||||
if (Flow == FlowDirection.Out)
|
||||
|
@ -340,14 +192,14 @@ namespace Bind.Structures
|
|||
}
|
||||
else
|
||||
{
|
||||
sb.Append(Type);
|
||||
sb.Append(CurrentType);
|
||||
if (Array > 0)
|
||||
sb.Append("[]");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(Type);
|
||||
sb.Append(CurrentType);
|
||||
if (Pointer)
|
||||
sb.Append("*");
|
||||
if (Array > 0)
|
||||
|
@ -363,6 +215,87 @@ namespace Bind.Structures
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
internal static Parameter Translate(Parameter par, string Category)
|
||||
{
|
||||
Enum @enum;
|
||||
string s;
|
||||
Parameter p = new Parameter(par);
|
||||
|
||||
// Translate enum types
|
||||
if (Enum.GLEnums.TryGetValue(p.CurrentType, out @enum) && @enum.Name != "GLenum")
|
||||
{
|
||||
if (Settings.Compatibility == Settings.Legacy.Tao)
|
||||
p.CurrentType = "int";
|
||||
else
|
||||
p.CurrentType = p.CurrentType.Insert(0, String.Format("{0}.", Settings.GLEnumsClass));
|
||||
}
|
||||
else if (Bind.Structures.Type.GLTypes.TryGetValue(p.CurrentType, out s))
|
||||
{
|
||||
// Check if the parameter is a generic GLenum. If yes,
|
||||
// check if a better match exists:
|
||||
if (s.Contains("GLenum") && !String.IsNullOrEmpty(Category))
|
||||
{
|
||||
if (Settings.Compatibility == Settings.Legacy.None)
|
||||
{
|
||||
// Better match: enum.Name == function.Category (e.g. GL_VERSION_1_1 etc)
|
||||
if (Enum.GLEnums.ContainsKey(Category))
|
||||
{
|
||||
p.CurrentType = String.Format("{0}.{1}", Settings.GLEnumsClass, Category);
|
||||
}
|
||||
else
|
||||
{
|
||||
p.CurrentType = String.Format("{0}.GLenum", Settings.GLEnumsClass);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p.CurrentType = "int";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is not enum, default translation:
|
||||
p.CurrentType = s;
|
||||
p.CurrentType =
|
||||
Bind.Structures.Type.CSTypes.ContainsKey(p.CurrentType) ?
|
||||
Bind.Structures.Type.CSTypes[p.CurrentType] : p.CurrentType;
|
||||
}
|
||||
}
|
||||
|
||||
//if (CSTypes.ContainsKey(p.CurrentType))
|
||||
// p.CurrentType = CSTypes[p.CurrentType];
|
||||
|
||||
// Translate pointer parameters
|
||||
if (p.Pointer)
|
||||
{
|
||||
p.WrapperType = WrapperTypes.ArrayParameter;
|
||||
|
||||
if (p.CurrentType.ToLower().Contains("char") || p.CurrentType.ToLower().Contains("string"))
|
||||
{
|
||||
// char* or string -> [In] String or [Out] StringBuilder
|
||||
p.CurrentType =
|
||||
p.Flow == Parameter.FlowDirection.Out ?
|
||||
"System.Text.StringBuilder" :
|
||||
"System.String";
|
||||
|
||||
p.Pointer = false;
|
||||
p.WrapperType = WrapperTypes.None;
|
||||
}
|
||||
else if (p.CurrentType.ToLower().Contains("void"))
|
||||
{
|
||||
p.WrapperType = WrapperTypes.GenericParameter;
|
||||
}
|
||||
}
|
||||
|
||||
if (p.CurrentType.ToLower().Contains("bool"))
|
||||
{
|
||||
// Is this actually used anywhere?
|
||||
p.WrapperType = WrapperTypes.BoolParameter;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -398,17 +331,12 @@ namespace Bind.Structures
|
|||
/// <returns>The parameter list of an opengl function in the form ( [parameters] )</returns>
|
||||
override public string ToString()
|
||||
{
|
||||
return ToString(false, null);
|
||||
return ToString(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public string ToString(bool taoCompatible)
|
||||
{
|
||||
return ToString(true, null);
|
||||
}
|
||||
|
||||
#region public string ToString(bool taoCompatible, Dictionary<string, string> CSTypes)
|
||||
#region public string ToString(bool taoCompatible)
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameter declaration string.
|
||||
|
@ -416,7 +344,7 @@ namespace Bind.Structures
|
|||
/// <param name="getCLSCompliant">If true, all types will be replaced by their CLSCompliant C# equivalents</param>
|
||||
/// <param name="CSTypes">The list of C# types equivalent to the OpenGL types.</param>
|
||||
/// <returns>The parameter list of an opengl function in the form ( [parameters] )</returns>
|
||||
public string ToString(bool taoCompatible, Dictionary<string, string> CSTypes)
|
||||
public string ToString(bool taoCompatible)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("(");
|
||||
|
@ -444,10 +372,66 @@ namespace Bind.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
public string CallString()
|
||||
{
|
||||
return CallString(false);
|
||||
}
|
||||
|
||||
public string CallString(bool taoCompatible)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.Append("(");
|
||||
|
||||
if (this.Count > 0)
|
||||
{
|
||||
foreach (Parameter p in this)
|
||||
{
|
||||
if (p.Unchecked)
|
||||
sb.Append("unchecked((" + p.CurrentType + ")");
|
||||
|
||||
if (p.CurrentType != "object")
|
||||
{
|
||||
if (p.CurrentType.ToLower().Contains("string"))
|
||||
{
|
||||
sb.Append(String.Format(
|
||||
"({0}{1})",
|
||||
p.CurrentType,
|
||||
(p.Array > 0) ? "[]" : ""));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(String.Format(
|
||||
"({0}{1})",
|
||||
p.CurrentType,
|
||||
(p.Pointer || p.Array > 0 || p.Reference) ? "*" : ""));
|
||||
}
|
||||
}
|
||||
|
||||
sb.Append(
|
||||
Utilities.Keywords.Contains(p.Name) ? "@" + p.Name : p.Name
|
||||
);
|
||||
|
||||
if (p.Unchecked)
|
||||
sb.Append(")");
|
||||
|
||||
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)
|
||||
if (p.CurrentType == type)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
238
Source/Bind/Structures/Type.cs
Normal file
238
Source/Bind/Structures/Type.cs
Normal file
|
@ -0,0 +1,238 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Bind.Structures
|
||||
{
|
||||
public class Type
|
||||
{
|
||||
internal static Dictionary<string, string> GLTypes;
|
||||
internal static Dictionary<string, string> CSTypes;
|
||||
|
||||
private static bool typesLoaded;
|
||||
|
||||
internal static void Initialize()
|
||||
{
|
||||
if (!typesLoaded)
|
||||
{
|
||||
if (GLTypes == null)
|
||||
{
|
||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\gl.tm"))
|
||||
{
|
||||
GLTypes = Bind.MainClass.Generator.ReadTypeMap(sr);
|
||||
}
|
||||
}
|
||||
if (CSTypes == null)
|
||||
{
|
||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\csharp.tm"))
|
||||
{
|
||||
CSTypes = Bind.MainClass.Generator.ReadCSTypeMap(sr);
|
||||
}
|
||||
}
|
||||
typesLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public Type()
|
||||
{
|
||||
}
|
||||
|
||||
public Type(Type t)
|
||||
{
|
||||
this.CurrentType = new string(t.CurrentType.ToCharArray());
|
||||
this.PreviousType = !String.IsNullOrEmpty(t.PreviousType) ? new string(t.PreviousType.ToCharArray()) : "";
|
||||
this.WrapperType = t.WrapperType;
|
||||
this.Array = t.Array;
|
||||
this.Pointer = t.Pointer;
|
||||
this.Reference = t.Reference;
|
||||
}
|
||||
|
||||
#region public string Type
|
||||
|
||||
string type;
|
||||
/// <summary>
|
||||
/// Gets the type of the parameter.
|
||||
/// </summary>
|
||||
public virtual string CurrentType
|
||||
{
|
||||
//get { return _type; }
|
||||
get
|
||||
{
|
||||
//if (Pointer && Settings.Compatibility == Settings.Legacy.Tao)
|
||||
// return "IntPtr";
|
||||
|
||||
return type;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!String.IsNullOrEmpty(type))
|
||||
PreviousType = type;
|
||||
if (!String.IsNullOrEmpty(value))
|
||||
type = value.Trim();
|
||||
|
||||
//Translate();
|
||||
|
||||
if (type.EndsWith("*"))
|
||||
{
|
||||
type = type.TrimEnd('*');
|
||||
Pointer = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public string PreviousType
|
||||
|
||||
private string _previous_type;
|
||||
|
||||
public string PreviousType
|
||||
{
|
||||
get { return _previous_type; }
|
||||
set { _previous_type = value; }
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region public bool Reference
|
||||
|
||||
bool reference;
|
||||
|
||||
public bool Reference
|
||||
{
|
||||
get { return reference; }
|
||||
set { reference = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public bool Array
|
||||
|
||||
int array;
|
||||
|
||||
public int Array
|
||||
{
|
||||
get { return array; }
|
||||
set { array = value > 0 ? value : 0; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public bool Pointer
|
||||
|
||||
bool pointer = false;
|
||||
|
||||
public bool Pointer
|
||||
{
|
||||
get { return pointer; }
|
||||
set { pointer = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public bool CLSCompliant
|
||||
|
||||
public bool CLSCompliant
|
||||
{
|
||||
get
|
||||
{
|
||||
return !(
|
||||
(Pointer && (Settings.Compatibility != Settings.Legacy.Tao)) ||
|
||||
CurrentType.Contains("UInt") ||
|
||||
CurrentType.Contains("SByte"));
|
||||
|
||||
|
||||
/*(Type.Contains("GLu") && !Type.Contains("GLubyte")) ||
|
||||
Type == "GLbitfield" ||
|
||||
Type.Contains("GLhandle") ||
|
||||
Type.Contains("GLhalf") ||
|
||||
Type == "GLbyte");*/
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WrapperType property
|
||||
|
||||
private WrapperTypes _wrapper_type = WrapperTypes.None;
|
||||
|
||||
public WrapperTypes WrapperType
|
||||
{
|
||||
get { return _wrapper_type; }
|
||||
set { _wrapper_type = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public string GetFullType()
|
||||
|
||||
public string GetFullType(Dictionary<string, string> CSTypes, bool compliant)
|
||||
{
|
||||
if (Pointer && Settings.Compatibility == Settings.Legacy.Tao)
|
||||
return "IntPtr";
|
||||
|
||||
if (!compliant)
|
||||
{
|
||||
return
|
||||
CurrentType +
|
||||
(Pointer ? "*" : "") +
|
||||
(Array > 0 ? "[]" : "");
|
||||
}
|
||||
|
||||
return
|
||||
GetCLSCompliantType() +
|
||||
(Pointer ? "*" : "") +
|
||||
(Array > 0 ? "[]" : "");
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public string GetCLSCompliantType()
|
||||
|
||||
public string GetCLSCompliantType()
|
||||
{
|
||||
if (!CLSCompliant)
|
||||
{
|
||||
if (Pointer && Settings.Compatibility == Settings.Legacy.Tao)
|
||||
return "IntPtr";
|
||||
|
||||
switch (CurrentType)
|
||||
{
|
||||
case "UInt16":
|
||||
return "Int16";
|
||||
case "UInt32":
|
||||
return "Int32";
|
||||
case "UInt64":
|
||||
return "Int64";
|
||||
case "SByte":
|
||||
return "Byte";
|
||||
}
|
||||
}
|
||||
|
||||
return CurrentType;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return CurrentType;
|
||||
}
|
||||
|
||||
internal static Type Translate(Type type)
|
||||
{
|
||||
Type t = new Type(type);
|
||||
|
||||
if (GLTypes.ContainsKey(t.CurrentType))
|
||||
t.CurrentType = GLTypes[t.CurrentType];
|
||||
|
||||
if (CSTypes.ContainsKey(t.CurrentType))
|
||||
t.CurrentType = CSTypes[t.CurrentType];
|
||||
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -157,20 +157,6 @@ namespace Bind
|
|||
|
||||
#endregion
|
||||
|
||||
#region internal static string StripGL2Extension(Function f)
|
||||
|
||||
internal static string StripGL2Extension(Function f)
|
||||
{
|
||||
string ext = GetGL2Extension(f.Name);
|
||||
if (String.IsNullOrEmpty(ext))
|
||||
return null;
|
||||
|
||||
f.Name = f.Name.Substring(0, f.Name.Length - ext.Length);
|
||||
return ext;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region internal static string GetGL2Extension(string name)
|
||||
|
||||
internal static string GetGL2Extension(string name)
|
||||
|
@ -195,7 +181,7 @@ namespace Bind
|
|||
if (name.EndsWith("APPLE")) { return "APPLE"; }
|
||||
if (name.EndsWith("OML")) { return "OML"; }
|
||||
if (name.EndsWith("I3D")) { return "I3D"; }
|
||||
return null;
|
||||
return "";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -227,5 +213,10 @@ namespace Bind
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
internal static string StripGL2Extension(string p)
|
||||
{
|
||||
return p.Substring(0, p.Length - GetGL2Extension(p).Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,41 +148,41 @@ namespace Examples.Windowing
|
|||
{
|
||||
GL.Begin(Enums.BeginMode.QUADS);
|
||||
|
||||
GL.Color3f(1, 0, 0);
|
||||
GL.Vertex3f(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, -1.0f);
|
||||
GL.Color3(1, 0, 0);
|
||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||
|
||||
GL.Color3f(1, 1, 0);
|
||||
GL.Vertex3f(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Color3(1, 1, 0);
|
||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
|
||||
GL.Color3f(1, 0, 1);
|
||||
GL.Vertex3f(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, -1.0f);
|
||||
GL.Color3(1, 0, 1);
|
||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||
|
||||
GL.Color3f(0, 1, 0);
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Color3(0, 1, 0);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
|
||||
GL.Color3f(0, 0, 1);
|
||||
GL.Vertex3f(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, -1.0f);
|
||||
GL.Color3(0, 0, 1);
|
||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||
|
||||
GL.Color3f(0, 1, 1);
|
||||
GL.Vertex3f(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, 1.0f);
|
||||
GL.Color3(0, 1, 1);
|
||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||
|
||||
GL.End();
|
||||
}
|
||||
|
|
|
@ -81,8 +81,8 @@ namespace Examples.Tests
|
|||
|
||||
while (!stop)
|
||||
{
|
||||
GL.Vertex2f(0.0f, 0.0f);
|
||||
//GL.Vertex2fv(v);
|
||||
GL.Vertex2(0.0f, 0.0f);
|
||||
GL.Vertex2(v);
|
||||
//GL.ARB.ActiveTexture(GL.Enums.ARB_multitexture.TEXTURE0_ARB);
|
||||
//dummy();
|
||||
GL.ColorPointer(2, GL.Enums.ColorPointerType.FLOAT, 0, v);
|
||||
|
|
|
@ -131,41 +131,41 @@ namespace Examples.Tutorial
|
|||
{
|
||||
GL.Begin(Enums.BeginMode.QUADS);
|
||||
|
||||
GL.Color3f(1, 0, 0);
|
||||
GL.Vertex3f(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, -1.0f);
|
||||
GL.Color3(1, 0, 0);
|
||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||
|
||||
GL.Color3f(1, 1, 0);
|
||||
GL.Vertex3f(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Color3(1, 1, 0);
|
||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
|
||||
GL.Color3f(1, 0, 1);
|
||||
GL.Vertex3f(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, -1.0f);
|
||||
GL.Color3(1, 0, 1);
|
||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||
|
||||
GL.Color3f(0, 1, 0);
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Color3(0, 1, 0);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
|
||||
GL.Color3f(0, 0, 1);
|
||||
GL.Vertex3f(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, -1.0f);
|
||||
GL.Color3(0, 0, 1);
|
||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||
|
||||
GL.Color3f(0, 1, 1);
|
||||
GL.Vertex3f(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, 1.0f);
|
||||
GL.Color3(0, 1, 1);
|
||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||
|
||||
GL.End();
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace Examples.Tutorial
|
|||
|
||||
d.Begin();
|
||||
|
||||
GL.Color3d(
|
||||
GL.Color3(
|
||||
1.0,
|
||||
c,
|
||||
1 - c
|
||||
|
@ -61,10 +61,10 @@ namespace Examples.Tutorial
|
|||
|
||||
GL.Begin(Enums.BeginMode.QUADS);
|
||||
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f( 1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f( 1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3( 1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3( 1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
|
||||
GL.End();
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace Examples.Tutorial
|
|||
GL.BindBuffer(GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, ibo);
|
||||
GL.IndexPointer(GL.Enums.IndexPointerType.FLOAT, 0, 0);
|
||||
|
||||
GL.Color3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Color3(1.0f, 1.0f, 1.0f);
|
||||
GL.DrawElements(
|
||||
GL.Enums.BeginMode.QUADS,
|
||||
idata.Length,
|
||||
|
@ -183,7 +183,7 @@ namespace Examples.Tutorial
|
|||
(IntPtr)(vdata.Length * 4),
|
||||
vdata,
|
||||
GL.Enums.VERSION_1_5.STATIC_DRAW);
|
||||
GL.GetBufferParameteriv(
|
||||
GL.GetBufferParameter(
|
||||
GL.Enums.VERSION_1_5.ARRAY_BUFFER,
|
||||
GL.Enums.VERSION_1_5.BUFFER_SIZE,
|
||||
out size);
|
||||
|
@ -200,7 +200,7 @@ namespace Examples.Tutorial
|
|||
idata,
|
||||
GL.Enums.VERSION_1_5.STATIC_DRAW
|
||||
);
|
||||
GL.GetBufferParameteriv(
|
||||
GL.GetBufferParameter(
|
||||
GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER,
|
||||
GL.Enums.VERSION_1_5.BUFFER_SIZE,
|
||||
out size);
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace Examples.Tutorial
|
|||
|
||||
GL.ShaderSource(vertex_shader_object, vertex_shader_source.Length, vertex_shader_source, (int[])null);
|
||||
GL.CompileShader(vertex_shader_object);
|
||||
GL.GetShaderiv(vertex_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status);
|
||||
GL.GetShader(vertex_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status);
|
||||
if (status != (int)Enums.Boolean.TRUE)
|
||||
{
|
||||
StringBuilder info = new StringBuilder(1024);
|
||||
|
@ -82,7 +82,7 @@ namespace Examples.Tutorial
|
|||
|
||||
GL.ShaderSource(fragment_shader_object, fragment_shader_source.Length, fragment_shader_source, (int[])null);
|
||||
GL.CompileShader(fragment_shader_object);
|
||||
GL.GetShaderiv(fragment_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status);
|
||||
GL.GetShader(fragment_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status);
|
||||
if (status != (int)Enums.Boolean.TRUE)
|
||||
{
|
||||
StringBuilder info = new StringBuilder(1024);
|
||||
|
@ -184,41 +184,41 @@ namespace Examples.Tutorial
|
|||
{
|
||||
GL.Begin(Enums.BeginMode.QUADS);
|
||||
|
||||
GL.Color3f(1, 0, 0);
|
||||
GL.Vertex3f(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, -1.0f);
|
||||
GL.Color3(1, 0, 0);
|
||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||
|
||||
GL.Color3f(1, 1, 0);
|
||||
GL.Vertex3f(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Color3(1, 1, 0);
|
||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
|
||||
GL.Color3f(1, 0, 1);
|
||||
GL.Vertex3f(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, -1.0f);
|
||||
GL.Color3(1, 0, 1);
|
||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||
|
||||
GL.Color3f(0, 1, 0);
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Color3(0, 1, 0);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
|
||||
GL.Color3f(0, 0, 1);
|
||||
GL.Vertex3f(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, -1.0f);
|
||||
GL.Color3(0, 0, 1);
|
||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||
|
||||
GL.Color3f(0, 1, 1);
|
||||
GL.Vertex3f(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, 1.0f);
|
||||
GL.Color3(0, 1, 1);
|
||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||
|
||||
GL.End();
|
||||
}
|
||||
|
|
|
@ -167,41 +167,41 @@ namespace Examples.WinForms
|
|||
{
|
||||
GL.Begin(Enums.BeginMode.QUADS);
|
||||
|
||||
GL.Color3f(1, 0, 0);
|
||||
GL.Vertex3f(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, -1.0f);
|
||||
GL.Color3(1, 0, 0);
|
||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||
|
||||
GL.Color3f(1, 1, 0);
|
||||
GL.Vertex3f(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Color3(1, 1, 0);
|
||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
|
||||
GL.Color3f(1, 0, 1);
|
||||
GL.Vertex3f(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, -1.0f);
|
||||
GL.Color3(1, 0, 1);
|
||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||
|
||||
GL.Color3f(0, 1, 0);
|
||||
GL.Vertex3f(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Color3(0, 1, 0);
|
||||
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
|
||||
GL.Color3f(0, 0, 1);
|
||||
GL.Vertex3f(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, -1.0f);
|
||||
GL.Color3(0, 0, 1);
|
||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||
|
||||
GL.Color3f(0, 1, 1);
|
||||
GL.Vertex3f(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3f(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3f(1.0f, -1.0f, 1.0f);
|
||||
GL.Color3(0, 1, 1);
|
||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||
|
||||
GL.End();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
|||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("0.3.9.3")]
|
||||
[assembly: AssemblyFileVersion("0.3.9.3")]
|
||||
[assembly: AssemblyVersion("0.3.9.4")]
|
||||
[assembly: AssemblyFileVersion("0.3.9.4")]
|
||||
|
|
Loading…
Reference in a new issue