Changed API.* to * in order to reflect changes in OpenTK.Platform.Windows.API.

Improved Disposable pattern implementation in most Windows classes.
This commit is contained in:
the_fiddler 2007-09-02 00:16:22 +00:00
parent 1d72cb7ab9
commit 5144535b8e
9 changed files with 1292 additions and 1041 deletions

View file

@ -46,7 +46,7 @@ namespace OpenTK.Platform.Windows
using LONG_PTR = System.IntPtr;
using COLORREF = System.Int32;
using RECT = OpenTK.Platform.Windows.API.Rectangle;
using RECT = OpenTK.Platform.Windows.Rectangle;
using WNDPROC = System.IntPtr;
@ -70,109 +70,13 @@ namespace OpenTK.Platform.Windows
PixelFormatDescriptorSize = (short)Marshal.SizeOf(typeof(PixelFormatDescriptor));
}
#region --- Constants ---
public struct Constants
{
// Mouse indicator flags (found in winuser.h)
public const int MOUSE_MOVE_RELATIVE = 0;
public const int MOUSE_MOVE_ABSOLUTE = 1;
public const int MOUSE_VIRTUAL_DESKTOP = 0x02; // the coordinates are mapped to the virtual desktop
public const int MOUSE_ATTRIBUTES_CHANGED = 0x04; // requery for mouse attributes
// Found in winuser.h
public const int KEYBOARD_OVERRUN_MAKE_CODE = 0xFF;
// WM_ACTIVATE state values (found in winuser.h)
public const int WA_INACTIVE = 0;
public const int WA_ACTIVE = 1;
public const int WA_CLICKACTIVE = 2;
// Window Messages (found in winuser.h)
public const int WM_NULL = 0x0000;
public const int WM_CREATE = 0x0001;
public const int WM_DESTROY = 0x0002;
public const int WM_MOVE = 0x0003;
public const int WM_SIZE = 0x0005;
public const int WM_ACTIVATE = 0x0006;
public const int WM_SETFOCUS = 0x0007;
public const int WM_KILLFOCUS = 0x0008;
public const int WM_ENABLE = 0x000A;
public const int WM_SETREDRAW = 0x000B;
public const int WM_SETTEXT = 0x000C;
public const int WM_GETTEXT = 0x000D;
public const int WM_GETTEXTLENGTH = 0x000E;
public const int WM_PAINT = 0x000F;
public const int WM_CLOSE = 0x0010;
// _WIN32_WCE
public const int WM_QUERYENDSESSION = 0x0011;
public const int WM_QUERYOPEN = 0x0013;
public const int WM_ENDSESSION = 0x0016;
public const int WM_QUIT = 0x0012;
public const int WM_ERASEBKGND = 0x0014;
public const int WM_SYSCOLORCHANGE = 0x0015;
public const int WM_SHOWWINDOW = 0x0018;
public const int WM_WININICHANGE = 0x001A;
// WINVER >= 0x400
public const int WM_SETTINGCHANGE = WM_WININICHANGE;
public const int WM_DEVMODECHANGE = 0x001B;
public const int WM_ACTIVATEAPP = 0x001C;
public const int WM_FONTCHANGE = 0x001D;
public const int WM_TIMECHANGE = 0x001E;
public const int WM_CANCELMODE = 0x001F;
public const int WM_SETCURSOR = 0x0020;
public const int WM_MOUSEACTIVATE = 0x0021;
public const int WM_CHILDACTIVATE = 0x0022;
public const int WM_QUEUESYNC = 0x0023;
public const int WM_GETMINMAXINFO = 0x0024;
public const int WM_WINDOWPOSCHANGING = 0x0046;
public const int WM_WINDOWPOSCHANGED = 0x0047;
// Keyboard events (found in winuser.h)
public const int WM_INPUT = 0x00FF; // Raw input. XP and higher only.
public const int WM_KEYDOWN = 0x0100;
public const int WM_KEYUP = 0x101;
public const int WM_SYSKEYDOWN = 0x0104;
public const int WM_SYSKEYUP = 0x0105;
public const int WM_COMMAND = 0x0111;
public const int WM_SYSCOMMAND = 0x0112;
public const int WM_ENTERIDLE = 0x121;
// Pixel types (found in wingdi.h)
public const byte PFD_TYPE_RGBA = 0;
public const byte PFD_TYPE_COLORINDEX = 1;
// Layer types (found in wingdi.h)
public const byte PFD_MAIN_PLANE = 0;
public const byte PFD_OVERLAY_PLANE = 1;
public const byte PFD_UNDERLAY_PLANE = unchecked((byte)-1);
// Device mode types (found in wingdi.h)
public const int DM_BITSPERPEL = 0x00040000;
public const int DM_PELSWIDTH = 0x00080000;
public const int DM_PELSHEIGHT = 0x00100000;
public const int DM_DISPLAYFLAGS = 0x00200000;
public const int DM_DISPLAYFREQUENCY = 0x00400000;
// ChangeDisplaySettings types (found in winuser.h)
public const int CDS_UPDATEREGISTRY = 0x00000001;
public const int CDS_TEST = 0x00000002;
public const int CDS_FULLSCREEN = 0x00000004;
// ChangeDisplaySettings results (found in winuser.h)
public const int DISP_CHANGE_SUCCESSFUL = 0;
public const int DISP_CHANGE_RESTART = 1;
public const int DISP_CHANGE_FAILED = -1;
// (found in winuser.h)
public const int ENUM_REGISTRY_SETTINGS = -2;
public const int ENUM_CURRENT_SETTINGS = -1;
}
#endregion
internal static readonly short PixelFormatDescriptorSize;
internal static readonly short PixelFormatDescriptorVersion;
internal static int RawInputSize;
internal static readonly int RawInputDeviceSize;
internal static readonly int RawInputHeaderSize;
internal static readonly int RawInputDeviceListSize;
internal static readonly int RawInputDeviceInfoSize;
#region --- Functions ---
@ -258,94 +162,6 @@ namespace OpenTK.Platform.Windows
IntPtr Instance,
IntPtr Param);
public enum WindowStyle : int
{
Overlapped = 0x00000000,
Popup = unchecked((int)0x80000000),
Child = 0x40000000,
Minimize = 0x20000000,
Visible = 0x10000000,
Disabled = 0x08000000,
ClipSiblings = 0x04000000,
ClipChildren = 0x02000000,
Maximize = 0x01000000,
Caption = 0x00C00000, // Border | DialogFrame
Border = 0x00800000,
DialogFrame = 0x00400000,
VScroll = 0x00200000,
HScreen = 0x00100000,
SystemMenu = 0x00080000,
ThickFrame = 0x00040000,
Group = 0x00020000,
TabStop = 0x00010000,
MinimizeBox = 0x00020000,
MaximizeBox = 0x00010000,
Tiled = Overlapped,
Iconic = Minimize,
SizeBox = ThickFrame,
TiledWindow = OverlappedWindow,
// Common window styles:
OverlappedWindow = Overlapped | Caption | SystemMenu | ThickFrame | MinimizeBox | MaximizeBox,
PopupWindow = Popup | Border | SystemMenu,
ChildWindow = Child
}
[Flags]
public enum ExtendedWindowStyle : int
{
DialogModalFrame = 0x00000001,
NoParentNotify = 0x00000004,
Topmost = 0x00000008,
AcceptFiles = 0x00000010,
Transparent = 0x00000020,
// #if(WINVER >= 0x0400)
MdiChild = 0x00000040,
ToolWindow = 0x00000080,
WindowEdge = 0x00000100,
ClientEdge = 0x00000200,
ContextHelp = 0x00000400,
// #endif
// #if(WINVER >= 0x0400)
Right = 0x00001000,
Left = 0x00000000,
RightToLeftReading = 0x00002000,
LeftToRightReading = 0x00000000,
LeftScrollbar = 0x00004000,
RightScrollbar = 0x00000000,
ControlParent = 0x00010000,
StaticEdge = 0x00020000,
ApplicationWindow = 0x00040000,
OverlappedWindow = WindowEdge | ClientEdge,
PaletteWindow = WindowEdge | ToolWindow | Topmost,
// #endif
// #if(_WIN32_WINNT >= 0x0500)
Layered = 0x00080000,
// #endif
// #if(WINVER >= 0x0500)
NoInheritLayout = 0x00100000, // Disable inheritence of mirroring by children
RightToLeftLayout = 0x00400000, // Right to left mirroring
// #endif /* WINVER >= 0x0500 */
// #if(_WIN32_WINNT >= 0x0501)
Composited = 0x02000000,
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(_WIN32_WINNT >= 0x0500)
NoActivate = 0x08000000
// #endif /* _WIN32_WINNT >= 0x0500 */
}
#endregion
#region DestroyWindow
[DllImport("user32.dll", SetLastError = true)]
@ -423,35 +239,9 @@ namespace OpenTK.Platform.Windows
/// <param name="flags">Not used</param>
/// <returns>True if there is a message pending.</returns>
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("User32.dll", CharSet = CharSet.Auto)]
[DllImport("User32.dll"), CLSCompliant(false)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PeekMessage(
out Message msg,
IntPtr hWnd,
int messageFilterMin,
int messageFilterMax,
int flags
);
/// <summary>
/// Low-level WINAPI function that checks the next message in the queue.
/// </summary>
/// <param name="msg">The pending message (if any) is stored here.</param>
/// <param name="hWnd">Not used</param>
/// <param name="messageFilterMin">Not used</param>
/// <param name="messageFilterMax">Not used</param>
/// <param name="flags">Not used</param>
/// <returns>True if there is a message pending.</returns>
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("User32.dll", CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PeekMessage(
out System.Windows.Forms.Message msg,
IntPtr hWnd,
int messageFilterMin,
int messageFilterMax,
int flags
);
public static extern bool PeekMessage(ref MSG msg, IntPtr hWnd, int messageFilterMin, int messageFilterMax, int flags);
#endregion
@ -472,14 +262,10 @@ namespace OpenTK.Platform.Windows
/// To get extended error information, call GetLastError.
/// </returns>
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("User32.dll", CharSet = CharSet.Auto)]
[DllImport("User32.dll"), CLSCompliant(false)]
//[return: MarshalAs(UnmanagedType.Bool)]
public static extern INT GetMessage(
out System.Windows.Forms.Message msg,
IntPtr windowHandle,
int messageFilterMin,
int messageFilterMax
);
public static extern INT GetMessage(ref MSG msg,
IntPtr windowHandle, int messageFilterMin, int messageFilterMax);
#endregion
@ -491,17 +277,7 @@ namespace OpenTK.Platform.Windows
[return: MarshalAs(UnmanagedType.Bool)]
public static extern BOOL PostMessage(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("User32.dll", CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern BOOL PostMessage(
HWND hWnd,
INT Msg,
WindowMessage Msg,
WPARAM wParam,
LPARAM lParam
);
@ -518,8 +294,8 @@ namespace OpenTK.Platform.Windows
#region DispatchMessage
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern LRESULT DispatchMessage(ref System.Windows.Forms.Message lpmsg);
[DllImport("User32.dll"), CLSCompliant(false)]
public static extern LRESULT DispatchMessage(ref MSG msg);
#endregion
@ -1195,26 +971,115 @@ namespace OpenTK.Platform.Windows
#endregion
#region --- Structures ---
#endregion
}
#region Message
#region --- Constants ---
[StructLayout(LayoutKind.Sequential)]
public struct Message
public struct Constants
{
public IntPtr HWnd;
public int Msg;
public IntPtr WParam;
public IntPtr LParam;
public IntPtr Result;
// Mouse indicator flags (found in winuser.h)
public const int MOUSE_MOVE_RELATIVE = 0;
public const int MOUSE_MOVE_ABSOLUTE = 1;
public const int MOUSE_VIRTUAL_DESKTOP = 0x02; // the coordinates are mapped to the virtual desktop
public const int MOUSE_ATTRIBUTES_CHANGED = 0x04; // requery for mouse attributes
//public int Time;
//public System.Drawing.Point p;
//System.Drawing.
// Found in winuser.h
public const int KEYBOARD_OVERRUN_MAKE_CODE = 0xFF;
// WM_ACTIVATE state values (found in winuser.h)
public const int WA_INACTIVE = 0;
public const int WA_ACTIVE = 1;
public const int WA_CLICKACTIVE = 2;
// Window Messages (found in winuser.h)
public const int WM_NULL = 0x0000;
public const int WM_CREATE = 0x0001;
public const int WM_DESTROY = 0x0002;
public const int WM_MOVE = 0x0003;
public const int WM_SIZE = 0x0005;
public const int WM_ACTIVATE = 0x0006;
public const int WM_SETFOCUS = 0x0007;
public const int WM_KILLFOCUS = 0x0008;
public const int WM_ENABLE = 0x000A;
public const int WM_SETREDRAW = 0x000B;
public const int WM_SETTEXT = 0x000C;
public const int WM_GETTEXT = 0x000D;
public const int WM_GETTEXTLENGTH = 0x000E;
public const int WM_PAINT = 0x000F;
public const int WM_CLOSE = 0x0010;
// _WIN32_WCE
public const int WM_QUERYENDSESSION = 0x0011;
public const int WM_QUERYOPEN = 0x0013;
public const int WM_ENDSESSION = 0x0016;
public const int WM_QUIT = 0x0012;
public const int WM_ERASEBKGND = 0x0014;
public const int WM_SYSCOLORCHANGE = 0x0015;
public const int WM_SHOWWINDOW = 0x0018;
public const int WM_WININICHANGE = 0x001A;
// WINVER >= 0x400
public const int WM_SETTINGCHANGE = WM_WININICHANGE;
public const int WM_DEVMODECHANGE = 0x001B;
public const int WM_ACTIVATEAPP = 0x001C;
public const int WM_FONTCHANGE = 0x001D;
public const int WM_TIMECHANGE = 0x001E;
public const int WM_CANCELMODE = 0x001F;
public const int WM_SETCURSOR = 0x0020;
public const int WM_MOUSEACTIVATE = 0x0021;
public const int WM_CHILDACTIVATE = 0x0022;
public const int WM_QUEUESYNC = 0x0023;
public const int WM_GETMINMAXINFO = 0x0024;
public const int WM_WINDOWPOSCHANGING = 0x0046;
public const int WM_WINDOWPOSCHANGED = 0x0047;
// Keyboard events (found in winuser.h)
public const int WM_INPUT = 0x00FF; // Raw input. XP and higher only.
public const int WM_KEYDOWN = 0x0100;
public const int WM_KEYUP = 0x101;
public const int WM_SYSKEYDOWN = 0x0104;
public const int WM_SYSKEYUP = 0x0105;
public const int WM_COMMAND = 0x0111;
public const int WM_SYSCOMMAND = 0x0112;
public const int WM_ENTERIDLE = 0x121;
// Pixel types (found in wingdi.h)
public const byte PFD_TYPE_RGBA = 0;
public const byte PFD_TYPE_COLORINDEX = 1;
// Layer types (found in wingdi.h)
public const byte PFD_MAIN_PLANE = 0;
public const byte PFD_OVERLAY_PLANE = 1;
public const byte PFD_UNDERLAY_PLANE = unchecked((byte)-1);
// Device mode types (found in wingdi.h)
public const int DM_BITSPERPEL = 0x00040000;
public const int DM_PELSWIDTH = 0x00080000;
public const int DM_PELSHEIGHT = 0x00100000;
public const int DM_DISPLAYFLAGS = 0x00200000;
public const int DM_DISPLAYFREQUENCY = 0x00400000;
// ChangeDisplaySettings types (found in winuser.h)
public const int CDS_UPDATEREGISTRY = 0x00000001;
public const int CDS_TEST = 0x00000002;
public const int CDS_FULLSCREEN = 0x00000004;
// ChangeDisplaySettings results (found in winuser.h)
public const int DISP_CHANGE_SUCCESSFUL = 0;
public const int DISP_CHANGE_RESTART = 1;
public const int DISP_CHANGE_FAILED = -1;
// (found in winuser.h)
public const int ENUM_REGISTRY_SETTINGS = -2;
public const int ENUM_CURRENT_SETTINGS = -1;
}
#endregion
#region --- Structures ---
#region CreateStruct
public struct CreateStruct
@ -1307,9 +1172,6 @@ namespace OpenTK.Platform.Windows
#region PixelFormatDescriptor
internal static short PixelFormatDescriptorSize;
internal static short PixelFormatDescriptorVersion;
/// <summary>
/// Describes a pixel format. It is used when interfacing with the WINAPI to create a new Context.
/// Found in WinGDI.h
@ -1708,8 +1570,6 @@ namespace OpenTK.Platform.Windows
#region RawInputDevice
public static readonly int RawInputDeviceSize;
/// <summary>
/// Defines information for the raw input devices.
/// </summary>
@ -1751,8 +1611,6 @@ namespace OpenTK.Platform.Windows
#region RawInputDeviceList
public static readonly int RawInputDeviceListSize;
/// <summary>
/// Contains information about a raw input device.
/// </summary>
@ -1778,8 +1636,6 @@ namespace OpenTK.Platform.Windows
#region RawInput
public static int RawInputSize;
/// <summary>
/// Contains the raw input from a device.
/// </summary>
@ -1811,8 +1667,6 @@ namespace OpenTK.Platform.Windows
#region RawInputHeader
public static readonly int RawInputHeaderSize;
/// <summary>
/// Contains the header information that is part of the raw input data.
/// </summary>
@ -1984,8 +1838,6 @@ namespace OpenTK.Platform.Windows
#region RawInputDeviceInfo
public static readonly int RawInputDeviceInfoSize;
/// <summary>
/// Defines the raw input data coming from any device.
/// </summary>
@ -2192,6 +2044,92 @@ namespace OpenTK.Platform.Windows
#region --- Enums ---
public enum WindowStyle : int
{
Overlapped = 0x00000000,
Popup = unchecked((int)0x80000000),
Child = 0x40000000,
Minimize = 0x20000000,
Visible = 0x10000000,
Disabled = 0x08000000,
ClipSiblings = 0x04000000,
ClipChildren = 0x02000000,
Maximize = 0x01000000,
Caption = 0x00C00000, // Border | DialogFrame
Border = 0x00800000,
DialogFrame = 0x00400000,
VScroll = 0x00200000,
HScreen = 0x00100000,
SystemMenu = 0x00080000,
ThickFrame = 0x00040000,
Group = 0x00020000,
TabStop = 0x00010000,
MinimizeBox = 0x00020000,
MaximizeBox = 0x00010000,
Tiled = Overlapped,
Iconic = Minimize,
SizeBox = ThickFrame,
TiledWindow = OverlappedWindow,
// Common window styles:
OverlappedWindow = Overlapped | Caption | SystemMenu | ThickFrame | MinimizeBox | MaximizeBox,
PopupWindow = Popup | Border | SystemMenu,
ChildWindow = Child
}
[Flags]
public enum ExtendedWindowStyle : int
{
DialogModalFrame = 0x00000001,
NoParentNotify = 0x00000004,
Topmost = 0x00000008,
AcceptFiles = 0x00000010,
Transparent = 0x00000020,
// #if(WINVER >= 0x0400)
MdiChild = 0x00000040,
ToolWindow = 0x00000080,
WindowEdge = 0x00000100,
ClientEdge = 0x00000200,
ContextHelp = 0x00000400,
// #endif
// #if(WINVER >= 0x0400)
Right = 0x00001000,
Left = 0x00000000,
RightToLeftReading = 0x00002000,
LeftToRightReading = 0x00000000,
LeftScrollbar = 0x00004000,
RightScrollbar = 0x00000000,
ControlParent = 0x00010000,
StaticEdge = 0x00020000,
ApplicationWindow = 0x00040000,
OverlappedWindow = WindowEdge | ClientEdge,
PaletteWindow = WindowEdge | ToolWindow | Topmost,
// #endif
// #if(_WIN32_WINNT >= 0x0500)
Layered = 0x00080000,
// #endif
// #if(WINVER >= 0x0500)
NoInheritLayout = 0x00100000, // Disable inheritence of mirroring by children
RightToLeftLayout = 0x00400000, // Right to left mirroring
// #endif /* WINVER >= 0x0500 */
// #if(_WIN32_WINNT >= 0x0501)
Composited = 0x02000000,
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(_WIN32_WINNT >= 0x0500)
NoActivate = 0x08000000
// #endif /* _WIN32_WINNT >= 0x0500 */
}
#region GetWindowLongOffsets enum
public enum GetWindowLongOffsets : int
@ -2749,6 +2687,266 @@ namespace OpenTK.Platform.Windows
#endregion
#region WindowMessage
public enum WindowMessage
{
NULL = 0x0000,
CREATE = 0x0001,
DESTROY = 0x0002,
MOVE = 0x0003,
SIZE = 0x0005,
ACTIVATE = 0x0006,
SETFOCUS = 0x0007,
KILLFOCUS = 0x0008,
// public const uint SETVISIBLE = 0x0009;
ENABLE = 0x000A,
SETREDRAW = 0x000B,
SETTEXT = 0x000C,
GETTEXT = 0x000D,
GETTEXTLENGTH = 0x000E,
PAINT = 0x000F,
CLOSE = 0x0010,
QUERYENDSESSION = 0x0011,
QUIT = 0x0012,
QUERYOPEN = 0x0013,
ERASEBKGND = 0x0014,
SYSCOLORCHANGE = 0x0015,
ENDSESSION = 0x0016,
// public const uint SYSTEMERROR = 0x0017;
SHOWWINDOW = 0x0018,
CTLCOLOR = 0x0019,
WININICHANGE = 0x001A,
SETTINGCHANGE = 0x001A,
DEVMODECHANGE = 0x001B,
ACTIVATEAPP = 0x001C,
FONTCHANGE = 0x001D,
TIMECHANGE = 0x001E,
CANCELMODE = 0x001F,
SETCURSOR = 0x0020,
MOUSEACTIVATE = 0x0021,
CHILDACTIVATE = 0x0022,
QUEUESYNC = 0x0023,
GETMINMAXINFO = 0x0024,
PAINTICON = 0x0026,
ICONERASEBKGND = 0x0027,
NEXTDLGCTL = 0x0028,
// public const uint ALTTABACTIVE = 0x0029;
SPOOLERSTATUS = 0x002A,
DRAWITEM = 0x002B,
MEASUREITEM = 0x002C,
DELETEITEM = 0x002D,
VKEYTOITEM = 0x002E,
CHARTOITEM = 0x002F,
SETFONT = 0x0030,
GETFONT = 0x0031,
SETHOTKEY = 0x0032,
GETHOTKEY = 0x0033,
// public const uint FILESYSCHANGE = 0x0034;
// public const uint ISACTIVEICON = 0x0035;
// public const uint QUERYPARKICON = 0x0036;
QUERYDRAGICON = 0x0037,
COMPAREITEM = 0x0039,
// public const uint TESTING = 0x003a;
// public const uint OTHERWINDOWCREATED = 0x003c;
GETOBJECT = 0x003D,
// public const uint ACTIVATESHELLWINDOW = 0x003e;
COMPACTING = 0x0041,
COMMNOTIFY = 0x0044,
WINDOWPOSCHANGING = 0x0046,
WINDOWPOSCHANGED = 0x0047,
POWER = 0x0048,
COPYDATA = 0x004A,
CANCELJOURNAL = 0x004B,
NOTIFY = 0x004E,
INPUTLANGCHANGEREQUEST = 0x0050,
INPUTLANGCHANGE = 0x0051,
TCARD = 0x0052,
HELP = 0x0053,
USERCHANGED = 0x0054,
NOTIFYFORMAT = 0x0055,
CONTEXTMENU = 0x007B,
STYLECHANGING = 0x007C,
STYLECHANGED = 0x007D,
DISPLAYCHANGE = 0x007E,
GETICON = 0x007F,
// Non-Client messages
SETICON = 0x0080,
NCCREATE = 0x0081,
NCDESTROY = 0x0082,
NCCALCSIZE = 0x0083,
NCHITTEST = 0x0084,
NCPAINT = 0x0085,
NCACTIVATE = 0x0086,
GETDLGCODE = 0x0087,
SYNCPAINT = 0x0088,
// public const uint SYNCTASK = 0x0089;
NCMOUSEMOVE = 0x00A0,
NCLBUTTONDOWN = 0x00A1,
NCLBUTTONUP = 0x00A2,
NCLBUTTONDBLCLK = 0x00A3,
NCRBUTTONDOWN = 0x00A4,
NCRBUTTONUP = 0x00A5,
NCRBUTTONDBLCLK = 0x00A6,
NCMBUTTONDOWN = 0x00A7,
NCMBUTTONUP = 0x00A8,
NCMBUTTONDBLCLK = 0x00A9,
// public const uint NCXBUTTONDOWN = 0x00ab;
// public const uint NCXBUTTONUP = 0x00ac;
// public const uint NCXBUTTONDBLCLK = 0x00ad;
INPUT = 0x00FF,
KEYDOWN = 0x0100,
KEYFIRST = 0x0100,
KEYUP = 0x0101,
CHAR = 0x0102,
DEADCHAR = 0x0103,
SYSKEYDOWN = 0x0104,
SYSKEYUP = 0x0105,
SYSCHAR = 0x0106,
SYSDEADCHAR = 0x0107,
KEYLAST = 0x0108,
IME_STARTCOMPOSITION = 0x010D,
IME_ENDCOMPOSITION = 0x010E,
IME_COMPOSITION = 0x010F,
IME_KEYLAST = 0x010F,
INITDIALOG = 0x0110,
COMMAND = 0x0111,
SYSCOMMAND = 0x0112,
TIMER = 0x0113,
HSCROLL = 0x0114,
VSCROLL = 0x0115,
INITMENU = 0x0116,
INITMENUPOPUP = 0x0117,
// public const uint SYSTIMER = 0x0118;
MENUSELECT = 0x011F,
MENUCHAR = 0x0120,
ENTERIDLE = 0x0121,
MENURBUTTONUP = 0x0122,
MENUDRAG = 0x0123,
MENUGETOBJECT = 0x0124,
UNINITMENUPOPUP = 0x0125,
MENUCOMMAND = 0x0126,
CHANGEUISTATE = 0x0127,
UPDATEUISTATE = 0x0128,
QUERYUISTATE = 0x0129,
// public const uint LBTRACKPOINT = 0x0131;
CTLCOLORMSGBOX = 0x0132,
CTLCOLOREDIT = 0x0133,
CTLCOLORLISTBOX = 0x0134,
CTLCOLORBTN = 0x0135,
CTLCOLORDLG = 0x0136,
CTLCOLORSCROLLBAR = 0x0137,
CTLCOLORSTATIC = 0x0138,
MOUSEMOVE = 0x0200,
MOUSEFIRST = 0x0200,
LBUTTONDOWN = 0x0201,
LBUTTONUP = 0x0202,
LBUTTONDBLCLK = 0x0203,
RBUTTONDOWN = 0x0204,
RBUTTONUP = 0x0205,
RBUTTONDBLCLK = 0x0206,
MBUTTONDOWN = 0x0207,
MBUTTONUP = 0x0208,
MBUTTONDBLCLK = 0x0209,
MOUSEWHEEL = 0x020A,
MOUSELAST = 0x020D,
// public const uint XBUTTONDOWN = 0x020B;
// public const uint XBUTTONUP = 0x020C;
// public const uint XBUTTONDBLCLK = 0x020D;
PARENTNOTIFY = 0x0210,
ENTERMENULOOP = 0x0211,
EXITMENULOOP = 0x0212,
NEXTMENU = 0x0213,
SIZING = 0x0214,
CAPTURECHANGED = 0x0215,
MOVING = 0x0216,
// public const uint POWERBROADCAST = 0x0218;
DEVICECHANGE = 0x0219,
MDICREATE = 0x0220,
MDIDESTROY = 0x0221,
MDIACTIVATE = 0x0222,
MDIRESTORE = 0x0223,
MDINEXT = 0x0224,
MDIMAXIMIZE = 0x0225,
MDITILE = 0x0226,
MDICASCADE = 0x0227,
MDIICONARRANGE = 0x0228,
MDIGETACTIVE = 0x0229,
/* D&D messages */
// public const uint DROPOBJECT = 0x022A;
// public const uint QUERYDROPOBJECT = 0x022B;
// public const uint BEGINDRAG = 0x022C;
// public const uint DRAGLOOP = 0x022D;
// public const uint DRAGSELECT = 0x022E;
// public const uint DRAGMOVE = 0x022F;
MDISETMENU = 0x0230,
ENTERSIZEMOVE = 0x0231,
EXITSIZEMOVE = 0x0232,
DROPFILES = 0x0233,
MDIREFRESHMENU = 0x0234,
IME_SETCONTEXT = 0x0281,
IME_NOTIFY = 0x0282,
IME_CONTROL = 0x0283,
IME_COMPOSITIONFULL = 0x0284,
IME_SELECT = 0x0285,
IME_CHAR = 0x0286,
IME_REQUEST = 0x0288,
IME_KEYDOWN = 0x0290,
IME_KEYUP = 0x0291,
NCMOUSEHOVER = 0x02A0,
MOUSEHOVER = 0x02A1,
NCMOUSELEAVE = 0x02A2,
MOUSELEAVE = 0x02A3,
CUT = 0x0300,
COPY = 0x0301,
PASTE = 0x0302,
CLEAR = 0x0303,
UNDO = 0x0304,
RENDERFORMAT = 0x0305,
RENDERALLFORMATS = 0x0306,
DESTROYCLIPBOARD = 0x0307,
DRAWCLIPBOARD = 0x0308,
PAINTCLIPBOARD = 0x0309,
VSCROLLCLIPBOARD = 0x030A,
SIZECLIPBOARD = 0x030B,
ASKCBFORMATNAME = 0x030C,
CHANGECBCHAIN = 0x030D,
HSCROLLCLIPBOARD = 0x030E,
QUERYNEWPALETTE = 0x030F,
PALETTEISCHANGING = 0x0310,
PALETTECHANGED = 0x0311,
HOTKEY = 0x0312,
PRINT = 0x0317,
PRINTCLIENT = 0x0318,
HANDHELDFIRST = 0x0358,
HANDHELDLAST = 0x035F,
AFXFIRST = 0x0360,
AFXLAST = 0x037F,
PENWINFIRST = 0x0380,
PENWINLAST = 0x038F,
APP = 0x8000,
USER = 0x0400,
// Our "private" ones
MOUSE_ENTER = 0x0401,
ASYNC_MESSAGE = 0x0403,
REFLECT = USER + 0x1c00,
CLOSE_INTERNAL = USER + 0x1c01,
// NotifyIcon (Systray) Balloon messages
BALLOONSHOW = USER + 0x0002,
BALLOONHIDE = USER + 0x0003,
BALLOONTIMEOUT = USER + 0x0004,
BALLOONUSERCLICK = USER + 0x0005
}
#endregion
#endregion
#region --- Callbacks ---
@ -2768,6 +2966,53 @@ namespace OpenTK.Platform.Windows
}
}
#region Message
[StructLayout(LayoutKind.Sequential), CLSCompliant(false)]
public struct MSG
{
public IntPtr HWnd;
public WindowMessage Message;
public IntPtr WParam;
public IntPtr LParam;
public uint Time;
public POINT Point;
public object RefObject;
public override string ToString()
{
return String.Format("msg=0x{0:x} ({1}) hwnd=0x{2:x} wparam=0x{3:x} lparam=0x{4:x} pt=0x{5:x}", (int)Message, Message.ToString(), HWnd.ToInt32(), WParam.ToInt32(), LParam.ToInt32(), Point);
}
}
#endregion
#region Point
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int X;
public int Y;
public POINT(int x, int y)
{
this.X = x;
this.Y = y;
}
public System.Drawing.Point ToPoint()
{
return new System.Drawing.Point(X, Y);
}
public override string ToString()
{
return "Point {" + X.ToString() + ", " + Y.ToString() + ")";
}
}
#endregion
#endregion
}
}

