Merge pull request #25 from jameson-ernst/master

Marshaling refinements and SDL_ShowMessageBox
This commit is contained in:
Ethan Lee 2013-07-14 22:15:51 -07:00
commit 7a4820d660
6 changed files with 258 additions and 106 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
bin/
obj/
*.userprefs

View file

@ -38,7 +38,7 @@ namespace SDL2
_leaveAllocatedInstance = new LPUtf8StrMarshaler(true),
_defaultInstance = new LPUtf8StrMarshaler(false);
private static ICustomMarshaler GetInstance(string cookie)
public static ICustomMarshaler GetInstance(string cookie)
{
switch (cookie)
{

View file

@ -366,27 +366,149 @@ namespace SDL2
#endregion
#region SDL_messagebox.h
[Flags]
public enum SDL_MessageBoxFlags : uint
{
SDL_MESSAGEBOX_ERROR = 0x00000010,
SDL_MESSAGEBOX_WARNING = 0x00000020,
SDL_MESSAGEBOX_INFORMATION = 0x00000040
SDL_MESSAGEBOX_ERROR = 0x00000010,
SDL_MESSAGEBOX_WARNING = 0x00000020,
SDL_MESSAGEBOX_INFORMATION = 0x00000040
}
[Flags]
public enum SDL_MessageBoxButtonFlags : uint
{
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001,
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002
}
[StructLayout(LayoutKind.Sequential)]
private struct INTERNAL_SDL_MessageBoxButtonData
{
public SDL_MessageBoxButtonFlags flags;
public int buttonid;
public IntPtr text; /* The UTF-8 button text */
}
[StructLayout(LayoutKind.Sequential)]
public struct SDL_MessageBoxButtonData
{
public SDL_MessageBoxButtonFlags flags;
public int buttonid;
public string text; /* The UTF-8 button text */
}
[StructLayout(LayoutKind.Sequential)]
public struct SDL_MessageBoxColor
{
public byte r, g, b;
}
public enum SDL_MessageBoxColorType
{
SDL_MESSAGEBOX_COLOR_BACKGROUND,
SDL_MESSAGEBOX_COLOR_TEXT,
SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,
SDL_MESSAGEBOX_COLOR_MAX
}
[StructLayout(LayoutKind.Sequential)]
public struct SDL_MessageBoxColorScheme
{
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = (int)SDL_MessageBoxColorType.SDL_MESSAGEBOX_COLOR_MAX)]
public SDL_MessageBoxColor[] colors;
}
[StructLayout(LayoutKind.Sequential)]
private struct INTERNAL_SDL_MessageBoxData
{
public SDL_MessageBoxFlags flags;
public IntPtr window; /* Parent window, can be NULL */
public IntPtr title; /* UTF-8 title */
public IntPtr message; /* UTF-8 message text */
public int numbuttons;
public IntPtr buttons;
public IntPtr colorScheme; /* Can be NULL to use system settings */
}
[StructLayout(LayoutKind.Sequential)]
public struct SDL_MessageBoxData
{
public SDL_MessageBoxFlags flags;
public IntPtr window; /* Parent window, can be NULL */
public string title; /* UTF-8 title */
public string message; /* UTF-8 message text */
public int numbuttons;
public SDL_MessageBoxButtonData[] buttons;
public SDL_MessageBoxColorScheme? colorScheme; /* Can be NULL to use system settings */
}
[DllImport(nativeLibName, EntryPoint = "SDL_ShowMessageBox", CallingConvention = CallingConvention.Cdecl)]
private static extern int INTERNAL_SDL_ShowMessageBox([In()] ref INTERNAL_SDL_MessageBoxData messageboxdata, out int buttonid);
public static unsafe int SDL_ShowMessageBox([In()] ref SDL_MessageBoxData messageboxdata, out int buttonid)
{
var utf8 = LPUtf8StrMarshaler.GetInstance(null);
var data = new INTERNAL_SDL_MessageBoxData()
{
flags = messageboxdata.flags,
window = messageboxdata.window,
title = utf8.MarshalManagedToNative(messageboxdata.title),
message = utf8.MarshalManagedToNative(messageboxdata.message),
numbuttons = messageboxdata.numbuttons,
};
var buttons = new INTERNAL_SDL_MessageBoxButtonData[messageboxdata.numbuttons];
for (int i = 0; i < messageboxdata.numbuttons; i++)
{
buttons[i] = new INTERNAL_SDL_MessageBoxButtonData()
{
flags = messageboxdata.buttons[i].flags,
buttonid = messageboxdata.buttons[i].buttonid,
text = utf8.MarshalManagedToNative(messageboxdata.buttons[i].text),
};
}
if (messageboxdata.colorScheme != null)
{
data.colorScheme = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SDL_MessageBoxColorScheme)));
Marshal.StructureToPtr(messageboxdata.colorScheme.Value, data.colorScheme, false);
}
int result;
fixed (INTERNAL_SDL_MessageBoxButtonData* buttonsPtr = &buttons[0])
{
data.buttons = (IntPtr)buttonsPtr;
result = INTERNAL_SDL_ShowMessageBox(ref data, out buttonid);
}
Marshal.FreeHGlobal(data.colorScheme);
for (int i = 0; i < messageboxdata.numbuttons; i++)
{
utf8.CleanUpNativeData(buttons[i].text);
}
utf8.CleanUpNativeData(data.message);
utf8.CleanUpNativeData(data.title);
return result;
}
/* window refers to an SDL_Window* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_ShowSimpleMessageBox(
UInt32 flags,
SDL_MessageBoxFlags flags,
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
string title,
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
string message,
IntPtr window
);
#endregion
#region SDL_version.h, SDL_revision.h
/* Similar to the headers, this is the version we're expecting to be
@ -908,7 +1030,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_UpdateWindowSurfaceRects(
IntPtr window,
SDL_Rect[] rects,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)]
SDL_Rect[] rects,
int numrects
);
@ -1015,23 +1138,23 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetRenderDrawBlendMode(
IntPtr renderer,
ref SDL_BlendMode blendMode
out SDL_BlendMode blendMode
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetRenderDrawColor(
IntPtr renderer,
ref byte r,
ref byte g,
ref byte b,
ref byte a
out byte r,
out byte g,
out byte b,
out byte a
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetRenderDriverInfo(
int index,
ref SDL_RendererInfo info
out SDL_RendererInfo info
);
/* IntPtr refers to an SDL_Renderer*, window to an SDL_Window* */
@ -1042,30 +1165,30 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetRendererInfo(
IntPtr renderer,
ref SDL_RendererInfo info
out SDL_RendererInfo info
);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetTextureAlphaMod(
IntPtr texture,
ref byte alpha
out byte alpha
);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetTextureBlendMode(
IntPtr texture,
ref SDL_BlendMode blendMode
out SDL_BlendMode blendMode
);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetTextureColorMod(
IntPtr texture,
ref byte r,
ref byte g,
ref byte b
out byte r,
out byte g,
out byte b
);
/* texture refers to an SDL_Texture*, pixels to a void* */
@ -1073,26 +1196,26 @@ namespace SDL2
public static extern int SDL_LockTexture(
IntPtr texture,
ref SDL_Rect rect,
ref IntPtr pixels,
ref int pitch
out IntPtr pixels,
out int pitch
);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_QueryTexture(
IntPtr texture,
ref uint format,
ref int access,
ref int w,
ref int h
out uint format,
out int access,
out int w,
out int h
);
/* texture refers to an SDL_Texture, pixels to a void* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_QueryTexturePixels(
IntPtr texture,
ref IntPtr pixels,
ref int pitch
out IntPtr pixels,
out int pitch
);
/* renderer refers to an SDL_Renderer* */
@ -1134,7 +1257,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_RenderDrawLines(
IntPtr renderer,
SDL_Point[] points,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)]
SDL_Point[] points,
int count
);
@ -1150,7 +1274,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_RenderDrawPoints(
IntPtr renderer,
SDL_Point[] points,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)]
SDL_Point[] points,
int count
);
@ -1165,7 +1290,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_RenderDrawRects(
IntPtr renderer,
SDL_Rect[] rects,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)]
SDL_Rect[] rects,
int count
);
@ -1180,7 +1306,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_RenderFillRects(
IntPtr renderer,
SDL_Rect[] rects,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)]
SDL_Rect[] rects,
int count
);
@ -1188,7 +1315,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_RendererGetViewport(
IntPtr renderer,
ref SDL_Rect rect
out SDL_Rect rect
);
/* renderer refers to an SDL_Renderer* */
@ -1669,7 +1796,7 @@ namespace SDL2
public struct SDL_Palette
{
public int ncolors;
public SDL_Color[] colors;
public IntPtr colors;
public int version;
public int refcount;
}
@ -1708,7 +1835,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_CalculateGammaRamp(
float gamma,
ref ushort ramp
[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
ushort[] ramp
);
/* format refers to an SDL_PixelFormat* */
@ -1730,9 +1858,9 @@ namespace SDL2
public static extern void SDL_GetRGB(
uint pixel,
IntPtr format,
ref byte r,
ref byte g,
ref byte b
out byte r,
out byte g,
out byte b
);
/* format refers to an SDL_PixelFormat* */
@ -1740,10 +1868,10 @@ namespace SDL2
public static extern void SDL_GetRGBA(
uint pixel,
IntPtr format,
ref byte r,
ref byte g,
ref byte b,
ref byte a
out byte r,
out byte g,
out byte b,
out byte a
);
/* format refers to an SDL_PixelFormat* */
@ -1777,18 +1905,19 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern SDL_bool SDL_PixelFormatEnumToMasks(
uint format,
ref int bpp,
ref uint Rmask,
ref uint Gmask,
ref uint Bmask,
ref uint Amask
out int bpp,
out uint Rmask,
out uint Gmask,
out uint Bmask,
out uint Amask
);
/* palette refers to an SDL_Palette* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_SetPaletteColors(
IntPtr palette,
SDL_Color[] colors,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct)]
SDL_Color[] colors,
int firstcolor,
int ncolors
);
@ -1822,10 +1951,11 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern SDL_bool SDL_EnclosePoints(
SDL_Point[] points,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 1)]
SDL_Point[] points,
int count,
ref SDL_Rect clip,
ref SDL_Rect result
out SDL_Rect result
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -1838,7 +1968,7 @@ namespace SDL2
public static extern SDL_bool SDL_IntersectRect(
ref SDL_Rect A,
ref SDL_Rect B,
ref SDL_Rect result
out SDL_Rect result
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -1863,7 +1993,7 @@ namespace SDL2
public static extern void SDL_UnionRect(
ref SDL_Rect A,
ref SDL_Rect B,
ref SDL_Rect result
out SDL_Rect result
);
#endregion
@ -1983,7 +2113,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_FillRects(
IntPtr dst,
SDL_Rect[] rects,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)]
SDL_Rect[] rects,
int count,
uint color
);
@ -1996,37 +2127,37 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_GetClipRect(
IntPtr surface,
ref SDL_Rect rect
out SDL_Rect rect
);
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetColorKey(
IntPtr surface,
ref uint key
out uint key
);
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetSurfaceAlphaMod(
IntPtr surface,
ref byte alpha
out byte alpha
);
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetSurfaceBlendMode(
IntPtr surface,
ref SDL_BlendMode blendMode
out SDL_BlendMode blendMode
);
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_GetSurfaceColorMod(
IntPtr surface,
ref byte r,
ref byte g,
ref byte b
out byte r,
out byte g,
out byte b
);
/* These are for SDL_LoadBMP, which is a macro in the SDL headers. */
@ -2618,7 +2749,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_PeepEvents(
SDL_Event[] events,
[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 1)]
SDL_Event[] events,
int numevents,
SDL_eventaction action,
SDL_EventType minType,
@ -2672,8 +2804,8 @@ namespace SDL2
/* userdata refers to a void* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern SDL_bool SDL_GetEventFilter(
ref SDL_EventFilter filter,
ref IntPtr userdata
out SDL_EventFilter filter,
out IntPtr userdata
);
/* userdata refers to a void* */
@ -3320,7 +3452,7 @@ namespace SDL2
/* Return value is a pointer to a UInt8 array */
/* Numkeys returns the size of the array if non-null */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr SDL_GetKeyboardState(ref int numkeys);
public static extern IntPtr SDL_GetKeyboardState(out int numkeys);
/* Get the current key modifier state for the keyboard. */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -3542,8 +3674,8 @@ namespace SDL2
public static extern int SDL_JoystickGetBall(
IntPtr joystick,
int ball,
ref int dx,
ref int dy
out int dx,
out int dy
);
/* joystick refers to an SDL_Joystick* */
@ -4312,14 +4444,14 @@ namespace SDL2
IntPtr src,
int freesrc,
ref SDL_AudioSpec spec,
ref IntPtr audio_buf,
ref uint audio_len
out IntPtr audio_buf,
out uint audio_len
);
public static SDL_AudioSpec SDL_LoadWAV(
string file,
ref SDL_AudioSpec spec,
ref IntPtr audio_buf,
ref uint audio_len
out IntPtr audio_buf,
out uint audio_len
) {
SDL_AudioSpec result;
IntPtr rwops = INTERNAL_SDL_RWFromFile(file, "rb");
@ -4327,8 +4459,8 @@ namespace SDL2
rwops,
1,
ref spec,
ref audio_buf,
ref audio_len
out audio_buf,
out audio_len
);
result = (SDL_AudioSpec) Marshal.PtrToStructure(
result_ptr,
@ -4346,8 +4478,10 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_MixAudio(
byte[] dst,
byte[] src,
[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)]
byte[] dst,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)]
byte[] src,
uint len,
int volume
);
@ -4355,8 +4489,10 @@ namespace SDL2
/* format refers to an SDL_AudioFormat */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_MixAudioFormat(
byte[] dst,
byte[] src,
[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 3)]
byte[] dst,
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 3)]
byte[] src,
ushort format,
uint len,
int volume
@ -4365,7 +4501,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_OpenAudio(
ref SDL_AudioSpec desired,
ref SDL_AudioSpec obtained
out SDL_AudioSpec obtained
);
/* uint refers to an SDL_AudioDeviceID */
@ -4375,7 +4511,7 @@ namespace SDL2
string device,
int iscapture,
ref SDL_AudioSpec desired,
ref SDL_AudioSpec obtained,
out SDL_AudioSpec obtained,
int allowed_changes
);

