mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-25 19:46:50 -05:00
Now directly using CS-SDL source
This commit is contained in:
parent
8c4646d57a
commit
0b3a15403c
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
#region License
|
||||
/* SDL2# - C# Wrapper for SDL2
|
||||
*
|
||||
* Copyright (c) 2013-2015 Ethan Lee.
|
||||
* Copyright (c) 2013-2016 Ethan Lee.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
@ -38,7 +38,7 @@ namespace SDL2
|
||||
#region SDL2# Variables
|
||||
|
||||
/* Used by DllImport to load the native library. */
|
||||
private const string nativeLibName = "SDL2_image.dll";
|
||||
private const string nativeLibName = "SDL2_image";
|
||||
|
||||
#endregion
|
||||
|
||||
@ -50,7 +50,7 @@ namespace SDL2
|
||||
*/
|
||||
public const int SDL_IMAGE_MAJOR_VERSION = 2;
|
||||
public const int SDL_IMAGE_MINOR_VERSION = 0;
|
||||
public const int SDL_IMAGE_PATCHLEVEL = 0;
|
||||
public const int SDL_IMAGE_PATCHLEVEL = 2;
|
||||
|
||||
[Flags]
|
||||
public enum IMG_InitFlags
|
||||
@ -68,12 +68,12 @@ namespace SDL2
|
||||
X.patch = SDL_IMAGE_PATCHLEVEL;
|
||||
}
|
||||
|
||||
[DllImport(nativeLibName, EntryPoint = "IMG_LinkedVersion", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_IMG_LinkedVersion();
|
||||
public static SDL.SDL_version IMG_LinkedVersion()
|
||||
[DllImport(nativeLibName, EntryPoint = "IMG_Linked_Version", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_IMG_Linked_Version();
|
||||
public static SDL.SDL_version IMG_Linked_Version()
|
||||
{
|
||||
SDL.SDL_version result;
|
||||
IntPtr result_ptr = INTERNAL_IMG_LinkedVersion();
|
||||
IntPtr result_ptr = INTERNAL_IMG_Linked_Version();
|
||||
result = (SDL.SDL_version) Marshal.PtrToStructure(
|
||||
result_ptr,
|
||||
typeof(SDL.SDL_version)
|
||||
@ -88,11 +88,14 @@ namespace SDL2
|
||||
public static extern void IMG_Quit();
|
||||
|
||||
/* IntPtr refers to an SDL_Surface* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr IMG_Load(
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string file
|
||||
[DllImport(nativeLibName, EntryPoint = "IMG_Load", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_IMG_Load(
|
||||
byte[] file
|
||||
);
|
||||
public static IntPtr IMG_Load(string file)
|
||||
{
|
||||
return INTERNAL_IMG_Load(SDL.UTF8_ToNative(file));
|
||||
}
|
||||
|
||||
/* src refers to an SDL_RWops*, IntPtr to an SDL_Surface* */
|
||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||
@ -104,21 +107,39 @@ namespace SDL2
|
||||
|
||||
/* src refers to an SDL_RWops*, IntPtr to an SDL_Surface* */
|
||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr IMG_LoadTyped_RW(
|
||||
[DllImport(nativeLibName, EntryPoint = "IMG_LoadTyped_RW", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_IMG_LoadTyped_RW(
|
||||
IntPtr src,
|
||||
int freesrc,
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string type
|
||||
byte[] type
|
||||
);
|
||||
public static IntPtr IMG_LoadTyped_RW(
|
||||
IntPtr src,
|
||||
int freesrc,
|
||||
string type
|
||||
) {
|
||||
return INTERNAL_IMG_LoadTyped_RW(
|
||||
src,
|
||||
freesrc,
|
||||
SDL.UTF8_ToNative(type)
|
||||
);
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr IMG_LoadTexture(
|
||||
[DllImport(nativeLibName, EntryPoint = "IMG_LoadTexture", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_IMG_LoadTexture(
|
||||
IntPtr renderer,
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string file
|
||||
byte[] file
|
||||
);
|
||||
public static IntPtr IMG_LoadTexture(
|
||||
IntPtr renderer,
|
||||
string file
|
||||
) {
|
||||
return INTERNAL_IMG_LoadTexture(
|
||||
renderer,
|
||||
SDL.UTF8_ToNative(file)
|
||||
);
|
||||
}
|
||||
|
||||
/* renderer refers to an SDL_Renderer*.
|
||||
* src refers to an SDL_RWops*.
|
||||
@ -137,17 +158,26 @@ namespace SDL2
|
||||
* IntPtr to an SDL_Texture*.
|
||||
*/
|
||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr IMG_LoadTextureTyped_RW(
|
||||
[DllImport(nativeLibName, EntryPoint = "IMG_LoadTextureTyped_RW", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_IMG_LoadTextureTyped_RW(
|
||||
IntPtr renderer,
|
||||
IntPtr src,
|
||||
int freesrc,
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string type
|
||||
byte[] type
|
||||
);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int IMG_InvertAlpha(int on);
|
||||
public static IntPtr IMG_LoadTextureTyped_RW(
|
||||
IntPtr renderer,
|
||||
IntPtr src,
|
||||
int freesrc,
|
||||
string type
|
||||
) {
|
||||
return INTERNAL_IMG_LoadTextureTyped_RW(
|
||||
renderer,
|
||||
src,
|
||||
freesrc,
|
||||
SDL.UTF8_ToNative(type)
|
||||
);
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Surface* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -157,12 +187,18 @@ namespace SDL2
|
||||
);
|
||||
|
||||
/* surface refers to an SDL_Surface* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int IMG_SavePNG(
|
||||
[DllImport(nativeLibName, EntryPoint = "IMG_SavePNG", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int INTERNAL_IMG_SavePNG(
|
||||
IntPtr surface,
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string file
|
||||
byte[] file
|
||||
);
|
||||
public static int IMG_SavePNG(IntPtr surface, string file)
|
||||
{
|
||||
return INTERNAL_IMG_SavePNG(
|
||||
surface,
|
||||
SDL.UTF8_ToNative(file)
|
||||
);
|
||||
}
|
||||
|
||||
/* surface refers to an SDL_Surface*, dst to an SDL_RWops* */
|
||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||
@ -173,6 +209,32 @@ namespace SDL2
|
||||
int freedst
|
||||
);
|
||||
|
||||
/* surface refers to an SDL_Surface* */
|
||||
[DllImport(nativeLibName, EntryPoint = "IMG_SaveJPG", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int INTERNAL_IMG_SaveJPG(
|
||||
IntPtr surface,
|
||||
byte[] file,
|
||||
int quality
|
||||
);
|
||||
public static int IMG_SaveJPG(IntPtr surface, string file, int quality)
|
||||
{
|
||||
return INTERNAL_IMG_SaveJPG(
|
||||
surface,
|
||||
SDL.UTF8_ToNative(file),
|
||||
quality
|
||||
);
|
||||
}
|
||||
|
||||
/* surface refers to an SDL_Surface*, dst to an SDL_RWops* */
|
||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int IMG_SaveJPG_RW(
|
||||
IntPtr surface,
|
||||
IntPtr dst,
|
||||
int freedst,
|
||||
int quality
|
||||
);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#region License
|
||||
/* SDL2# - C# Wrapper for SDL2
|
||||
*
|
||||
* Copyright (c) 2013-2015 Ethan Lee.
|
||||
* Copyright (c) 2013-2016 Ethan Lee.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
@ -38,7 +38,7 @@ namespace SDL2
|
||||
#region SDL2# Variables
|
||||
|
||||
/* Used by DllImport to load the native library. */
|
||||
private const string nativeLibName = "SDL2_mixer.dll";
|
||||
private const string nativeLibName = "SDL2_mixer";
|
||||
|
||||
#endregion
|
||||
|
||||
@ -50,7 +50,7 @@ namespace SDL2
|
||||
*/
|
||||
public const int SDL_MIXER_MAJOR_VERSION = 2;
|
||||
public const int SDL_MIXER_MINOR_VERSION = 0;
|
||||
public const int SDL_MIXER_PATCHLEVEL = 0;
|
||||
public const int SDL_MIXER_PATCHLEVEL = 2;
|
||||
|
||||
/* In C, you can redefine this value before including SDL_mixer.h.
|
||||
* We're not going to allow this in SDL2#, since the value of this
|
||||
@ -69,9 +69,9 @@ namespace SDL2
|
||||
{
|
||||
MIX_INIT_FLAC = 0x00000001,
|
||||
MIX_INIT_MOD = 0x00000002,
|
||||
MIX_INIT_MP3 = 0x00000004,
|
||||
MIX_INIT_OGG = 0x00000008,
|
||||
MIX_INIT_FLUIDSYNTH = 0x00000010,
|
||||
MIX_INIT_MP3 = 0x00000008,
|
||||
MIX_INIT_OGG = 0x00000010,
|
||||
MIX_INIT_MID = 0x00000020,
|
||||
}
|
||||
|
||||
public enum Mix_Fading
|
||||
@ -189,11 +189,14 @@ namespace SDL2
|
||||
}
|
||||
|
||||
/* IntPtr refers to a Mix_Music* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr Mix_LoadMUS(
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string file
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_LoadMUS", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_Mix_LoadMUS(
|
||||
byte[] file
|
||||
);
|
||||
public static IntPtr Mix_LoadMUS(string file)
|
||||
{
|
||||
return INTERNAL_Mix_LoadMUS(SDL.UTF8_ToNative(file));
|
||||
}
|
||||
|
||||
/* IntPtr refers to a Mix_Chunk* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -221,16 +224,26 @@ namespace SDL2
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_GetNumChunkDecoders();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)]
|
||||
public static extern string Mix_GetChunkDecoder(int index);
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_GetChunkDecoder", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_Mix_GetChunkDecoder(int index);
|
||||
public static string Mix_GetChunkDecoder(int index)
|
||||
{
|
||||
return SDL.UTF8_ToManaged(
|
||||
INTERNAL_Mix_GetChunkDecoder(index)
|
||||
);
|
||||
}
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_GetNumMusicDecoders();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)]
|
||||
public static extern string Mix_GetMusicDecoder(int index);
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicDecoder", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_Mix_GetMusicDecoder(int index);
|
||||
public static string Mix_GetMusicDecoder(int index)
|
||||
{
|
||||
return SDL.UTF8_ToManaged(
|
||||
INTERNAL_Mix_GetMusicDecoder(index)
|
||||
);
|
||||
}
|
||||
|
||||
/* music refers to a Mix_Music* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -449,11 +462,16 @@ namespace SDL2
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_PlayingMusic();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_SetMusicCMD(
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string command
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_SetMusicCMD", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int INTERNAL_Mix_SetMusicCMD(
|
||||
byte[] command
|
||||
);
|
||||
public static int Mix_SetMusicCMD(string command)
|
||||
{
|
||||
return INTERNAL_Mix_SetMusicCMD(
|
||||
SDL.UTF8_ToNative(command)
|
||||
);
|
||||
}
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_SetSynchroValue(int value);
|
||||
@ -461,15 +479,23 @@ namespace SDL2
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_GetSynchroValue();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_SetSoundFonts(
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string paths
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_SetSoundFonts", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int INTERNAL_Mix_SetSoundFonts(
|
||||
byte[] paths
|
||||
);
|
||||
public static int Mix_SetSoundFonts(string paths)
|
||||
{
|
||||
return INTERNAL_Mix_SetSoundFonts(
|
||||
SDL.UTF8_ToNative(paths)
|
||||
);
|
||||
}
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)]
|
||||
public static extern string Mix_GetSoundFonts();
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_GetSoundFonts", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_Mix_GetSoundFonts();
|
||||
public static string Mix_GetSoundFonts()
|
||||
{
|
||||
return SDL.UTF8_ToManaged(INTERNAL_Mix_GetSoundFonts());
|
||||
}
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_EachSoundFont(
|
@ -1,7 +1,7 @@
|
||||
#region License
|
||||
/* SDL2# - C# Wrapper for SDL2
|
||||
*
|
||||
* Copyright (c) 2013-2015 Ethan Lee.
|
||||
* Copyright (c) 2013-2016 Ethan Lee.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
@ -38,7 +38,7 @@ namespace SDL2
|
||||
#region SDL2# Variables
|
||||
|
||||
/* Used by DllImport to load the native library. */
|
||||
private const string nativeLibName = "SDL2_ttf.dll";
|
||||
private const string nativeLibName = "SDL2_ttf";
|
||||
|
||||
#endregion
|
||||
|
||||
@ -93,12 +93,18 @@ namespace SDL2
|
||||
public static extern int TTF_Init();
|
||||
|
||||
/* IntPtr refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_OpenFont(
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string file,
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_OpenFont", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_TTF_OpenFont(
|
||||
byte[] file,
|
||||
int ptsize
|
||||
);
|
||||
public static IntPtr TTF_OpenFont(string file, int ptsize)
|
||||
{
|
||||
return INTERNAL_TTF_OpenFont(
|
||||
SDL.UTF8_ToNative(file),
|
||||
ptsize
|
||||
);
|
||||
}
|
||||
|
||||
/* src refers to an SDL_RWops*, IntPtr to a TTF_Font* */
|
||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||
@ -110,13 +116,23 @@ namespace SDL2
|
||||
);
|
||||
|
||||
/* IntPtr refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_OpenFontIndex(
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string file,
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_OpenFontIndex", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_TTF_OpenFontIndex(
|
||||
byte[] file,
|
||||
int ptsize,
|
||||
long index
|
||||
);
|
||||
public static IntPtr TTF_OpenFontIndex(
|
||||
string file,
|
||||
int ptsize,
|
||||
long index
|
||||
) {
|
||||
return INTERNAL_TTF_OpenFontIndex(
|
||||
SDL.UTF8_ToNative(file),
|
||||
ptsize,
|
||||
index
|
||||
);
|
||||
}
|
||||
|
||||
/* src refers to an SDL_RWops*, IntPtr to a TTF_Font* */
|
||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||
@ -185,18 +201,28 @@ namespace SDL2
|
||||
public static extern int TTF_FontFaceIsFixedWidth(IntPtr font);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)]
|
||||
public static extern string TTF_FontFaceFamilyName(
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_FontFaceFamilyName", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_TTF_FontFaceFamilyName(
|
||||
IntPtr font
|
||||
);
|
||||
public static string TTF_FontFaceFamilyName(IntPtr font)
|
||||
{
|
||||
return SDL.UTF8_ToManaged(
|
||||
INTERNAL_TTF_FontFaceFamilyName(font)
|
||||
);
|
||||
}
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)]
|
||||
public static extern string TTF_FontFaceStyleName(
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_FontFaceStyleName", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_TTF_FontFaceStyleName(
|
||||
IntPtr font
|
||||
);
|
||||
public static string TTF_FontFaceStyleName(IntPtr font)
|
||||
{
|
||||
return SDL.UTF8_ToManaged(
|
||||
INTERNAL_TTF_FontFaceStyleName(font)
|
||||
);
|
||||
}
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -218,21 +244,33 @@ namespace SDL2
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_SizeText(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
||||
string text,
|
||||
out int w,
|
||||
out int h
|
||||
);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_SizeUTF8(
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_SizeUTF8", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int INTERNAL_TTF_SizeUTF8(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string text,
|
||||
byte[] text,
|
||||
out int w,
|
||||
out int h
|
||||
);
|
||||
public static int TTF_SizeUTF8(
|
||||
IntPtr font,
|
||||
string text,
|
||||
out int w,
|
||||
out int h
|
||||
) {
|
||||
return INTERNAL_TTF_SizeUTF8(
|
||||
font,
|
||||
SDL.UTF8_ToNative(text),
|
||||
out w,
|
||||
out h
|
||||
);
|
||||
}
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -254,13 +292,23 @@ namespace SDL2
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderUTF8_Solid(
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Solid", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_TTF_RenderUTF8_Solid(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string text,
|
||||
byte[] text,
|
||||
SDL.SDL_Color fg
|
||||
);
|
||||
public static IntPtr TTF_RenderUTF8_Solid(
|
||||
IntPtr font,
|
||||
string text,
|
||||
SDL.SDL_Color fg
|
||||
) {
|
||||
return INTERNAL_TTF_RenderUTF8_Solid(
|
||||
font,
|
||||
SDL.UTF8_ToNative(text),
|
||||
fg
|
||||
);
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -290,14 +338,26 @@ namespace SDL2
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderUTF8_Shaded(
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Shaded", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_TTF_RenderUTF8_Shaded(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string text,
|
||||
byte[] text,
|
||||
SDL.SDL_Color fg,
|
||||
SDL.SDL_Color bg
|
||||
);
|
||||
public static IntPtr TTF_RenderUTF8_Shaded(
|
||||
IntPtr font,
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
SDL.SDL_Color bg
|
||||
) {
|
||||
return INTERNAL_TTF_RenderUTF8_Shaded(
|
||||
font,
|
||||
SDL.UTF8_ToNative(text),
|
||||
fg,
|
||||
bg
|
||||
);
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -328,13 +388,23 @@ namespace SDL2
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderUTF8_Blended(
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Blended", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_TTF_RenderUTF8_Blended(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string text,
|
||||
byte[] text,
|
||||
SDL.SDL_Color fg
|
||||
);
|
||||
public static IntPtr TTF_RenderUTF8_Blended(
|
||||
IntPtr font,
|
||||
string text,
|
||||
SDL.SDL_Color fg
|
||||
) {
|
||||
return INTERNAL_TTF_RenderUTF8_Blended(
|
||||
font,
|
||||
SDL.UTF8_ToNative(text),
|
||||
fg
|
||||
);
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -356,14 +426,26 @@ namespace SDL2
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderUTF8_Blended_Wrapped(
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Blended_Wrapped", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_TTF_RenderUTF8_Blended_Wrapped(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
||||
string text,
|
||||
byte[] text,
|
||||
SDL.SDL_Color fg,
|
||||
uint wrapped
|
||||
);
|
||||
public static IntPtr TTF_RenderUTF8_Blended_Wrapped(
|
||||
IntPtr font,
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
uint wrapped
|
||||
) {
|
||||
return INTERNAL_TTF_RenderUTF8_Blended_Wrapped(
|
||||
font,
|
||||
SDL.UTF8_ToNative(text),
|
||||
fg,
|
||||
wrapped
|
||||
);
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
@ -70,12 +70,11 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AutofacModule.cs" />
|
||||
<Compile Include="CS-SDL\SDL2.cs" />
|
||||
<Compile Include="CS-SDL\SDL2_image.cs" />
|
||||
<Compile Include="CS-SDL\SDL2_mixer.cs" />
|
||||
<Compile Include="CS-SDL\SDL2_ttf.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SDL2-CS\LPUtf8StrMarshaler.cs" />
|
||||
<Compile Include="SDL2-CS\SDL2.cs" />
|
||||
<Compile Include="SDL2-CS\SDL2_image.cs" />
|
||||
<Compile Include="SDL2-CS\SDL2_mixer.cs" />
|
||||
<Compile Include="SDL2-CS\SDL2_ttf.cs" />
|
||||
<Compile Include="SDL2Font.cs" />
|
||||
<Compile Include="SDL2Label.cs" />
|
||||
<Compile Include="SDL2MusicPlayer.cs" />
|
||||
|
@ -1,106 +0,0 @@
|
||||
/* SDL2# - C# Wrapper for SDL2
|
||||
*
|
||||
* Copyright (c) 2013-2015 Ethan Lee.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software in a
|
||||
* product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
* Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com>
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SDL2
|
||||
{
|
||||
internal unsafe class LPUtf8StrMarshaler : ICustomMarshaler
|
||||
{
|
||||
public const string LeaveAllocated = "LeaveAllocated";
|
||||
|
||||
private static ICustomMarshaler
|
||||
_leaveAllocatedInstance = new LPUtf8StrMarshaler(true),
|
||||
_defaultInstance = new LPUtf8StrMarshaler(false);
|
||||
|
||||
public static ICustomMarshaler GetInstance(string cookie)
|
||||
{
|
||||
switch (cookie)
|
||||
{
|
||||
case "LeaveAllocated":
|
||||
return _leaveAllocatedInstance;
|
||||
default:
|
||||
return _defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _leaveAllocated;
|
||||
|
||||
public LPUtf8StrMarshaler(bool leaveAllocated)
|
||||
{
|
||||
_leaveAllocated = leaveAllocated;
|
||||
}
|
||||
|
||||
public object MarshalNativeToManaged(IntPtr pNativeData)
|
||||
{
|
||||
if (pNativeData == IntPtr.Zero)
|
||||
return null;
|
||||
var ptr = (byte*)pNativeData;
|
||||
while (*ptr != 0)
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
var bytes = new byte[ptr - (byte*)pNativeData];
|
||||
Marshal.Copy(pNativeData, bytes, 0, bytes.Length);
|
||||
return Encoding.UTF8.GetString(bytes);
|
||||
}
|
||||
|
||||
public IntPtr MarshalManagedToNative(object ManagedObj)
|
||||
{
|
||||
if (ManagedObj == null)
|
||||
return IntPtr.Zero;
|
||||
var str = ManagedObj as string;
|
||||
if (str == null)
|
||||
{
|
||||
throw new ArgumentException("ManagedObj must be a string.", "ManagedObj");
|
||||
}
|
||||
var bytes = Encoding.UTF8.GetBytes(str);
|
||||
var mem = SDL.SDL_malloc((IntPtr) (bytes.Length + 1));
|
||||
Marshal.Copy(bytes, 0, mem, bytes.Length);
|
||||
((byte*)mem)[bytes.Length] = 0;
|
||||
return mem;
|
||||
}
|
||||
|
||||
public void CleanUpManagedData(object ManagedObj)
|
||||
{
|
||||
}
|
||||
|
||||
public void CleanUpNativeData(IntPtr pNativeData)
|
||||
{
|
||||
if (!_leaveAllocated)
|
||||
{
|
||||
SDL.SDL_free(pNativeData);
|
||||
}
|
||||
}
|
||||
|
||||
public int GetNativeDataSize ()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,5 +2,4 @@
|
||||
<packages>
|
||||
<package id="Autofac" version="4.8.1" targetFramework="net461" />
|
||||
<package id="log4net" version="2.0.8" targetFramework="net461" />
|
||||
<package id="SDL2-CS" version="2.0.0.0" targetFramework="net461" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user