View file

@ -45,32 +45,32 @@ namespace OpenTK.Platform.Windows
[System.CLSCompliant(false)]
public static
unsafe int ChoosePixelFormat(IntPtr hDc, API.PixelFormatDescriptor* pPfd)
unsafe int ChoosePixelFormat(IntPtr hDc, PixelFormatDescriptor* pPfd)
{
unsafe { return Delegates.wglChoosePixelFormat((IntPtr)hDc, (API.PixelFormatDescriptor*)pPfd); }
unsafe { return Delegates.wglChoosePixelFormat((IntPtr)hDc, (PixelFormatDescriptor*)pPfd); }
}
public static
int ChoosePixelFormat(IntPtr hDc, API.PixelFormatDescriptor[] pPfd)
int ChoosePixelFormat(IntPtr hDc, PixelFormatDescriptor[] pPfd)
{
unsafe
{
fixed (API.PixelFormatDescriptor* pPfd_ptr = pPfd)
fixed (PixelFormatDescriptor* pPfd_ptr = pPfd)
{
int retval = Delegates.wglChoosePixelFormat((IntPtr)hDc, (API.PixelFormatDescriptor*)pPfd_ptr);
int retval = Delegates.wglChoosePixelFormat((IntPtr)hDc, (PixelFormatDescriptor*)pPfd_ptr);
return retval;
}
}
}
public static
int ChoosePixelFormat(IntPtr hDc, ref API.PixelFormatDescriptor pPfd)
int ChoosePixelFormat(IntPtr hDc, ref PixelFormatDescriptor pPfd)
{
unsafe
{
fixed (API.PixelFormatDescriptor* pPfd_ptr = &pPfd)
fixed (PixelFormatDescriptor* pPfd_ptr = &pPfd)
{
int retval = Delegates.wglChoosePixelFormat((IntPtr)hDc, (API.PixelFormatDescriptor*)pPfd_ptr);
int retval = Delegates.wglChoosePixelFormat((IntPtr)hDc, (PixelFormatDescriptor*)pPfd_ptr);
return retval;
}
}
@ -78,44 +78,44 @@ namespace OpenTK.Platform.Windows
[System.CLSCompliant(false)]
public static
unsafe int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, API.PixelFormatDescriptor* ppfd)
unsafe int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, PixelFormatDescriptor* ppfd)
{
unsafe { return Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (API.PixelFormatDescriptor*)ppfd); }
unsafe { return Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (PixelFormatDescriptor*)ppfd); }
}
[System.CLSCompliant(false)]
public static
unsafe int DescribePixelFormat(IntPtr hdc, int ipfd, Int32 cjpfd, API.PixelFormatDescriptor* ppfd)
unsafe int DescribePixelFormat(IntPtr hdc, int ipfd, Int32 cjpfd, PixelFormatDescriptor* ppfd)
{
unsafe
{
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (API.PixelFormatDescriptor*)ppfd);
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (PixelFormatDescriptor*)ppfd);
return retval;
}
}
[System.CLSCompliant(false)]
public static
int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, API.PixelFormatDescriptor[] ppfd)
int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, PixelFormatDescriptor[] ppfd)
{
unsafe
{
fixed (API.PixelFormatDescriptor* ppfd_ptr = ppfd)
fixed (PixelFormatDescriptor* ppfd_ptr = ppfd)
{
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (API.PixelFormatDescriptor*)ppfd_ptr);
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (PixelFormatDescriptor*)ppfd_ptr);
return retval;
}
}
}
public static
int DescribePixelFormat(IntPtr hdc, int ipfd, Int32 cjpfd, API.PixelFormatDescriptor[] ppfd)
int DescribePixelFormat(IntPtr hdc, int ipfd, Int32 cjpfd, PixelFormatDescriptor[] ppfd)
{
unsafe
{
fixed (API.PixelFormatDescriptor* ppfd_ptr = ppfd)
fixed (PixelFormatDescriptor* ppfd_ptr = ppfd)
{
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (API.PixelFormatDescriptor*)ppfd_ptr);
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (PixelFormatDescriptor*)ppfd_ptr);
return retval;
}
}
@ -123,26 +123,26 @@ namespace OpenTK.Platform.Windows
[System.CLSCompliant(false)]
public static
int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, ref API.PixelFormatDescriptor ppfd)
int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, ref PixelFormatDescriptor ppfd)
{
unsafe
{
fixed (API.PixelFormatDescriptor* ppfd_ptr = &ppfd)
fixed (PixelFormatDescriptor* ppfd_ptr = &ppfd)
{
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (API.PixelFormatDescriptor*)ppfd_ptr);
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (PixelFormatDescriptor*)ppfd_ptr);
return retval;
}
}
}
public static
int DescribePixelFormat(IntPtr hdc, int ipfd, Int32 cjpfd, ref API.PixelFormatDescriptor ppfd)
int DescribePixelFormat(IntPtr hdc, int ipfd, Int32 cjpfd, ref PixelFormatDescriptor ppfd)
{
unsafe
{
fixed (API.PixelFormatDescriptor* ppfd_ptr = &ppfd)
fixed (PixelFormatDescriptor* ppfd_ptr = &ppfd)
{
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (API.PixelFormatDescriptor*)ppfd_ptr);
int retval = Delegates.wglDescribePixelFormat((IntPtr)hdc, (int)ipfd, (UInt32)cjpfd, (PixelFormatDescriptor*)ppfd_ptr);
return retval;
}
}
@ -174,32 +174,32 @@ namespace OpenTK.Platform.Windows
[System.CLSCompliant(false)]
public static
unsafe Boolean SetPixelFormat(IntPtr hdc, int ipfd, API.PixelFormatDescriptor* ppfd)
unsafe Boolean SetPixelFormat(IntPtr hdc, int ipfd, PixelFormatDescriptor* ppfd)
{
unsafe { return Delegates.wglSetPixelFormat((IntPtr)hdc, (int)ipfd, (API.PixelFormatDescriptor*)ppfd); }
unsafe { return Delegates.wglSetPixelFormat((IntPtr)hdc, (int)ipfd, (PixelFormatDescriptor*)ppfd); }
}
public static
Boolean SetPixelFormat(IntPtr hdc, int ipfd, API.PixelFormatDescriptor[] ppfd)
Boolean SetPixelFormat(IntPtr hdc, int ipfd, PixelFormatDescriptor[] ppfd)
{
unsafe
{
fixed (API.PixelFormatDescriptor* ppfd_ptr = ppfd)
fixed (PixelFormatDescriptor* ppfd_ptr = ppfd)
{
Boolean retval = Delegates.wglSetPixelFormat((IntPtr)hdc, (int)ipfd, (API.PixelFormatDescriptor*)ppfd_ptr);
Boolean retval = Delegates.wglSetPixelFormat((IntPtr)hdc, (int)ipfd, (PixelFormatDescriptor*)ppfd_ptr);
return retval;
}
}
}
public static
Boolean SetPixelFormat(IntPtr hdc, int ipfd, ref API.PixelFormatDescriptor ppfd)
Boolean SetPixelFormat(IntPtr hdc, int ipfd, ref PixelFormatDescriptor ppfd)
{
unsafe
{
fixed (API.PixelFormatDescriptor* ppfd_ptr = &ppfd)
fixed (PixelFormatDescriptor* ppfd_ptr = &ppfd)
{
Boolean retval = Delegates.wglSetPixelFormat((IntPtr)hdc, (int)ipfd, (API.PixelFormatDescriptor*)ppfd_ptr);
Boolean retval = Delegates.wglSetPixelFormat((IntPtr)hdc, (int)ipfd, (PixelFormatDescriptor*)ppfd_ptr);
return retval;
}
}
@ -225,44 +225,44 @@ namespace OpenTK.Platform.Windows
[System.CLSCompliant(false)]
public static
unsafe Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, API.LayerPlaneDescriptor* plpd)
unsafe Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, LayerPlaneDescriptor* plpd)
{
unsafe { return Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (API.LayerPlaneDescriptor*)plpd); }
unsafe { return Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (LayerPlaneDescriptor*)plpd); }
}
[System.CLSCompliant(false)]
public static
unsafe Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, Int32 nBytes, API.LayerPlaneDescriptor* plpd)
unsafe Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, Int32 nBytes, LayerPlaneDescriptor* plpd)
{
unsafe
{
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (API.LayerPlaneDescriptor*)plpd);
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (LayerPlaneDescriptor*)plpd);
return retval;
}
}
[System.CLSCompliant(false)]
public static
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, API.LayerPlaneDescriptor[] plpd)
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, LayerPlaneDescriptor[] plpd)
{
unsafe
{
fixed (API.LayerPlaneDescriptor* plpd_ptr = plpd)
fixed (LayerPlaneDescriptor* plpd_ptr = plpd)
{
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (API.LayerPlaneDescriptor*)plpd_ptr);
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (LayerPlaneDescriptor*)plpd_ptr);
return retval;
}
}
}
public static
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, Int32 nBytes, API.LayerPlaneDescriptor[] plpd)
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, Int32 nBytes, LayerPlaneDescriptor[] plpd)
{
unsafe
{
fixed (API.LayerPlaneDescriptor* plpd_ptr = plpd)
fixed (LayerPlaneDescriptor* plpd_ptr = plpd)
{
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (API.LayerPlaneDescriptor*)plpd_ptr);
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (LayerPlaneDescriptor*)plpd_ptr);
return retval;
}
}
@ -270,26 +270,26 @@ namespace OpenTK.Platform.Windows
[System.CLSCompliant(false)]
public static
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, ref API.LayerPlaneDescriptor plpd)
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, ref LayerPlaneDescriptor plpd)
{
unsafe
{
fixed (API.LayerPlaneDescriptor* plpd_ptr = &plpd)
fixed (LayerPlaneDescriptor* plpd_ptr = &plpd)
{
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (API.LayerPlaneDescriptor*)plpd_ptr);
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (LayerPlaneDescriptor*)plpd_ptr);
return retval;
}
}
}
public static
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, Int32 nBytes, ref API.LayerPlaneDescriptor plpd)
Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, Int32 nBytes, ref LayerPlaneDescriptor plpd)
{
unsafe
{
fixed (API.LayerPlaneDescriptor* plpd_ptr = &plpd)
fixed (LayerPlaneDescriptor* plpd_ptr = &plpd)
{
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (API.LayerPlaneDescriptor*)plpd_ptr);
Boolean retval = Delegates.wglDescribeLayerPlane((IntPtr)hDc, (int)pixelFormat, (int)layerPlane, (UInt32)nBytes, (LayerPlaneDescriptor*)plpd_ptr);
return retval;
}
}
@ -394,32 +394,32 @@ namespace OpenTK.Platform.Windows
[System.CLSCompliant(false)]
public static
unsafe Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat* glyphMetrics)
unsafe Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat* glyphMetrics)
{
unsafe { return Delegates.wglUseFontOutlinesA((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (API.GlyphMetricsFloat*)glyphMetrics); }
unsafe { return Delegates.wglUseFontOutlinesA((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (GlyphMetricsFloat*)glyphMetrics); }
}
public static
Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat[] glyphMetrics)
Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat[] glyphMetrics)
{
unsafe
{
fixed (API.GlyphMetricsFloat* glyphMetrics_ptr = glyphMetrics)
fixed (GlyphMetricsFloat* glyphMetrics_ptr = glyphMetrics)
{
Boolean retval = Delegates.wglUseFontOutlinesA((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (API.GlyphMetricsFloat*)glyphMetrics_ptr);
Boolean retval = Delegates.wglUseFontOutlinesA((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (GlyphMetricsFloat*)glyphMetrics_ptr);
return retval;
}
}
}
public static
Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, ref API.GlyphMetricsFloat glyphMetrics)
Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, ref GlyphMetricsFloat glyphMetrics)
{
unsafe
{
fixed (API.GlyphMetricsFloat* glyphMetrics_ptr = &glyphMetrics)
fixed (GlyphMetricsFloat* glyphMetrics_ptr = &glyphMetrics)
{
Boolean retval = Delegates.wglUseFontOutlinesA((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (API.GlyphMetricsFloat*)glyphMetrics_ptr);
Boolean retval = Delegates.wglUseFontOutlinesA((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (GlyphMetricsFloat*)glyphMetrics_ptr);
return retval;
}
}
@ -427,32 +427,32 @@ namespace OpenTK.Platform.Windows
[System.CLSCompliant(false)]
public static
unsafe Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat* glyphMetrics)
unsafe Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat* glyphMetrics)
{
unsafe { return Delegates.wglUseFontOutlinesW((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (API.GlyphMetricsFloat*)glyphMetrics); }
unsafe { return Delegates.wglUseFontOutlinesW((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (GlyphMetricsFloat*)glyphMetrics); }
}
public static
Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat[] glyphMetrics)
Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat[] glyphMetrics)
{
unsafe
{
fixed (API.GlyphMetricsFloat* glyphMetrics_ptr = glyphMetrics)
fixed (GlyphMetricsFloat* glyphMetrics_ptr = glyphMetrics)
{
Boolean retval = Delegates.wglUseFontOutlinesW((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (API.GlyphMetricsFloat*)glyphMetrics_ptr);
Boolean retval = Delegates.wglUseFontOutlinesW((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (GlyphMetricsFloat*)glyphMetrics_ptr);
return retval;
}
}
}
public static
Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, ref API.GlyphMetricsFloat glyphMetrics)
Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, ref GlyphMetricsFloat glyphMetrics)
{
unsafe
{
fixed (API.GlyphMetricsFloat* glyphMetrics_ptr = &glyphMetrics)
fixed (GlyphMetricsFloat* glyphMetrics_ptr = &glyphMetrics)
{
Boolean retval = Delegates.wglUseFontOutlinesW((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (API.GlyphMetricsFloat*)glyphMetrics_ptr);
Boolean retval = Delegates.wglUseFontOutlinesW((IntPtr)hDC, (Int32)first, (Int32)count, (Int32)listBase, (float)thickness, (float)deviation, (Int32)fontMode, (GlyphMetricsFloat*)glyphMetrics_ptr);
return retval;
}
}

View file

@ -27,10 +27,10 @@ namespace OpenTK.Platform.Windows
internal extern static Boolean CopyContext(IntPtr hglrcSrc, IntPtr hglrcDst, UInt32 mask);
[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglChoosePixelFormat", ExactSpelling = true)]
internal extern static unsafe int ChoosePixelFormat(IntPtr hDc, API.PixelFormatDescriptor* pPfd);
internal extern static unsafe int ChoosePixelFormat(IntPtr hDc, PixelFormatDescriptor* pPfd);
[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglDescribePixelFormat", ExactSpelling = true)]
internal extern static unsafe int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, API.PixelFormatDescriptor* ppfd);
internal extern static unsafe int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, PixelFormatDescriptor* ppfd);
[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglGetCurrentDC", ExactSpelling = true)]
internal extern static IntPtr GetCurrentDC();
@ -45,7 +45,7 @@ namespace OpenTK.Platform.Windows
internal extern static int GetPixelFormat(IntPtr hdc);
[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglSetPixelFormat", ExactSpelling = true)]
internal extern static unsafe Boolean SetPixelFormat(IntPtr hdc, int ipfd, API.PixelFormatDescriptor* ppfd);
internal extern static unsafe Boolean SetPixelFormat(IntPtr hdc, int ipfd, PixelFormatDescriptor* ppfd);
[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglSwapBuffers", ExactSpelling = true)]
internal extern static Boolean SwapBuffers(IntPtr hdc);
@ -57,7 +57,7 @@ namespace OpenTK.Platform.Windows
internal extern static IntPtr CreateLayerContext(IntPtr hDc, int level);
[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglDescribeLayerPlane", ExactSpelling = true)]
internal extern static unsafe Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, API.LayerPlaneDescriptor* plpd);
internal extern static unsafe Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, LayerPlaneDescriptor* plpd);
[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglSetLayerPaletteEntries", ExactSpelling = true)]
internal extern static unsafe int SetLayerPaletteEntries(IntPtr hdc, int iLayerPlane, int iStart, int cEntries, Int32* pcr);
@ -78,10 +78,10 @@ namespace OpenTK.Platform.Windows
internal extern static Boolean UseFontBitmapsW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase);
[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglUseFontOutlinesA", CharSet = CharSet.Auto)]
internal extern static unsafe Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat* glyphMetrics);
internal extern static unsafe Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat* glyphMetrics);
[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(Wgl.Library, EntryPoint = "wglUseFontOutlinesW", CharSet = CharSet.Auto)]
internal extern static unsafe Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat* glyphMetrics);
internal extern static unsafe Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat* glyphMetrics);
}
}
}

View file

@ -28,10 +28,10 @@ namespace OpenTK.Platform.Windows
internal delegate Boolean CopyContext(IntPtr hglrcSrc, IntPtr hglrcDst, UInt32 mask);
internal static CopyContext wglCopyContext = null;
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate int ChoosePixelFormat(IntPtr hDc, API.PixelFormatDescriptor* pPfd);
internal unsafe delegate int ChoosePixelFormat(IntPtr hDc, PixelFormatDescriptor* pPfd);
internal unsafe static ChoosePixelFormat wglChoosePixelFormat = null;
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, API.PixelFormatDescriptor* ppfd);
internal unsafe delegate int DescribePixelFormat(IntPtr hdc, int ipfd, UInt32 cjpfd, PixelFormatDescriptor* ppfd);
internal unsafe static DescribePixelFormat wglDescribePixelFormat = null;
[System.Security.SuppressUnmanagedCodeSecurity()]
internal delegate IntPtr GetCurrentDC();
@ -46,7 +46,7 @@ namespace OpenTK.Platform.Windows
internal delegate int GetPixelFormat(IntPtr hdc);
internal static GetPixelFormat wglGetPixelFormat = null;
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate Boolean SetPixelFormat(IntPtr hdc, int ipfd, API.PixelFormatDescriptor* ppfd);
internal unsafe delegate Boolean SetPixelFormat(IntPtr hdc, int ipfd, PixelFormatDescriptor* ppfd);
internal unsafe static SetPixelFormat wglSetPixelFormat = null;
[System.Security.SuppressUnmanagedCodeSecurity()]
internal delegate Boolean SwapBuffers(IntPtr hdc);
@ -58,7 +58,7 @@ namespace OpenTK.Platform.Windows
internal delegate IntPtr CreateLayerContext(IntPtr hDc, int level);
internal static CreateLayerContext wglCreateLayerContext = null;
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, API.LayerPlaneDescriptor* plpd);
internal unsafe delegate Boolean DescribeLayerPlane(IntPtr hDc, int pixelFormat, int layerPlane, UInt32 nBytes, LayerPlaneDescriptor* plpd);
internal unsafe static DescribeLayerPlane wglDescribeLayerPlane = null;
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate int SetLayerPaletteEntries(IntPtr hdc, int iLayerPlane, int iStart, int cEntries, Int32* pcr);
@ -79,10 +79,10 @@ namespace OpenTK.Platform.Windows
internal delegate Boolean UseFontBitmapsW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase);
internal static UseFontBitmapsW wglUseFontBitmapsW = null;
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat* glyphMetrics);
internal unsafe delegate Boolean UseFontOutlinesA(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat* glyphMetrics);
internal unsafe static UseFontOutlinesA wglUseFontOutlinesA = null;
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, API.GlyphMetricsFloat* glyphMetrics);
internal unsafe delegate Boolean UseFontOutlinesW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase, float thickness, float deviation, Int32 fontMode, GlyphMetricsFloat* glyphMetrics);
internal unsafe static UseFontOutlinesW wglUseFontOutlinesW = null;
[System.Security.SuppressUnmanagedCodeSecurity()]
internal delegate IntPtr CreateBufferRegionARB(IntPtr hDC, int iLayerPlane, UInt32 uType);

View file

@ -31,7 +31,7 @@ namespace OpenTK.Platform.Windows
#region --- Contructors ---
public WinGLContext()
: this(new DisplayMode(640, 480, new ColorDepth(32), 16, 0, 0, 2, false, false, false, 0.0f))
: this(new DisplayMode(640, 480, new ColorMode(32), 16, 0, 0, 2, false, false, false, 0.0f))
{
}
@ -72,20 +72,20 @@ namespace OpenTK.Platform.Windows
Debug.WriteLine(String.Format("Device context: {0}", deviceContext));
Debug.Write("Setting pixel format... ");
API.PixelFormatDescriptor pixelFormat = new API.PixelFormatDescriptor();
PixelFormatDescriptor pixelFormat = new PixelFormatDescriptor();
pixelFormat.Size = API.PixelFormatDescriptorSize;
pixelFormat.Version = API.PixelFormatDescriptorVersion;
pixelFormat.Flags =
API.PixelFormatDescriptorFlags.SUPPORT_OPENGL |
API.PixelFormatDescriptorFlags.DRAW_TO_WINDOW;
PixelFormatDescriptorFlags.SUPPORT_OPENGL |
PixelFormatDescriptorFlags.DRAW_TO_WINDOW;
pixelFormat.ColorBits = (byte)(mode.Color.Red + mode.Color.Green + mode.Color.Blue);
if (mode.Color.IsIndexed)
{
pixelFormat.PixelType = API.PixelType.INDEXED;
pixelFormat.PixelType = PixelType.INDEXED;
}
else
{
pixelFormat.PixelType = API.PixelType.RGBA;
pixelFormat.PixelType = PixelType.RGBA;
pixelFormat.RedBits = (byte)mode.Color.Red;
pixelFormat.GreenBits = (byte)mode.Color.Green;
pixelFormat.BlueBits = (byte)mode.Color.Blue;
@ -107,17 +107,17 @@ namespace OpenTK.Platform.Windows
if (mode.DepthBits <= 0)
{
pixelFormat.Flags |= API.PixelFormatDescriptorFlags.DEPTH_DONTCARE;
pixelFormat.Flags |= PixelFormatDescriptorFlags.DEPTH_DONTCARE;
}
if (mode.Stereo)
{
pixelFormat.Flags |= API.PixelFormatDescriptorFlags.STEREO;
pixelFormat.Flags |= PixelFormatDescriptorFlags.STEREO;
}
if (mode.Buffers > 1)
{
pixelFormat.Flags |= API.PixelFormatDescriptorFlags.DOUBLEBUFFER;
pixelFormat.Flags |= PixelFormatDescriptorFlags.DOUBLEBUFFER;
}
// TODO: More elaborate mode setting, using DescribePixelFormat.
@ -209,8 +209,8 @@ namespace OpenTK.Platform.Windows
while (!done)
{
API.DeviceMode currentMode = new API.DeviceMode();
IntPtr handle = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(API.DeviceMode)));
DeviceMode currentMode = new DeviceMode();
IntPtr handle = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DeviceMode)));
Marshal.StructureToPtr(currentMode, handle, true);
done = (API.EnumDisplaySettings(null, index++, handle) != 0) ? false : true;
@ -231,7 +231,7 @@ namespace OpenTK.Platform.Windows
DisplayMode mode = new DisplayMode(
currentMode.PelsWidth,
currentMode.PelsHeight,
new ColorDepth(currentMode.BitsPerPel),
new ColorMode(currentMode.BitsPerPel),
0,
0,
0,
@ -256,7 +256,7 @@ namespace OpenTK.Platform.Windows
public void Dispose()
{
Debug.Print("Manually disposing WinGLContext {0}.", this.renderContext);
//Debug.Print("Manually disposing WinGLContext {0}.", this.renderContext);
Dispose(true);
GC.SuppressFinalize(this);
}
@ -265,7 +265,8 @@ namespace OpenTK.Platform.Windows
{
if (!disposed)
{
// Clean unmanaged resources here:
// Clean unmanaged resources here
// The following call uses the Debug and Wgl classes, making it unsafe?
ReleaseResources();
if (calledManually)
@ -290,9 +291,8 @@ namespace OpenTK.Platform.Windows
Wgl.Imports.MakeCurrent(IntPtr.Zero, IntPtr.Zero);
if (!Wgl.Imports.DeleteContext(renderContext))
{
throw new ApplicationException(
"Could not destroy the OpenGL render context. Error: " + Marshal.GetLastWin32Error()
);
//throw new ApplicationException("Could not destroy the OpenGL render context. Error: " + Marshal.GetLastWin32Error());
//Debug.Print("Could not destroy the OpenGL render context. Error: {0}", Marshal.GetLastWin32Error());
}
renderContext = IntPtr.Zero;
}
@ -301,8 +301,8 @@ namespace OpenTK.Platform.Windows
{
if (!API.ReleaseDC(windowHandle, deviceContext))
{
throw new ApplicationException(
"Could not release device context. Error: " + Marshal.GetLastWin32Error());
//throw new ApplicationException("Could not release device context. Error: " + Marshal.GetLastWin32Error());
//Debug.Print("Could not destroy the device context. Error: {0}", Marshal.GetLastWin32Error());
}
}
@ -310,9 +310,8 @@ namespace OpenTK.Platform.Windows
{
if (!API.FreeLibrary(opengl32Handle))
{
throw new ApplicationException(
"FreeLibray call failed ('opengl32.dll'), Error: " + Marshal.GetLastWin32Error()
);
//throw new ApplicationException("FreeLibray call failed ('opengl32.dll'), Error: " + Marshal.GetLastWin32Error());
//Debug.Print("Could not release {0}. Error: {1}", opengl32Name, Marshal.GetLastWin32Error());
}
opengl32Handle = IntPtr.Zero;
}

View file

@ -17,7 +17,7 @@ using System.Diagnostics;
namespace OpenTK.Platform.Windows
{
sealed class WinGLControl : OpenTK.Platform.IGLControl
sealed class WinGLControl : IGLControl, IDisposable
{
private WinGLContext glContext;
private bool fullscreen;
@ -25,7 +25,7 @@ namespace OpenTK.Platform.Windows
private DisplayMode mode;
private bool disposed;
private Message msg; // Used only by the IsIdle event.
private MSG msg; // Used only by the IsIdle event.
#region --- Constructors ---
@ -39,6 +39,8 @@ namespace OpenTK.Platform.Windows
glContext = new WinGLContext(mode);
}
#endregion
void c_HandleCreated(object sender, EventArgs e)
{
Debug.Print("GLControl handle created, creating WinGLContext.");
@ -66,9 +68,7 @@ namespace OpenTK.Platform.Windows
glContext.Dispose();
}
#endregion
#region --- IGLControl membmers ---
#region --- IGLControl members ---
#region public bool IsIdle
@ -76,7 +76,7 @@ namespace OpenTK.Platform.Windows
{
get
{
return !API.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
return !API.PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0);
}
}
@ -115,7 +115,7 @@ namespace OpenTK.Platform.Windows
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
//GC.SuppressFinalize(this);
}
private void Dispose(bool calledManually)
@ -132,12 +132,12 @@ namespace OpenTK.Platform.Windows
disposed = true;
}
}
/*
~WinGLControl()
{
Dispose(false);
}
*/
#endregion
}
}

View file

@ -21,7 +21,7 @@ namespace OpenTK.Platform.Windows
/// Drives GameWindow on Windows.
/// This class supports OpenTK, and is not intended for use by OpenTK programs.
/// </summary>
sealed class WinGLNative : NativeWindow, INativeGLWindow, IDisposable
sealed class WinGLNative : NativeWindow, INativeGLWindow
{
#region --- Fields ---
@ -35,6 +35,11 @@ namespace OpenTK.Platform.Windows
private WindowInfo window;
private int top, bottom, left, right;
/// <summary>
/// For use in PeekMessage. System.Windows.Forms.Message causes deadlock there.
/// </summary>
private MSG myGoodMsg = new MSG();
/// <summary>
/// For use in WndProc only.
/// </summary>
@ -65,12 +70,12 @@ namespace OpenTK.Platform.Windows
/// <param name="m">Reference to the incoming Windows Message.</param>
protected override void WndProc(ref Message m)
{
switch (m.Msg)
switch ((WindowMessage)m.Msg)
{
case API.Constants.WM_WINDOWPOSCHANGED:
case WindowMessage.WINDOWPOSCHANGED:
// Get window size
width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.WindowPosition), "cx"));
height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.WindowPosition), "cy"));
width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(WindowPosition), "cx"));
height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(WindowPosition), "cy"));
width -= (left_border + right_border);
height -= (top_border + bottom_border);
//if (resizeEventArgs.Width != width || resizeEventArgs.Height != height)
@ -86,10 +91,10 @@ namespace OpenTK.Platform.Windows
// If the message was not a resize notification, send it to the default WndProc.
break;
case API.Constants.WM_CREATE:
case WindowMessage.CREATE:
// Set the window width and height:
this.mode.Width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.CreateStruct), "cx"));
this.mode.Height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.CreateStruct), "cy"));
this.mode.Width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(CreateStruct), "cx"));
this.mode.Height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(CreateStruct), "cy"));
this.mode.Width -= (left_border + right_border);
this.mode.Height -= (top_border + bottom_border);
@ -97,21 +102,23 @@ namespace OpenTK.Platform.Windows
this.OnCreate(EventArgs.Empty);
return;
case API.Constants.WM_CLOSE:
case WindowMessage.CLOSE:
this.DestroyWindow();
return;
case API.Constants.WM_DESTROY:
case WindowMessage.DESTROY:
this.OnDestroy(EventArgs.Empty);
break;
case API.Constants.WM_QUIT:
case WindowMessage.QUIT:
isExiting = true;
//this.Dispose();
//Debug.WriteLine("Application quit.");
return;
}
DefWndProc(ref m);
//DefWndProc(ref m);
base.WndProc(ref m);
}
#endregion
@ -121,12 +128,12 @@ namespace OpenTK.Platform.Windows
#region public void ProcessEvents()
private int ret;
System.Windows.Forms.Message msg;
MSG msg;
public void ProcessEvents()
{
while (!IsIdle)
{
ret = API.GetMessage(out msg, Handle, 0, 0);
ret = API.GetMessage(ref msg, Handle, 0, 0);
if (ret == -1)
{
throw new ApplicationException(String.Format(
@ -195,7 +202,7 @@ namespace OpenTK.Platform.Windows
get
{
//return !API.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
return !API.PeekMessage(out msg, this.Handle, 0, 0, 0);
return !API.PeekMessage(ref myGoodMsg, this.Handle, 0, 0, 0);
//return API.GetQueueStatus(API.QueueStatusFlags.ALLEVENTS) == 0;
}
}
@ -220,21 +227,21 @@ namespace OpenTK.Platform.Windows
CreateParams cp = new CreateParams();
cp.ClassStyle =
(int)API.WindowClassStyle.OwnDC |
(int)API.WindowClassStyle.VRedraw |
(int)API.WindowClassStyle.HRedraw |
(int)API.WindowClassStyle.Ime;
(int)WindowClassStyle.OwnDC |
(int)WindowClassStyle.VRedraw |
(int)WindowClassStyle.HRedraw |
(int)WindowClassStyle.Ime;
cp.Style =
(int)API.WindowStyle.Visible |
(int)API.WindowStyle.ClipChildren |
(int)API.WindowStyle.ClipSiblings |
(int)API.WindowStyle.OverlappedWindow;
(int)WindowStyle.Visible |
(int)WindowStyle.ClipChildren |
(int)WindowStyle.ClipSiblings |
(int)WindowStyle.OverlappedWindow;
API.Rectangle rect = new API.Rectangle();
Rectangle rect = new Rectangle();
rect.top = rect.left = 0;
rect.bottom = windowMode.Height;
rect.right = windowMode.Width;
API.AdjustWindowRect(ref rect, API.WindowStyle.OverlappedWindow, false);
API.AdjustWindowRect(ref rect, WindowStyle.OverlappedWindow, false);
// Not used
Top = 0;
@ -315,7 +322,7 @@ namespace OpenTK.Platform.Windows
public void DestroyWindow()
{
Debug.Print("Destroying window: {0}", window.ToString());
API.PostMessage(this.Handle, API.Constants.WM_DESTROY, IntPtr.Zero, IntPtr.Zero);
API.PostMessage(this.Handle, WindowMessage.DESTROY, IntPtr.Zero, IntPtr.Zero);
}
#endregion
@ -428,7 +435,7 @@ namespace OpenTK.Platform.Windows
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
//GC.SuppressFinalize(this);
}
private void Dispose(bool calledManually)
@ -441,17 +448,17 @@ namespace OpenTK.Platform.Windows
{
// Safe to clean managed resources
glContext.Dispose();
base.DestroyHandle();
//base.DestroyHandle();
}
disposed = true;
}
}
/*
~WinGLNative()
{
Dispose(false);
}
*/
#endregion
}

