mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 05:15:42 +00:00
Fixed build.
This commit is contained in:
parent
b2ac1d4c61
commit
7bf2e84373
|
@ -24,7 +24,6 @@ namespace Examples.Tests
|
||||||
{
|
{
|
||||||
InputDriver driver;
|
InputDriver driver;
|
||||||
Dictionary<IntPtr, ListBox> keyboardListBoxes = new Dictionary<IntPtr, ListBox>(4);
|
Dictionary<IntPtr, ListBox> keyboardListBoxes = new Dictionary<IntPtr, ListBox>(4);
|
||||||
bool stop_polling;
|
|
||||||
|
|
||||||
public S04_Input_Logger()
|
public S04_Input_Logger()
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,10 +22,27 @@ namespace Examples.Tutorial
|
||||||
this.CreateWindow(new DisplayMode(800, 600));
|
this.CreateWindow(new DisplayMode(800, 600));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Override the OnResize method to respond to window resize events.
|
||||||
|
/// Do not forget to call base.OnResize() so that event listeners
|
||||||
|
/// will be notified of window resize events!
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||||
|
{
|
||||||
|
GL.Viewport(0, 0, e.Width, e.Height);
|
||||||
|
|
||||||
|
GL.MatrixMode(GL.Enums.MatrixMode.PROJECTION);
|
||||||
|
GL.LoadIdentity();
|
||||||
|
GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
|
||||||
|
|
||||||
|
base.OnResize(e);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Override the OnRenderFrame method to add your drawing code.
|
/// Override the OnRenderFrame method to add your drawing code.
|
||||||
/// Do not forget to call base.OnRenderFrame() so that event listeners
|
/// Do not forget to call base.OnRenderFrame() so that event listeners
|
||||||
/// will be notified every time a frame is drawn!
|
/// will be notified of frame rendering events!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="e">Not used.</param>
|
/// <param name="e">Not used.</param>
|
||||||
public override void OnRenderFrame(EventArgs e)
|
public override void OnRenderFrame(EventArgs e)
|
||||||
|
|
|
@ -360,31 +360,46 @@ namespace OpenTK.OpenGL
|
||||||
|
|
||||||
internal class GetProcAddressWindows : IGetProcAddress
|
internal class GetProcAddressWindows : IGetProcAddress
|
||||||
{
|
{
|
||||||
|
[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglGetProcAddress", ExactSpelling = true)]
|
||||||
|
private static extern IntPtr wglGetProcAddress(String lpszProc);
|
||||||
|
|
||||||
public IntPtr GetProcAddress(string function)
|
public IntPtr GetProcAddress(string function)
|
||||||
{
|
{
|
||||||
return OpenTK.Platform.Windows.Wgl.Imports.GetProcAddress(function);
|
return wglGetProcAddress(function);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class GetProcAddressX11 : IGetProcAddress
|
internal class GetProcAddressX11 : IGetProcAddress
|
||||||
{
|
{
|
||||||
|
[DllImport(Library, EntryPoint = "glXGetProcAddress")]
|
||||||
|
private static extern IntPtr glxGetProcAddress([MarshalAs(UnmanagedType.LPTStr)] string procName);
|
||||||
|
|
||||||
public IntPtr GetProcAddress(string function)
|
public IntPtr GetProcAddress(string function)
|
||||||
{
|
{
|
||||||
return X11.Glx.GetProcAddress(function);
|
return glxGetProcAddress(function);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class GetProcAddressOSX : IGetProcAddress
|
internal class GetProcAddressOSX : IGetProcAddress
|
||||||
{
|
{
|
||||||
|
private const string Library = "libdl.dylib";
|
||||||
|
|
||||||
|
[DllImport(Library, EntryPoint = "NSIsSymbolNameDefined")]
|
||||||
|
private static extern bool NSIsSymbolNameDefined(string s);
|
||||||
|
[DllImport(Library, EntryPoint = "NSLookupAndBindSymbol")]
|
||||||
|
private static extern IntPtr NSLookupAndBindSymbol(string s);
|
||||||
|
[DllImport(Library, EntryPoint = "NSAddressOfSymbol")]
|
||||||
|
private static extern IntPtr NSAddressOfSymbol(IntPtr symbol);
|
||||||
|
|
||||||
public IntPtr GetProcAddress(string function)
|
public IntPtr GetProcAddress(string function)
|
||||||
{
|
{
|
||||||
string fname = "_" + function;
|
string fname = "_" + function;
|
||||||
if (!OSX.Functions.NSIsSymbolNameDefined(fname))
|
if (!NSIsSymbolNameDefined(fname))
|
||||||
return IntPtr.Zero;
|
return IntPtr.Zero;
|
||||||
|
|
||||||
IntPtr symbol = OSX.Functions.NSLookupAndBindSymbol(fname);
|
IntPtr symbol = NSLookupAndBindSymbol(fname);
|
||||||
if (symbol != IntPtr.Zero)
|
if (symbol != IntPtr.Zero)
|
||||||
symbol = OSX.Functions.NSAddressOfSymbol(symbol);
|
symbol = NSAddressOfSymbol(symbol);
|
||||||
|
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
@ -439,7 +454,7 @@ namespace OpenTK.OpenGL
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region private static Delegate GetExtensionDelegate(string name, Type signature)
|
#region internal static Delegate GetExtensionDelegate(string name, Type signature)
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a System.Delegate that can be used to call a dynamically exported OpenGL function.
|
/// Creates a System.Delegate that can be used to call a dynamically exported OpenGL function.
|
||||||
|
@ -450,7 +465,7 @@ namespace OpenTK.OpenGL
|
||||||
/// A System.Delegate that can be used to call this OpenGL function or null
|
/// A System.Delegate that can be used to call this OpenGL function or null
|
||||||
/// if the function is not available in the current OpenGL context.
|
/// if the function is not available in the current OpenGL context.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
private static Delegate GetExtensionDelegate(string name, Type signature)
|
internal static Delegate GetExtensionDelegate(string name, Type signature)
|
||||||
{
|
{
|
||||||
IntPtr address = GetAddress(name);
|
IntPtr address = GetAddress(name);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace OpenTK.OpenGL
|
||||||
{
|
{
|
||||||
MethodInfo m = importsClass.GetMethod(name.Substring(3), BindingFlags.Static | BindingFlags.NonPublic);
|
MethodInfo m = importsClass.GetMethod(name.Substring(3), BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
return
|
return
|
||||||
Utilities.GetExtensionDelegate(name, signature) ??
|
GL.GetExtensionDelegate(name, signature) ??
|
||||||
(m != null ? Delegate.CreateDelegate(signature, m) : null);
|
(m != null ? Delegate.CreateDelegate(signature, m) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,12 +62,12 @@ namespace OpenTK.Platform.Windows
|
||||||
if (importsClass.GetMethod(realName,
|
if (importsClass.GetMethod(realName,
|
||||||
BindingFlags.NonPublic | BindingFlags.Static) != null)
|
BindingFlags.NonPublic | BindingFlags.Static) != null)
|
||||||
{
|
{
|
||||||
d = Utilities.GetExtensionDelegate(name, signature) ??
|
d = GetExtensionDelegate(name, signature) ??
|
||||||
Delegate.CreateDelegate(signature, typeof(Imports), realName);
|
Delegate.CreateDelegate(signature, typeof(Imports), realName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
d = Utilities.GetExtensionDelegate(name, signature);
|
d = GetExtensionDelegate(name, signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
|
@ -75,6 +75,35 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region private static Delegate GetExtensionDelegate(string name, Type signature)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a System.Delegate that can be used to call a dynamically exported OpenGL function.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name of the OpenGL function (eg. "glNewList")</param>
|
||||||
|
/// <param name="signature">The signature of the OpenGL function.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A System.Delegate that can be used to call this OpenGL function or null
|
||||||
|
/// if the function is not available in the current OpenGL context.
|
||||||
|
/// </returns>
|
||||||
|
private static Delegate GetExtensionDelegate(string name, Type signature)
|
||||||
|
{
|
||||||
|
IntPtr address = Imports.GetProcAddress(name);
|
||||||
|
|
||||||
|
if (address == IntPtr.Zero ||
|
||||||
|
address == new IntPtr(1) || // Workaround for buggy nvidia drivers which return
|
||||||
|
address == new IntPtr(2)) // 1 or 2 instead of IntPtr.Zero for some extensions.
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Marshal.GetDelegateForFunctionPointer(address, signature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads all Wgl entry points, core and extensions.
|
/// Loads all Wgl entry points, core and extensions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue