Merged with bind branch: updated GL.cs wrappers, Glx and Glu implementation suppoort files, faster Bind.

This commit is contained in:
the_fiddler 2007-09-02 00:40:43 +00:00
parent 0b0da23f52
commit 9120a732ea
23 changed files with 4096 additions and 2906 deletions

View file

@ -10,6 +10,7 @@ using System.Text;
using System.IO;
using Bind.Structures;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace Bind.GL2
{
@ -56,6 +57,10 @@ namespace Bind.GL2
public virtual void Process()
{
Function.endingsAddV =
new Regex(@"(Coord1|Attrib(I?)1(u?)|Stream1|Uniform2(u?)|Parameter|Fog(Coord)?.*|VertexWeight|(Fragment)?Light(Model)?|Material|ReplacementCodeu?b?|Tex(Gen|Env)|Indexu?b?)", RegexOptions.Compiled);
Bind.Structures.Type.Initialize(glTypemap, csTypemap);
Bind.Structures.Enum.Initialize(enumSpec, enumSpecExt);
Bind.Structures.Function.Initialize();
@ -173,7 +178,7 @@ namespace Bind.GL2
// Get function name:
d.Name = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries)[0];
if (d.Name.Contains("UseFontOutlinesA"))
if (d.Name.Contains("QueryHyperpipeBestAttribSGIX"))
{
}
@ -201,7 +206,7 @@ namespace Bind.GL2
p.Name = Utilities.Keywords.Contains(words[1]) ? "@" + words[1] : words[1];
p.CurrentType = words[2];
p.Pointer = words[4] == "array" ? true : words[4] == "reference" ? true : false;
p.Pointer = words[4].Contains("array") ? true : words[4].Contains("reference") ? true : false;
p.Flow = words[3] == "in" ? Parameter.FlowDirection.In : Parameter.FlowDirection.Out;
d.Parameters.Add(p);

View file

@ -72,7 +72,9 @@ namespace Bind
mode =
arg == "gl2" ? GeneratorMode.GL2 :
arg == "gl3" ? GeneratorMode.GL3 :
arg == "wgl" ? GeneratorMode.Wgl : GeneratorMode.GL2;
arg == "wgl" ? GeneratorMode.Wgl :
arg == "glu" ? GeneratorMode.Glu :
arg == "glx" ? GeneratorMode.Glx : GeneratorMode.GL2;
break;
case "namespace":
case "ns":
@ -120,17 +122,18 @@ namespace Bind
break;
case GeneratorMode.Wgl:
if (Settings.OutputPath == Settings.DefaultOutputPath)
{
Settings.OutputPath = Settings.DefaultWglOutputPath;
}
if (Settings.OutputNamespace == Settings.DefaultOutputNamespace)
{
Settings.OutputNamespace = "OpenTK.Platform.Windows";
}
Generator = new Bind.Wgl.Generator();
break;
case GeneratorMode.Glu:
Generator = new Bind.Glu.Generator();
break;
case GeneratorMode.Glx:
Generator = new Bind.Glx.Generator();
break;
case GeneratorMode.GL3:
default:
throw new NotImplementedException(String.Format("Mode {0} not implemented.", mode));
}

View file

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("0.9.7.4")]
[assembly: AssemblyFileVersion("0.9.7.4")]
[assembly: AssemblyVersion("0.9.7.5")]
[assembly: AssemblyFileVersion("0.9.7.5")]

View file

@ -16,9 +16,9 @@ namespace Bind
public static string OutputPath = "..\\..\\..\\Source\\OpenTK\\OpenGL\\Bindings";
public static string OutputNamespace = "OpenTK.OpenGL";
public readonly static string DefaultInputPath = "..\\..\\..\\Source\\Bind\\Specifications";
public readonly static string DefaultOutputPath = "..\\..\\..\\Source\\OpenTK\\OpenGL\\Bindings";
public readonly static string DefaultOutputNamespace = "OpenTK.OpenGL";
public const string DefaultInputPath = "..\\..\\..\\Source\\Bind\\Specifications";
public const string DefaultOutputPath = "..\\..\\..\\Source\\OpenTK\\OpenGL\\Bindings";
public const string DefaultOutputNamespace = "OpenTK.OpenGL";
public static string OutputClass = "GL";
public static string FunctionPrefix = "gl";
@ -36,8 +36,6 @@ namespace Bind
public static Legacy Compatibility = Legacy.None;
public readonly static string DefaultWglOutputPath = "..\\..\\..\\Source\\OpenTK\\Platform\\Windows\\Bindings";
/// <summary>
/// The name of the C# enum which holds every single OpenGL enum (for compatibility purposes).
/// </summary>

View file

@ -0,0 +1,23 @@
GLUnurbs Glu.GLUnurbs
GLUTesselator Glu.GLUTesselator
GLUquadric Glu.GLUquadric
# Unknown types (try to infer!)
NurbsObj int
QuadricObj int
TesselatorObj int
FunctionPointer IntPtr
VoidPointer VoidPointer
Float64 Float64
Float64Pointer Float64Pointer
Float32 Float32
Float32Pointer Float32Pointer
SizeI GLsizei
UInt8 GLubyte
# Enum types (find Tao-compatible solution!)
TextureTarget TextureTarget
PixelFormat PixelFormat
PixelType PixelType
MapTarget MapTarget

View file

@ -4,9 +4,10 @@ DMbuffer,*,*, DMbuffer,*,*
DMparams,*,*, DMparams,*,*
Display,*,*, Display,*,*
DisplayPointer,*,*, Display *,*,*
FunctionPointer,*,*, __GLXextFuncPtr,*,*
FunctionPointer,*,*, __GLXextFuncPtr,*,*
GLXContext,*,*, GLXContext,*,*
constGLXContext,*,*, const GLXContext,*,*
#constGLXContext,*,*, const GLXContext,*,*
constGLXContext,*,*, GLXContext,*,*
GLXContextID,*,*, GLXContextID,*,*
GLXDrawable,*,*, GLXDrawable,*,*
GLXFBConfig,*,*, GLXFBConfig,*,*
@ -26,7 +27,8 @@ GLfunction,*,*, GLfunction,*,*
GLubyte,*,*, GLubyte,*,*
Pixmap,*,*, Pixmap,*,*
Status,*,*, Status,*,*
Uint,*,*, unsigned int,*,*
#Uint,*,*, unsigned int,*,*
Uint uint
VLNode,*,*, VLNode,*,*
VLPath,*,*, VLPath,*,*
VLServer,*,*, VLServer,*,*
@ -35,9 +37,12 @@ XVisualInfo,*,*, XVisualInfo,*,*
XVisualInfoPointer,*,*, XVisualInfo *,*,*
float,*,*, float,*,*
int,*,*, int,*,*
uint,*,*, unsigned int,*,*
int32_t,*,*, int32_t,*,*
int64_t,*,*, int64_t,*,*
#uint,*,*, unsigned int,*,*
uint uint
int32_t,*,*, int32_t,*,*
int64_t,*,*, int64_t,*,*
long,*,*, long,*,*
ulong,*,*, unsigned long,*,*
#ulong,*,*, unsigned long,*,*
ulong ulong
void,*,*, void,*,*
Void Void

View file

@ -52,8 +52,25 @@ LPVOID, void*
#String, const char *
UINT, UInt32
USHORT, UInt16
VOID, Void
VOID, void
VoidPointer, void*
float, float
int, int
#void, *
# Glu types.
Float64 double
Float64Pointer double*
Float32 float
Float32Pointer float*
# Glx types.
Void void
Bool bool
int64_t long
int32_t int
Display IntPtr
Window IntPtr
Pixmap IntPtr
__GLXextFuncPtr IntPtr

View file

@ -76,7 +76,7 @@ namespace Bind.Structures
#region public bool Unchecked
private bool @unchecked = false;
private bool @unchecked;
public bool Unchecked
{

View file

@ -59,14 +59,12 @@ namespace Bind.Structures
public Delegate(Delegate d)
{
this.Category = !String.IsNullOrEmpty(d.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.Category = d.Category;
this.Name = d.Name;
this.Parameters = new ParameterCollection(d.Parameters);
this.ReturnType = new Type(d.ReturnType);
this.Version = !String.IsNullOrEmpty(d.Version) ? new string(d.Version.ToCharArray()) : "";
//this.Unsafe = d.Unsafe;
this.Version = d.Version;
//this.Version = !String.IsNullOrEmpty(d.Version) ? new string(d.Version.ToCharArray()) : "";
}
#endregion
@ -451,7 +449,7 @@ namespace Bind.Structures
#region protected void WrapParameters(Function function, List<Function> wrappers)
protected static int index = 0;
protected static int index;
/// <summary>
/// This function needs some heavy refactoring. I'm ashamed I ever wrote it, but it works...
@ -522,7 +520,7 @@ namespace Bind.Structures
WrapParameters(function, wrappers);
--index;
if (function.Name == "UseFontOutlinesA")
//if (function.Name == "UseFontOutlinesA")
{
}
@ -631,7 +629,6 @@ namespace Bind.Structures
static List<string> handle_statements = new List<string>();
static List<string> fixed_statements = new List<string>();
static List<string> assign_statements = new List<string>();
static string function_call_statement;
protected FunctionBody CreateBody(Function fun, bool wantCLSCompliance)
{
@ -642,7 +639,7 @@ namespace Bind.Structures
fixed_statements.Clear();
assign_statements.Clear();
if (f.Name == "LoadDisplayColorTableEXT")
//if (f.Name == "LoadDisplayColorTableEXT")
{
}
@ -652,10 +649,10 @@ namespace Bind.Structures
{
if (p.NeedsPin)
{
// Use GCHandle to obtain pointer to generic parameters and 'fixed' for arrays.
// This is because fixed can only take the address of fields, not managed objects.
if (p.WrapperType == WrapperTypes.GenericParameter)
{
// Use GCHandle to obtain pointer to generic parameters and 'fixed' for arrays.
// This is because fixed can only take the address of fields, not managed objects.
handle_statements.Add(String.Format(
"{0} {1} = {0}.Alloc({2}, System.Runtime.InteropServices.GCHandleType.Pinned);",
"System.Runtime.InteropServices.GCHandle", p.Name + "_ptr", p.Name));
@ -674,6 +671,7 @@ namespace Bind.Structures
p.WrapperType == WrapperTypes.ArrayParameter ||
p.WrapperType == WrapperTypes.ReferenceParameter)
{
// A fixed statement is issued for all non-generic pointers, arrays and references.
fixed_statements.Add(String.Format(
"fixed ({0}* {1} = {2})",
wantCLSCompliance && !p.CLSCompliant ? p.GetCLSCompliantType() : p.CurrentType,

View file

@ -16,27 +16,43 @@ namespace Bind.Structures
public class Enum
{
internal static EnumCollection GLEnums;
internal static EnumCollection AuxEnums;
private static bool enumsLoaded;
internal static void Initialize(string enumFile, string enumextFile, string auxFile)
{
Initialize(enumFile, enumextFile);
using (System.IO.StreamReader sr = new System.IO.StreamReader(Path.Combine(Settings.InputPath, "GL2\\enum.spec")))
{
AuxEnums = Bind.MainClass.Generator.ReadEnums(sr);
}
}
internal static void Initialize(string enumFile, string enumextFile)
{
if (!enumsLoaded)
{
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, enumFile))
if (!String.IsNullOrEmpty(enumFile))
{
GLEnums = Bind.MainClass.Generator.ReadEnums(sr);
}
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, enumextFile))
{
foreach (Bind.Structures.Enum e in Bind.MainClass.Generator.ReadEnums(sr).Values)
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, enumFile))
{
//enums.Add(e.Name, e);
Utilities.Merge(GLEnums, e);
GLEnums = Bind.MainClass.Generator.ReadEnums(sr);
}
}
if (!String.IsNullOrEmpty(enumextFile))
{
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, enumextFile))
{
foreach (Bind.Structures.Enum e in Bind.MainClass.Generator.ReadEnums(sr).Values)
{
//enums.Add(e.Name, e);
Utilities.Merge(GLEnums, e);
}
}
}
enumsLoaded = true;
}
}

View file

@ -31,23 +31,18 @@ namespace Bind.Structures
#endregion
Regex functionsNotToTrim = new Regex(@"(Coord1|Attrib(I?)1(u?)|Stream1|Uniform2(u?))[dfis]v");
//Regex endings = new Regex(@"(.)+[df(u?[isb])]v?");
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"
});
static Regex endings = new Regex(@"([df]|u?[isb])v?", RegexOptions.Compiled | RegexOptions.RightToLeft);
static Regex endingsNotToTrim = new Regex("(ib|[tdr]s|nd)", RegexOptions.Compiled | RegexOptions.RightToLeft);
/// <summary>
/// Add a trailing v to functions matching this regex. Used to differntiate between overloads taking both
/// a 'type' and a 'ref type' (such overloads are not CLS Compliant).
/// </summary>
/// <remarks>
/// The default Regex matches no functions. Create a new Regex in Bind.Generator classes to override the default behavior.
/// </remarks>
internal static Regex endingsAddV = new Regex("^0", RegexOptions.Compiled);
#region --- Constructors ---
public Function()
@ -55,14 +50,7 @@ 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)
{
@ -103,7 +91,7 @@ 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.
@ -117,7 +105,8 @@ namespace Bind.Structures
trimmedName = value.Trim();
}
}
*/
public string TrimmedName;
#endregion
#region public override string Name
@ -134,25 +123,25 @@ namespace Bind.Structures
{
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.
TrimmedName = value;
if (Settings.Compatibility == Settings.Legacy.Tao)
{
// 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.
TrimmedName = value;
}
else
{
TrimmedName = Utilities.StripGL2Extension(value);
//if (TrimmedName.Contains("Uniform2iv"))
{
//Console.Write("niar");
}
//{
// Console.Write("niar");
//}
// Remove overload
/*
for (int i = 3; i >= 1; i--)
{
if (endings.Contains(TrimmedName.Substring(TrimmedName.Length - i)))
@ -165,7 +154,7 @@ namespace Bind.Structures
// TODO: Add better handling for CLS-Compliance on ref ('v') functions.
if (Char.IsDigit(TrimmedName[TrimmedName.Length - (i + 1)]))
{
if (!functionsNotToTrim.IsMatch(Name))
if (!endingsAddV.IsMatch(Name))
{
TrimmedName = TrimmedName.Substring(0, TrimmedName.Length - i);
}
@ -181,6 +170,27 @@ namespace Bind.Structures
return;
}
}
*/
if (!endingsNotToTrim.IsMatch(Name))
{
// Some endings should not be trimmed, for example: 'b' from Attrib
Match m = endings.Match(TrimmedName);
if (m.Index + m.Length == TrimmedName.Length)
{ // Only trim endings, not internal matches.
if (m.Value[m.Length - 1] == 'v' && endingsAddV.IsMatch(Name))
{ // Only trim ending 'v' when there is a number
TrimmedName = TrimmedName.Substring(0, m.Index) + "v";
}
else
{
TrimmedName = TrimmedName.Substring(0, m.Index);
}
}
}
}
}
}
@ -217,7 +227,8 @@ namespace Bind.Structures
public bool Equals(Function other)
{
return !String.IsNullOrEmpty(this.TrimmedName) && !String.IsNullOrEmpty(other.TrimmedName) &&
return
!String.IsNullOrEmpty(this.TrimmedName) && !String.IsNullOrEmpty(other.TrimmedName) &&
this.TrimmedName == other.TrimmedName &&
this.Parameters.ToString(true) == other.Parameters.ToString(true);
}

View file

@ -11,13 +11,14 @@ using System.Runtime.InteropServices;
namespace Bind.Structures
{
#region Parameter class
/// <summary>
/// Represents a single parameter of an opengl function.
/// </summary>
public class Parameter : Type
{
string cache;
bool rebuild;
#region Constructors
/// <summary>
@ -38,24 +39,33 @@ namespace Bind.Structures
if (p == null)
return;
this.Name = !String.IsNullOrEmpty(p.Name) ? new string(p.Name.ToCharArray()) : "";
this.Name = p.Name;
this.Unchecked = p.Unchecked;
this.UnmanagedType = p.UnmanagedType;
this.Flow = p.Flow;
this.cache = p.cache;
//this.rebuild = false;
}
#endregion
#region public string Name
string _name;
string _name = String.Empty;
/// <summary>
/// Gets or sets the name of the parameter.
/// </summary>
public string Name
{
get { return _name; }
set { _name = value; }
set
{
if (_name != value)
{
_name = value;
rebuild = true;
}
}
}
#endregion
@ -69,7 +79,14 @@ namespace Bind.Structures
private UnmanagedType UnmanagedType
{
get { return _unmanaged_type; }
set { _unmanaged_type = value; }
set
{
if (_unmanaged_type != value)
{
_unmanaged_type = value;
rebuild = true;
}
}
}
#endregion
@ -95,7 +112,14 @@ namespace Bind.Structures
public FlowDirection Flow
{
get { return _flow; }
set { _flow = value; }
set
{
if (_flow != value)
{
_flow = value;
rebuild = true;
}
}
}
#endregion
@ -120,7 +144,31 @@ namespace Bind.Structures
public bool Unchecked
{
get { return _unchecked; }
set { _unchecked = value; }
set
{
if (_unchecked != value)
{
_unchecked = value;
rebuild = true;
}
}
}
#endregion
#region public override string CurrentType
public override string CurrentType
{
get
{
return base.CurrentType;
}
set
{
base.CurrentType = value;
rebuild = true;
}
}
#endregion
@ -138,58 +186,59 @@ namespace Bind.Structures
public string ToString(bool taoCompatible)
{
StringBuilder sb = new StringBuilder();
//if (UnmanagedType == UnmanagedType.AsAny && Flow == FlowDirection.In)
// sb.Append("[MarshalAs(UnmanagedType.AsAny)] ");
//if (UnmanagedType == UnmanagedType.LPArray)
// sb.Append("[MarshalAs(UnmanagedType.LPArray)] ");
//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 (!String.IsNullOrEmpty(cache) && !rebuild)
{
if (Flow == FlowDirection.Out)
sb.Append("out ");
else
sb.Append("ref ");
return cache;
}
if (taoCompatible && Settings.Compatibility == Settings.Legacy.Tao)
else
{
if (Pointer)
StringBuilder sb = new StringBuilder();
if (Flow == FlowDirection.Out)
sb.Append("[Out] ");
else if (Flow == FlowDirection.Undefined)
sb.Append("[In, Out] ");
if (Reference)
{
sb.Append("IntPtr");
if (Flow == FlowDirection.Out)
sb.Append("out ");
else
sb.Append("ref ");
}
if (taoCompatible && Settings.Compatibility == Settings.Legacy.Tao)
{
if (Pointer)
{
sb.Append("IntPtr");
}
else
{
sb.Append(CurrentType);
if (Array > 0)
sb.Append("[]");
}
}
else
{
sb.Append(CurrentType);
if (Pointer)
sb.Append("*");
if (Array > 0)
sb.Append("[]");
}
}
else
{
sb.Append(CurrentType);
if (Pointer)
sb.Append("*");
if (Array > 0)
sb.Append("[]");
}
if (!String.IsNullOrEmpty(Name))
{
sb.Append(" ");
sb.Append(Utilities.Keywords.Contains(Name) ? "@" + Name : Name);
if (!String.IsNullOrEmpty(Name))
{
sb.Append(" ");
sb.Append(Utilities.Keywords.Contains(Name) ? "@" + Name : Name);
}
rebuild = false;
cache = sb.ToString();
return cache;
}
return sb.ToString();
}
#endregion
@ -203,7 +252,9 @@ namespace Bind.Structures
Parameter p = new Parameter(par);
// Translate enum types
if (Enum.GLEnums.TryGetValue(p.CurrentType, out @enum) && @enum.Name != "GLenum")
if ((Enum.GLEnums.TryGetValue(p.CurrentType, out @enum) ||
(Enum.AuxEnums != null && Enum.AuxEnums.TryGetValue(p.CurrentType, out @enum))) &&
@enum.Name != "GLenum")
{
if (Settings.Compatibility == Settings.Legacy.Tao)
p.CurrentType = "int";
@ -305,8 +356,6 @@ namespace Bind.Structures
#endregion
}
#endregion
#region ParameterCollection class
/// <summary>
@ -314,6 +363,10 @@ namespace Bind.Structures
/// </summary>
public class ParameterCollection : List<Parameter>
{
string cache = String.Empty;
string callStringCache = String.Empty;
bool rebuild = true;
#region Constructors
public ParameterCollection()
@ -330,6 +383,12 @@ namespace Bind.Structures
#endregion
new public void Add(Parameter p)
{
rebuild = true;
base.Add(p);
}
#region override public string ToString()
/// <summary>
@ -353,28 +412,36 @@ namespace Bind.Structures
/// <returns>The parameter list of an opengl function in the form ( [parameters] )</returns>
public string ToString(bool taoCompatible)
{
StringBuilder sb = new StringBuilder();
sb.Append("(");
if (this.Count > 0)
if (!rebuild)
{
foreach (Parameter p in this)
{
if (taoCompatible)
{
sb.Append(p.ToString(true));
}
else
{
sb.Append(p.ToString());
}
sb.Append(", ");
}
sb.Replace(", ", ")", sb.Length - 2, 2);
return cache;
}
else
sb.Append(")");
{
StringBuilder sb = new StringBuilder();
sb.Append("(");
if (this.Count > 0)
{
foreach (Parameter p in this)
{
if (taoCompatible)
{
sb.Append(p.ToString(true));
}
else
{
sb.Append(p.ToString());
}
sb.Append(", ");
}
sb.Replace(", ", ")", sb.Length - 2, 2);
}
else
sb.Append(")");
return sb.ToString();
cache = sb.ToString();
return cache;
}
}
#endregion
@ -386,58 +453,66 @@ namespace Bind.Structures
public string CallString(bool taoCompatible)
{
StringBuilder sb = new StringBuilder();
sb.Append("(");
if (this.Count > 0)
if (!rebuild)
{
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 if (p.Pointer || p.Array > 0 || p.Reference)
{
sb.Append(String.Format("({0}*)",
p.CurrentType /*, (p.Pointer || p.Array > 0) ? "*" : ""*/));
}
//else if (p.Reference)
//{
// sb.Append(String.Format("{0} ({1})",
// p.Flow == Parameter.FlowDirection.Out ? "out" : "ref", p.CurrentType));
//}
else
{
sb.Append(String.Format("({0})", p.CurrentType));
}
}
sb.Append(
Utilities.Keywords.Contains(p.Name) ? "@" + p.Name : p.Name
);
if (p.Unchecked)
sb.Append(")");
sb.Append(", ");
}
sb.Replace(", ", ")", sb.Length - 2, 2);
return callStringCache;
}
else
{
sb.Append(")");
}
StringBuilder sb = new StringBuilder();
return sb.ToString();
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 if (p.Pointer || p.Array > 0 || p.Reference)
{
sb.Append(String.Format("({0}*)",
p.CurrentType /*, (p.Pointer || p.Array > 0) ? "*" : ""*/));
}
//else if (p.Reference)
//{
// sb.Append(String.Format("{0} ({1})",
// p.Flow == Parameter.FlowDirection.Out ? "out" : "ref", p.CurrentType));
//}
else
{
sb.Append(String.Format("({0})", p.CurrentType));
}
}
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(")");
}
callStringCache = sb.ToString();
return callStringCache;
}
}
public bool ContainsType(string type)

