[SDL] Fixed cursor support

SDL.CreateColorCursor takes 3 arguments, not 5.
This commit is contained in:
thefiddler 2014-04-27 21:09:51 +02:00
parent 48e21328c5
commit d787656328
2 changed files with 22 additions and 10 deletions

View file

@ -83,7 +83,7 @@ namespace OpenTK.Platform.SDL2
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_CreateColorCursor", ExactSpelling = true)] [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_CreateColorCursor", ExactSpelling = true)]
public static extern Cursor CreateColorCursor(Surface surface, int w, int h, int hot_x, int hot_y); public static extern Cursor CreateColorCursor(Surface surface, int hot_x, int hot_y);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_FreeCursor", ExactSpelling = true)] [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_FreeCursor", ExactSpelling = true)]
@ -242,6 +242,10 @@ namespace OpenTK.Platform.SDL2
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetModState", ExactSpelling = true)] [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetModState", ExactSpelling = true)]
public static extern Keymod GetModState(); public static extern Keymod GetModState();
[SuppressUnmanagedCodeSecurity]
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetMouseState", ExactSpelling = true)]
public static extern ButtonFlags GetMouseState(out int hx, out int hy);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetNumDisplayModes", ExactSpelling = true)] [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetNumDisplayModes", ExactSpelling = true)]
public static extern int GetNumDisplayModes(int displayIndex); public static extern int GetNumDisplayModes(int displayIndex);

View file

@ -498,21 +498,29 @@ namespace OpenTK.Platform.SDL2
IntPtr cursor_surface = IntPtr cursor_surface =
SDL.CreateRGBSurfaceFrom( SDL.CreateRGBSurfaceFrom(
new IntPtr(pixels), new IntPtr(pixels),
cursor.Width, value.Width,
cursor.Height, value.Height,
32, 32,
cursor.Width * 4, value.Width * 4,
0xff000000, 0xff000000,
0x00ff0000, 0x00ff0000,
0x0000ff00, 0x0000ff00,
0x000000ff); 0x000000ff);
sdl_cursor = SDL.CreateColorCursor( if (cursor_surface == IntPtr.Zero)
cursor_surface, {
cursor.Width, Debug.Print("[SDL2] Failed to create cursor surface. Error: {0}",
cursor.Height, SDL.GetError());
cursor.X, return;
cursor.Y); }
sdl_cursor = SDL.CreateColorCursor(cursor_surface, value.X, value.Y);
if (sdl_cursor == IntPtr.Zero)
{
Debug.Print("[SDL2] Failed to create cursor. Error: {0}",
SDL.GetError());
return;
}
if (sdl_cursor != IntPtr.Zero) if (sdl_cursor != IntPtr.Zero)
{ {