View file

@ -23,7 +23,7 @@ namespace OpenTK.Platform.Windows
/// <summary>
/// Input event data.
/// </summary>
private API.RawInput data = new API.RawInput();
private RawInput data = new RawInput();
/// <summary>
/// The total number of input devices connected to this system.
/// </summary>
@ -70,12 +70,12 @@ namespace OpenTK.Platform.Windows
/// <param name="msg">The WM_INPUT message, containing the data on the input event.</param>
protected override void WndProc(ref Message msg)
{
switch (msg.Msg)
switch ((WindowMessage)msg.Msg)
{
case API.Constants.WM_INPUT:
case WindowMessage.INPUT:
size = 0;
// Get the size of the input data
API.GetRawInputData(msg.LParam, API.GetRawInputDataEnum.INPUT,
API.GetRawInputData(msg.LParam, GetRawInputDataEnum.INPUT,
IntPtr.Zero, ref size, API.RawInputHeaderSize);
//if (data == null || API.RawInputSize < size)
@ -83,21 +83,21 @@ namespace OpenTK.Platform.Windows
// throw new ApplicationException("Critical error when processing raw windows input.");
//}
if (size == API.GetRawInputData(msg.LParam, API.GetRawInputDataEnum.INPUT,
if (size == API.GetRawInputData(msg.LParam, GetRawInputDataEnum.INPUT,
data, ref size, API.RawInputHeaderSize))
{
switch (data.Header.Type)
{
case API.RawInputDeviceType.KEYBOARD:
case RawInputDeviceType.KEYBOARD:
if (!keyboardDriver.ProcessKeyboardEvent(data))
API.DefRawInputProc(ref data, 1, (uint)API.RawInputHeaderSize);
return;
case API.RawInputDeviceType.MOUSE:
case RawInputDeviceType.MOUSE:
API.DefRawInputProc(ref data, 1, (uint)API.RawInputHeaderSize);
return;
case API.RawInputDeviceType.HID:
case RawInputDeviceType.HID:
API.DefRawInputProc(ref data, 1, (uint)API.RawInputHeaderSize);
return;
}
@ -110,13 +110,13 @@ namespace OpenTK.Platform.Windows
}
break;
case API.Constants.WM_CLOSE:
case API.Constants.WM_DESTROY:
case WindowMessage.CLOSE:
case WindowMessage.DESTROY:
Debug.Print("Input window detached from parent {0}.", Handle);
ReleaseHandle();
break;
case API.Constants.WM_QUIT:
case WindowMessage.QUIT:
Debug.WriteLine("Input window quit.");
this.Dispose();
break;
@ -168,6 +168,7 @@ namespace OpenTK.Platform.Windows
if (manual)
{
keyboardDriver.Dispose();
this.ReleaseHandle();
}
disposed = true;

View file

@ -23,10 +23,10 @@ namespace OpenTK.Platform.Windows
private List<Keyboard> keyboards = new List<Keyboard>();
private IntPtr windowHandle;
#region internal static Dictionary<API.VirtualKeys, Input.Key> KeyMap
#region internal static Dictionary<VirtualKeys, Input.Key> KeyMap
internal static Dictionary<API.VirtualKeys, Input.Key> KeyMap =
new Dictionary<API.VirtualKeys, Input.Key>((int)API.VirtualKeys.Last);
internal static Dictionary<VirtualKeys, Input.Key> KeyMap =
new Dictionary<VirtualKeys, Input.Key>((int)VirtualKeys.Last);
private static bool keyMapExists;
/// <summary>
@ -38,81 +38,81 @@ namespace OpenTK.Platform.Windows
{
try
{
KeyMap.Add(API.VirtualKeys.ESCAPE, Input.Key.Escape);
KeyMap.Add(VirtualKeys.ESCAPE, Input.Key.Escape);
// Function keys
for (int i = 0; i < 24; i++)
{
KeyMap.Add((API.VirtualKeys)((int)API.VirtualKeys.F1 + i), Input.Key.F1 + i);
KeyMap.Add((VirtualKeys)((int)VirtualKeys.F1 + i), Input.Key.F1 + i);
}
// Number keys (0-9)
for (int i = 0; i <= 9; i++)
{
KeyMap.Add((API.VirtualKeys)(0x30 + i), Input.Key.Number0 + i);
KeyMap.Add((VirtualKeys)(0x30 + i), Input.Key.Number0 + i);
}
// Letters (A-Z)
for (int i = 0; i < 26; i++)
{
KeyMap.Add((API.VirtualKeys)(0x41 + i), Input.Key.A + i);
KeyMap.Add((VirtualKeys)(0x41 + i), Input.Key.A + i);
}
KeyMap.Add(API.VirtualKeys.TAB, Input.Key.Tab);
KeyMap.Add(API.VirtualKeys.CAPITAL, Input.Key.CapsLock);
KeyMap.Add(API.VirtualKeys.LCONTROL, Input.Key.ControlLeft);
KeyMap.Add(API.VirtualKeys.LSHIFT, Input.Key.ShiftLeft);
KeyMap.Add(API.VirtualKeys.LWIN, Input.Key.WinLeft);
KeyMap.Add(API.VirtualKeys.LMENU, Input.Key.AltLeft);
KeyMap.Add(API.VirtualKeys.SPACE, Input.Key.Space);
KeyMap.Add(API.VirtualKeys.RMENU, Input.Key.AltRight);
KeyMap.Add(API.VirtualKeys.RWIN, Input.Key.WinRight);
KeyMap.Add(API.VirtualKeys.APPS, Input.Key.Menu);
KeyMap.Add(API.VirtualKeys.RCONTROL, Input.Key.ControlRight);
KeyMap.Add(API.VirtualKeys.RSHIFT, Input.Key.ShiftRight);
KeyMap.Add(API.VirtualKeys.RETURN, Input.Key.Enter);
KeyMap.Add(API.VirtualKeys.BACK, Input.Key.BackSpace);
KeyMap.Add(VirtualKeys.TAB, Input.Key.Tab);
KeyMap.Add(VirtualKeys.CAPITAL, Input.Key.CapsLock);
KeyMap.Add(VirtualKeys.LCONTROL, Input.Key.ControlLeft);
KeyMap.Add(VirtualKeys.LSHIFT, Input.Key.ShiftLeft);
KeyMap.Add(VirtualKeys.LWIN, Input.Key.WinLeft);
KeyMap.Add(VirtualKeys.LMENU, Input.Key.AltLeft);
KeyMap.Add(VirtualKeys.SPACE, Input.Key.Space);
KeyMap.Add(VirtualKeys.RMENU, Input.Key.AltRight);
KeyMap.Add(VirtualKeys.RWIN, Input.Key.WinRight);
KeyMap.Add(VirtualKeys.APPS, Input.Key.Menu);
KeyMap.Add(VirtualKeys.RCONTROL, Input.Key.ControlRight);
KeyMap.Add(VirtualKeys.RSHIFT, Input.Key.ShiftRight);
KeyMap.Add(VirtualKeys.RETURN, Input.Key.Enter);
KeyMap.Add(VirtualKeys.BACK, Input.Key.BackSpace);
KeyMap.Add(API.VirtualKeys.OEM_1, Input.Key.Semicolon); // Varies by keyboard, ;: on Win2K/US
KeyMap.Add(API.VirtualKeys.OEM_2, Input.Key.Slash); // Varies by keyboard, /? on Win2K/US
KeyMap.Add(API.VirtualKeys.OEM_3, Input.Key.Tilde); // Varies by keyboard, `~ on Win2K/US
KeyMap.Add(API.VirtualKeys.OEM_4, Input.Key.BracketLeft); // Varies by keyboard, [{ on Win2K/US
KeyMap.Add(API.VirtualKeys.OEM_5, Input.Key.BackSlash); // Varies by keyboard, \| on Win2K/US
KeyMap.Add(API.VirtualKeys.OEM_6, Input.Key.BracketRight); // Varies by keyboard, ]} on Win2K/US
KeyMap.Add(API.VirtualKeys.OEM_7, Input.Key.Quote); // Varies by keyboard, '" on Win2K/US
KeyMap.Add(API.VirtualKeys.OEM_PLUS, Input.Key.Plus); // Invariant: +
KeyMap.Add(API.VirtualKeys.OEM_COMMA, Input.Key.Comma); // Invariant: ,
KeyMap.Add(API.VirtualKeys.OEM_MINUS, Input.Key.Minus); // Invariant: -
KeyMap.Add(API.VirtualKeys.OEM_PERIOD, Input.Key.Period); // Invariant: .
KeyMap.Add(VirtualKeys.OEM_1, Input.Key.Semicolon); // Varies by keyboard, ;: on Win2K/US
KeyMap.Add(VirtualKeys.OEM_2, Input.Key.Slash); // Varies by keyboard, /? on Win2K/US
KeyMap.Add(VirtualKeys.OEM_3, Input.Key.Tilde); // Varies by keyboard, `~ on Win2K/US
KeyMap.Add(VirtualKeys.OEM_4, Input.Key.BracketLeft); // Varies by keyboard, [{ on Win2K/US
KeyMap.Add(VirtualKeys.OEM_5, Input.Key.BackSlash); // Varies by keyboard, \| on Win2K/US
KeyMap.Add(VirtualKeys.OEM_6, Input.Key.BracketRight); // Varies by keyboard, ]} on Win2K/US
KeyMap.Add(VirtualKeys.OEM_7, Input.Key.Quote); // Varies by keyboard, '" on Win2K/US
KeyMap.Add(VirtualKeys.OEM_PLUS, Input.Key.Plus); // Invariant: +
KeyMap.Add(VirtualKeys.OEM_COMMA, Input.Key.Comma); // Invariant: ,
KeyMap.Add(VirtualKeys.OEM_MINUS, Input.Key.Minus); // Invariant: -
KeyMap.Add(VirtualKeys.OEM_PERIOD, Input.Key.Period); // Invariant: .
KeyMap.Add(API.VirtualKeys.HOME, Input.Key.Home);
KeyMap.Add(API.VirtualKeys.END, Input.Key.End);
KeyMap.Add(API.VirtualKeys.DELETE, Input.Key.Delete);
KeyMap.Add(API.VirtualKeys.PRIOR, Input.Key.PageUp);
KeyMap.Add(API.VirtualKeys.NEXT, Input.Key.PageDown);
KeyMap.Add(API.VirtualKeys.PRINT, Input.Key.PrintScreen);
KeyMap.Add(API.VirtualKeys.PAUSE, Input.Key.Pause);
KeyMap.Add(API.VirtualKeys.NUMLOCK, Input.Key.NumLock);
KeyMap.Add(VirtualKeys.HOME, Input.Key.Home);
KeyMap.Add(VirtualKeys.END, Input.Key.End);
KeyMap.Add(VirtualKeys.DELETE, Input.Key.Delete);
KeyMap.Add(VirtualKeys.PRIOR, Input.Key.PageUp);
KeyMap.Add(VirtualKeys.NEXT, Input.Key.PageDown);
KeyMap.Add(VirtualKeys.PRINT, Input.Key.PrintScreen);
KeyMap.Add(VirtualKeys.PAUSE, Input.Key.Pause);
KeyMap.Add(VirtualKeys.NUMLOCK, Input.Key.NumLock);
KeyMap.Add(API.VirtualKeys.SLEEP, Input.Key.Sleep);
KeyMap.Add(VirtualKeys.SLEEP, Input.Key.Sleep);
// Keypad
for (int i = 0; i <= 9; i++)
{
KeyMap.Add((API.VirtualKeys)((int)API.VirtualKeys.NUMPAD0 + i), Input.Key.Keypad0 + i);
KeyMap.Add((VirtualKeys)((int)VirtualKeys.NUMPAD0 + i), Input.Key.Keypad0 + i);
}
KeyMap.Add(API.VirtualKeys.DECIMAL, Input.Key.KeypadDecimal);
KeyMap.Add(API.VirtualKeys.ADD, Input.Key.KeypadAdd);
KeyMap.Add(API.VirtualKeys.SUBTRACT, Input.Key.KeypadSubtract);
KeyMap.Add(API.VirtualKeys.DIVIDE, Input.Key.KeypadDivide);
KeyMap.Add(API.VirtualKeys.MULTIPLY, Input.Key.KeypadMultiply);
KeyMap.Add(VirtualKeys.DECIMAL, Input.Key.KeypadDecimal);
KeyMap.Add(VirtualKeys.ADD, Input.Key.KeypadAdd);
KeyMap.Add(VirtualKeys.SUBTRACT, Input.Key.KeypadSubtract);
KeyMap.Add(VirtualKeys.DIVIDE, Input.Key.KeypadDivide);
KeyMap.Add(VirtualKeys.MULTIPLY, Input.Key.KeypadMultiply);
// Navigation
KeyMap.Add(API.VirtualKeys.UP, Input.Key.Up);
KeyMap.Add(API.VirtualKeys.DOWN, Input.Key.Down);
KeyMap.Add(API.VirtualKeys.LEFT, Input.Key.Left);
KeyMap.Add(API.VirtualKeys.RIGHT, Input.Key.Right);
KeyMap.Add(VirtualKeys.UP, Input.Key.Up);
KeyMap.Add(VirtualKeys.DOWN, Input.Key.Down);
KeyMap.Add(VirtualKeys.LEFT, Input.Key.Left);
KeyMap.Add(VirtualKeys.RIGHT, Input.Key.Right);
}
catch (ArgumentException e)
{
@ -156,18 +156,18 @@ namespace OpenTK.Platform.Windows
internal void UpdateKeyboardList()
{
int count = WinRawInput.DeviceCount;
API.RawInputDeviceList[] ridl = new API.RawInputDeviceList[count];
RawInputDeviceList[] ridl = new RawInputDeviceList[count];
for (int i = 0; i < count; i++)
ridl[i] = new API.RawInputDeviceList();
ridl[i] = new RawInputDeviceList();
API.GetRawInputDeviceList(ridl, ref count, API.RawInputDeviceListSize);
// Discover keyboard devices:
for (int i = 0; i < count; i++)
{
uint size = 0;
API.GetRawInputDeviceInfo(ridl[i].Device, API.RawInputDeviceInfoEnum.DEVICENAME, IntPtr.Zero, ref size);
API.GetRawInputDeviceInfo(ridl[i].Device, RawInputDeviceInfoEnum.DEVICENAME, IntPtr.Zero, ref size);
IntPtr name_ptr = Marshal.AllocHGlobal((IntPtr)size);
API.GetRawInputDeviceInfo(ridl[i].Device, API.RawInputDeviceInfoEnum.DEVICENAME, name_ptr, ref size);
API.GetRawInputDeviceInfo(ridl[i].Device, RawInputDeviceInfoEnum.DEVICENAME, name_ptr, ref size);
string name = Marshal.PtrToStringAnsi(name_ptr);
Marshal.FreeHGlobal(name_ptr);
if (name.ToLower().Contains("root"))
@ -175,7 +175,7 @@ namespace OpenTK.Platform.Windows
// This is a terminal services devices, skip it.
continue;
}
else if (ridl[i].Type == API.RawInputDeviceType.KEYBOARD || ridl[i].Type == API.RawInputDeviceType.HID)
else if (ridl[i].Type == RawInputDeviceType.KEYBOARD || ridl[i].Type == RawInputDeviceType.HID)
{
//It's a keyboard or a USB device that could be a keyboard
@ -206,9 +206,9 @@ namespace OpenTK.Platform.Windows
kb.Description = deviceDesc;
// Register the keyboard:
API.RawInputDeviceInfo info = new API.RawInputDeviceInfo();
RawInputDeviceInfo info = new RawInputDeviceInfo();
int devInfoSize = API.RawInputDeviceInfoSize;
API.GetRawInputDeviceInfo(ridl[i].Device, API.RawInputDeviceInfoEnum.DEVICEINFO,
API.GetRawInputDeviceInfo(ridl[i].Device, RawInputDeviceInfoEnum.DEVICEINFO,
info, ref devInfoSize);
kb.NumberOfLeds = info.Device.Keyboard.NumberOfIndicators;
@ -232,12 +232,12 @@ namespace OpenTK.Platform.Windows
internal void RegisterKeyboardDevice(Keyboard kb)
{
API.RawInputDevice[] rid = new API.RawInputDevice[1];
RawInputDevice[] rid = new RawInputDevice[1];
// Keyboard is 1/6 (page/id). See http://www.microsoft.com/whdc/device/input/HID_HWID.mspx
rid[0] = new API.RawInputDevice();
rid[0] = new RawInputDevice();
rid[0].UsagePage = 1;
rid[0].Usage = 6;
rid[0].Flags = API.RawInputDeviceFlags.INPUTSINK;
rid[0].Flags = RawInputDeviceFlags.INPUTSINK;
rid[0].Target = windowHandle;
if (!API.RegisterRawInputDevices(rid, 1, API.RawInputDeviceSize))
@ -264,30 +264,30 @@ namespace OpenTK.Platform.Windows
/// </summary>
/// <param name="rin"></param>
/// <returns></returns>
internal bool ProcessKeyboardEvent(API.RawInput rin)
internal bool ProcessKeyboardEvent(RawInput rin)
{
//Keyboard key = keyboards[0];
//rin.Header.Device;
switch (rin.Header.Type)
{
case API.RawInputDeviceType.KEYBOARD:
case RawInputDeviceType.KEYBOARD:
bool pressed =
rin.Data.Keyboard.Message == API.Constants.WM_KEYDOWN ||
rin.Data.Keyboard.Message == API.Constants.WM_SYSKEYDOWN;
rin.Data.Keyboard.Message == (int)WindowMessage.KEYDOWN ||
rin.Data.Keyboard.Message == (int)WindowMessage.SYSKEYDOWN;
// Generic control, shift, alt keys may be sent instead of left/right.
// It seems you have to explicitly register left/right events.
switch (rin.Data.Keyboard.VKey)
{
case API.VirtualKeys.SHIFT:
case VirtualKeys.SHIFT:
keyboards[0][Input.Key.ShiftLeft] = keyboards[0][Input.Key.ShiftRight] = pressed;
return true;
case API.VirtualKeys.CONTROL:
case VirtualKeys.CONTROL:
keyboards[0][Input.Key.ControlLeft] = keyboards[0][Input.Key.ControlRight] = pressed;
return true;
case API.VirtualKeys.MENU:
case VirtualKeys.MENU:
keyboards[0][Input.Key.AltLeft] = keyboards[0][Input.Key.AltRight] = pressed;
return true;
@ -349,9 +349,8 @@ namespace OpenTK.Platform.Windows
{
if (manual)
{
//keyboards.Clear();
keyboards.Clear();
}
disposed = true;
}
}