Fixed build.

This commit is contained in:
the_fiddler 2007-09-22 15:07:28 +00:00
parent b2ac1d4c61
commit 7bf2e84373
5 changed files with 72 additions and 12 deletions

View file

@ -24,7 +24,6 @@ namespace Examples.Tests
{
InputDriver driver;
Dictionary<IntPtr, ListBox> keyboardListBoxes = new Dictionary<IntPtr, ListBox>(4);
bool stop_polling;
public S04_Input_Logger()
{

View file

@ -22,10 +22,27 @@ namespace Examples.Tutorial
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>
/// Override the OnRenderFrame method to add your drawing code.
/// 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>
/// <param name="e">Not used.</param>
public override void OnRenderFrame(EventArgs e)

View file

@ -360,31 +360,46 @@ namespace OpenTK.OpenGL
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)
{
return OpenTK.Platform.Windows.Wgl.Imports.GetProcAddress(function);
return wglGetProcAddress(function);
}
}
internal class GetProcAddressX11 : IGetProcAddress
{
[DllImport(Library, EntryPoint = "glXGetProcAddress")]
private static extern IntPtr glxGetProcAddress([MarshalAs(UnmanagedType.LPTStr)] string procName);
public IntPtr GetProcAddress(string function)
{
return X11.Glx.GetProcAddress(function);
return glxGetProcAddress(function);
}
}
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)
{
string fname = "_" + function;
if (!OSX.Functions.NSIsSymbolNameDefined(fname))
if (!NSIsSymbolNameDefined(fname))
return IntPtr.Zero;
IntPtr symbol = OSX.Functions.NSLookupAndBindSymbol(fname);
IntPtr symbol = NSLookupAndBindSymbol(fname);
if (symbol != IntPtr.Zero)
symbol = OSX.Functions.NSAddressOfSymbol(symbol);
symbol = NSAddressOfSymbol(symbol);
return symbol;
}
@ -439,7 +454,7 @@ namespace OpenTK.OpenGL
#endregion
#region private static Delegate GetExtensionDelegate(string name, Type signature)
#region internal static Delegate GetExtensionDelegate(string name, Type signature)
/// <summary>
/// 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
/// if the function is not available in the current OpenGL context.
/// </returns>
private static Delegate GetExtensionDelegate(string name, Type signature)
internal static Delegate GetExtensionDelegate(string name, Type signature)
{
IntPtr address = GetAddress(name);

View file

@ -47,7 +47,7 @@ namespace OpenTK.OpenGL
{
MethodInfo m = importsClass.GetMethod(name.Substring(3), BindingFlags.Static | BindingFlags.NonPublic);
return
Utilities.GetExtensionDelegate(name, signature) ??
GL.GetExtensionDelegate(name, signature) ??
(m != null ? Delegate.CreateDelegate(signature, m) : null);
}

View file

@ -62,12 +62,12 @@ namespace OpenTK.Platform.Windows
if (importsClass.GetMethod(realName,
BindingFlags.NonPublic | BindingFlags.Static) != null)
{
d = Utilities.GetExtensionDelegate(name, signature) ??
d = GetExtensionDelegate(name, signature) ??
Delegate.CreateDelegate(signature, typeof(Imports), realName);
}
else
{
d = Utilities.GetExtensionDelegate(name, signature);
d = GetExtensionDelegate(name, signature);
}
return d;
@ -75,6 +75,35 @@ namespace OpenTK.Platform.Windows
#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>
/// Loads all Wgl entry points, core and extensions.
/// </summary>