View file

@ -61,7 +61,7 @@ namespace SDL2
IMG_INIT_WEBP = 0x00000008
}
public static void SDL_IMAGE_VERSION(ref SDL.SDL_version X)
public static void SDL_IMAGE_VERSION(out SDL.SDL_version X)
{
X.major = SDL_IMAGE_MAJOR_VERSION;
X.minor = SDL_IMAGE_MINOR_VERSION;
@ -107,7 +107,10 @@ namespace SDL2
/* IntPtr refers to an SDL_Surface* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr IMG_ReadXPMFromArray(ref char[] xpm);
public static extern IntPtr IMG_ReadXPMFromArray(
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)]
string[] xpm
);
#endregion
}

View file

@ -137,7 +137,7 @@ namespace SDL2
IntPtr b // void*
);
public static void SDL_MIXER_VERSION(ref SDL.SDL_version X)
public static void SDL_MIXER_VERSION(out SDL.SDL_version X)
{
X.major = SDL_MIXER_MAJOR_VERSION;
X.minor = SDL_MIXER_MINOR_VERSION;
@ -205,11 +205,18 @@ namespace SDL2
/* IntPtr refers to a Mix_Chunk* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Mix_QuickLoad_WAV(byte[] mem);
public static extern IntPtr Mix_QuickLoad_WAV(
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1)]
byte[] mem
);
/* IntPtr refers to a Mix_Chunk* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Mix_Chunk Mix_QuickLoad_RAW(byte[] mem, uint len);
public static extern Mix_Chunk Mix_QuickLoad_RAW(
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 1)]
byte[] mem,
uint len
);
/* chunk refers to a Mix_Chunk* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]

View file

@ -66,7 +66,7 @@ namespace SDL2
public const int TTF_HINTING_MONO = 2;
public const int TTF_HINTING_NONE = 3;
public static void SDL_TTF_VERSION(ref SDL.SDL_version X)
public static void SDL_TTF_VERSION(out SDL.SDL_version X)
{
X.major = SDL_TTF_MAJOR_VERSION;
X.minor = SDL_TTF_MINOR_VERSION;
@ -188,11 +188,11 @@ namespace SDL2
public static extern int TTF_GlyphMetrics(
IntPtr font,
ushort ch,
ref int minx,
ref int maxx,
ref int miny,
ref int maxy,
ref int advance
out int minx,
out int maxx,
out int miny,
out int maxy,
out int advance
);
/* font refers to a TTF_Font* */
@ -201,8 +201,8 @@ namespace SDL2
IntPtr font,
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
string text,
ref int w,
ref int h
out int w,
out int h
);
/* font refers to a TTF_Font* */
@ -211,24 +211,25 @@ namespace SDL2
IntPtr font,
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
string text,
ref int w,
ref int h
out int w,
out int h
);
/* font refers to a TTF_Font* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int TTF_SizeUNICODE(
IntPtr font,
ushort[] text,
ref int w,
ref int h
[In()] [MarshalAs(UnmanagedType.LPWStr)]
string text,
out int w,
out int h
);
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr TTF_RenderText_Solid(
IntPtr font,
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
[In()] [MarshalAs(UnmanagedType.LPStr)]
string text,
SDL.SDL_Color fg
);
@ -246,7 +247,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr TTF_RenderUNICODE_Solid(
IntPtr font,
ushort[] text,
[In()] [MarshalAs(UnmanagedType.LPWStr)]
string text,
SDL.SDL_Color fg
);
@ -262,7 +264,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr TTF_RenderText_Shaded(
IntPtr font,
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
[In()] [MarshalAs(UnmanagedType.LPStr)]
string text,
SDL.SDL_Color fg,
SDL.SDL_Color bg
@ -282,7 +284,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr TTF_RenderUNICODE_Shaded(
IntPtr font,
ushort[] text,
[In()] [MarshalAs(UnmanagedType.LPWStr)]
string text,
SDL.SDL_Color fg,
SDL.SDL_Color bg
);
@ -300,7 +303,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr TTF_RenderText_Blended(
IntPtr font,
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
[In()] [MarshalAs(UnmanagedType.LPStr)]
string text,
SDL.SDL_Color fg
);
@ -318,7 +321,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr TTF_RenderUNICODE_Blended(
IntPtr font,
ushort[] text,
[In()] [MarshalAs(UnmanagedType.LPWStr)]
string text,
SDL.SDL_Color fg
);
@ -326,7 +330,7 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr TTF_RenderText_Blended_Wrapped(
IntPtr font,
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
[In()] [MarshalAs(UnmanagedType.LPStr)]
string text,
SDL.SDL_Color fg,
uint wrapped
@ -346,7 +350,8 @@ namespace SDL2
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr TTF_RenderUNICODE_Blended_Wrapped(
IntPtr font,
ushort[] text,
[In()] [MarshalAs(UnmanagedType.LPWStr)]
string text,
SDL.SDL_Color fg,
uint wrapped
);