From 1f9c9eac4467b48e9a06d83110fa52d7f5678c77 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Tue, 10 Nov 2009 22:51:35 +0000 Subject: [PATCH 01/27] Added missing license information. --- Source/OpenTK/NativeWindow.cs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Source/OpenTK/NativeWindow.cs b/Source/OpenTK/NativeWindow.cs index 3adf192d..c25e4166 100644 --- a/Source/OpenTK/NativeWindow.cs +++ b/Source/OpenTK/NativeWindow.cs @@ -1,4 +1,31 @@ -using System; +#region License +// +// The Open Toolkit Library License +// +// Copyright (c) 2006 - 2009 the Open Toolkit library. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +#endregion + +using System; using System.ComponentModel; using System.Drawing; using OpenTK.Graphics; From 5991bee09f15d3dd4b7de397fe044b1900c8ccf1 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Wed, 11 Nov 2009 18:21:45 +0000 Subject: [PATCH 02/27] * Source/OpenTK/BlittableValueType.cs: Removed struct constraint. Sometimes consumers of this class may not be able to use struct generic constraints - the class is now usable in this case. * Source/Examples/OpenTK/Test/BlittableValueTypes.cs: Test BlittableValueType class using several different types. --- .../OpenTK/Test/BlittableValueTypes.cs | 93 +++++++++++++++++++ Source/OpenTK/BlittableValueType.cs | 32 ++++--- 2 files changed, 112 insertions(+), 13 deletions(-) create mode 100644 Source/Examples/OpenTK/Test/BlittableValueTypes.cs diff --git a/Source/Examples/OpenTK/Test/BlittableValueTypes.cs b/Source/Examples/OpenTK/Test/BlittableValueTypes.cs new file mode 100644 index 00000000..706ead06 --- /dev/null +++ b/Source/Examples/OpenTK/Test/BlittableValueTypes.cs @@ -0,0 +1,93 @@ +#region License +// +// The Open Toolkit Library License +// +// Copyright (c) 2006 - 2008 the Open Toolkit library, except where noted. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +#endregion + +using System; +using System.Diagnostics; +using System.Reflection; +using OpenTK; + +namespace Examples.Tests +{ + struct Simple { public int Value; } + struct Generic { public T Value; } + enum Enum { First, Second } + struct Complex { public Simple Value; } + struct Complex { public Generic Value; } + struct Complex2 { public Enum Value; } + struct Complex3 { public Class Value; } + struct Complex4 : Interface { public Class Value; } + class Class { public int Value; } + class Class { public T Value; } + interface Interface { } + + [Example("Blittable Value Types", ExampleCategory.OpenTK, "Test", Documentation="BlittableValueTypes")] + public class BlittableValueTypes + { + public static void Main() + { + PrintType(new Simple()); + PrintType(new Generic()); + PrintType(new Generic()); + PrintType(new Complex()); + PrintType(new Complex()); + PrintType(new Complex2()); + PrintType(new Complex3()); + PrintType(new Complex4()); + PrintType(new Class()); + PrintType(new Class()); + } + + static bool CheckBlittable(T type) + { + return BlittableValueType.Check(type); + } + + static int GetStride(T type) + { + return BlittableValueType.StrideOf(type); + } + + static void PrintType(T instance) + { + Type type = typeof(T); + string typename = type.GetFields()[0].FieldType.ToString(); + + Trace.Write(type.IsClass ? "class " : type.IsEnum ? "enum " : type.IsInterface ? "interface " : "struct "); + Trace.Write(type.Name); + if (type.IsGenericType) + Trace.Write(String.Format("<{0}>", type.GetGenericArguments()[0].Name)); + Trace.Write(" { "); + + Trace.Write(typename.Substring(typename.LastIndexOf('.') + 1)); + Trace.Write(" } "); + Trace.Write(CheckBlittable(instance) ? "is blittable " : "is not blittable "); + try { Trace.Write(String.Format("({0} bytes)", GetStride(instance))); } + catch (Exception e) { Trace.Write(String.Format("({0})", e.GetType().Name)); } + Trace.WriteLine(""); + } + } +} diff --git a/Source/OpenTK/BlittableValueType.cs b/Source/OpenTK/BlittableValueType.cs index 06c202d8..8b89a889 100644 --- a/Source/OpenTK/BlittableValueType.cs +++ b/Source/OpenTK/BlittableValueType.cs @@ -1,4 +1,4 @@ -#region License +#region License // // The Open Toolkit Library License // @@ -43,11 +43,12 @@ namespace OpenTK /// A blittable value type is a struct that only references other value types recursively, /// which allows it to be passed to unmanaged code directly. /// - public static class BlittableValueType where T : struct + public static class BlittableValueType { #region Fields static readonly Type Type; + static readonly int stride; #endregion @@ -56,6 +57,12 @@ namespace OpenTK static BlittableValueType() { Type = typeof(T); + if (Type.IsValueType) + { + // Does this support generic types? On Mono 2.4.3 it does + // http://msdn.microsoft.com/en-us/library/5s4920fa.aspx + stride = Marshal.SizeOf(typeof(T)); + } } #endregion @@ -65,7 +72,7 @@ namespace OpenTK /// /// Gets the size of the type in bytes. /// - public static readonly int Stride = Marshal.SizeOf(typeof(T)); + public static int Stride { get { return stride; } } #region Check @@ -103,6 +110,9 @@ namespace OpenTK if (type.IsPrimitive) return true; + if (!type.IsValueType) + return false; + FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Debug.Indent(); foreach (FieldInfo field in fields) @@ -151,7 +161,7 @@ namespace OpenTK /// Checks whether type is a blittable value type. /// /// An instance of the type to check. - public static bool Check(T type) where T : struct + public static bool Check(T type) { return BlittableValueType.Check(); } @@ -160,7 +170,7 @@ namespace OpenTK /// Checks whether type is a blittable value type. /// /// An instance of the type to check. - public static bool Check(T[] type) where T : struct + public static bool Check(T[] type) { return BlittableValueType.Check(); } @@ -169,7 +179,7 @@ namespace OpenTK /// Checks whether type is a blittable value type. /// /// An instance of the type to check. - public static bool Check(T[,] type) where T : struct + public static bool Check(T[,] type) { return BlittableValueType.Check(); } @@ -178,7 +188,7 @@ namespace OpenTK /// Checks whether type is a blittable value type. /// /// An instance of the type to check. - public static bool Check(T[, ,] type) where T : struct + public static bool Check(T[, ,] type) { return BlittableValueType.Check(); } @@ -188,14 +198,14 @@ namespace OpenTK /// /// An instance of the type to check. [CLSCompliant(false)] - public static bool Check(T[][] type) where T : struct + public static bool Check(T[][] type) { return BlittableValueType.Check(); } #endregion - #region From + #region StrideOf /// /// Returns the size of the specified value type in bytes. @@ -205,7 +215,6 @@ namespace OpenTK /// An integer, specifying the size of the type in bytes. /// Occurs when type is not blittable. public static int StrideOf(T type) - where T : struct { if (!Check(type)) throw new ArgumentException("type"); @@ -221,7 +230,6 @@ namespace OpenTK /// An integer, specifying the size of the type in bytes. /// Occurs when type is not blittable. public static int StrideOf(T[] type) - where T : struct { if (!Check(type)) throw new ArgumentException("type"); @@ -237,7 +245,6 @@ namespace OpenTK /// An integer, specifying the size of the type in bytes. /// Occurs when type is not blittable. public static int StrideOf(T[,] type) - where T : struct { if (!Check(type)) throw new ArgumentException("type"); @@ -253,7 +260,6 @@ namespace OpenTK /// An integer, specifying the size of the type in bytes. /// Occurs when type is not blittable. public static int StrideOf(T[, ,] type) - where T : struct { if (!Check(type)) throw new ArgumentException("type"); From 598c447b2cacf278af83587b308e91836349885e Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Wed, 11 Nov 2009 18:23:52 +0000 Subject: [PATCH 03/27] * BlittableValueType.cs: Clarify how BlittableValueType.Stride works on non-blittable types. --- Source/OpenTK/BlittableValueType.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/OpenTK/BlittableValueType.cs b/Source/OpenTK/BlittableValueType.cs index 8b89a889..f0a160ce 100644 --- a/Source/OpenTK/BlittableValueType.cs +++ b/Source/OpenTK/BlittableValueType.cs @@ -72,6 +72,9 @@ namespace OpenTK /// /// Gets the size of the type in bytes. /// + /// + /// This property returns 0 for non-blittable types. + /// public static int Stride { get { return stride; } } #region Check From 01bb1971e4c5d7599b83e0abaa848952a46965fd Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Wed, 11 Nov 2009 22:37:04 +0000 Subject: [PATCH 04/27] * Vector4.cs: * Vector3.cs: * Vector2.cs: * Vector4d.cs: * Vector3d.cs: * Vector2d.cs: Removed code using C# 3.0 features. --- Source/OpenTK/Math/Vector2.cs | 4 ++-- Source/OpenTK/Math/Vector2d.cs | 2 +- Source/OpenTK/Math/Vector3.cs | 4 ++-- Source/OpenTK/Math/Vector3d.cs | 2 +- Source/OpenTK/Math/Vector4.cs | 4 ++-- Source/OpenTK/Math/Vector4d.cs | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/OpenTK/Math/Vector2.cs b/Source/OpenTK/Math/Vector2.cs index da08ae5a..9dad9391 100644 --- a/Source/OpenTK/Math/Vector2.cs +++ b/Source/OpenTK/Math/Vector2.cs @@ -1,4 +1,4 @@ -#region --- License --- +#region --- License --- /* Copyright (c) 2006 - 2008 The Open Toolkit library. @@ -908,7 +908,7 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector2 vec, ref Quaternion quat, out Vector2 result) { - Quaternion v = new Quaternion() { X = vec.X, Y = vec.Y, Z = 0, W = 0 }; + Quaternion v = new Quaternion(vec.X, vec.Y, 0, 0); Quaternion i; Quaternion t; Quaternion.Invert(ref quat, out i); diff --git a/Source/OpenTK/Math/Vector2d.cs b/Source/OpenTK/Math/Vector2d.cs index 98c6dfd4..4c4c68f9 100644 --- a/Source/OpenTK/Math/Vector2d.cs +++ b/Source/OpenTK/Math/Vector2d.cs @@ -796,7 +796,7 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector2d vec, ref Quaterniond quat, out Vector2d result) { - Quaterniond v = new Quaterniond() { X = vec.X, Y = vec.Y, Z = 0, W = 0 }; + Quaterniond v = new Quaterniond(vec.X, vec.Y, 0, 0); Quaterniond i; Quaterniond t; Quaterniond.Invert(ref quat, out i); diff --git a/Source/OpenTK/Math/Vector3.cs b/Source/OpenTK/Math/Vector3.cs index a34584de..35e52064 100644 --- a/Source/OpenTK/Math/Vector3.cs +++ b/Source/OpenTK/Math/Vector3.cs @@ -1,4 +1,4 @@ -#region --- License --- +#region --- License --- /* Copyright (c) 2006 - 2008 The Open Toolkit library. @@ -1115,7 +1115,7 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector3 vec, ref Quaternion quat, out Vector3 result) { - Quaternion v = new Quaternion() { X = vec.X, Y = vec.Y, Z = vec.Z, W = 0 }; + Quaternion v = new Quaternion(vec.X, vec.Y, vec.Z, 0); Quaternion i; Quaternion t; Quaternion.Invert(ref quat, out i); diff --git a/Source/OpenTK/Math/Vector3d.cs b/Source/OpenTK/Math/Vector3d.cs index d924395b..9ad39e2f 100644 --- a/Source/OpenTK/Math/Vector3d.cs +++ b/Source/OpenTK/Math/Vector3d.cs @@ -1111,7 +1111,7 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector3d vec, ref Quaterniond quat, out Vector3d result) { - Quaterniond v = new Quaterniond() { X = vec.X, Y = vec.Y, Z = vec.Z, W = 0 }; + Quaterniond v = new Quaterniond(vec.X, vec.Y, vec.Z, 0); Quaterniond i; Quaterniond t; Quaterniond.Invert(ref quat, out i); diff --git a/Source/OpenTK/Math/Vector4.cs b/Source/OpenTK/Math/Vector4.cs index ccbd7d16..0994241b 100644 --- a/Source/OpenTK/Math/Vector4.cs +++ b/Source/OpenTK/Math/Vector4.cs @@ -1,4 +1,4 @@ -#region --- License --- +#region --- License --- /* Copyright (c) 2006 - 2008 The Open Toolkit library. @@ -963,7 +963,7 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector4 vec, ref Quaternion quat, out Vector4 result) { - Quaternion v = new Quaternion() { X = vec.X, Y = vec.Y, Z = vec.Z, W = vec.W }; + Quaternion v = new Quaternion(vec.X, vec.Y, vec.Z, vec.W); Quaternion i; Quaternion t; Quaternion.Invert(ref quat, out i); diff --git a/Source/OpenTK/Math/Vector4d.cs b/Source/OpenTK/Math/Vector4d.cs index 5e58f281..9cfe2c98 100644 --- a/Source/OpenTK/Math/Vector4d.cs +++ b/Source/OpenTK/Math/Vector4d.cs @@ -966,7 +966,7 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector4d vec, ref Quaterniond quat, out Vector4d result) { - Quaterniond v = new Quaterniond() { X = vec.X, Y = vec.Y, Z = vec.Z, W = vec.W }; + Quaterniond v = new Quaterniond(vec.X, vec.Y, vec.Z, vec.W); Quaterniond i; Quaterniond t; Quaterniond.Invert(ref quat, out i); From fe01e67d396c65b8c576187386a0103c21452da4 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Thu, 12 Nov 2009 15:41:41 +0000 Subject: [PATCH 05/27] Do not hook ProcessExit event if an X server is not available. Should fix issue [#1364]: 1.0 beta-1 throws TypeInitializationException in OpenTK.Platform.X11.API when running on windows. Cleaned up stale comments and code. --- Source/OpenTK/Platform/X11/API.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Source/OpenTK/Platform/X11/API.cs b/Source/OpenTK/Platform/X11/API.cs index 068934df..8a46e1af 100644 --- a/Source/OpenTK/Platform/X11/API.cs +++ b/Source/OpenTK/Platform/X11/API.cs @@ -74,24 +74,15 @@ namespace OpenTK.Platform.X11 { Debug.Print("Initializing threaded X11: {0}.", Functions.XInitThreads().ToString()); - AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); - - // Bad idea - Windows.Forms will steal our events! - //Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms"); - //defaultDisplay = (IntPtr)xplatui.GetField("DisplayHandle", System.Reflection.BindingFlags.Static | - // System.Reflection.BindingFlags.NonPublic).GetValue(null); - defaultDisplay = Functions.XOpenDisplay(IntPtr.Zero); if (defaultDisplay == IntPtr.Zero) throw new PlatformException("Could not establish connection to the X-Server."); - //defaultScreen = Functions.XDefaultScreen(DefaultDisplay); - //rootWindow = Functions.XRootWindow(DefaultDisplay, DefaultScreen); screenCount = Functions.XScreenCount(DefaultDisplay); - //Debug.Print("Default Display: {0}, Default Screen: {1}, Default Root Window: {2}, Screen Count: {3}", - // DefaultDisplay, DefaultScreen, RootWindow, ScreenCount); Debug.Print("Display connection: {0}, Screen count: {1}", DefaultDisplay, ScreenCount); + + AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); } static void CurrentDomain_ProcessExit(object sender, EventArgs e) From 6979e24254def43c72c633296e997ec3675d2d12 Mon Sep 17 00:00:00 2001 From: kanato Date: Sat, 14 Nov 2009 00:30:57 +0000 Subject: [PATCH 06/27] MacOS: Fix bug where application started from the command line would not be in the foreground and not respond to keyboard events. --- Source/OpenTK/Platform/MacOS/Application.cs | 13 +++++++++ .../MacOS/CarbonBindings/CarbonAPI.cs | 28 +++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Source/OpenTK/Platform/MacOS/Application.cs b/Source/OpenTK/Platform/MacOS/Application.cs index ba2ccdc4..5c649787 100644 --- a/Source/OpenTK/Platform/MacOS/Application.cs +++ b/Source/OpenTK/Platform/MacOS/Application.cs @@ -40,8 +40,21 @@ namespace OpenTK.Platform.MacOS.Carbon API.Gestalt(GestaltSelector.SystemVersionBugFix, out osBugfix); Debug.Print("Running on Mac OS X {0}.{1}.{2}.", osMajor, osMinor, osBugfix); + + TransformProcessToForeground(); } + private static void TransformProcessToForeground() + { + Carbon.ProcessSerialNumber psn = new ProcessSerialNumber(); + + Debug.Print("Setting process to be foreground application."); + + API.GetCurrentProcess(ref psn); + API.TransformProcessType(ref psn, ProcessApplicationTransformState.kProcessTransformToForegroundApplication); + API.SetFrontProcess(ref psn); + } + internal static CarbonGLNative WindowEventHandler { get { return eventHandler; } diff --git a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs index 1e7bc61a..117dc84f 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs @@ -388,8 +388,22 @@ namespace OpenTK.Platform.MacOS.Carbon }; #endregion + #region --- Process Manager --- - enum HICoordinateSpace + enum ProcessApplicationTransformState : int + { + kProcessTransformToForegroundApplication = 1, + } + + struct ProcessSerialNumber + { + public ulong high; + public ulong low; + } + + #endregion + + enum HICoordinateSpace { _72DPIGlobal = 1, ScreenPixel = 2, @@ -756,8 +770,18 @@ namespace OpenTK.Platform.MacOS.Carbon internal static extern void DisposeEventHandlerUPP(IntPtr userUPP); #endregion + #region --- Process Manager --- - [DllImport(carbon)] + [DllImport(carbon)] + internal static extern int TransformProcessType(ref Carbon.ProcessSerialNumber psn, ProcessApplicationTransformState type); + [DllImport(carbon)] + internal static extern int GetCurrentProcess(ref Carbon.ProcessSerialNumber psn); + [DllImport(carbon)] + internal static extern int SetFrontProcess(ref Carbon.ProcessSerialNumber psn); + + #endregion + + [DllImport(carbon)] static extern IntPtr GetControlBounds(IntPtr control, out Rect bounds); internal static Rect GetControlBounds(IntPtr control) From ed05d8e12c9f06d27dbc956081461a6e7ed74ef6 Mon Sep 17 00:00:00 2001 From: kanato Date: Sat, 14 Nov 2009 18:40:56 +0000 Subject: [PATCH 07/27] MacOS: Several minor fixes: * Implement MouseWheel event * Implement KeyPress event * Fix generation of MouseMove events * Fix right mouse button up event --- .../MacOS/CarbonBindings/CarbonAPI.cs | 19 +++ .../MacOS/CarbonBindings/MacOSKeys.cs | 3 - .../OpenTK/Platform/MacOS/CarbonGLNative.cs | 145 +++++++++++------- 3 files changed, 105 insertions(+), 62 deletions(-) diff --git a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs index 117dc84f..e91f0ebd 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs @@ -640,6 +640,25 @@ namespace OpenTK.Platform.MacOS.Carbon return (MouseButton)button; } + static internal int GetEventMouseWheelDelta(IntPtr inEvent) + { + int delta; + + unsafe + { + int* d = δ + + OSStatus result = API.GetEventParameter(inEvent, + EventParamName.MouseWheelDelta, EventParamType.typeSInt32, + IntPtr.Zero, (uint)sizeof(int), IntPtr.Zero, (IntPtr)d); + + if (result != OSStatus.NoError) + throw new MacOSException(result); + } + + return delta; + } + static internal OSStatus GetEventWindowMouseLocation(IntPtr inEvent, out HIPoint pt) { HIPoint point; diff --git a/Source/OpenTK/Platform/MacOS/CarbonBindings/MacOSKeys.cs b/Source/OpenTK/Platform/MacOS/CarbonBindings/MacOSKeys.cs index 95fb6cf1..90868408 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonBindings/MacOSKeys.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonBindings/MacOSKeys.cs @@ -121,7 +121,4 @@ namespace OpenTK.Platform.MacOS.Carbon Command = 0x0100, // Open-Apple - Windows key Option = 0x0800, // Option key is same position as the alt key on non-mac keyboards. } - partial class API - { - } } diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs index 47044bfc..7cca609a 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -64,6 +64,8 @@ namespace OpenTK.Platform.MacOS static Dictionary mWindows = new Dictionary(); + KeyPressEventArgs mKeyPressArgs = new KeyPressEventArgs((char)0); + #endregion #region AGL Device Hack @@ -331,25 +333,35 @@ namespace OpenTK.Platform.MacOS private OSStatus ProcessKeyboardEvent(IntPtr inCaller, IntPtr inEvent, EventInfo evt, IntPtr userData) { System.Diagnostics.Debug.Assert(evt.EventClass == EventClass.Keyboard); - MacOSKeyCode code; - char charCode; + MacOSKeyCode code = (MacOSKeyCode)0; + char charCode = '\0'; + + //Debug.Print("Processing keyboard event {0}", evt.KeyboardEventKind); + + switch (evt.KeyboardEventKind) + { + case KeyboardEventKind.RawKeyDown: + case KeyboardEventKind.RawKeyRepeat: + case KeyboardEventKind.RawKeyUp: + GetCharCodes(inEvent, out code, out charCode); + mKeyPressArgs.KeyChar = charCode; + break; + } switch (evt.KeyboardEventKind) { case KeyboardEventKind.RawKeyRepeat: - GetCharCodes(inEvent, out code, out charCode); InputDriver.Keyboard[0].KeyRepeat = true; goto case KeyboardEventKind.RawKeyDown; case KeyboardEventKind.RawKeyDown: - GetCharCodes(inEvent, out code, out charCode); + OnKeyPress(mKeyPressArgs); InputDriver.Keyboard[0][Keymap[code]] = true; return OSStatus.EventNotHandled; case KeyboardEventKind.RawKeyUp: - GetCharCodes(inEvent, out code, out charCode); InputDriver.Keyboard[0][Keymap[code]] = false; - + return OSStatus.EventNotHandled; case KeyboardEventKind.RawKeyModifiersChanged: @@ -362,6 +374,7 @@ namespace OpenTK.Platform.MacOS } + private OSStatus ProcessWindowEvent(IntPtr inCaller, IntPtr inEvent, EventInfo evt, IntPtr userData) { System.Diagnostics.Debug.Assert(evt.EventClass == EventClass.Window); @@ -426,21 +439,6 @@ namespace OpenTK.Platform.MacOS } } - - if (this.windowState == WindowState.Fullscreen) - { - InputDriver.Mouse[0].Position = new Point((int)pt.X, (int)pt.Y); - } - else - { - // ignore clicks in the title bar - if (pt.Y < mTitlebarHeight) - return OSStatus.EventNotHandled; - - InputDriver.Mouse[0].Position = - new Point((int)pt.X, (int)(pt.Y - mTitlebarHeight)); - } - switch (evt.MouseEventKind) { case MouseEventKind.MouseDown: @@ -462,9 +460,11 @@ namespace OpenTK.Platform.MacOS } - break; + return OSStatus.NoError; case MouseEventKind.MouseUp: + button = API.GetEventMouseButton(inEvent); + switch (button) { case MouseButton.Primary: @@ -482,12 +482,43 @@ namespace OpenTK.Platform.MacOS button = API.GetEventMouseButton(inEvent); - break; + return OSStatus.NoError; + + case MouseEventKind.WheelMoved: + + int delta = API.GetEventMouseWheelDelta(inEvent) / 3; + + InputDriver.Mouse[0].Wheel += delta; + + return OSStatus.NoError; case MouseEventKind.MouseMoved: case MouseEventKind.MouseDragged: - //Debug.Print("MouseMoved: {0}", InputDriver.Mouse[0].Position); + if (this.windowState == WindowState.Fullscreen) + { + Point mousePosInClient = new Point((int)pt.X, (int)pt.Y); + + if (mousePosInClient.X != InputDriver.Mouse[0].X || + mousePosInClient.Y != InputDriver.Mouse[0].Y) + { + InputDriver.Mouse[0].Position = mousePosInClient; + } + } + else + { + // ignore clicks in the title bar + if (pt.Y < mTitlebarHeight) + return OSStatus.EventNotHandled; + + Point mousePosInClient = new Point((int)pt.X, (int)(pt.Y - mTitlebarHeight)); + + if (mousePosInClient.X != InputDriver.Mouse[0].X || + mousePosInClient.Y != InputDriver.Mouse[0].Y) + { + InputDriver.Mouse[0].Position = mousePosInClient; + } + } return OSStatus.EventNotHandled; @@ -496,8 +527,6 @@ namespace OpenTK.Platform.MacOS return OSStatus.EventNotHandled; } - - return OSStatus.EventNotHandled; } private static void GetCharCodes(IntPtr inEvent, out MacOSKeyCode code, out char charCode) @@ -598,18 +627,6 @@ namespace OpenTK.Platform.MacOS bounds = GetRegion().ToRectangle(); } - protected virtual void OnClosing(CancelEventArgs e) - { - if (Closing != null) - Closing(this, e); - } - - protected virtual void OnClosed() - { - if (Closed != null) - Closed(this, EventArgs.Empty); - } - #endregion #region INativeGLWindow Members @@ -894,8 +911,7 @@ namespace OpenTK.Platform.MacOS windowState = value; - if (WindowStateChanged != null) - WindowStateChanged(this, EventArgs.Empty); + OnWindowStateChanged(); OnResize(); } @@ -928,44 +944,55 @@ namespace OpenTK.Platform.MacOS WindowBorderChanged(this, EventArgs.Empty); } } - } + } - public event EventHandler Idle; + #region --- Event wrappers --- + private void OnKeyPress(KeyPressEventArgs keyPressArgs) + { + if (KeyPress != null) + KeyPress(this, keyPressArgs); + } + + + private void OnWindowStateChanged() + { + if (WindowStateChanged != null) + WindowStateChanged(this, EventArgs.Empty); + } + + protected virtual void OnClosing(CancelEventArgs e) + { + if (Closing != null) + Closing(this, e); + } + + protected virtual void OnClosed() + { + if (Closed != null) + Closed(this, EventArgs.Empty); + } + + #endregion + + public event EventHandler Idle; public event EventHandler Load; - public event EventHandler Unload; - public event EventHandler Move; - public event EventHandler Resize; - public event EventHandler Closing; - public event EventHandler Closed; - public event EventHandler Disposed; - public event EventHandler IconChanged; - public event EventHandler TitleChanged; - public event EventHandler ClientSizeChanged; - public event EventHandler VisibleChanged; - public event EventHandler WindowInfoChanged; - public event EventHandler FocusedChanged; - public event EventHandler WindowBorderChanged; - public event EventHandler WindowStateChanged; - public event EventHandler KeyPress; - public event EventHandler MouseEnter; - public event EventHandler MouseLeave; #endregion From 52e89c13b151083f152440989f2417320365d0cf Mon Sep 17 00:00:00 2001 From: kanato Date: Sat, 14 Nov 2009 21:33:07 +0000 Subject: [PATCH 08/27] MacOS: Clean up AglContext destruction code. Implement INativeWindow.Close method. --- Source/OpenTK/Platform/MacOS/AglContext.cs | 26 ++++++++----------- .../OpenTK/Platform/MacOS/CarbonGLNative.cs | 13 +++++++++- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Source/OpenTK/Platform/MacOS/AglContext.cs b/Source/OpenTK/Platform/MacOS/AglContext.cs index c2bf34e9..f57e8d7c 100644 --- a/Source/OpenTK/Platform/MacOS/AglContext.cs +++ b/Source/OpenTK/Platform/MacOS/AglContext.cs @@ -358,6 +358,7 @@ namespace OpenTK.Platform.MacOS #endregion #region IDisposable Members + ~AglContext() { Dispose(false); @@ -374,25 +375,20 @@ namespace OpenTK.Platform.MacOS return; Debug.Print("Disposing of AGL context."); - - try - { - throw new Exception(); - } - catch (Exception e) - { - Debug.WriteLine(e.StackTrace); - } - Agl.aglSetCurrentContext(IntPtr.Zero); - Agl.aglSetDrawable(Handle.Handle, IntPtr.Zero); - - Debug.Print("Set drawable to null for context {0}.", Handle.Handle); + + //Debug.Print("Setting drawable to null for context {0}.", Handle.Handle); + //Agl.aglSetDrawable(Handle.Handle, IntPtr.Zero); + // I do not know MacOS allows us to destroy a context from a separate thread, + // like the finalizer thread. It's untested, but worst case is probably + // an exception on application exit, which would be logged to the console. + Debug.Print("Destroying context"); if (Agl.aglDestroyContext(Handle.Handle) == true) { - Handle = ContextHandle.Zero; - return; + Debug.Print("Context destruction completed successfully."); + Handle = ContextHandle.Zero; + return; } // failed to destroy context. diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs index 7cca609a..f1899bdb 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -124,6 +124,8 @@ namespace OpenTK.Platform.MacOS Debug.Print("Disposing of CarbonGLNative window."); + API.DisposeWindow(window.WindowRef); + mIsDisposed = true; mExists = false; @@ -136,6 +138,7 @@ namespace OpenTK.Platform.MacOS } DisposeUPP(); + } ~CarbonGLNative() @@ -842,7 +845,15 @@ namespace OpenTK.Platform.MacOS public void Close() { - throw new NotImplementedException(); + CancelEventArgs e = new CancelEventArgs(); + OnClosing(e); + + if (e.Cancel) + return; + + OnClosed(); + + Dispose(); } public WindowState WindowState From 103190ebf408f27f9241ac100af15fe23c8e10c1 Mon Sep 17 00:00:00 2001 From: kanato Date: Sun, 15 Nov 2009 03:55:29 +0000 Subject: [PATCH 09/27] MacOS: Implement mouse enter / leave events. --- .../MacOS/CarbonBindings/CarbonAPI.cs | 59 ++++++++++++++++++- .../OpenTK/Platform/MacOS/CarbonGLNative.cs | 58 +++++++++++++++--- 2 files changed, 109 insertions(+), 8 deletions(-) diff --git a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs index e91f0ebd..e924fed1 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs @@ -11,6 +11,8 @@ using System; using System.Runtime.InteropServices; using System.Diagnostics; using System.Drawing; +using EventTime = System.Double; + namespace OpenTK.Platform.MacOS.Carbon { @@ -121,6 +123,13 @@ namespace OpenTK.Platform.MacOS.Carbon #region --- Types defined in CarbonEvents.h --- + enum EventAttributes : uint + { + kEventAttributeNone = 0, + kEventAttributeUserEvent = (1 << 0), + kEventAttributeMonitored = 1 << 3, + } + [StructLayout(LayoutKind.Sequential)] internal struct EventTypeSpec { @@ -238,6 +247,8 @@ namespace OpenTK.Platform.MacOS.Carbon internal enum EventParamName : int { + WindowRef = 0x77696e64, // typeWindowRef, + // Mouse Events MouseLocation = 0x6d6c6f63, // typeHIPoint WindowMouseLocation = 0x776d6f75, // typeHIPoint @@ -255,6 +266,8 @@ namespace OpenTK.Platform.MacOS.Carbon } internal enum EventParamType : int { + typeWindowRef = 0x77696e64, + typeMouseButton = 0x6d62746e, typeMouseWheelAxis = 0x6d776178, typeHIPoint = 0x68697074, @@ -409,7 +422,7 @@ namespace OpenTK.Platform.MacOS.Carbon ScreenPixel = 2, Window = 3, View = 4 -}; + }; #region --- Carbon API Methods --- @@ -502,6 +515,12 @@ namespace OpenTK.Platform.MacOS.Carbon [DllImport(carbon)] static extern void ReleaseEvent(IntPtr theEvent); + internal static void SendEvent(IntPtr theEvent) + { + IntPtr theTarget = GetEventDispatcherTarget(); + SendEventToEventTarget(theEvent, theTarget); + } + // Processes events in the queue and then returns. internal static void ProcessEvents() { @@ -572,6 +591,26 @@ namespace OpenTK.Platform.MacOS.Carbon #endregion #region --- Getting Event Parameters --- + [DllImport(carbon,EntryPoint="CreateEvent")] + static extern OSStatus _CreateEvent( IntPtr inAllocator, + EventClass inClassID, UInt32 kind, EventTime when, + EventAttributes flags,out IntPtr outEvent); + + internal static IntPtr CreateWindowEvent(WindowEventKind kind) + { + IntPtr retval; + + OSStatus stat = _CreateEvent(IntPtr.Zero, EventClass.Window, (uint)kind, + 0, EventAttributes.kEventAttributeNone, out retval); + + if (stat != OSStatus.NoError) + { + throw new MacOSException(stat); + } + + return retval; + } + [DllImport(carbon)] static extern OSStatus GetEventParameter( IntPtr inEvent, EventParamName inName, EventParamType inDesiredType, @@ -678,6 +717,24 @@ namespace OpenTK.Platform.MacOS.Carbon } } + + static internal OSStatus GetEventWindowRef(IntPtr inEvent, out IntPtr windowRef) + { + IntPtr retval; + + unsafe + { + IntPtr* parm = &retval; + OSStatus result = API.GetEventParameter(inEvent, + EventParamName.WindowRef, EventParamType.typeWindowRef, IntPtr.Zero, + (uint)sizeof(IntPtr), IntPtr.Zero, (IntPtr)parm); + + windowRef = retval; + + return result; + } + } + static internal OSStatus GetEventMouseLocation(IntPtr inEvent, out HIPoint pt) { HIPoint point; diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs index f1899bdb..df1b912d 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -66,6 +66,8 @@ namespace OpenTK.Platform.MacOS KeyPressEventArgs mKeyPressArgs = new KeyPressEventArgs((char)0); + bool mMouseIn = false; + #endregion #region AGL Device Hack @@ -421,12 +423,13 @@ namespace OpenTK.Platform.MacOS System.Diagnostics.Debug.Assert(evt.EventClass == EventClass.Mouse); MouseButton button = MouseButton.Primary; HIPoint pt = new HIPoint(); + HIPoint screenLoc = new HIPoint(); - OSStatus err; + OSStatus err = API.GetEventMouseLocation(inEvent, out screenLoc); if (this.windowState == WindowState.Fullscreen) { - err = API.GetEventMouseLocation(inEvent, out pt); + pt = screenLoc; } else { @@ -442,6 +445,17 @@ namespace OpenTK.Platform.MacOS } } + Point mousePosInClient = new Point((int)pt.X, (int)pt.Y); + if (this.windowState != WindowState.Fullscreen) + { + mousePosInClient.Y -= mTitlebarHeight; + } + + // check for enter/leave events + IntPtr thisEventWindow; + API.GetEventWindowRef(inEvent, out thisEventWindow); + CheckEnterLeaveEvents(thisEventWindow, mousePosInClient); + switch (evt.MouseEventKind) { case MouseEventKind.MouseDown: @@ -497,11 +511,11 @@ namespace OpenTK.Platform.MacOS case MouseEventKind.MouseMoved: case MouseEventKind.MouseDragged: + + //Debug.Print("Mouse Location: {0}, {1}", pt.X, pt.Y); if (this.windowState == WindowState.Fullscreen) { - Point mousePosInClient = new Point((int)pt.X, (int)pt.Y); - if (mousePosInClient.X != InputDriver.Mouse[0].X || mousePosInClient.Y != InputDriver.Mouse[0].Y) { @@ -511,11 +525,9 @@ namespace OpenTK.Platform.MacOS else { // ignore clicks in the title bar - if (pt.Y < mTitlebarHeight) + if (pt.Y < 0) return OSStatus.EventNotHandled; - Point mousePosInClient = new Point((int)pt.X, (int)(pt.Y - mTitlebarHeight)); - if (mousePosInClient.X != InputDriver.Mouse[0].X || mousePosInClient.Y != InputDriver.Mouse[0].Y) { @@ -532,6 +544,24 @@ namespace OpenTK.Platform.MacOS } } + private void CheckEnterLeaveEvents(IntPtr eventWindowRef, Point pt) + { + bool thisIn = eventWindowRef == window.WindowRef; + + if (pt.Y < 0) + thisIn = false; + + if (thisIn != mMouseIn) + { + mMouseIn = thisIn; + + if (mMouseIn) + OnMouseEnter(); + else + OnMouseLeave(); + } + } + private static void GetCharCodes(IntPtr inEvent, out MacOSKeyCode code, out char charCode) { code = API.GetEventKeyboardKeyCode(inEvent); @@ -984,6 +1014,20 @@ namespace OpenTK.Platform.MacOS Closed(this, EventArgs.Empty); } + + private void OnMouseLeave() + { + if (MouseLeave != null) + MouseLeave(this, EventArgs.Empty); + } + + private void OnMouseEnter() + { + if (MouseEnter != null) + MouseEnter(this, EventArgs.Empty); + } + + #endregion public event EventHandler Idle; From 63b314c4a8567e6a6ef54db7cc289f71c46f1b04 Mon Sep 17 00:00:00 2001 From: kanato Date: Sun, 15 Nov 2009 04:12:37 +0000 Subject: [PATCH 10/27] MacOS: Implement Focused property and FocusChanged event. --- .../OpenTK/Platform/MacOS/CarbonGLNative.cs | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs index df1b912d..15c45bf1 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -67,6 +67,7 @@ namespace OpenTK.Platform.MacOS KeyPressEventArgs mKeyPressArgs = new KeyPressEventArgs((char)0); bool mMouseIn = false; + bool mIsActive = false; #endregion @@ -202,6 +203,8 @@ namespace OpenTK.Platform.MacOS new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClose), new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClosed), new EventTypeSpec(EventClass.Window, WindowEventKind.WindowBoundsChanged), + new EventTypeSpec(EventClass.Window, WindowEventKind.WindowActivate), + new EventTypeSpec(EventClass.Window, WindowEventKind.WindowDeactivate), //new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseDown), //new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseUp), @@ -412,6 +415,14 @@ namespace OpenTK.Platform.MacOS return OSStatus.EventNotHandled; + case WindowEventKind.WindowActivate: + OnActivate(); + return OSStatus.EventNotHandled; + + case WindowEventKind.WindowDeactivate: + OnDeactivate(); + return OSStatus.EventNotHandled; + default: Debug.Print("{0}", evt); @@ -772,7 +783,7 @@ namespace OpenTK.Platform.MacOS public bool Focused { - get { throw new NotImplementedException(); } + get { return this.mIsActive; } } public Rectangle Bounds @@ -1027,6 +1038,18 @@ namespace OpenTK.Platform.MacOS MouseEnter(this, EventArgs.Empty); } + private void OnActivate() + { + mIsActive = true; + if (FocusedChanged != null) + FocusedChanged(this, EventArgs.Empty); + } + private void OnDeactivate() + { + mIsActive = false; + if (FocusedChanged != null) + FocusedChanged(this, EventArgs.Empty); + } #endregion From d695bb599ce330569e15c6b6adb663e18991144c Mon Sep 17 00:00:00 2001 From: kanato Date: Sun, 15 Nov 2009 18:08:49 +0000 Subject: [PATCH 11/27] MacOS: Add proper icon support for the dock. --- .../MacOS/CarbonBindings/CarbonAPI.cs | 15 +++++ .../OpenTK/Platform/MacOS/CarbonGLNative.cs | 59 ++++++++++++++++++- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs index e924fed1..4ae61ca9 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs @@ -416,6 +416,7 @@ namespace OpenTK.Platform.MacOS.Carbon #endregion + enum HICoordinateSpace { _72DPIGlobal = 1, @@ -855,6 +856,20 @@ namespace OpenTK.Platform.MacOS.Carbon [DllImport(carbon)] internal static extern int SetFrontProcess(ref Carbon.ProcessSerialNumber psn); + #endregion + #region --- Setting Dock Tile --- + + [DllImport(carbon)] + internal extern static IntPtr CGColorSpaceCreateDeviceRGB(); + [DllImport(carbon)] + internal extern static IntPtr CGDataProviderCreateWithData(IntPtr info, IntPtr[] data, int size, IntPtr releasefunc); + [DllImport(carbon)] + internal extern static IntPtr CGImageCreate(int width, int height, int bitsPerComponent, int bitsPerPixel, int bytesPerRow, IntPtr colorspace, uint bitmapInfo, IntPtr provider, IntPtr decode, int shouldInterpolate, int intent); + [DllImport(carbon)] + internal extern static void SetApplicationDockTileImage(IntPtr imageRef); + [DllImport(carbon)] + internal extern static void RestoreApplicationDockTileImage(); + #endregion [DllImport(carbon)] diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs index 15c45bf1..4a113bcf 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -69,6 +69,8 @@ namespace OpenTK.Platform.MacOS bool mMouseIn = false; bool mIsActive = false; + Icon mIcon; + #endregion #region AGL Device Hack @@ -752,10 +754,63 @@ namespace OpenTK.Platform.MacOS public Icon Icon { - get { return null; } - set { } + get { return mIcon; } + set { + SetIcon(value); + } } + private void SetIcon(Icon icon) + { + // The code for this function was adapted from Mono's XplatUICarbon implementation, + // written by Geoff Norton + // http://anonsvn.mono-project.com/viewvc/trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUICarbon.cs?view=markup&pathrev=136932 + if (icon == null) + { + API.RestoreApplicationDockTileImage(); + } + else + { + Bitmap bitmap; + int size; + IntPtr[] data; + int index; + + bitmap = new Bitmap(128, 128); + using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap)) + { + g.DrawImage(icon.ToBitmap(), 0, 0, 128, 128); + } + index = 0; + size = bitmap.Width * bitmap.Height; + data = new IntPtr[size]; + + for (int y = 0; y < bitmap.Height; y++) + { + for (int x = 0; x < bitmap.Width; x++) + { + int pixel = bitmap.GetPixel(x, y).ToArgb(); + if (BitConverter.IsLittleEndian) + { + byte a = (byte)((pixel >> 24) & 0xFF); + byte r = (byte)((pixel >> 16) & 0xFF); + byte g = (byte)((pixel >> 8) & 0xFF); + byte b = (byte)(pixel & 0xFF); + data[index++] = (IntPtr)(a + (r << 8) + (g << 16) + (b << 24)); + } + else + { + data[index++] = (IntPtr)pixel; + } + } + } + + IntPtr provider = API.CGDataProviderCreateWithData(IntPtr.Zero, data, size * 4, IntPtr.Zero); + IntPtr image = API.CGImageCreate(128, 128, 8, 32, 4 * 128, API.CGColorSpaceCreateDeviceRGB(), 4, provider, IntPtr.Zero, 0, 0); + API.SetApplicationDockTileImage(image); + } + } + public string Title { get From 69c05cdb20c4eaed0a104faa6307dc7e74869a47 Mon Sep 17 00:00:00 2001 From: kanato Date: Sun, 15 Nov 2009 19:31:23 +0000 Subject: [PATCH 12/27] MacOS: Correct resizing behavior and correctly implement Bounds, ClientRectangle, and ClientSize getters and setters. --- .../OpenTK/Platform/MacOS/CarbonGLNative.cs | 58 +++++++++---------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs index 4a113bcf..df28debc 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -43,6 +43,8 @@ namespace OpenTK.Platform.MacOS CarbonWindowInfo window; CarbonInput mInputDriver; + + [Obsolete] GraphicsContext context; static MacOSKeyMap Keymap = new MacOSKeyMap(); @@ -50,7 +52,8 @@ namespace OpenTK.Platform.MacOS IntPtr uppHandler; string title = "OpenTK Window"; - Rectangle bounds, windowedBounds, clientRectangle; + Rectangle bounds, clientRectangle; + Rectangle windowedBounds; bool mIsDisposed = false; bool mExists = true; DisplayDevice mDisplayDevice; @@ -257,6 +260,7 @@ namespace OpenTK.Platform.MacOS Debug.Print("Prev Size: {0}, {1}", Width, Height); + // TODO: if we go full screen we need to make this use the device specified. bounds = DisplayDevice.Default.Bounds; Debug.Print("New Size: {0}, {1}", Width, Height); @@ -631,34 +635,19 @@ namespace OpenTK.Platform.MacOS if (WindowState == WindowState.Fullscreen) return; - // Todo: why call SizeWindow twice? + // The bounds of the window should be the size specified, but + // API.SizeWindow sets the content region size. So + // we reduce the size to get the correct bounds. + width -= (short)(bounds.Width - clientRectangle.Width); + height -= (short)(bounds.Height - clientRectangle.Height); + API.SizeWindow(window.WindowRef, width, height, true); - bounds.Width = (short)width; - bounds.Height = (short)height; - - Rect contentBounds = API.GetWindowBounds(window.WindowRef, WindowRegionCode.ContentRegion); - - Rect newSize = new Rect(0, 0, - (short)(2 * width - contentBounds.Width), - (short)(2 * height - contentBounds.Height)); - - Debug.Print("Content region was: {0}", contentBounds); - Debug.Print("Resizing window to: {0}", newSize); - - API.SizeWindow(window.WindowRef, newSize.Width, newSize.Height, true); - - contentBounds = API.GetWindowBounds(window.WindowRef, WindowRegionCode.ContentRegion); - Debug.Print("New content region size: {0}", contentBounds); - clientRectangle = contentBounds.ToRectangle(); } protected void OnResize() { LoadSize(); - if (context != null && this.windowState != WindowState.Fullscreen) - context.Update(window); - if (Resize != null) { Resize(this, EventArgs.Empty); @@ -670,7 +659,11 @@ namespace OpenTK.Platform.MacOS if (WindowState == WindowState.Fullscreen) return; - bounds = GetRegion().ToRectangle(); + Rect r = API.GetWindowBounds(window.WindowRef, WindowRegionCode.StructureRegion); + bounds = new Rectangle(r.X, r.Y, r.Width, r.Height); + + r = API.GetWindowBounds(window.WindowRef, WindowRegionCode.GlobalPortRegion); + clientRectangle = new Rectangle(0, 0, r.Width, r.Height); } #endregion @@ -762,8 +755,8 @@ namespace OpenTK.Platform.MacOS private void SetIcon(Icon icon) { - // The code for this function was adapted from Mono's XplatUICarbon implementation, - // written by Geoff Norton + // The code for this function was adapted from Mono's + // XplatUICarbon implementation, written by Geoff Norton // http://anonsvn.mono-project.com/viewvc/trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUICarbon.cs?view=markup&pathrev=136932 if (icon == null) { @@ -845,7 +838,8 @@ namespace OpenTK.Platform.MacOS { get { - return bounds; + + return bounds; } set { @@ -858,7 +852,7 @@ namespace OpenTK.Platform.MacOS { get { - return bounds.Location; + return Bounds.Location; } set { @@ -875,7 +869,6 @@ namespace OpenTK.Platform.MacOS set { SetSize((short)value.Width, (short)value.Height); - context.Update(WindowInfo); } } @@ -919,11 +912,13 @@ namespace OpenTK.Platform.MacOS { get { - return clientRectangle; + return clientRectangle; } set { - throw new NotImplementedException(); + // just set the size, and ignore the location value. + // this is the behavior of the Windows WinGLNative. + ClientSize = value.Size; } } @@ -935,7 +930,8 @@ namespace OpenTK.Platform.MacOS } set { - throw new NotImplementedException(); + API.SizeWindow(window.WindowRef, (short)value.Width, (short)value.Height, true); + OnResize(); } } From 1bc11bb8077031101fd05a4ddb877404f4eb6829 Mon Sep 17 00:00:00 2001 From: kanato Date: Sun, 15 Nov 2009 22:00:14 +0000 Subject: [PATCH 13/27] MacOS: Fix crash in CheckEnterLeaveEvents if using WinForms too. --- Source/OpenTK/Platform/MacOS/CarbonGLNative.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs index df28debc..ee8a247a 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -563,6 +563,9 @@ namespace OpenTK.Platform.MacOS private void CheckEnterLeaveEvents(IntPtr eventWindowRef, Point pt) { + if (window == null) + return; + bool thisIn = eventWindowRef == window.WindowRef; if (pt.Y < 0) From c84e3ef0dac39b5adfb3093916744bfb91db5ec3 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 10:09:11 +0000 Subject: [PATCH 14/27] Fixed InvalidCastException in keyboard logging delegates. --- Source/Examples/OpenTK/Test/InputLogger.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Examples/OpenTK/Test/InputLogger.cs b/Source/Examples/OpenTK/Test/InputLogger.cs index e26220a7..b6f49d13 100644 --- a/Source/Examples/OpenTK/Test/InputLogger.cs +++ b/Source/Examples/OpenTK/Test/InputLogger.cs @@ -195,16 +195,16 @@ namespace Examples.Tests #region Keyboards - delegate void ControlLogKeyboard(GameWindow input_window, InputLogger control, OpenTK.Input.KeyboardDevice sender, Key key); + delegate void ControlLogKeyboard(GameWindow input_window, InputLogger control, OpenTK.Input.KeyboardDevice sender, KeyboardKeyEventArgs e); ControlLogKeyboard ControlLogKeyboardDown = - delegate(GameWindow input_window, InputLogger control, KeyboardDevice sender, Key key) + delegate(GameWindow input_window, InputLogger control, KeyboardDevice sender, KeyboardKeyEventArgs e) { - control.keyboardListBoxes[sender.DeviceID].Items.Add(key); + control.keyboardListBoxes[sender.DeviceID].Items.Add(e.Key); }; ControlLogKeyboard ControlLogKeyboardUp = - delegate(GameWindow input_window, InputLogger control, KeyboardDevice sender, Key key) + delegate(GameWindow input_window, InputLogger control, KeyboardDevice sender, KeyboardKeyEventArgs e) { - control.keyboardListBoxes[sender.DeviceID].Items.Remove(key); + control.keyboardListBoxes[sender.DeviceID].Items.Remove(e.Key); }; #endregion From a8c0c7adf4a545ea72d461e75fd4879d2f14040c Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 10:38:49 +0000 Subject: [PATCH 15/27] Preserve the sign of the mouse position. Fixes issue [#1376]: "mouse position". --- Source/OpenTK/Platform/Windows/WinGLNative.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/OpenTK/Platform/Windows/WinGLNative.cs b/Source/OpenTK/Platform/Windows/WinGLNative.cs index cf622365..812809ba 100644 --- a/Source/OpenTK/Platform/Windows/WinGLNative.cs +++ b/Source/OpenTK/Platform/Windows/WinGLNative.cs @@ -293,8 +293,8 @@ namespace OpenTK.Platform.Windows case WindowMessage.MOUSEMOVE: Point point = new Point( - (int)(lParam.ToInt32() & 0x0000FFFF), - (int)(lParam.ToInt32() & 0xFFFF0000) >> 16); + (short)((uint)lParam.ToInt32() & 0x0000FFFF), + (short)(((uint)lParam.ToInt32() & 0xFFFF0000) >> 16)); mouse.Position = point; { if (!ClientRectangle.Contains(point)) From d5175d1d9cae91de8d67aab6fe5fe7f5defcd63b Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 10:56:07 +0000 Subject: [PATCH 16/27] Launch samples on a different thread than the launcher. Samples may install their own message loops and some operating systems do not behave correctly with multiple message loops on a single thread. --- Source/Examples/ExampleBrowser.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/Examples/ExampleBrowser.cs b/Source/Examples/ExampleBrowser.cs index da61a3a5..5f615445 100644 --- a/Source/Examples/ExampleBrowser.cs +++ b/Source/Examples/ExampleBrowser.cs @@ -32,6 +32,7 @@ using System.Drawing.Text; using System.Reflection; using System.Windows.Forms; using OpenTK.Examples.Properties; +using System.Threading; namespace Examples { @@ -333,7 +334,11 @@ namespace Examples } Trace.WriteLine(String.Format("Launching sample: \"{0}\"", e.Attribute.Title)); Trace.WriteLine(String.Empty); - main.Invoke(null, null); + + Thread thread = new Thread((ThreadStart)delegate { main.Invoke(null, null); }); + thread.IsBackground = true; + thread.Start(); + thread.Join(); } catch (TargetInvocationException expt) { From 3c0787c6a9d4f272af2ace50e38549d3418465bb Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 11:17:20 +0000 Subject: [PATCH 17/27] Make context current on loading thread and be more defensive when retrieving unmanaged entry points. Resolves issue [#1378]: "OpenGL Extensions test fails". --- Source/Examples/OpenTK/Test/Extensions.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Source/Examples/OpenTK/Test/Extensions.cs b/Source/Examples/OpenTK/Test/Extensions.cs index 6bd6d9c3..a9ad6aea 100644 --- a/Source/Examples/OpenTK/Test/Extensions.cs +++ b/Source/Examples/OpenTK/Test/Extensions.cs @@ -55,9 +55,15 @@ namespace Examples.WinForms { Application.Idle -= StartAsync; - // Create a context in order to load all GL methods (GL.LoadAll() is called automatically.) - using (GLControl control = new GLControl(GraphicsMode.Default, 3, 0, GraphicsContextFlags.Default)) + // Create a context to load all GL entry points. + // The loading part is handled automatically by OpenTK. + using (INativeWindow window = new OpenTK.NativeWindow()) + using (IGraphicsContext context = new GraphicsContext(GraphicsMode.Default, window.WindowInfo, 3, 0, GraphicsContextFlags.Default)) { + window.ProcessEvents(); + context.MakeCurrent(window.WindowInfo); + (context as IGraphicsContextInternal).LoadAll(); + TextBoxVendor.Text = GL.GetString(StringName.Vendor); TextBoxRenderer.Text = GL.GetString(StringName.Renderer); TextBoxVersion.Text = GL.GetString(StringName.Version); @@ -73,11 +79,14 @@ namespace Examples.WinForms foreach (Function f in LoadFunctionsFromType(typeof(GL))) { + FieldInfo @delegate = delegates.GetField(f.EntryPoint, + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); + // Only show a function as supported when all relevant overloads are supported. if (!functions.ContainsKey(f)) - functions.Add(f, (bool)delegates.GetField(f.EntryPoint).GetValue(null)); + functions.Add(f, @delegate != null && @delegate.GetValue(null) != null); else - functions[f] &= (bool)delegates.GetField(f.EntryPoint).GetValue(null); + functions[f] &= @delegate != null && @delegate.GetValue(null) != null; } // Count supported functions using the delegates directly. From f509286611171f6d2abd980208b34daee49b709e Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 11:23:12 +0000 Subject: [PATCH 18/27] Renamed "Entry" to "Unmanaged Name" to clarify its purpose. --- .../OpenTK/Test/Extensions.Designer.cs | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/Source/Examples/OpenTK/Test/Extensions.Designer.cs b/Source/Examples/OpenTK/Test/Extensions.Designer.cs index ba62eec3..9cadd734 100644 --- a/Source/Examples/OpenTK/Test/Extensions.Designer.cs +++ b/Source/Examples/OpenTK/Test/Extensions.Designer.cs @@ -30,12 +30,6 @@ { this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); - this.SupportedColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); - this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.CategoryColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Version = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ExtensionColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Entry = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.LabelVendor = new System.Windows.Forms.Label(); this.LabelRenderer = new System.Windows.Forms.Label(); this.LabelVersion = new System.Windows.Forms.Label(); @@ -44,6 +38,12 @@ this.TextBoxVersion = new System.Windows.Forms.TextBox(); this.LabelSupport = new System.Windows.Forms.Label(); this.TextBoxSupport = new System.Windows.Forms.TextBox(); + this.SupportedColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.CategoryColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Version = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ExtensionColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.UnmanagedName = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // @@ -67,55 +67,13 @@ this.CategoryColumn, this.Version, this.ExtensionColumn, - this.Entry}); + this.UnmanagedName}); this.dataGridView1.Location = new System.Drawing.Point(0, 110); this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.ReadOnly = true; this.dataGridView1.Size = new System.Drawing.Size(939, 397); this.dataGridView1.TabIndex = 1; // - // SupportedColumn - // - this.SupportedColumn.HeaderText = ""; - this.SupportedColumn.Name = "SupportedColumn"; - this.SupportedColumn.ReadOnly = true; - this.SupportedColumn.Width = 24; - // - // NameColumn - // - this.NameColumn.HeaderText = "Name"; - this.NameColumn.Name = "NameColumn"; - this.NameColumn.ReadOnly = true; - this.NameColumn.Width = 852; - // - // CategoryColumn - // - this.CategoryColumn.HeaderText = "Category"; - this.CategoryColumn.Name = "CategoryColumn"; - this.CategoryColumn.ReadOnly = true; - this.CategoryColumn.Width = 5; - // - // Version - // - this.Version.HeaderText = "Introduced"; - this.Version.Name = "Version"; - this.Version.ReadOnly = true; - this.Version.Width = 5; - // - // ExtensionColumn - // - this.ExtensionColumn.HeaderText = "Extension"; - this.ExtensionColumn.Name = "ExtensionColumn"; - this.ExtensionColumn.ReadOnly = true; - this.ExtensionColumn.Width = 5; - // - // Entry - // - this.Entry.HeaderText = "Entry"; - this.Entry.Name = "Entry"; - this.Entry.ReadOnly = true; - this.Entry.Width = 5; - // // LabelVendor // this.LabelVendor.AutoSize = true; @@ -192,6 +150,48 @@ this.TextBoxSupport.Size = new System.Drawing.Size(856, 20); this.TextBoxSupport.TabIndex = 9; // + // SupportedColumn + // + this.SupportedColumn.HeaderText = ""; + this.SupportedColumn.Name = "SupportedColumn"; + this.SupportedColumn.ReadOnly = true; + this.SupportedColumn.Width = 24; + // + // NameColumn + // + this.NameColumn.HeaderText = "Name"; + this.NameColumn.Name = "NameColumn"; + this.NameColumn.ReadOnly = true; + this.NameColumn.Width = 852; + // + // CategoryColumn + // + this.CategoryColumn.HeaderText = "Category"; + this.CategoryColumn.Name = "CategoryColumn"; + this.CategoryColumn.ReadOnly = true; + this.CategoryColumn.Width = 5; + // + // Version + // + this.Version.HeaderText = "Introduced"; + this.Version.Name = "Version"; + this.Version.ReadOnly = true; + this.Version.Width = 5; + // + // ExtensionColumn + // + this.ExtensionColumn.HeaderText = "Extension"; + this.ExtensionColumn.Name = "ExtensionColumn"; + this.ExtensionColumn.ReadOnly = true; + this.ExtensionColumn.Width = 5; + // + // UnmanagedName + // + this.UnmanagedName.HeaderText = "Unmanaged Name"; + this.UnmanagedName.Name = "UnmanagedName"; + this.UnmanagedName.ReadOnly = true; + this.UnmanagedName.Width = 5; + // // Extensions // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); @@ -231,6 +231,6 @@ private System.Windows.Forms.DataGridViewTextBoxColumn CategoryColumn; private System.Windows.Forms.DataGridViewTextBoxColumn Version; private System.Windows.Forms.DataGridViewTextBoxColumn ExtensionColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn Entry; + private System.Windows.Forms.DataGridViewTextBoxColumn UnmanagedName; } } \ No newline at end of file From 64717727779ce9a0380bade23e33d44d5e5210b0 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 12:15:35 +0000 Subject: [PATCH 19/27] Added support for fractional mouse wheel values. Fixes issue [#1279]: "Mouse wheel does not seem to work". --- Source/Examples/OpenTK/Test/InputLogger.cs | 2 +- Source/OpenTK/Input/MouseDevice.cs | 52 +++++++++++++------ Source/OpenTK/Platform/Windows/WinGLNative.cs | 2 +- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/Source/Examples/OpenTK/Test/InputLogger.cs b/Source/Examples/OpenTK/Test/InputLogger.cs index b6f49d13..3ef58210 100644 --- a/Source/Examples/OpenTK/Test/InputLogger.cs +++ b/Source/Examples/OpenTK/Test/InputLogger.cs @@ -188,7 +188,7 @@ namespace Examples.Tests ControlLogMouseWheel ControlLogMouseWheelChanges = delegate(GameWindow input_window, InputLogger control, object sender, MouseWheelEventArgs e) { - control.MouseWheelText.Text = e.Value.ToString(); + control.MouseWheelText.Text = e.ValuePrecise.ToString("F2"); }; #endregion diff --git a/Source/OpenTK/Input/MouseDevice.cs b/Source/OpenTK/Input/MouseDevice.cs index aba9524e..fc7a2604 100644 --- a/Source/OpenTK/Input/MouseDevice.cs +++ b/Source/OpenTK/Input/MouseDevice.cs @@ -46,7 +46,7 @@ namespace OpenTK.Input IntPtr id; int numButtons, numWheels; readonly bool[] button_state = new bool[Enum.GetValues(typeof(MouseButton)).Length]; - int wheel, last_wheel; + float wheel, last_wheel; Point pos = new Point(), last_pos = new Point(); MouseMoveEventArgs move_args = new MouseMoveEventArgs(); MouseButtonEventArgs button_args = new MouseButtonEventArgs(); @@ -131,9 +131,19 @@ namespace OpenTK.Input #region public int Wheel /// - /// Gets an integer representing the absolute wheel position. + /// Gets the absolute wheel position in integer units. + /// To support high-precision mice, it is recommended to use instead. /// public int Wheel + { + get { return (int)(wheel + 0.5f); } + internal set { WheelPrecise = value; } + } + + /// + /// Gets the absolute wheel position in floating-point units. + /// + public float WheelPrecise { get { return wheel; } internal set @@ -142,11 +152,11 @@ namespace OpenTK.Input wheel_args.X = pos.X; wheel_args.Y = pos.Y; - wheel_args.Value = wheel; - wheel_args.Delta = wheel - last_wheel; - - WheelChanged(this, wheel_args ); - + wheel_args.ValuePrecise = wheel; + wheel_args.DeltaPrecise = wheel - last_wheel; + + WheelChanged(this, wheel_args); + last_wheel = wheel; } } @@ -296,8 +306,8 @@ namespace OpenTK.Input { get { - int result = wheel - wheel_last_accessed; - wheel_last_accessed = wheel; + int result = (int)(wheel - wheel_last_accessed + 0.5f); + wheel_last_accessed = (int)wheel; return result; } } @@ -561,8 +571,8 @@ namespace OpenTK.Input { #region Fields - int value; - int delta; + float value; + float delta; #endregion @@ -601,14 +611,26 @@ namespace OpenTK.Input #region Public Members /// - /// Gets the value of the wheel. + /// Gets the value of the wheel in integer units. + /// To support high-precision mice, it is recommended to use instead. /// - public int Value { get { return this.value; } internal set { this.value = value; } } + public int Value { get { return (int)(value + 0.5f); } } /// - /// Gets the change in value of the wheel for this event. + /// Gets the change in value of the wheel for this event in integer units. + /// To support high-precision mice, it is recommended to use instead. /// - public int Delta { get { return delta; } internal set { delta = value; } } + public int Delta { get { return (int)(delta + 0.5f); } } + + /// + /// Gets the precise value of the wheel in floating-point units. + /// + public float ValuePrecise { get { return value; } internal set { this.value = value; } } + + /// + /// Gets the precise change in value of the wheel for this event in floating-point units. + /// + public float DeltaPrecise { get { return delta; } internal set { delta = value; } } #endregion } diff --git a/Source/OpenTK/Platform/Windows/WinGLNative.cs b/Source/OpenTK/Platform/Windows/WinGLNative.cs index 812809ba..ed0ba013 100644 --- a/Source/OpenTK/Platform/Windows/WinGLNative.cs +++ b/Source/OpenTK/Platform/Windows/WinGLNative.cs @@ -316,7 +316,7 @@ namespace OpenTK.Platform.Windows case WindowMessage.MOUSEWHEEL: // This is due to inconsistent behavior of the WParam value on 64bit arch, whese // wparam = 0xffffffffff880000 or wparam = 0x00000000ff100000 - mouse.Wheel += (int)((long)wParam << 32 >> 48) / 120; + mouse.WheelPrecise += ((long)wParam << 32 >> 48) / 120.0f; break; case WindowMessage.LBUTTONDOWN: From 0605607e6ae835a6e8d1980e499c5eb941b75e16 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 13:00:42 +0000 Subject: [PATCH 20/27] Changed vector-quaternion transformations to use standard q * v * q^-1 convention. Fixes issue [#1372]: "[Math] Vector transformation by Quaternion follows non-standard quaternion math convention". --- Source/OpenTK/Math/Vector2.cs | 8 +++----- Source/OpenTK/Math/Vector2d.cs | 8 +++----- Source/OpenTK/Math/Vector3.cs | 8 +++----- Source/OpenTK/Math/Vector3d.cs | 8 +++----- Source/OpenTK/Math/Vector4.cs | 8 +++----- Source/OpenTK/Math/Vector4d.cs | 8 +++----- 6 files changed, 18 insertions(+), 30 deletions(-) diff --git a/Source/OpenTK/Math/Vector2.cs b/Source/OpenTK/Math/Vector2.cs index 9dad9391..5946fdd3 100644 --- a/Source/OpenTK/Math/Vector2.cs +++ b/Source/OpenTK/Math/Vector2.cs @@ -908,12 +908,10 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector2 vec, ref Quaternion quat, out Vector2 result) { - Quaternion v = new Quaternion(vec.X, vec.Y, 0, 0); - Quaternion i; - Quaternion t; + Quaternion v = new Quaternion(vec.X, vec.Y, 0, 0), i, t; Quaternion.Invert(ref quat, out i); - t = i * v; - v = t * quat; + Quaternion.Multiply(ref quat, ref v, out t); + Quaternion.Multiply(ref t, ref i, out v); result = new Vector2(v.X, v.Y); } diff --git a/Source/OpenTK/Math/Vector2d.cs b/Source/OpenTK/Math/Vector2d.cs index 4c4c68f9..70bddeab 100644 --- a/Source/OpenTK/Math/Vector2d.cs +++ b/Source/OpenTK/Math/Vector2d.cs @@ -796,12 +796,10 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector2d vec, ref Quaterniond quat, out Vector2d result) { - Quaterniond v = new Quaterniond(vec.X, vec.Y, 0, 0); - Quaterniond i; - Quaterniond t; + Quaterniond v = new Quaterniond(vec.X, vec.Y, 0, 0), i, t; Quaterniond.Invert(ref quat, out i); - t = i * v; - v = t * quat; + Quaterniond.Multiply(ref quat, ref v, out t); + Quaterniond.Multiply(ref t, ref i, out v); result = new Vector2d(v.X, v.Y); } diff --git a/Source/OpenTK/Math/Vector3.cs b/Source/OpenTK/Math/Vector3.cs index 35e52064..f297c110 100644 --- a/Source/OpenTK/Math/Vector3.cs +++ b/Source/OpenTK/Math/Vector3.cs @@ -1115,12 +1115,10 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector3 vec, ref Quaternion quat, out Vector3 result) { - Quaternion v = new Quaternion(vec.X, vec.Y, vec.Z, 0); - Quaternion i; - Quaternion t; + Quaternion v = new Quaternion(vec.X, vec.Y, vec.Z, 0), i, t; Quaternion.Invert(ref quat, out i); - t = i * v; - v = t * quat; + Quaternion.Multiply(ref quat, ref v, out t); + Quaternion.Multiply(ref t, ref i, out v); result = new Vector3(v.X, v.Y, v.Z); } diff --git a/Source/OpenTK/Math/Vector3d.cs b/Source/OpenTK/Math/Vector3d.cs index 9ad39e2f..2c1fdc99 100644 --- a/Source/OpenTK/Math/Vector3d.cs +++ b/Source/OpenTK/Math/Vector3d.cs @@ -1111,12 +1111,10 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector3d vec, ref Quaterniond quat, out Vector3d result) { - Quaterniond v = new Quaterniond(vec.X, vec.Y, vec.Z, 0); - Quaterniond i; - Quaterniond t; + Quaterniond v = new Quaterniond(vec.X, vec.Y, vec.Z, 0), i, t; Quaterniond.Invert(ref quat, out i); - t = i * v; - v = t * quat; + Quaterniond.Multiply(ref quat, ref v, out t); + Quaterniond.Multiply(ref t, ref i, out v); result = new Vector3d(v.X, v.Y, v.Z); } diff --git a/Source/OpenTK/Math/Vector4.cs b/Source/OpenTK/Math/Vector4.cs index 0994241b..f13a6fe0 100644 --- a/Source/OpenTK/Math/Vector4.cs +++ b/Source/OpenTK/Math/Vector4.cs @@ -963,12 +963,10 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector4 vec, ref Quaternion quat, out Vector4 result) { - Quaternion v = new Quaternion(vec.X, vec.Y, vec.Z, vec.W); - Quaternion i; - Quaternion t; + Quaternion v = new Quaternion(vec.X, vec.Y, vec.Z, vec.W), i, t; Quaternion.Invert(ref quat, out i); - t = i * v; - v = t * quat; + Quaternion.Multiply(ref quat, ref v, out t); + Quaternion.Multiply(ref t, ref i, out v); result = new Vector4(v.X, v.Y, v.Z, v.W); } diff --git a/Source/OpenTK/Math/Vector4d.cs b/Source/OpenTK/Math/Vector4d.cs index 9cfe2c98..abe6d164 100644 --- a/Source/OpenTK/Math/Vector4d.cs +++ b/Source/OpenTK/Math/Vector4d.cs @@ -966,12 +966,10 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector4d vec, ref Quaterniond quat, out Vector4d result) { - Quaterniond v = new Quaterniond(vec.X, vec.Y, vec.Z, vec.W); - Quaterniond i; - Quaterniond t; + Quaterniond v = new Quaterniond(vec.X, vec.Y, vec.Z, vec.W), i, t; Quaterniond.Invert(ref quat, out i); - t = i * v; - v = t * quat; + Quaterniond.Multiply(ref quat, ref v, out t); + Quaterniond.Multiply(ref t, ref i, out v); result = new Vector4d(v.X, v.Y, v.Z, v.W); } From bbe606da5398a2dec4891bca15f9d2bbdc43a677 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 13:23:04 +0000 Subject: [PATCH 21/27] Vector3(d).Cross: do not modify 'result' more than once to ensure that Cross(ref a, ref b, out a) works correctly. Optimized vector-quaternion transform. Fixes issue [#1373]: "[Math] optimize Vector transform by Quaternion". --- Source/OpenTK/Math/Vector3.cs | 27 +++++++++++++++------------ Source/OpenTK/Math/Vector3d.cs | 27 +++++++++++++++------------ 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/Source/OpenTK/Math/Vector3.cs b/Source/OpenTK/Math/Vector3.cs index f297c110..9baa652e 100644 --- a/Source/OpenTK/Math/Vector3.cs +++ b/Source/OpenTK/Math/Vector3.cs @@ -837,9 +837,9 @@ namespace OpenTK /// The cross product of the two inputs public static Vector3 Cross(Vector3 left, Vector3 right) { - return new Vector3(left.Y * right.Z - left.Z * right.Y, - left.Z * right.X - left.X * right.Z, - left.X * right.Y - left.Y * right.X); + Vector3 result; + Cross(ref left, ref right, out result); + return result; } /// @@ -851,9 +851,9 @@ namespace OpenTK /// The cross product of the two inputs public static void Cross(ref Vector3 left, ref Vector3 right, out Vector3 result) { - result.X = left.Y * right.Z - left.Z * right.Y; - result.Y = left.Z * right.X - left.X * right.Z; - result.Z = left.X * right.Y - left.Y * right.X; + result = new Vector3(left.Y * right.Z - left.Z * right.Y, + left.Z * right.X - left.X * right.Z, + left.X * right.Y - left.Y * right.X); } #endregion @@ -1115,12 +1115,15 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector3 vec, ref Quaternion quat, out Vector3 result) { - Quaternion v = new Quaternion(vec.X, vec.Y, vec.Z, 0), i, t; - Quaternion.Invert(ref quat, out i); - Quaternion.Multiply(ref quat, ref v, out t); - Quaternion.Multiply(ref t, ref i, out v); - - result = new Vector3(v.X, v.Y, v.Z); + // Since vec.W == 0, we can optimize quat * vec * quat^-1 as follows: + // vec + 2.0 * cross(quat.xyz, cross(quat.xyz, vec) + quat.w * vec) + Vector3 xyz = quat.Xyz, temp, temp2; + Vector3.Cross(ref xyz, ref vec, out temp); + Vector3.Multiply(ref vec, quat.W, out temp2); + Vector3.Add(ref temp, ref temp2, out temp); + Vector3.Cross(ref xyz, ref temp, out temp); + Vector3.Multiply(ref temp, 2, out temp); + Vector3.Add(ref vec, ref temp, out result); } /// Transform a Vector3 by the given Matrix, and project the resulting Vector4 back to a Vector3 diff --git a/Source/OpenTK/Math/Vector3d.cs b/Source/OpenTK/Math/Vector3d.cs index 2c1fdc99..d7e4d685 100644 --- a/Source/OpenTK/Math/Vector3d.cs +++ b/Source/OpenTK/Math/Vector3d.cs @@ -836,9 +836,9 @@ namespace OpenTK /// The cross product of the two inputs public static Vector3d Cross(Vector3d left, Vector3d right) { - return new Vector3d(left.Y * right.Z - left.Z * right.Y, - left.Z * right.X - left.X * right.Z, - left.X * right.Y - left.Y * right.X); + Vector3d result; + Cross(ref left, ref right, out result); + return result; } /// @@ -850,9 +850,9 @@ namespace OpenTK /// The cross product of the two inputs public static void Cross(ref Vector3d left, ref Vector3d right, out Vector3d result) { - result.X = left.Y * right.Z - left.Z * right.Y; - result.Y = left.Z * right.X - left.X * right.Z; - result.Z = left.X * right.Y - left.Y * right.X; + result = new Vector3d(left.Y * right.Z - left.Z * right.Y, + left.Z * right.X - left.X * right.Z, + left.X * right.Y - left.Y * right.X); } #endregion @@ -1111,12 +1111,15 @@ namespace OpenTK /// The result of the operation. public static void Transform(ref Vector3d vec, ref Quaterniond quat, out Vector3d result) { - Quaterniond v = new Quaterniond(vec.X, vec.Y, vec.Z, 0), i, t; - Quaterniond.Invert(ref quat, out i); - Quaterniond.Multiply(ref quat, ref v, out t); - Quaterniond.Multiply(ref t, ref i, out v); - - result = new Vector3d(v.X, v.Y, v.Z); + // Since vec.W == 0, we can optimize quat * vec * quat^-1 as follows: + // vec + 2.0 * cross(quat.xyz, cross(quat.xyz, vec) + quat.w * vec) + Vector3d xyz = quat.Xyz, temp, temp2; + Vector3d.Cross(ref xyz, ref vec, out temp); + Vector3d.Multiply(ref vec, quat.W, out temp2); + Vector3d.Add(ref temp, ref temp2, out temp); + Vector3d.Cross(ref xyz, ref temp, out temp); + Vector3d.Multiply(ref temp, 2, out temp); + Vector3d.Add(ref vec, ref temp, out result); } /// From 9cb660bf852c65ab63e53f01d4aa3bf78fec4b6f Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 14:15:56 +0000 Subject: [PATCH 22/27] Added new OpenGL 3.x tokens to GenerateMipmap. Fixes issue [#1162]: "GL.GenerateMipmap argument". --- Source/Bind/Specifications/GL2/enumext.spec | 6 ++++++ Source/OpenTK/Graphics/OpenGL/GLEnums.cs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Source/Bind/Specifications/GL2/enumext.spec b/Source/Bind/Specifications/GL2/enumext.spec index 9c5ff5a9..ce94eab6 100644 --- a/Source/Bind/Specifications/GL2/enumext.spec +++ b/Source/Bind/Specifications/GL2/enumext.spec @@ -7721,7 +7721,11 @@ BufferPointerNameARB enum: GenerateMipmapTarget enum: use TextureTarget TEXTURE_1D + use TextureTarget TEXTURE_1D_ARRAY use TextureTarget TEXTURE_2D + use TextureTarget TEXTURE_2D_ARRAY + use TextureTarget TEXTURE_2D_MULTISAMPLE + use TextureTarget TEXTURE_2D_MULTISAMPLE_ARRAY use TextureTarget TEXTURE_3D use TextureTarget TEXTURE_CUBE_MAP @@ -7839,7 +7843,9 @@ GetTextureParameter enum: TextureTarget enum: TEXTURE_2D_MULTISAMPLE = 0x9100 + PROXY_TEXTURE_2D_MULTISAMPLE = 0x9101 TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9102 + PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9103 ActiveUniformType enum: SAMPLER_2D_MULTISAMPLE = 0x9108 diff --git a/Source/OpenTK/Graphics/OpenGL/GLEnums.cs b/Source/OpenTK/Graphics/OpenGL/GLEnums.cs index 6624ccae..67badec1 100644 --- a/Source/OpenTK/Graphics/OpenGL/GLEnums.cs +++ b/Source/OpenTK/Graphics/OpenGL/GLEnums.cs @@ -7016,6 +7016,10 @@ namespace OpenTK.Graphics.OpenGL Texture2D = ((int)0x0DE1), Texture3D = ((int)0x806F), TextureCubeMap = ((int)0x8513), + Texture1DArray = ((int)0x8C18), + Texture2DArray = ((int)0x8C1A), + Texture2DMultisample = ((int)0x9100), + Texture2DMultisampleArray = ((int)0x9102), } public enum GetColorTableParameterPName : int @@ -10457,7 +10461,9 @@ namespace OpenTK.Graphics.OpenGL ProxyTexture2DArray = ((int)0x8C1B), TextureBuffer = ((int)0x8C2A), Texture2DMultisample = ((int)0x9100), + ProxyTexture2DMultisample = ((int)0x9101), Texture2DMultisampleArray = ((int)0x9102), + ProxyTexture2DMultisampleArray = ((int)0x9103), } public enum TextureTargetMultisample : int From b96aaabcaedce7d133624a5e754bda4f05542728 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 14:28:37 +0000 Subject: [PATCH 23/27] Made unix kernel detection less strict. The program is now allowed to run even the specific kernel name is unknown. Partly fixes issue [#1382]: "OpenTK and other Unix OS". --- Source/OpenTK/Configuration.cs | 37 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Source/OpenTK/Configuration.cs b/Source/OpenTK/Configuration.cs index ad844296..4b855f3c 100644 --- a/Source/OpenTK/Configuration.cs +++ b/Source/OpenTK/Configuration.cs @@ -53,25 +53,26 @@ namespace OpenTK else if (System.Environment.OSVersion.Platform == PlatformID.Unix || System.Environment.OSVersion.Platform == (PlatformID)4) { - - // Distinguish between Unix and Mac OS X kernels. - switch (DetectUnixKernel()) + // Distinguish between Linux, Mac OS X and other Unix operating systems. + string kernel_name = DetectUnixKernel(); + switch (kernel_name) { - case "Unix": - runningOnUnix = true; - break; - - case "Linux": - runningOnLinux = runningOnUnix = true; - break; - - case "Darwin": - runningOnMacOS = runningOnUnix = true; - break; + case null: + case "": + throw new PlatformNotSupportedException( + "Unknown platform. Please file a bug report at http://www.opentk.com/node/add/project-issue/opentk"); - default: - throw new PlatformNotSupportedException( - DetectUnixKernel() + ": Unknown Unix platform. Please report this error at http://www.opentk.com."); + case "Linux": + runningOnLinux = runningOnUnix = true; + break; + + case "Darwin": + runningOnMacOS = runningOnUnix = true; + break; + + default: + runningOnUnix = true; + break; } } else @@ -178,7 +179,7 @@ namespace OpenTK } /// - /// Detects the unix kernel by p/invoking the uname call in libc. + /// Detects the unix kernel by p/invoking uname (libc). /// /// private static string DetectUnixKernel() From fa2cdee5efa98df96b98f4a9b10b3aca3fc17b62 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 15:00:24 +0000 Subject: [PATCH 24/27] Removed invalid BGRA token from VertexAttribPointerType. --- Source/Bind/Specifications/GL2/enumext.spec | 12 +++++++----- Source/OpenTK/Graphics/OpenGL/GLEnums.cs | 2 -- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Bind/Specifications/GL2/enumext.spec b/Source/Bind/Specifications/GL2/enumext.spec index ce94eab6..8db0a713 100644 --- a/Source/Bind/Specifications/GL2/enumext.spec +++ b/Source/Bind/Specifications/GL2/enumext.spec @@ -7906,12 +7906,14 @@ GetPName enum: # ARB_vertex_array_bgra tokens # http://www.opengl.org/registry/specs/ARB/vertex_array_bgra.txt +# The following tokens are incorrect. They are valid for the +# parameteter, not the parameter - but is not an enum! +# (Maybe something changed between the ARB spec and its core version?) +#ColorPointerType enum: +# BGRA = 0x80E1 -ColorPointerType enum: - BGRA = 0x80E1 - -VertexAttribPointerType enum: - BGRA = 0x80E1 +#VertexAttribPointerType enum: +# BGRA = 0x80E1 # ARB_seamless_cube_map tokens # http://www.opengl.org/registry/specs/ARB/seamless_cube_map.txt diff --git a/Source/OpenTK/Graphics/OpenGL/GLEnums.cs b/Source/OpenTK/Graphics/OpenGL/GLEnums.cs index 67badec1..014e1c07 100644 --- a/Source/OpenTK/Graphics/OpenGL/GLEnums.cs +++ b/Source/OpenTK/Graphics/OpenGL/GLEnums.cs @@ -5418,7 +5418,6 @@ namespace OpenTK.Graphics.OpenGL Float = ((int)0x1406), Double = ((int)0x140A), HalfFloat = ((int)0x140B), - Bgra = ((int)0x80E1), } public enum ColorTableParameterPName : int @@ -11928,7 +11927,6 @@ namespace OpenTK.Graphics.OpenGL Float = ((int)0x1406), Double = ((int)0x140A), HalfFloat = ((int)0x140B), - Bgra = ((int)0x80E1), } public enum VertexAttribPointerTypeArb : int From 9d3c251c75c81a5e74b2c6e6bcaa0860d11e4b10 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 15:13:57 +0000 Subject: [PATCH 25/27] VertexAttribIPointer should take the integer subset (VertexAttribIPointerType) of VertexAttribPointerType. Fixes issue [#1166]: "VertexAttribIPointer pointer type parameter". --- Source/Bind/Specifications/GL2/enumext.spec | 11 +++++ .../Bind/Specifications/GL2/gloverrides.xml | 2 +- Source/OpenTK/Graphics/OpenGL/GL.cs | 40 +++++++++---------- Source/OpenTK/Graphics/OpenGL/GLCore.cs | 2 +- Source/OpenTK/Graphics/OpenGL/GLDelegates.cs | 2 +- Source/OpenTK/Graphics/OpenGL/GLEnums.cs | 10 +++++ 6 files changed, 44 insertions(+), 23 deletions(-) diff --git a/Source/Bind/Specifications/GL2/enumext.spec b/Source/Bind/Specifications/GL2/enumext.spec index 8db0a713..acc73255 100644 --- a/Source/Bind/Specifications/GL2/enumext.spec +++ b/Source/Bind/Specifications/GL2/enumext.spec @@ -7937,4 +7937,15 @@ GetPName enum: # ARB_draw_elements_base_vertex tokens # http://www.opengl.org/registry/specs/ARB/draw_elements_base_vertex.txt +# VertexAttribIPointerType (see OpenGL 3.2 reference card) +# Note: the underscore is there to avoid changing IPointer to Ipointer. +VertexAttribI_PointerType enum: + use DataType BYTE + use DataType UNSIGNED_BYTE + use DataType SHORT + use DataType UNSIGNED_SHORT + use DataType INT + use DataType UNSIGNED_INT + + # End (don't remove, or the last token may be removed!) diff --git a/Source/Bind/Specifications/GL2/gloverrides.xml b/Source/Bind/Specifications/GL2/gloverrides.xml index e9321d3d..85a04912 100644 --- a/Source/Bind/Specifications/GL2/gloverrides.xml +++ b/Source/Bind/Specifications/GL2/gloverrides.xml @@ -247,7 +247,7 @@ - VertexAttribParameter + VertexAttribIPointerType diff --git a/Source/OpenTK/Graphics/OpenGL/GL.cs b/Source/OpenTK/Graphics/OpenGL/GL.cs index 7daffdf8..b7a7afdf 100644 --- a/Source/OpenTK/Graphics/OpenGL/GL.cs +++ b/Source/OpenTK/Graphics/OpenGL/GL.cs @@ -80549,7 +80549,7 @@ namespace OpenTK.Graphics.OpenGL [AutoGenerated(Category = "Version30", Version = "3.0", EntryPoint = "glVertexAttribIPointer")] public static - void VertexAttribIPointer(Int32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribParameter type, Int32 stride, [InAttribute, OutAttribute] ref T4 pointer) + void VertexAttribIPointer(Int32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribIPointerType type, Int32 stride, [InAttribute, OutAttribute] ref T4 pointer) where T4 : struct { #if DEBUG @@ -80559,7 +80559,7 @@ namespace OpenTK.Graphics.OpenGL GCHandle pointer_ptr = GCHandle.Alloc(pointer, GCHandleType.Pinned); try { - Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribParameter)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); + Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribIPointerType)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); pointer = (T4)pointer_ptr.Target; } finally @@ -80573,7 +80573,7 @@ namespace OpenTK.Graphics.OpenGL [AutoGenerated(Category = "Version30", Version = "3.0", EntryPoint = "glVertexAttribIPointer")] public static - void VertexAttribIPointer(Int32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribParameter type, Int32 stride, [InAttribute, OutAttribute] T4[,,] pointer) + void VertexAttribIPointer(Int32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribIPointerType type, Int32 stride, [InAttribute, OutAttribute] T4[,,] pointer) where T4 : struct { #if DEBUG @@ -80583,7 +80583,7 @@ namespace OpenTK.Graphics.OpenGL GCHandle pointer_ptr = GCHandle.Alloc(pointer, GCHandleType.Pinned); try { - Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribParameter)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); + Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribIPointerType)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); } finally { @@ -80596,7 +80596,7 @@ namespace OpenTK.Graphics.OpenGL [AutoGenerated(Category = "Version30", Version = "3.0", EntryPoint = "glVertexAttribIPointer")] public static - void VertexAttribIPointer(Int32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribParameter type, Int32 stride, [InAttribute, OutAttribute] T4[,] pointer) + void VertexAttribIPointer(Int32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribIPointerType type, Int32 stride, [InAttribute, OutAttribute] T4[,] pointer) where T4 : struct { #if DEBUG @@ -80606,7 +80606,7 @@ namespace OpenTK.Graphics.OpenGL GCHandle pointer_ptr = GCHandle.Alloc(pointer, GCHandleType.Pinned); try { - Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribParameter)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); + Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribIPointerType)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); } finally { @@ -80619,7 +80619,7 @@ namespace OpenTK.Graphics.OpenGL [AutoGenerated(Category = "Version30", Version = "3.0", EntryPoint = "glVertexAttribIPointer")] public static - void VertexAttribIPointer(Int32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribParameter type, Int32 stride, [InAttribute, OutAttribute] T4[] pointer) + void VertexAttribIPointer(Int32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribIPointerType type, Int32 stride, [InAttribute, OutAttribute] T4[] pointer) where T4 : struct { #if DEBUG @@ -80629,7 +80629,7 @@ namespace OpenTK.Graphics.OpenGL GCHandle pointer_ptr = GCHandle.Alloc(pointer, GCHandleType.Pinned); try { - Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribParameter)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); + Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribIPointerType)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); } finally { @@ -80642,13 +80642,13 @@ namespace OpenTK.Graphics.OpenGL [AutoGenerated(Category = "Version30", Version = "3.0", EntryPoint = "glVertexAttribIPointer")] public static - void VertexAttribIPointer(Int32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribParameter type, Int32 stride, IntPtr pointer) + void VertexAttribIPointer(Int32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribIPointerType type, Int32 stride, IntPtr pointer) { #if DEBUG using (new ErrorHelper(GraphicsContext.CurrentContext)) { #endif - Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribParameter)type, (Int32)stride, (IntPtr)pointer); + Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribIPointerType)type, (Int32)stride, (IntPtr)pointer); #if DEBUG } #endif @@ -80657,7 +80657,7 @@ namespace OpenTK.Graphics.OpenGL [System.CLSCompliant(false)] [AutoGenerated(Category = "Version30", Version = "3.0", EntryPoint = "glVertexAttribIPointer")] public static - void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribParameter type, Int32 stride, [InAttribute, OutAttribute] ref T4 pointer) + void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribIPointerType type, Int32 stride, [InAttribute, OutAttribute] ref T4 pointer) where T4 : struct { #if DEBUG @@ -80667,7 +80667,7 @@ namespace OpenTK.Graphics.OpenGL GCHandle pointer_ptr = GCHandle.Alloc(pointer, GCHandleType.Pinned); try { - Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribParameter)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); + Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribIPointerType)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); pointer = (T4)pointer_ptr.Target; } finally @@ -80682,7 +80682,7 @@ namespace OpenTK.Graphics.OpenGL [System.CLSCompliant(false)] [AutoGenerated(Category = "Version30", Version = "3.0", EntryPoint = "glVertexAttribIPointer")] public static - void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribParameter type, Int32 stride, [InAttribute, OutAttribute] T4[,,] pointer) + void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribIPointerType type, Int32 stride, [InAttribute, OutAttribute] T4[,,] pointer) where T4 : struct { #if DEBUG @@ -80692,7 +80692,7 @@ namespace OpenTK.Graphics.OpenGL GCHandle pointer_ptr = GCHandle.Alloc(pointer, GCHandleType.Pinned); try { - Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribParameter)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); + Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribIPointerType)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); } finally { @@ -80706,7 +80706,7 @@ namespace OpenTK.Graphics.OpenGL [System.CLSCompliant(false)] [AutoGenerated(Category = "Version30", Version = "3.0", EntryPoint = "glVertexAttribIPointer")] public static - void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribParameter type, Int32 stride, [InAttribute, OutAttribute] T4[,] pointer) + void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribIPointerType type, Int32 stride, [InAttribute, OutAttribute] T4[,] pointer) where T4 : struct { #if DEBUG @@ -80716,7 +80716,7 @@ namespace OpenTK.Graphics.OpenGL GCHandle pointer_ptr = GCHandle.Alloc(pointer, GCHandleType.Pinned); try { - Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribParameter)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); + Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribIPointerType)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); } finally { @@ -80730,7 +80730,7 @@ namespace OpenTK.Graphics.OpenGL [System.CLSCompliant(false)] [AutoGenerated(Category = "Version30", Version = "3.0", EntryPoint = "glVertexAttribIPointer")] public static - void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribParameter type, Int32 stride, [InAttribute, OutAttribute] T4[] pointer) + void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribIPointerType type, Int32 stride, [InAttribute, OutAttribute] T4[] pointer) where T4 : struct { #if DEBUG @@ -80740,7 +80740,7 @@ namespace OpenTK.Graphics.OpenGL GCHandle pointer_ptr = GCHandle.Alloc(pointer, GCHandleType.Pinned); try { - Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribParameter)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); + Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribIPointerType)type, (Int32)stride, (IntPtr)pointer_ptr.AddrOfPinnedObject()); } finally { @@ -80754,13 +80754,13 @@ namespace OpenTK.Graphics.OpenGL [System.CLSCompliant(false)] [AutoGenerated(Category = "Version30", Version = "3.0", EntryPoint = "glVertexAttribIPointer")] public static - void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribParameter type, Int32 stride, IntPtr pointer) + void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribIPointerType type, Int32 stride, IntPtr pointer) { #if DEBUG using (new ErrorHelper(GraphicsContext.CurrentContext)) { #endif - Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribParameter)type, (Int32)stride, (IntPtr)pointer); + Delegates.glVertexAttribIPointer((UInt32)index, (Int32)size, (OpenTK.Graphics.OpenGL.VertexAttribIPointerType)type, (Int32)stride, (IntPtr)pointer); #if DEBUG } #endif diff --git a/Source/OpenTK/Graphics/OpenGL/GLCore.cs b/Source/OpenTK/Graphics/OpenGL/GLCore.cs index 98bd9f26..44481ec0 100644 --- a/Source/OpenTK/Graphics/OpenGL/GLCore.cs +++ b/Source/OpenTK/Graphics/OpenGL/GLCore.cs @@ -5339,7 +5339,7 @@ namespace OpenTK.Graphics.OpenGL internal extern static unsafe void VertexAttribI4usvEXT(UInt32 index, UInt16* v); [System.Security.SuppressUnmanagedCodeSecurity()] [System.Runtime.InteropServices.DllImport(GL.Library, EntryPoint = "glVertexAttribIPointer", ExactSpelling = true)] - internal extern static void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribParameter type, Int32 stride, IntPtr pointer); + internal extern static void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribIPointerType type, Int32 stride, IntPtr pointer); [System.Security.SuppressUnmanagedCodeSecurity()] [System.Runtime.InteropServices.DllImport(GL.Library, EntryPoint = "glVertexAttribIPointerEXT", ExactSpelling = true)] internal extern static void VertexAttribIPointerEXT(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.NvVertexProgram4 type, Int32 stride, IntPtr pointer); diff --git a/Source/OpenTK/Graphics/OpenGL/GLDelegates.cs b/Source/OpenTK/Graphics/OpenGL/GLDelegates.cs index e41d10b9..442e664d 100644 --- a/Source/OpenTK/Graphics/OpenGL/GLDelegates.cs +++ b/Source/OpenTK/Graphics/OpenGL/GLDelegates.cs @@ -5337,7 +5337,7 @@ namespace OpenTK.Graphics.OpenGL internal unsafe delegate void VertexAttribI4usvEXT(UInt32 index, UInt16* v); internal unsafe static VertexAttribI4usvEXT glVertexAttribI4usvEXT; [System.Security.SuppressUnmanagedCodeSecurity()] - internal delegate void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribParameter type, Int32 stride, IntPtr pointer); + internal delegate void VertexAttribIPointer(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.VertexAttribIPointerType type, Int32 stride, IntPtr pointer); internal static VertexAttribIPointer glVertexAttribIPointer; [System.Security.SuppressUnmanagedCodeSecurity()] internal delegate void VertexAttribIPointerEXT(UInt32 index, Int32 size, OpenTK.Graphics.OpenGL.NvVertexProgram4 type, Int32 stride, IntPtr pointer); diff --git a/Source/OpenTK/Graphics/OpenGL/GLEnums.cs b/Source/OpenTK/Graphics/OpenGL/GLEnums.cs index 014e1c07..79d48f6c 100644 --- a/Source/OpenTK/Graphics/OpenGL/GLEnums.cs +++ b/Source/OpenTK/Graphics/OpenGL/GLEnums.cs @@ -11884,6 +11884,16 @@ namespace OpenTK.Graphics.OpenGL TimeoutIgnored = unchecked((int)0xFFFFFFFFFFFFFFFF), } + public enum VertexAttribIPointerType : int + { + Byte = ((int)0x1400), + UnsignedByte = ((int)0x1401), + Short = ((int)0x1402), + UnsignedShort = ((int)0x1403), + Int = ((int)0x1404), + UnsignedInt = ((int)0x1405), + } + public enum VertexAttribParameter : int { ArrayEnabled = ((int)0x8622), From 4e04838148f556d4bbd53c7c40c5662b73d37ed9 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 16:14:32 +0000 Subject: [PATCH 26/27] Added new OpenGL 3.1 tokens for ARB_texture_rectangle, ARB_shader_objects and EXT_gpu_shader4. Fixes issue [#1355]: "TextureRectangle tokens for ActiveUniformType". --- Source/Bind/Specifications/GL2/enumext.spec | 18 ++++++++++++++++++ Source/OpenTK/Graphics/OpenGL/GLEnums.cs | 11 +++++++++++ 2 files changed, 29 insertions(+) diff --git a/Source/Bind/Specifications/GL2/enumext.spec b/Source/Bind/Specifications/GL2/enumext.spec index acc73255..d9dc5837 100644 --- a/Source/Bind/Specifications/GL2/enumext.spec +++ b/Source/Bind/Specifications/GL2/enumext.spec @@ -7556,6 +7556,24 @@ SizedInternalFormat enum: use PixelInternalFormat RGBA8UI use PixelInternalFormat RGBA16UI use PixelInternalFormat RGBA32UI + +TextureTarget enum: + TEXTURE_RECTANGLE = 0x84F5 # ARB_texture_rectangle + PROXY_TEXTURE_RECTANGLE = 0x84F7 # ARB_texture_rectangle + +GetPName enum: + TEXTURE_BINDING_RECTANGLE = 0x84F6 # ARB_texture_rectangle + MAX_RECTANGLE_TEXTURE_SIZE = 0x84F8 # ARB_texture_rectangle + +ActiveUniformType enum: + SAMPLER_2D_RECT = 0x8B63 # ARB_shader_objects + ARB_texture_rectangle + SAMPLER_2D_RECT_SHADOW = 0x8B64 # ARB_shader_objects + ARB_texture_rectangle + SAMPLER_BUFFER = 0x8DC2 # EXT_gpu_shader4 + ARB_texture_buffer_object + INT_SAMPLER_2D_RECT = 0x8DCD # EXT_gpu_shader4 + ARB_texture_rectangle + INT_SAMPLER_BUFFER = 0x8DD0 # EXT_gpu_shader4 + ARB_texture_buffer_object + UNSIGNED_INT_SAMPLER_2D_RECT = 0x8DD5 # EXT_gpu_shader4 + ARB_texture_rectangle + UNSIGNED_INT_SAMPLER_BUFFER = 0x8DD8 # EXT_gpu_shader4 + ARB_texture_buffer_object + # Non-core diff --git a/Source/OpenTK/Graphics/OpenGL/GLEnums.cs b/Source/OpenTK/Graphics/OpenGL/GLEnums.cs index 79d48f6c..a1411370 100644 --- a/Source/OpenTK/Graphics/OpenGL/GLEnums.cs +++ b/Source/OpenTK/Graphics/OpenGL/GLEnums.cs @@ -74,6 +74,8 @@ namespace OpenTK.Graphics.OpenGL SamplerCube = ((int)0x8B60), Sampler1DShadow = ((int)0x8B61), Sampler2DShadow = ((int)0x8B62), + Sampler2DRect = ((int)0x8B63), + Sampler2DRectShadow = ((int)0x8B64), FloatMat2x3 = ((int)0x8B65), FloatMat2x4 = ((int)0x8B66), FloatMat3x2 = ((int)0x8B67), @@ -82,6 +84,7 @@ namespace OpenTK.Graphics.OpenGL FloatMat4x3 = ((int)0x8B6A), Sampler1DArray = ((int)0x8DC0), Sampler2DArray = ((int)0x8DC1), + SamplerBuffer = ((int)0x8DC2), Sampler1DArrayShadow = ((int)0x8DC3), Sampler2DArrayShadow = ((int)0x8DC4), SamplerCubeShadow = ((int)0x8DC5), @@ -92,14 +95,18 @@ namespace OpenTK.Graphics.OpenGL IntSampler2D = ((int)0x8DCA), IntSampler3D = ((int)0x8DCB), IntSamplerCube = ((int)0x8DCC), + IntSampler2DRect = ((int)0x8DCD), IntSampler1DArray = ((int)0x8DCE), IntSampler2DArray = ((int)0x8DCF), + IntSamplerBuffer = ((int)0x8DD0), UnsignedIntSampler1D = ((int)0x8DD1), UnsignedIntSampler2D = ((int)0x8DD2), UnsignedIntSampler3D = ((int)0x8DD3), UnsignedIntSamplerCube = ((int)0x8DD4), + UnsignedIntSampler2DRect = ((int)0x8DD5), UnsignedIntSampler1DArray = ((int)0x8DD6), UnsignedIntSampler2DArray = ((int)0x8DD7), + UnsignedIntSamplerBuffer = ((int)0x8DD8), Sampler2DMultisample = ((int)0x9108), IntSampler2DMultisample = ((int)0x9109), UnsignedIntSampler2DMultisample = ((int)0x910A), @@ -7569,6 +7576,8 @@ namespace OpenTK.Graphics.OpenGL MaxRenderbufferSize = ((int)0x84E8), MaxRenderbufferSizeExt = ((int)0x84E8), TextureCompressionHint = ((int)0x84EF), + TextureBindingRectangle = ((int)0x84F6), + MaxRectangleTextureSize = ((int)0x84F8), MaxTextureLodBias = ((int)0x84FD), TextureCubeMap = ((int)0x8513), TextureBindingCubeMap = ((int)0x8514), @@ -10443,8 +10452,10 @@ namespace OpenTK.Graphics.OpenGL TextureMaxLod = ((int)0x813B), TextureBaseLevel = ((int)0x813C), TextureMaxLevel = ((int)0x813D), + TextureRectangle = ((int)0x84F5), TextureRectangleArb = ((int)0x84F5), TextureRectangleNv = ((int)0x84F5), + ProxyTextureRectangle = ((int)0x84F7), TextureCubeMap = ((int)0x8513), TextureBindingCubeMap = ((int)0x8514), TextureCubeMapPositiveX = ((int)0x8515), From 3aa67b84a31177d2f5dca4c5ebce0a4b8f45ba4e Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 16 Nov 2009 16:23:36 +0000 Subject: [PATCH 27/27] Added strongly-typed tokens for GetActiveUniformBlock, which was introduced in OpenGL 3.1. Fixes issue [#1216]: "[GL] GetActiveUniformBlock* methods take ArbUniformBufferObject parameters". --- Source/Bind/Specifications/GL2/enumext.spec | 9 +++++++ .../Bind/Specifications/GL2/gloverrides.xml | 4 ++++ Source/OpenTK/Graphics/OpenGL/GL.cs | 24 +++++++++---------- Source/OpenTK/Graphics/OpenGL/GLCore.cs | 2 +- Source/OpenTK/Graphics/OpenGL/GLDelegates.cs | 2 +- Source/OpenTK/Graphics/OpenGL/GLEnums.cs | 11 +++++++++ 6 files changed, 38 insertions(+), 14 deletions(-) diff --git a/Source/Bind/Specifications/GL2/enumext.spec b/Source/Bind/Specifications/GL2/enumext.spec index d9dc5837..0e7ca858 100644 --- a/Source/Bind/Specifications/GL2/enumext.spec +++ b/Source/Bind/Specifications/GL2/enumext.spec @@ -7573,6 +7573,15 @@ ActiveUniformType enum: INT_SAMPLER_BUFFER = 0x8DD0 # EXT_gpu_shader4 + ARB_texture_buffer_object UNSIGNED_INT_SAMPLER_2D_RECT = 0x8DD5 # EXT_gpu_shader4 + ARB_texture_rectangle UNSIGNED_INT_SAMPLER_BUFFER = 0x8DD8 # EXT_gpu_shader4 + ARB_texture_buffer_object + +ActiveUniformBlockParameter enum: + use ARB_uniform_buffer_object UNIFORM_BLOCK_BINDING + use ARB_uniform_buffer_object UNIFORM_BLOCK_DATA_SIZE + use ARB_uniform_buffer_object UNIFORM_BLOCK_NAME_LENGTH + use ARB_uniform_buffer_object UNIFORM_BLOCK_ACTIVE_UNIFORMS + use ARB_uniform_buffer_object UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES + use ARB_uniform_buffer_object UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER + use ARB_uniform_buffer_object UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER # Non-core diff --git a/Source/Bind/Specifications/GL2/gloverrides.xml b/Source/Bind/Specifications/GL2/gloverrides.xml index 85a04912..cd42adf6 100644 --- a/Source/Bind/Specifications/GL2/gloverrides.xml +++ b/Source/Bind/Specifications/GL2/gloverrides.xml @@ -269,6 +269,10 @@ SizedInternalFormat + + ActiveUniformBlockParameter + + diff --git a/Source/OpenTK/Graphics/OpenGL/GL.cs b/Source/OpenTK/Graphics/OpenGL/GL.cs index b7a7afdf..8dfe3f8d 100644 --- a/Source/OpenTK/Graphics/OpenGL/GL.cs +++ b/Source/OpenTK/Graphics/OpenGL/GL.cs @@ -41812,13 +41812,13 @@ namespace OpenTK.Graphics.OpenGL [System.CLSCompliant(false)] [AutoGenerated(Category = "ArbUniformBufferObject", Version = "2.0", EntryPoint = "glGetActiveUniformBlockiv")] public static - unsafe void GetActiveUniformBlock(Int32 program, Int32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ArbUniformBufferObject pname, [OutAttribute] Int32* @params) + unsafe void GetActiveUniformBlock(Int32 program, Int32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter pname, [OutAttribute] Int32* @params) { #if DEBUG using (new ErrorHelper(GraphicsContext.CurrentContext)) { #endif - Delegates.glGetActiveUniformBlockiv((UInt32)program, (UInt32)uniformBlockIndex, (OpenTK.Graphics.OpenGL.ArbUniformBufferObject)pname, (Int32*)@params); + Delegates.glGetActiveUniformBlockiv((UInt32)program, (UInt32)uniformBlockIndex, (OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter)pname, (Int32*)@params); #if DEBUG } #endif @@ -41826,7 +41826,7 @@ namespace OpenTK.Graphics.OpenGL [AutoGenerated(Category = "ArbUniformBufferObject", Version = "2.0", EntryPoint = "glGetActiveUniformBlockiv")] public static - void GetActiveUniformBlock(Int32 program, Int32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ArbUniformBufferObject pname, [OutAttribute] Int32[] @params) + void GetActiveUniformBlock(Int32 program, Int32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter pname, [OutAttribute] Int32[] @params) { #if DEBUG using (new ErrorHelper(GraphicsContext.CurrentContext)) @@ -41836,7 +41836,7 @@ namespace OpenTK.Graphics.OpenGL { fixed (Int32* @params_ptr = @params) { - Delegates.glGetActiveUniformBlockiv((UInt32)program, (UInt32)uniformBlockIndex, (OpenTK.Graphics.OpenGL.ArbUniformBufferObject)pname, (Int32*)@params_ptr); + Delegates.glGetActiveUniformBlockiv((UInt32)program, (UInt32)uniformBlockIndex, (OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter)pname, (Int32*)@params_ptr); } } #if DEBUG @@ -41846,7 +41846,7 @@ namespace OpenTK.Graphics.OpenGL [AutoGenerated(Category = "ArbUniformBufferObject", Version = "2.0", EntryPoint = "glGetActiveUniformBlockiv")] public static - void GetActiveUniformBlock(Int32 program, Int32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ArbUniformBufferObject pname, [OutAttribute] out Int32 @params) + void GetActiveUniformBlock(Int32 program, Int32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter pname, [OutAttribute] out Int32 @params) { #if DEBUG using (new ErrorHelper(GraphicsContext.CurrentContext)) @@ -41856,7 +41856,7 @@ namespace OpenTK.Graphics.OpenGL { fixed (Int32* @params_ptr = &@params) { - Delegates.glGetActiveUniformBlockiv((UInt32)program, (UInt32)uniformBlockIndex, (OpenTK.Graphics.OpenGL.ArbUniformBufferObject)pname, (Int32*)@params_ptr); + Delegates.glGetActiveUniformBlockiv((UInt32)program, (UInt32)uniformBlockIndex, (OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter)pname, (Int32*)@params_ptr); @params = *@params_ptr; } } @@ -41868,13 +41868,13 @@ namespace OpenTK.Graphics.OpenGL [System.CLSCompliant(false)] [AutoGenerated(Category = "ArbUniformBufferObject", Version = "2.0", EntryPoint = "glGetActiveUniformBlockiv")] public static - unsafe void GetActiveUniformBlock(UInt32 program, UInt32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ArbUniformBufferObject pname, [OutAttribute] Int32* @params) + unsafe void GetActiveUniformBlock(UInt32 program, UInt32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter pname, [OutAttribute] Int32* @params) { #if DEBUG using (new ErrorHelper(GraphicsContext.CurrentContext)) { #endif - Delegates.glGetActiveUniformBlockiv((UInt32)program, (UInt32)uniformBlockIndex, (OpenTK.Graphics.OpenGL.ArbUniformBufferObject)pname, (Int32*)@params); + Delegates.glGetActiveUniformBlockiv((UInt32)program, (UInt32)uniformBlockIndex, (OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter)pname, (Int32*)@params); #if DEBUG } #endif @@ -41883,7 +41883,7 @@ namespace OpenTK.Graphics.OpenGL [System.CLSCompliant(false)] [AutoGenerated(Category = "ArbUniformBufferObject", Version = "2.0", EntryPoint = "glGetActiveUniformBlockiv")] public static - void GetActiveUniformBlock(UInt32 program, UInt32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ArbUniformBufferObject pname, [OutAttribute] Int32[] @params) + void GetActiveUniformBlock(UInt32 program, UInt32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter pname, [OutAttribute] Int32[] @params) { #if DEBUG using (new ErrorHelper(GraphicsContext.CurrentContext)) @@ -41893,7 +41893,7 @@ namespace OpenTK.Graphics.OpenGL { fixed (Int32* @params_ptr = @params) { - Delegates.glGetActiveUniformBlockiv((UInt32)program, (UInt32)uniformBlockIndex, (OpenTK.Graphics.OpenGL.ArbUniformBufferObject)pname, (Int32*)@params_ptr); + Delegates.glGetActiveUniformBlockiv((UInt32)program, (UInt32)uniformBlockIndex, (OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter)pname, (Int32*)@params_ptr); } } #if DEBUG @@ -41904,7 +41904,7 @@ namespace OpenTK.Graphics.OpenGL [System.CLSCompliant(false)] [AutoGenerated(Category = "ArbUniformBufferObject", Version = "2.0", EntryPoint = "glGetActiveUniformBlockiv")] public static - void GetActiveUniformBlock(UInt32 program, UInt32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ArbUniformBufferObject pname, [OutAttribute] out Int32 @params) + void GetActiveUniformBlock(UInt32 program, UInt32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter pname, [OutAttribute] out Int32 @params) { #if DEBUG using (new ErrorHelper(GraphicsContext.CurrentContext)) @@ -41914,7 +41914,7 @@ namespace OpenTK.Graphics.OpenGL { fixed (Int32* @params_ptr = &@params) { - Delegates.glGetActiveUniformBlockiv((UInt32)program, (UInt32)uniformBlockIndex, (OpenTK.Graphics.OpenGL.ArbUniformBufferObject)pname, (Int32*)@params_ptr); + Delegates.glGetActiveUniformBlockiv((UInt32)program, (UInt32)uniformBlockIndex, (OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter)pname, (Int32*)@params_ptr); @params = *@params_ptr; } } diff --git a/Source/OpenTK/Graphics/OpenGL/GLCore.cs b/Source/OpenTK/Graphics/OpenGL/GLCore.cs index 44481ec0..a8f0e67d 100644 --- a/Source/OpenTK/Graphics/OpenGL/GLCore.cs +++ b/Source/OpenTK/Graphics/OpenGL/GLCore.cs @@ -1526,7 +1526,7 @@ namespace OpenTK.Graphics.OpenGL internal extern static unsafe void GetActiveUniformARB(UInt32 programObj, UInt32 index, Int32 maxLength, [OutAttribute] Int32* length, [OutAttribute] Int32* size, [OutAttribute] OpenTK.Graphics.OpenGL.ArbShaderObjects* type, [OutAttribute] StringBuilder name); [System.Security.SuppressUnmanagedCodeSecurity()] [System.Runtime.InteropServices.DllImport(GL.Library, EntryPoint = "glGetActiveUniformBlockiv", ExactSpelling = true)] - internal extern static unsafe void GetActiveUniformBlockiv(UInt32 program, UInt32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ArbUniformBufferObject pname, [OutAttribute] Int32* @params); + internal extern static unsafe void GetActiveUniformBlockiv(UInt32 program, UInt32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter pname, [OutAttribute] Int32* @params); [System.Security.SuppressUnmanagedCodeSecurity()] [System.Runtime.InteropServices.DllImport(GL.Library, EntryPoint = "glGetActiveUniformBlockName", ExactSpelling = true)] internal extern static unsafe void GetActiveUniformBlockName(UInt32 program, UInt32 uniformBlockIndex, Int32 bufSize, [OutAttribute] Int32* length, [OutAttribute] StringBuilder uniformBlockName); diff --git a/Source/OpenTK/Graphics/OpenGL/GLDelegates.cs b/Source/OpenTK/Graphics/OpenGL/GLDelegates.cs index 442e664d..2306cd3c 100644 --- a/Source/OpenTK/Graphics/OpenGL/GLDelegates.cs +++ b/Source/OpenTK/Graphics/OpenGL/GLDelegates.cs @@ -1524,7 +1524,7 @@ namespace OpenTK.Graphics.OpenGL internal unsafe delegate void GetActiveUniformARB(UInt32 programObj, UInt32 index, Int32 maxLength, [OutAttribute] Int32* length, [OutAttribute] Int32* size, [OutAttribute] OpenTK.Graphics.OpenGL.ArbShaderObjects* type, [OutAttribute] StringBuilder name); internal unsafe static GetActiveUniformARB glGetActiveUniformARB; [System.Security.SuppressUnmanagedCodeSecurity()] - internal unsafe delegate void GetActiveUniformBlockiv(UInt32 program, UInt32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ArbUniformBufferObject pname, [OutAttribute] Int32* @params); + internal unsafe delegate void GetActiveUniformBlockiv(UInt32 program, UInt32 uniformBlockIndex, OpenTK.Graphics.OpenGL.ActiveUniformBlockParameter pname, [OutAttribute] Int32* @params); internal unsafe static GetActiveUniformBlockiv glGetActiveUniformBlockiv; [System.Security.SuppressUnmanagedCodeSecurity()] internal unsafe delegate void GetActiveUniformBlockName(UInt32 program, UInt32 uniformBlockIndex, Int32 bufSize, [OutAttribute] Int32* length, [OutAttribute] StringBuilder uniformBlockName); diff --git a/Source/OpenTK/Graphics/OpenGL/GLEnums.cs b/Source/OpenTK/Graphics/OpenGL/GLEnums.cs index a1411370..29ea98f3 100644 --- a/Source/OpenTK/Graphics/OpenGL/GLEnums.cs +++ b/Source/OpenTK/Graphics/OpenGL/GLEnums.cs @@ -51,6 +51,17 @@ namespace OpenTK.Graphics.OpenGL FloatMat4 = ((int)0x8B5C), } + public enum ActiveUniformBlockParameter : int + { + UniformBlockBinding = ((int)0x8A3F), + UniformBlockDataSize = ((int)0x8A40), + UniformBlockNameLength = ((int)0x8A41), + UniformBlockActiveUniforms = ((int)0x8A42), + UniformBlockActiveUniformIndices = ((int)0x8A43), + UniformBlockReferencedByVertexShader = ((int)0x8A44), + UniformBlockReferencedByFragmentShader = ((int)0x8A46), + } + public enum ActiveUniformType : int { Int = ((int)0x1404),