Fixed PixelFormatDescriptorFlags.

Fixed SetWindowLongPtr on 32bit platforms.
Added DescribePixelFormat.
Added SetLastError to SetPixelFormat.
This commit is contained in:
the_fiddler 2008-02-28 13:45:38 +00:00
parent 009a4aa1b4
commit 8d9b66ef18

View file

@ -218,14 +218,32 @@ namespace OpenTK.Platform.Windows
LPARAM lParam LPARAM lParam
); );
internal static IntPtr SetWindowLong(IntPtr handle, GetWindowLongOffsets index, IntPtr newValue)
{
if (IntPtr.Size == 4)
return (IntPtr)SetWindowLong(handle, index, (LONG)newValue);
return SetWindowLongPtr(handle, index, newValue);
}
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("user32.dll", SetLastError = true)] [DllImport("user32.dll", SetLastError = true)]
internal static extern LONG_PTR SetWindowLongPtr( static extern LONG SetWindowLong(
HWND hWnd,
GetWindowLongOffsets nIndex,
LONG dwNewLong
);
[SuppressUnmanagedCodeSecurity]
[DllImport("user32.dll", SetLastError = true)]
static extern LONG_PTR SetWindowLongPtr(
HWND hWnd, HWND hWnd,
GetWindowLongOffsets nIndex, GetWindowLongOffsets nIndex,
LONG_PTR dwNewLong LONG_PTR dwNewLong
); );
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("user32.dll", SetLastError = true)] [DllImport("user32.dll", SetLastError = true)]
internal static extern LONG_PTR GetWindowLongPtr( internal static extern LONG_PTR GetWindowLongPtr(
@ -417,17 +435,14 @@ namespace OpenTK.Platform.Windows
#region ChoosePixelFormat #region ChoosePixelFormat
/// <summary>
///
/// </summary>
/// <param name="dc"></param>
/// <param name="pfd"></param>
/// <returns></returns>
[DllImport("gdi32.dll")] [DllImport("gdi32.dll")]
internal static extern int ChoosePixelFormat(IntPtr dc, ref PixelFormatDescriptor pfd); internal static extern int ChoosePixelFormat(IntPtr dc, ref PixelFormatDescriptor pfd);
#endregion #endregion
[DllImport("gdi32.dll")]
internal static extern int DescribePixelFormat(IntPtr deviceContext, int pixel, int pfdSize, ref PixelFormatDescriptor pixelFormat);
#region SetPixelFormat #region SetPixelFormat
/// <summary> /// <summary>
@ -437,7 +452,7 @@ namespace OpenTK.Platform.Windows
/// <param name="format"></param> /// <param name="format"></param>
/// <param name="pfd"></param> /// <param name="pfd"></param>
/// <returns></returns> /// <returns></returns>
[DllImport("gdi32.dll")] [DllImport("gdi32.dll", SetLastError=true)]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool SetPixelFormat(IntPtr dc, int format, ref PixelFormatDescriptor pfd); internal static extern bool SetPixelFormat(IntPtr dc, int format, ref PixelFormatDescriptor pfd);
@ -2498,20 +2513,20 @@ namespace OpenTK.Platform.Windows
internal enum PixelFormatDescriptorFlags : int internal enum PixelFormatDescriptorFlags : int
{ {
// PixelFormatDescriptor flags // PixelFormatDescriptor flags
DOUBLEBUFFER, DOUBLEBUFFER = 0x01,
STEREO, STEREO = 0x02,
DRAW_TO_WINDOW, DRAW_TO_WINDOW = 0x04,
DRAW_TO_BITMAP, DRAW_TO_BITMAP = 0x08,
SUPPORT_GDI, SUPPORT_GDI = 0x10,
SUPPORT_OPENGL, SUPPORT_OPENGL = 0x20,
GENERIC_FORMAT, GENERIC_FORMAT = 0x40,
NEED_PALETTE, NEED_PALETTE = 0x80,
NEED_SYSTEM_PALETTE, NEED_SYSTEM_PALETTE = 0x100,
SWAP_EXCHANGE, SWAP_EXCHANGE = 0x200,
SWAP_COPY, SWAP_COPY = 0x400,
SWAP_LAYER_BUFFERS, SWAP_LAYER_BUFFERS = 0x800,
GENERIC_ACCELERATED, GENERIC_ACCELERATED = 0x1000,
SUPPORT_DIRECTDRAW, SUPPORT_DIRECTDRAW = 0x2000,
// PixelFormatDescriptor flags for use in ChoosePixelFormat only // PixelFormatDescriptor flags for use in ChoosePixelFormat only
DEPTH_DONTCARE = unchecked((int)0x20000000), DEPTH_DONTCARE = unchecked((int)0x20000000),