mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-02 07:40:59 +00:00
Merged with gl3 branch. Resolved conflicts. Added IMouseDriver.cs
This commit is contained in:
parent
d423f6e94c
commit
09bd00885c
|
@ -12,7 +12,14 @@ namespace Bind.GL2
|
||||||
internal static SpecReader specReader;
|
internal static SpecReader specReader;
|
||||||
internal static SpecWriter specWriter;
|
internal static SpecWriter specWriter;
|
||||||
|
|
||||||
string specFolder;
|
protected static string glTypemap = "gl.tm";
|
||||||
|
protected static string csTypemap = "csharp.tm";
|
||||||
|
protected static string enumSpec = "enum.spec";
|
||||||
|
protected static string enumSpecExt = "enumext.spec";
|
||||||
|
protected static string glSpec = "gl.spec";
|
||||||
|
protected static string glSpecExt = "";
|
||||||
|
|
||||||
|
protected string specFolder;
|
||||||
|
|
||||||
public Generator(string folder)
|
public Generator(string folder)
|
||||||
{
|
{
|
||||||
|
@ -25,12 +32,12 @@ namespace Bind.GL2
|
||||||
|
|
||||||
#region public void Process()
|
#region public void Process()
|
||||||
|
|
||||||
public void Process()
|
public virtual void Process()
|
||||||
{
|
{
|
||||||
Bind.Structures.Type.Initialize();
|
Bind.Structures.Type.Initialize(glTypemap, csTypemap);
|
||||||
Bind.Structures.Enum.Initialize();
|
Bind.Structures.Enum.Initialize(enumSpec, enumSpecExt);
|
||||||
Bind.Structures.Function.Initialize();
|
Bind.Structures.Function.Initialize();
|
||||||
Bind.Structures.Delegate.Initialize();
|
Bind.Structures.Delegate.Initialize(glSpec, glSpecExt);
|
||||||
|
|
||||||
// Process enums and delegates - create wrappers.
|
// Process enums and delegates - create wrappers.
|
||||||
Trace.WriteLine("Processing specs, please wait...");
|
Trace.WriteLine("Processing specs, please wait...");
|
||||||
|
|
|
@ -24,9 +24,11 @@ namespace Bind.GL2
|
||||||
// Disable BeforeFieldInit
|
// Disable BeforeFieldInit
|
||||||
sw.WriteLine("static {0}()", Settings.DelegatesClass);
|
sw.WriteLine("static {0}()", Settings.DelegatesClass);
|
||||||
sw.WriteLine("{");
|
sw.WriteLine("{");
|
||||||
//sw.Indent();
|
// --- Workaround for mono gmcs 1.2.4 issue, where static initalization fails. ---
|
||||||
//sw.WriteLine("{0}.ReloadFunctions();", Settings.GLClass);
|
sw.Indent();
|
||||||
//sw.Unindent();
|
sw.WriteLine("{0}.ReloadFunctions();", Settings.GLClass);
|
||||||
|
sw.Unindent();
|
||||||
|
// --- End workaround ---
|
||||||
sw.WriteLine("}");
|
sw.WriteLine("}");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
foreach (Bind.Structures.Delegate d in delegates.Values)
|
foreach (Bind.Structures.Delegate d in delegates.Values)
|
||||||
|
@ -35,13 +37,19 @@ namespace Bind.GL2
|
||||||
sw.WriteLine("internal {0};", d.ToString());
|
sw.WriteLine("internal {0};", d.ToString());
|
||||||
if (d.Extension == "Core")
|
if (d.Extension == "Core")
|
||||||
{
|
{
|
||||||
sw.WriteLine(
|
/*sw.WriteLine(
|
||||||
"internal {0}static {1} gl{1} = ({1}){2}.{3}(\"gl{1}\", typeof({1})) ?? new {1}({4}.{1});",
|
"internal {0}static {1} gl{1} = ({1}){2}.{3}(\"gl{1}\", typeof({1})) ?? new {1}({4}.{1});",
|
||||||
d.Unsafe ? "unsafe " : "",
|
d.Unsafe ? "unsafe " : "",
|
||||||
d.Name,
|
d.Name,
|
||||||
Settings.GLClass,
|
Settings.GLClass,
|
||||||
"GetDelegateForExtensionMethod",
|
"GetDelegateForExtensionMethod",
|
||||||
Settings.ImportsClass);
|
Settings.ImportsClass);*/
|
||||||
|
// --- Workaround for mono gmcs 1.2.4 issue, where static initalization fails. ---
|
||||||
|
sw.WriteLine(
|
||||||
|
"internal {0}static {1} gl{1} = null;",
|
||||||
|
d.Unsafe ? "unsafe " : "",
|
||||||
|
d.Name);
|
||||||
|
// --- End workaround ---
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -174,7 +182,7 @@ namespace Bind.GL2
|
||||||
else if (Settings.Compatibility == Settings.Legacy.Tao)
|
else if (Settings.Compatibility == Settings.Legacy.Tao)
|
||||||
{
|
{
|
||||||
// Tao legacy mode: dump all enums as constants in GLClass.
|
// Tao legacy mode: dump all enums as constants in GLClass.
|
||||||
foreach (Bind.Structures.Constant c in enums["GLenum"].ConstantCollection.Values)
|
foreach (Bind.Structures.Constant c in enums[Settings.CompleteEnumName].ConstantCollection.Values)
|
||||||
{
|
{
|
||||||
// Print constants avoiding circular definitions
|
// Print constants avoiding circular definitions
|
||||||
if (c.Name != c.Value)
|
if (c.Name != c.Value)
|
||||||
|
|
|
@ -91,9 +91,11 @@ namespace Bind
|
||||||
Settings.OutputPath = b[1];
|
Settings.OutputPath = b[1];
|
||||||
break;
|
break;
|
||||||
case "mode":
|
case "mode":
|
||||||
|
string arg = b[1].ToLower();
|
||||||
mode =
|
mode =
|
||||||
b[1].ToLower() == "gl2" ? GeneratorMode.GL2 :
|
arg == "gl2" ? GeneratorMode.GL2 :
|
||||||
b[1].ToLower() == "gl3" ? GeneratorMode.GL3 : GeneratorMode.GL2;
|
arg == "gl3" ? GeneratorMode.GL3 :
|
||||||
|
arg == "wgl" ? GeneratorMode.Wgl : GeneratorMode.GL2;
|
||||||
break;
|
break;
|
||||||
case "namespace":
|
case "namespace":
|
||||||
case "ns":
|
case "ns":
|
||||||
|
@ -144,6 +146,10 @@ namespace Bind
|
||||||
Generator = new Bind.GL2.Generator(Settings.InputPath);
|
Generator = new Bind.GL2.Generator(Settings.InputPath);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GeneratorMode.Wgl:
|
||||||
|
Generator = new Bind.Wgl.Generator(Settings.InputPath);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException(String.Format("Mode {0} not implemented.", mode));
|
throw new NotImplementedException(String.Format("Mode {0} not implemented.", mode));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Bind
|
||||||
{
|
{
|
||||||
static class Settings
|
static class Settings
|
||||||
{
|
{
|
||||||
public static string InputPath = "..\\..\\..\\Source\\Bind\\Specifications";
|
public static string InputPath = "..\\..\\..\\Source\\Bind\\Specifications\\gl2";
|
||||||
public static string OutputPath = "..\\..\\..\\Source\\OpenTK\\OpenGL\\Bindings";
|
public static string OutputPath = "..\\..\\..\\Source\\OpenTK\\OpenGL\\Bindings";
|
||||||
public static string OutputNamespace = "OpenTK.OpenGL";
|
public static string OutputNamespace = "OpenTK.OpenGL";
|
||||||
public static string GLClass = "GL";
|
public static string GLClass = "GL";
|
||||||
|
|
|
@ -22,15 +22,25 @@ namespace Bind.Structures
|
||||||
internal static DelegateCollection Delegates;
|
internal static DelegateCollection Delegates;
|
||||||
|
|
||||||
private static bool delegatesLoaded;
|
private static bool delegatesLoaded;
|
||||||
internal static void Initialize()
|
internal static void Initialize(string glSpec, string glSpecExt)
|
||||||
{
|
{
|
||||||
if (!delegatesLoaded)
|
if (!delegatesLoaded)
|
||||||
{
|
{
|
||||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\gl.spec"))
|
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glSpec))
|
||||||
{
|
{
|
||||||
Delegates = Bind.MainClass.Generator.ReadDelegates(sr);
|
Delegates = Bind.MainClass.Generator.ReadDelegates(sr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(glSpecExt))
|
||||||
|
{
|
||||||
|
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glSpecExt))
|
||||||
|
{
|
||||||
|
foreach (Delegate d in Bind.MainClass.Generator.ReadDelegates(sr).Values)
|
||||||
|
{
|
||||||
|
Utilities.Merge(Delegates, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
delegatesLoaded = true;
|
delegatesLoaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +54,7 @@ namespace Bind.Structures
|
||||||
|
|
||||||
public Delegate(Delegate d)
|
public Delegate(Delegate d)
|
||||||
{
|
{
|
||||||
this.Category = new string(d.Category.ToCharArray());
|
this.Category = !String.IsNullOrEmpty(d.Category) ? new string(d.Category.ToCharArray()) : "";
|
||||||
//this.Extension = !String.IsNullOrEmpty(d.Extension) ? new string(d.Extension.ToCharArray()) : "";
|
//this.Extension = !String.IsNullOrEmpty(d.Extension) ? new string(d.Extension.ToCharArray()) : "";
|
||||||
this.Name = new string(d.Name.ToCharArray());
|
this.Name = new string(d.Name.ToCharArray());
|
||||||
//this.NeedsWrapper = d.NeedsWrapper;
|
//this.NeedsWrapper = d.NeedsWrapper;
|
||||||
|
|
|
@ -18,16 +18,16 @@ namespace Bind.Structures
|
||||||
|
|
||||||
private static bool enumsLoaded;
|
private static bool enumsLoaded;
|
||||||
|
|
||||||
internal static void Initialize()
|
internal static void Initialize(string enumFile, string enumextFile)
|
||||||
{
|
{
|
||||||
if (!enumsLoaded)
|
if (!enumsLoaded)
|
||||||
{
|
{
|
||||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\enum.spec"))
|
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, enumFile))
|
||||||
{
|
{
|
||||||
GLEnums = Bind.MainClass.Generator.ReadEnums(sr);
|
GLEnums = Bind.MainClass.Generator.ReadEnums(sr);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\enumext.spec"))
|
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, enumextFile))
|
||||||
{
|
{
|
||||||
foreach (Bind.Structures.Enum e in Bind.MainClass.Generator.ReadEnums(sr).Values)
|
foreach (Bind.Structures.Enum e in Bind.MainClass.Generator.ReadEnums(sr).Values)
|
||||||
{
|
{
|
||||||
|
|
|
@ -151,13 +151,19 @@ namespace Bind.Structures
|
||||||
// Remove overload
|
// Remove overload
|
||||||
if (endings.Contains(trimmedName.Substring(trimmedName.Length - 3)))
|
if (endings.Contains(trimmedName.Substring(trimmedName.Length - 3)))
|
||||||
{
|
{
|
||||||
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 3);
|
if (!trimmedName.EndsWith("v"))
|
||||||
|
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 3);
|
||||||
|
else
|
||||||
|
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 3) + "v";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endings.Contains(trimmedName.Substring(trimmedName.Length - 2)))
|
if (endings.Contains(trimmedName.Substring(trimmedName.Length - 2)))
|
||||||
{
|
{
|
||||||
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 2);
|
if (!trimmedName.EndsWith("v"))
|
||||||
|
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 2);
|
||||||
|
else
|
||||||
|
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 2) + "v";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,8 +173,10 @@ namespace Bind.Structures
|
||||||
// do not want to change, or an actual overload (glColor3s). We assume
|
// do not want to change, or an actual overload (glColor3s). We assume
|
||||||
// (perhaps incorrectly), that an 's' preceeded be a digit indicates an
|
// (perhaps incorrectly), that an 's' preceeded be a digit indicates an
|
||||||
// overload. If there is no digit, we assume a plural form (no change).
|
// overload. If there is no digit, we assume a plural form (no change).
|
||||||
if (Char.IsDigit(trimmedName[trimmedName.Length - 2]))
|
if (!trimmedName.EndsWith("v"))
|
||||||
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 1);
|
if (Char.IsDigit(trimmedName[trimmedName.Length - 2]))
|
||||||
|
TrimmedName = trimmedName.Substring(0, trimmedName.Length - 1);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,20 +12,20 @@ namespace Bind.Structures
|
||||||
|
|
||||||
private static bool typesLoaded;
|
private static bool typesLoaded;
|
||||||
|
|
||||||
internal static void Initialize()
|
internal static void Initialize(string glTypes, string csTypes)
|
||||||
{
|
{
|
||||||
if (!typesLoaded)
|
if (!typesLoaded)
|
||||||
{
|
{
|
||||||
if (GLTypes == null)
|
if (GLTypes == null)
|
||||||
{
|
{
|
||||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\gl.tm"))
|
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glTypes))
|
||||||
{
|
{
|
||||||
GLTypes = Bind.MainClass.Generator.ReadTypeMap(sr);
|
GLTypes = Bind.MainClass.Generator.ReadTypeMap(sr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CSTypes == null)
|
if (CSTypes == null)
|
||||||
{
|
{
|
||||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, "gl2\\csharp.tm"))
|
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, csTypes))
|
||||||
{
|
{
|
||||||
CSTypes = Bind.MainClass.Generator.ReadCSTypeMap(sr);
|
CSTypes = Bind.MainClass.Generator.ReadCSTypeMap(sr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,24 @@ namespace Bind
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region internal static void Merge(EnumCollection enums, Bind.Structures.Enum t)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Merges the given enum into the enum list. If an enum of the same name exists,
|
||||||
|
/// it merges their respective constants.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="enums"></param>
|
||||||
|
/// <param name="t"></param>
|
||||||
|
internal static void Merge(DelegateCollection delegates, Bind.Structures.Delegate t)
|
||||||
|
{
|
||||||
|
if (!delegates.ContainsKey(t.Name))
|
||||||
|
{
|
||||||
|
delegates.Add(t.Name, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region internal static string GetGL2Extension(string name)
|
#region internal static string GetGL2Extension(string name)
|
||||||
|
|
||||||
internal static string GetGL2Extension(string name)
|
internal static string GetGL2Extension(string name)
|
||||||
|
|
|
@ -82,7 +82,7 @@ namespace Examples.Tests
|
||||||
while (!stop)
|
while (!stop)
|
||||||
{
|
{
|
||||||
GL.Vertex2(0.0f, 0.0f);
|
GL.Vertex2(0.0f, 0.0f);
|
||||||
GL.Vertex2(v);
|
GL.Vertex2v(v);
|
||||||
//GL.ARB.ActiveTexture(GL.Enums.ARB_multitexture.TEXTURE0_ARB);
|
//GL.ARB.ActiveTexture(GL.Enums.ARB_multitexture.TEXTURE0_ARB);
|
||||||
//dummy();
|
//dummy();
|
||||||
GL.ColorPointer(2, GL.Enums.ColorPointerType.FLOAT, 0, v);
|
GL.ColorPointer(2, GL.Enums.ColorPointerType.FLOAT, 0, v);
|
||||||
|
|
|
@ -184,7 +184,7 @@ namespace Examples.Tutorial
|
||||||
(IntPtr)(vdata.Length * 4),
|
(IntPtr)(vdata.Length * 4),
|
||||||
vdata,
|
vdata,
|
||||||
GL.Enums.VERSION_1_5.STATIC_DRAW);
|
GL.Enums.VERSION_1_5.STATIC_DRAW);
|
||||||
GL.GetBufferParameter(
|
GL.GetBufferParameterv(
|
||||||
GL.Enums.VERSION_1_5.ARRAY_BUFFER,
|
GL.Enums.VERSION_1_5.ARRAY_BUFFER,
|
||||||
GL.Enums.VERSION_1_5.BUFFER_SIZE,
|
GL.Enums.VERSION_1_5.BUFFER_SIZE,
|
||||||
out size);
|
out size);
|
||||||
|
@ -201,7 +201,7 @@ namespace Examples.Tutorial
|
||||||
idata,
|
idata,
|
||||||
GL.Enums.VERSION_1_5.STATIC_DRAW
|
GL.Enums.VERSION_1_5.STATIC_DRAW
|
||||||
);
|
);
|
||||||
GL.GetBufferParameter(
|
GL.GetBufferParameterv(
|
||||||
GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER,
|
GL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER,
|
||||||
GL.Enums.VERSION_1_5.BUFFER_SIZE,
|
GL.Enums.VERSION_1_5.BUFFER_SIZE,
|
||||||
out size);
|
out size);
|
||||||
|
|
|
@ -70,22 +70,26 @@ namespace Examples.Tutorial
|
||||||
|
|
||||||
GL.ShaderSource(vertex_shader_object, vertex_shader_source.Length, vertex_shader_source, (int[])null);
|
GL.ShaderSource(vertex_shader_object, vertex_shader_source.Length, vertex_shader_source, (int[])null);
|
||||||
GL.CompileShader(vertex_shader_object);
|
GL.CompileShader(vertex_shader_object);
|
||||||
GL.GetShader(vertex_shader_object, GL.Enums.VERSION_2_0.COMPILE_STATUS, out status);
|
GL.GetShaderv(vertex_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status);
|
||||||
if (status != (int)GL.Enums.Boolean.TRUE)
|
if (status != (int)Enums.Boolean.TRUE)
|
||||||
{
|
{
|
||||||
StringBuilder info = new StringBuilder(1024);
|
int length = 0;
|
||||||
GL.GetShaderInfoLog(vertex_shader_object, info.MaxCapacity, (int[])null, info);
|
GL.GetShaderv(vertex_shader_object, Enums.VERSION_2_0.INFO_LOG_LENGTH, out length);
|
||||||
|
StringBuilder info = new StringBuilder(length);
|
||||||
|
GL.GetShaderInfoLog(vertex_shader_object, info.Capacity, out length, info);
|
||||||
|
|
||||||
throw new Exception(info.ToString());
|
throw new Exception(info.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
GL.ShaderSource(fragment_shader_object, fragment_shader_source.Length, fragment_shader_source, (int[])null);
|
GL.ShaderSource(fragment_shader_object, fragment_shader_source.Length, fragment_shader_source, (int[])null);
|
||||||
GL.CompileShader(fragment_shader_object);
|
GL.CompileShader(fragment_shader_object);
|
||||||
GL.GetShader(fragment_shader_object, GL.Enums.VERSION_2_0.COMPILE_STATUS, out status);
|
GL.GetShaderv(fragment_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status);
|
||||||
if (status != (int)GL.Enums.Boolean.TRUE)
|
if (status != (int)Enums.Boolean.TRUE)
|
||||||
{
|
{
|
||||||
StringBuilder info = new StringBuilder(1024);
|
int length;
|
||||||
GL.GetShaderInfoLog(fragment_shader_object, 1024, (int[])null, info);
|
GL.GetShaderv(vertex_shader_object, Enums.VERSION_2_0.INFO_LOG_LENGTH, out length);
|
||||||
|
StringBuilder info = new StringBuilder(length);
|
||||||
|
GL.GetShaderInfoLog(fragment_shader_object, info.Capacity, out length, info);
|
||||||
|
|
||||||
throw new Exception(info.ToString());
|
throw new Exception(info.ToString());
|
||||||
}
|
}
|
||||||
|
|
11
Source/OpenTK/Input/IMouseDriver.cs
Normal file
11
Source/OpenTK/Input/IMouseDriver.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenTK.Input
|
||||||
|
{
|
||||||
|
public interface IMouseDriver
|
||||||
|
{
|
||||||
|
IList<Keyboard> Mouse { get; }
|
||||||
|
}
|
||||||
|
}
|
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