View file

@ -52,12 +52,15 @@ namespace Bind.Structures
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;
if (t != null)
{
this.CurrentType = t.CurrentType;
this.PreviousType = t.PreviousType;
this.WrapperType = t.WrapperType;
this.Array = t.Array;
this.Pointer = t.Pointer;
this.Reference = t.Reference;
}
}
#endregion
@ -136,7 +139,7 @@ namespace Bind.Structures
#region public bool Pointer
bool pointer = false;
bool pointer;
public bool Pointer
{

View file

@ -66,7 +66,7 @@ namespace Bind
public static class Utilities
{
public static char[] Separators = { ' ', '\n', ',', '(', ')', ';', '#' };
public static readonly char[] Separators = { ' ', '\n', ',', '(', ')', ';', '#' };
#region internal StreamReader OpenSpecFile(string file)

View file

@ -8,6 +8,8 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Text.RegularExpressions;
using Bind.Structures;
namespace Bind.Wgl
{

View file

@ -119,7 +119,7 @@ namespace Examples.Windowing
0.0, 0.0, 0.0,
0.0, 1.0, 0.0
);
GL.Rotatef(angle + angle_add, 0.0f, 1.0f, 0.0f);
GL.Rotate(angle + angle_add, 0.0f, 1.0f, 0.0f);
angle += 0.5f;
GL.Clear(Enums.ClearBufferMask.COLOR_BUFFER_BIT | Enums.ClearBufferMask.DEPTH_BUFFER_BIT);

View file

@ -87,11 +87,11 @@ namespace Examples.Tutorial
GL.ShaderSource(vertex_shader_object, vertex_shader_source.Length, vertex_shader_source, (int[])null);
GL.CompileShader(vertex_shader_object);
GL.GetShaderv(vertex_shader_object, GL.Enums.VERSION_2_0.COMPILE_STATUS, out status);
GL.GetShader(vertex_shader_object, GL.Enums.VERSION_2_0.COMPILE_STATUS, out status);
if (status != (int)GL.Enums.Boolean.TRUE)
{
int length = 0;
GL.GetShaderv(vertex_shader_object, GL.Enums.VERSION_2_0.INFO_LOG_LENGTH, out length);
GL.GetShader(vertex_shader_object, GL.Enums.VERSION_2_0.INFO_LOG_LENGTH, out length);
StringBuilder info = new StringBuilder(length);
GL.GetShaderInfoLog(vertex_shader_object, info.Capacity, out length, info);
@ -100,11 +100,11 @@ namespace Examples.Tutorial
GL.ShaderSource(fragment_shader_object, fragment_shader_source.Length, fragment_shader_source, (int[])null);
GL.CompileShader(fragment_shader_object);
GL.GetShaderv(fragment_shader_object, GL.Enums.VERSION_2_0.COMPILE_STATUS, out status);
GL.GetShader(fragment_shader_object, GL.Enums.VERSION_2_0.COMPILE_STATUS, out status);
if (status != (int)GL.Enums.Boolean.TRUE)
{
int length;
GL.GetShaderv(vertex_shader_object, GL.Enums.VERSION_2_0.INFO_LOG_LENGTH, out length);
GL.GetShader(vertex_shader_object, GL.Enums.VERSION_2_0.INFO_LOG_LENGTH, out length);
StringBuilder info = new StringBuilder(length);
GL.GetShaderInfoLog(fragment_shader_object, info.Capacity, out length, info);
@ -163,7 +163,7 @@ namespace Examples.Tutorial
0.0, 0.0, 0.0,
0.0, 1.0, 0.0
);
GL.Rotatef(angle, 0.0f, 1.0f, 0.0f);
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
angle += 0.05f;
}

File diff suppressed because it is too large Load diff

View file

@ -14,7 +14,7 @@ namespace OpenTK.OpenGL
/// <summary>
/// Provides access to GLU functions.
/// </summary>
public class Glu
public static partial class Glu
{
#region GLU functions

View file

@ -528,10 +528,10 @@ XF86VidModeGetGammaRampSize(
#region X11 Structures
#region public class VisualInfo
#region internal class XVisualInfo
[StructLayout(LayoutKind.Sequential)]
public class VisualInfo
public class XVisualInfo
{
public IntPtr visual;
public VisualID visualid;

View file

@ -11,4 +11,24 @@ namespace OpenTK.Platform.X11
// Disable BeforeFieldInit optimization.
static Glx() { }
}
public struct GLXDrawable
{
}
public struct GLXContext
{
}
public struct GLXHyperpipeNetworkPointer
{
}
public struct GLXHyperpipeConfig
{
}
public struct GLXHyperpipeConfigPointer
{
}
}

View file

@ -18,7 +18,7 @@ namespace OpenTK.Platform.X11
{
public WindowInfo()
{
visinfo = new VisualInfo();
visinfo = new XVisualInfo();
}
public WindowInfo(WindowInfo parent)
@ -35,7 +35,7 @@ namespace OpenTK.Platform.X11
private IntPtr rootWindow, handle, topLevelWindow, display;
private int screen;
private WindowInfo parent;
private VisualInfo visinfo;
private XVisualInfo visinfo;
public IntPtr RootWindow { get { return rootWindow; } set { rootWindow = value; } }
public IntPtr TopLevelWindow { get { return topLevelWindow; } set { topLevelWindow = value; } }

View file

@ -107,7 +107,7 @@ namespace OpenTK.Platform.X11
}
else
{
windowInfo.VisualInfo = (VisualInfo)Marshal.PtrToStructure(visual, typeof(VisualInfo));
windowInfo.VisualInfo = (XVisualInfo)Marshal.PtrToStructure(visual, typeof(XVisualInfo));
Debug.Print("Prepared visual: {0}", windowInfo.VisualInfo.ToString());
}
}