Merge pull request #27 from jameson-ernst/master

Fixed gamma-ramp marshaling, more out params
This commit is contained in:
Ethan Lee 2013-07-24 16:57:29 -07:00
commit 5dd0738ebd
2 changed files with 34 additions and 28 deletions

View file

@ -352,8 +352,8 @@ namespace SDL2
/* userdata refers to a void* */ /* userdata refers to a void* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_LogGetOutputFunction( public static extern void SDL_LogGetOutputFunction(
ref SDL_LogOutputFunction callback, out SDL_LogOutputFunction callback,
ref IntPtr userdata out IntPtr userdata
); );
/* userdata refers to a void* */ /* userdata refers to a void* */
@ -533,7 +533,7 @@ namespace SDL2
public byte patch; public byte patch;
} }
public static void SDL_VERSION(ref SDL_version x) public static void SDL_VERSION(out SDL_version x)
{ {
x.major = SDL_MAJOR_VERSION; x.major = SDL_MAJOR_VERSION;
x.minor = SDL_MINOR_VERSION; x.minor = SDL_MINOR_VERSION;
@ -551,7 +551,7 @@ namespace SDL2
} }
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
private static extern void SDL_GetVersion(ref SDL_version ver); private static extern void SDL_GetVersion(out SDL_version ver);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)]
@ -692,8 +692,8 @@ namespace SDL2
int width, int width,
int height, int height,
SDL_WindowFlags window_flags, SDL_WindowFlags window_flags,
ref IntPtr window, out IntPtr window,
ref IntPtr renderer out IntPtr renderer
); );
/* IntPtr refers to an SDL_Window*. data is a void* pointer. */ /* IntPtr refers to an SDL_Window*. data is a void* pointer. */
@ -715,13 +715,13 @@ namespace SDL2
public static extern IntPtr SDL_GetClosestDisplayMode( public static extern IntPtr SDL_GetClosestDisplayMode(
int displayIndex, int displayIndex,
ref SDL_DisplayMode mode, ref SDL_DisplayMode mode,
ref SDL_DisplayMode closest out SDL_DisplayMode closest
); );
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetCurrentDisplayMode( public static extern int SDL_GetCurrentDisplayMode(
int displayIndex, int displayIndex,
ref SDL_DisplayMode mode out SDL_DisplayMode mode
); );
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -731,20 +731,20 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetDesktopDisplayMode( public static extern int SDL_GetDesktopDisplayMode(
int displayIndex, int displayIndex,
ref SDL_DisplayMode mode out SDL_DisplayMode mode
); );
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetDisplayBounds( public static extern int SDL_GetDisplayBounds(
int displayIndex, int displayIndex,
ref SDL_Rect rect out SDL_Rect rect
); );
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetDisplayMode( public static extern int SDL_GetDisplayMode(
int displayIndex, int displayIndex,
int modeIndex, int modeIndex,
ref SDL_DisplayMode mode out SDL_DisplayMode mode
); );
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -788,7 +788,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetWindowDisplayMode( public static extern int SDL_GetWindowDisplayMode(
IntPtr window, IntPtr window,
ref SDL_DisplayMode mode out SDL_DisplayMode mode
); );
/* window refers to an SDL_Window* */ /* window refers to an SDL_Window* */
@ -803,9 +803,12 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetWindowGammaRamp( public static extern int SDL_GetWindowGammaRamp(
IntPtr window, IntPtr window,
ref ushort red, [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
ref ushort green, ushort[] red,
ref ushort blue [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
ushort[] green,
[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
ushort[] blue
); );
/* window refers to an SDL_Window* */ /* window refers to an SDL_Window* */
@ -826,16 +829,16 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_GetWindowPosition( public static extern void SDL_GetWindowPosition(
IntPtr window, IntPtr window,
ref int x, out int x,
ref int y out int y
); );
/* window refers to an SDL_Window* */ /* window refers to an SDL_Window* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_GetWindowSize( public static extern void SDL_GetWindowSize(
IntPtr window, IntPtr window,
ref int w, out int w,
ref int h out int h
); );
/* IntPtr refers to an SDL_Surface*, window to an SDL_Window* */ /* IntPtr refers to an SDL_Surface*, window to an SDL_Window* */
@ -853,8 +856,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GL_BindTexture( public static extern int SDL_GL_BindTexture(
IntPtr texture, IntPtr texture,
ref float texw, out float texw,
ref float texh out float texh
); );
/* IntPtr and window refer to an SDL_GLContext and SDL_Window* */ /* IntPtr and window refer to an SDL_GLContext and SDL_Window* */
@ -881,7 +884,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GL_GetAttribute( public static extern int SDL_GL_GetAttribute(
SDL_GLattr attr, SDL_GLattr attr,
ref int value out int value
); );
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -968,9 +971,12 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_SetWindowGammaRamp( public static extern int SDL_SetWindowGammaRamp(
IntPtr window, IntPtr window,
ref ushort red, [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
ref ushort green, ushort[] red,
ref ushort blue [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
ushort[] green,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
ushort[] blue
); );
/* window refers to an SDL_Window* */ /* window refers to an SDL_Window* */

View file

@ -176,9 +176,9 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_QuerySpec( public static extern int Mix_QuerySpec(
ref int frequency, out int frequency,
ref ushort format, out ushort format,
ref int channels out int channels
); );
/* These are for Mix_LoadWAV, which is a macro in the C header. /* These are for Mix_LoadWAV, which is a macro in the C header.