Improved opengl overload trimming.
This commit is contained in:
parent
3833030a9a
commit
ac2a2f9a70
6 changed files with 9852 additions and 9814 deletions
|
@ -22,6 +22,9 @@ namespace Bind.Structures
|
|||
internal static DelegateCollection Delegates;
|
||||
|
||||
private static bool delegatesLoaded;
|
||||
|
||||
#region internal static void Initialize(string glSpec, string glSpecExt)
|
||||
|
||||
internal static void Initialize(string glSpec, string glSpecExt)
|
||||
{
|
||||
if (!delegatesLoaded)
|
||||
|
@ -45,6 +48,8 @@ namespace Bind.Structures
|
|||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- Constructors ---
|
||||
|
||||
public Delegate()
|
||||
|
|
|
@ -17,6 +17,9 @@ namespace Bind.Structures
|
|||
internal static FunctionCollection Wrappers;
|
||||
|
||||
private static bool loaded;
|
||||
|
||||
#region internal static void Initialize()
|
||||
|
||||
internal static void Initialize()
|
||||
{
|
||||
if (!loaded)
|
||||
|
@ -25,26 +28,24 @@ namespace Bind.Structures
|
|||
loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
#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"
|
||||
"fv", "f",
|
||||
"dv", "d",
|
||||
"i", "iv",
|
||||
"s", "sv",
|
||||
"b", "bv",
|
||||
"ui", "uiv",
|
||||
"us", "usv",
|
||||
"ub", "ubv"
|
||||
});
|
||||
|
||||
#region --- Constructors ---
|
||||
|
@ -139,45 +140,42 @@ namespace Bind.Structures
|
|||
// 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 = value;
|
||||
TrimmedName = Utilities.StripGL2Extension(value);
|
||||
|
||||
//if (TrimmedName.Contains("Uniform2iv"))
|
||||
{
|
||||
trimmedName = trimmedName.Substring(0, trimmedName.Length - ext.Length);
|
||||
//Console.Write("niar");
|
||||
}
|
||||
|
||||
// Remove overload
|
||||
if (endings.Contains(trimmedName.Substring(trimmedName.Length - 3)))
|
||||
for (int i = 3; i >= 1; i--)
|
||||
{
|
||||
if (!trimmedName.EndsWith("v"))
|
||||
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 3);
|
||||
else
|
||||
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 3) + "v";
|
||||
return;
|
||||
}
|
||||
|
||||
if (endings.Contains(trimmedName.Substring(trimmedName.Length - 2)))
|
||||
{
|
||||
if (!trimmedName.EndsWith("v"))
|
||||
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 2);
|
||||
else
|
||||
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 2) + "v";
|
||||
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 (!trimmedName.EndsWith("v"))
|
||||
if (Char.IsDigit(trimmedName[trimmedName.Length - 2]))
|
||||
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 1);
|
||||
|
||||
return;
|
||||
if (endings.Contains(TrimmedName.Substring(TrimmedName.Length - i)))
|
||||
{
|
||||
// If there is a digit before the ending (e.g. 3fv) then we will remove
|
||||
// the ending (some functions are blacklisted for CLS-Compliance).
|
||||
// Otherwise, if there is no digit, but it ends with a 'v', do not remove
|
||||
// the 'v' (CLS-Compliance). If no digit and it ends with a (plural) 's',
|
||||
// do not remove anything (e.g. glCallLists)
|
||||
// TODO: Add better handling for CLS-Compliance on ref ('v') functions.
|
||||
if (Char.IsDigit(TrimmedName[TrimmedName.Length - (i + 1)]))
|
||||
{
|
||||
if (!functionsNotToTrim.IsMatch(Name))
|
||||
{
|
||||
TrimmedName = TrimmedName.Substring(0, TrimmedName.Length - i);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Function {0} blacklisted from trimming (CLS-Compliance).", Name);
|
||||
}
|
||||
}
|
||||
else if (TrimmedName.EndsWith("v"))
|
||||
{
|
||||
TrimmedName = TrimmedName.Substring(0, TrimmedName.Length - i) + "v";
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,11 +87,11 @@ namespace Examples.Tests
|
|||
|
||||
while (!stop)
|
||||
{
|
||||
GL.Vertex2(0.0f, 0.0f);
|
||||
GL.Vertex2v(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);
|
||||
//GL.ColorPointer(2, GL.Enums.ColorPointerType.FLOAT, 0, v);
|
||||
//glVertex2f_1(0.0f, 0.0f);
|
||||
//glVertex2f_2(0.0f, 0.0f);
|
||||
//glVertex2fv(v);
|
||||
|
|
|
@ -165,42 +165,43 @@ namespace Examples.WinForms
|
|||
|
||||
#endregion
|
||||
|
||||
#region DrawCube
|
||||
public void DrawCube()
|
||||
#region private void DrawCube()
|
||||
|
||||
private void DrawCube()
|
||||
{
|
||||
GL.Begin(GL.Enums.BeginMode.QUADS);
|
||||
|
||||
GL.Color3(1, 0, 0);
|
||||
GL.Color3(1.0f, 0.0f, 0.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.Color3(1, 1, 0);
|
||||
GL.Color3(1.0f, 1.0f, 0.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.Color3(1, 0, 1);
|
||||
GL.Color3(1.0f, 0.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.Color3(0, 1, 0);
|
||||
GL.Color3(0.0f, 1.0f, 0.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.Color3(0, 0, 1);
|
||||
GL.Color3(0.0f, 0.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.Color3(0, 1, 1);
|
||||
GL.Color3(0.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);
|
||||
|
@ -208,8 +209,9 @@ namespace Examples.WinForms
|
|||
|
||||
GL.End();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IExample Members
|
||||
|
||||
public void Launch()
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue