mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-28 14:16:01 -04: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
|
#region License
|
||||||
/* SDL2# - C# Wrapper for SDL2
|
/* 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.
|
* 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
|
* In no event will the authors be held liable for any damages arising from
|
||||||
@ -38,7 +38,7 @@ namespace SDL2
|
|||||||
#region SDL2# Variables
|
#region SDL2# Variables
|
||||||
|
|
||||||
/* Used by DllImport to load the native library. */
|
/* Used by DllImport to load the native library. */
|
||||||
private const string nativeLibName = "SDL2_image.dll";
|
private const string nativeLibName = "SDL2_image";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ namespace SDL2
|
|||||||
*/
|
*/
|
||||||
public const int SDL_IMAGE_MAJOR_VERSION = 2;
|
public const int SDL_IMAGE_MAJOR_VERSION = 2;
|
||||||
public const int SDL_IMAGE_MINOR_VERSION = 0;
|
public const int SDL_IMAGE_MINOR_VERSION = 0;
|
||||||
public const int SDL_IMAGE_PATCHLEVEL = 0;
|
public const int SDL_IMAGE_PATCHLEVEL = 2;
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum IMG_InitFlags
|
public enum IMG_InitFlags
|
||||||
@ -68,12 +68,12 @@ namespace SDL2
|
|||||||
X.patch = SDL_IMAGE_PATCHLEVEL;
|
X.patch = SDL_IMAGE_PATCHLEVEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport(nativeLibName, EntryPoint = "IMG_LinkedVersion", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "IMG_Linked_Version", CallingConvention = CallingConvention.Cdecl)]
|
||||||
private static extern IntPtr INTERNAL_IMG_LinkedVersion();
|
private static extern IntPtr INTERNAL_IMG_Linked_Version();
|
||||||
public static SDL.SDL_version IMG_LinkedVersion()
|
public static SDL.SDL_version IMG_Linked_Version()
|
||||||
{
|
{
|
||||||
SDL.SDL_version result;
|
SDL.SDL_version result;
|
||||||
IntPtr result_ptr = INTERNAL_IMG_LinkedVersion();
|
IntPtr result_ptr = INTERNAL_IMG_Linked_Version();
|
||||||
result = (SDL.SDL_version) Marshal.PtrToStructure(
|
result = (SDL.SDL_version) Marshal.PtrToStructure(
|
||||||
result_ptr,
|
result_ptr,
|
||||||
typeof(SDL.SDL_version)
|
typeof(SDL.SDL_version)
|
||||||
@ -88,11 +88,14 @@ namespace SDL2
|
|||||||
public static extern void IMG_Quit();
|
public static extern void IMG_Quit();
|
||||||
|
|
||||||
/* IntPtr refers to an SDL_Surface* */
|
/* IntPtr refers to an SDL_Surface* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "IMG_Load", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr IMG_Load(
|
private static extern IntPtr INTERNAL_IMG_Load(
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] file
|
||||||
string 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* */
|
/* src refers to an SDL_RWops*, IntPtr to an SDL_Surface* */
|
||||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||||
@ -104,21 +107,39 @@ namespace SDL2
|
|||||||
|
|
||||||
/* src refers to an SDL_RWops*, IntPtr to an SDL_Surface* */
|
/* src refers to an SDL_RWops*, IntPtr to an SDL_Surface* */
|
||||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "IMG_LoadTyped_RW", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr IMG_LoadTyped_RW(
|
private static extern IntPtr INTERNAL_IMG_LoadTyped_RW(
|
||||||
IntPtr src,
|
IntPtr src,
|
||||||
int freesrc,
|
int freesrc,
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] type
|
||||||
string 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* */
|
/* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "IMG_LoadTexture", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr IMG_LoadTexture(
|
private static extern IntPtr INTERNAL_IMG_LoadTexture(
|
||||||
IntPtr renderer,
|
IntPtr renderer,
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] file
|
||||||
string 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*.
|
/* renderer refers to an SDL_Renderer*.
|
||||||
* src refers to an SDL_RWops*.
|
* src refers to an SDL_RWops*.
|
||||||
@ -137,17 +158,26 @@ namespace SDL2
|
|||||||
* IntPtr to an SDL_Texture*.
|
* IntPtr to an SDL_Texture*.
|
||||||
*/
|
*/
|
||||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "IMG_LoadTextureTyped_RW", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr IMG_LoadTextureTyped_RW(
|
private static extern IntPtr INTERNAL_IMG_LoadTextureTyped_RW(
|
||||||
IntPtr renderer,
|
IntPtr renderer,
|
||||||
IntPtr src,
|
IntPtr src,
|
||||||
int freesrc,
|
int freesrc,
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] type
|
||||||
string type
|
|
||||||
);
|
);
|
||||||
|
public static IntPtr IMG_LoadTextureTyped_RW(
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
IntPtr renderer,
|
||||||
public static extern int IMG_InvertAlpha(int on);
|
IntPtr src,
|
||||||
|
int freesrc,
|
||||||
|
string type
|
||||||
|
) {
|
||||||
|
return INTERNAL_IMG_LoadTextureTyped_RW(
|
||||||
|
renderer,
|
||||||
|
src,
|
||||||
|
freesrc,
|
||||||
|
SDL.UTF8_ToNative(type)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/* IntPtr refers to an SDL_Surface* */
|
/* IntPtr refers to an SDL_Surface* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
@ -157,12 +187,18 @@ namespace SDL2
|
|||||||
);
|
);
|
||||||
|
|
||||||
/* surface refers to an SDL_Surface* */
|
/* surface refers to an SDL_Surface* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "IMG_SavePNG", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int IMG_SavePNG(
|
private static extern int INTERNAL_IMG_SavePNG(
|
||||||
IntPtr surface,
|
IntPtr surface,
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] file
|
||||||
string 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* */
|
/* surface refers to an SDL_Surface*, dst to an SDL_RWops* */
|
||||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||||
@ -173,6 +209,32 @@ namespace SDL2
|
|||||||
int freedst
|
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
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
#region License
|
#region License
|
||||||
/* SDL2# - C# Wrapper for SDL2
|
/* 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.
|
* 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
|
* In no event will the authors be held liable for any damages arising from
|
||||||
@ -38,7 +38,7 @@ namespace SDL2
|
|||||||
#region SDL2# Variables
|
#region SDL2# Variables
|
||||||
|
|
||||||
/* Used by DllImport to load the native library. */
|
/* Used by DllImport to load the native library. */
|
||||||
private const string nativeLibName = "SDL2_mixer.dll";
|
private const string nativeLibName = "SDL2_mixer";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ namespace SDL2
|
|||||||
*/
|
*/
|
||||||
public const int SDL_MIXER_MAJOR_VERSION = 2;
|
public const int SDL_MIXER_MAJOR_VERSION = 2;
|
||||||
public const int SDL_MIXER_MINOR_VERSION = 0;
|
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.
|
/* 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
|
* 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_FLAC = 0x00000001,
|
||||||
MIX_INIT_MOD = 0x00000002,
|
MIX_INIT_MOD = 0x00000002,
|
||||||
MIX_INIT_MP3 = 0x00000004,
|
MIX_INIT_MP3 = 0x00000008,
|
||||||
MIX_INIT_OGG = 0x00000008,
|
MIX_INIT_OGG = 0x00000010,
|
||||||
MIX_INIT_FLUIDSYNTH = 0x00000010,
|
MIX_INIT_MID = 0x00000020,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Mix_Fading
|
public enum Mix_Fading
|
||||||
@ -189,11 +189,14 @@ namespace SDL2
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* IntPtr refers to a Mix_Music* */
|
/* IntPtr refers to a Mix_Music* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "Mix_LoadMUS", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr Mix_LoadMUS(
|
private static extern IntPtr INTERNAL_Mix_LoadMUS(
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] file
|
||||||
string file
|
|
||||||
);
|
);
|
||||||
|
public static IntPtr Mix_LoadMUS(string file)
|
||||||
|
{
|
||||||
|
return INTERNAL_Mix_LoadMUS(SDL.UTF8_ToNative(file));
|
||||||
|
}
|
||||||
|
|
||||||
/* IntPtr refers to a Mix_Chunk* */
|
/* IntPtr refers to a Mix_Chunk* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
@ -221,16 +224,26 @@ namespace SDL2
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int Mix_GetNumChunkDecoders();
|
public static extern int Mix_GetNumChunkDecoders();
|
||||||
|
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "Mix_GetChunkDecoder", CallingConvention = CallingConvention.Cdecl)]
|
||||||
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)]
|
private static extern IntPtr INTERNAL_Mix_GetChunkDecoder(int index);
|
||||||
public static extern string Mix_GetChunkDecoder(int index);
|
public static string Mix_GetChunkDecoder(int index)
|
||||||
|
{
|
||||||
|
return SDL.UTF8_ToManaged(
|
||||||
|
INTERNAL_Mix_GetChunkDecoder(index)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int Mix_GetNumMusicDecoders();
|
public static extern int Mix_GetNumMusicDecoders();
|
||||||
|
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicDecoder", CallingConvention = CallingConvention.Cdecl)]
|
||||||
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)]
|
private static extern IntPtr INTERNAL_Mix_GetMusicDecoder(int index);
|
||||||
public static extern string 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* */
|
/* music refers to a Mix_Music* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
@ -449,11 +462,16 @@ namespace SDL2
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int Mix_PlayingMusic();
|
public static extern int Mix_PlayingMusic();
|
||||||
|
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "Mix_SetMusicCMD", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int Mix_SetMusicCMD(
|
private static extern int INTERNAL_Mix_SetMusicCMD(
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] command
|
||||||
string command
|
|
||||||
);
|
);
|
||||||
|
public static int Mix_SetMusicCMD(string command)
|
||||||
|
{
|
||||||
|
return INTERNAL_Mix_SetMusicCMD(
|
||||||
|
SDL.UTF8_ToNative(command)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int Mix_SetSynchroValue(int value);
|
public static extern int Mix_SetSynchroValue(int value);
|
||||||
@ -461,15 +479,23 @@ namespace SDL2
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int Mix_GetSynchroValue();
|
public static extern int Mix_GetSynchroValue();
|
||||||
|
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "Mix_SetSoundFonts", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int Mix_SetSoundFonts(
|
private static extern int INTERNAL_Mix_SetSoundFonts(
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] paths
|
||||||
string paths
|
|
||||||
);
|
);
|
||||||
|
public static int Mix_SetSoundFonts(string paths)
|
||||||
|
{
|
||||||
|
return INTERNAL_Mix_SetSoundFonts(
|
||||||
|
SDL.UTF8_ToNative(paths)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "Mix_GetSoundFonts", CallingConvention = CallingConvention.Cdecl)]
|
||||||
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)]
|
private static extern IntPtr INTERNAL_Mix_GetSoundFonts();
|
||||||
public static extern string Mix_GetSoundFonts();
|
public static string Mix_GetSoundFonts()
|
||||||
|
{
|
||||||
|
return SDL.UTF8_ToManaged(INTERNAL_Mix_GetSoundFonts());
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int Mix_EachSoundFont(
|
public static extern int Mix_EachSoundFont(
|
@ -1,7 +1,7 @@
|
|||||||
#region License
|
#region License
|
||||||
/* SDL2# - C# Wrapper for SDL2
|
/* 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.
|
* 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
|
* In no event will the authors be held liable for any damages arising from
|
||||||
@ -38,7 +38,7 @@ namespace SDL2
|
|||||||
#region SDL2# Variables
|
#region SDL2# Variables
|
||||||
|
|
||||||
/* Used by DllImport to load the native library. */
|
/* Used by DllImport to load the native library. */
|
||||||
private const string nativeLibName = "SDL2_ttf.dll";
|
private const string nativeLibName = "SDL2_ttf";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -93,12 +93,18 @@ namespace SDL2
|
|||||||
public static extern int TTF_Init();
|
public static extern int TTF_Init();
|
||||||
|
|
||||||
/* IntPtr refers to a TTF_Font* */
|
/* IntPtr refers to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "TTF_OpenFont", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr TTF_OpenFont(
|
private static extern IntPtr INTERNAL_TTF_OpenFont(
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] file,
|
||||||
string file,
|
|
||||||
int ptsize
|
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* */
|
/* src refers to an SDL_RWops*, IntPtr to a TTF_Font* */
|
||||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||||
@ -110,13 +116,23 @@ namespace SDL2
|
|||||||
);
|
);
|
||||||
|
|
||||||
/* IntPtr refers to a TTF_Font* */
|
/* IntPtr refers to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "TTF_OpenFontIndex", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr TTF_OpenFontIndex(
|
private static extern IntPtr INTERNAL_TTF_OpenFontIndex(
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] file,
|
||||||
string file,
|
|
||||||
int ptsize,
|
int ptsize,
|
||||||
long index
|
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* */
|
/* src refers to an SDL_RWops*, IntPtr to a TTF_Font* */
|
||||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||||
@ -185,18 +201,28 @@ namespace SDL2
|
|||||||
public static extern int TTF_FontFaceIsFixedWidth(IntPtr font);
|
public static extern int TTF_FontFaceIsFixedWidth(IntPtr font);
|
||||||
|
|
||||||
/* font refers to a TTF_Font* */
|
/* font refers to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "TTF_FontFaceFamilyName", CallingConvention = CallingConvention.Cdecl)]
|
||||||
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)]
|
private static extern IntPtr INTERNAL_TTF_FontFaceFamilyName(
|
||||||
public static extern string TTF_FontFaceFamilyName(
|
|
||||||
IntPtr font
|
IntPtr font
|
||||||
);
|
);
|
||||||
|
public static string TTF_FontFaceFamilyName(IntPtr font)
|
||||||
|
{
|
||||||
|
return SDL.UTF8_ToManaged(
|
||||||
|
INTERNAL_TTF_FontFaceFamilyName(font)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/* font refers to a TTF_Font* */
|
/* font refers to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "TTF_FontFaceStyleName", CallingConvention = CallingConvention.Cdecl)]
|
||||||
[return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)]
|
private static extern IntPtr INTERNAL_TTF_FontFaceStyleName(
|
||||||
public static extern string TTF_FontFaceStyleName(
|
|
||||||
IntPtr font
|
IntPtr font
|
||||||
);
|
);
|
||||||
|
public static string TTF_FontFaceStyleName(IntPtr font)
|
||||||
|
{
|
||||||
|
return SDL.UTF8_ToManaged(
|
||||||
|
INTERNAL_TTF_FontFaceStyleName(font)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/* font refers to a TTF_Font* */
|
/* font refers to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
@ -218,21 +244,33 @@ namespace SDL2
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int TTF_SizeText(
|
public static extern int TTF_SizeText(
|
||||||
IntPtr font,
|
IntPtr font,
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
||||||
string text,
|
string text,
|
||||||
out int w,
|
out int w,
|
||||||
out int h
|
out int h
|
||||||
);
|
);
|
||||||
|
|
||||||
/* font refers to a TTF_Font* */
|
/* font refers to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "TTF_SizeUTF8", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int TTF_SizeUTF8(
|
public static extern int INTERNAL_TTF_SizeUTF8(
|
||||||
IntPtr font,
|
IntPtr font,
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] text,
|
||||||
string text,
|
|
||||||
out int w,
|
out int w,
|
||||||
out int h
|
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* */
|
/* font refers to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
@ -254,13 +292,23 @@ namespace SDL2
|
|||||||
);
|
);
|
||||||
|
|
||||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Solid", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr TTF_RenderUTF8_Solid(
|
private static extern IntPtr INTERNAL_TTF_RenderUTF8_Solid(
|
||||||
IntPtr font,
|
IntPtr font,
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] text,
|
||||||
string text,
|
|
||||||
SDL.SDL_Color fg
|
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* */
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
@ -290,14 +338,26 @@ namespace SDL2
|
|||||||
);
|
);
|
||||||
|
|
||||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Shaded", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr TTF_RenderUTF8_Shaded(
|
private static extern IntPtr INTERNAL_TTF_RenderUTF8_Shaded(
|
||||||
IntPtr font,
|
IntPtr font,
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] text,
|
||||||
string text,
|
|
||||||
SDL.SDL_Color fg,
|
SDL.SDL_Color fg,
|
||||||
SDL.SDL_Color bg
|
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* */
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
@ -328,13 +388,23 @@ namespace SDL2
|
|||||||
);
|
);
|
||||||
|
|
||||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Blended", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr TTF_RenderUTF8_Blended(
|
private static extern IntPtr INTERNAL_TTF_RenderUTF8_Blended(
|
||||||
IntPtr font,
|
IntPtr font,
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] text,
|
||||||
string text,
|
|
||||||
SDL.SDL_Color fg
|
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* */
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
@ -356,14 +426,26 @@ namespace SDL2
|
|||||||
);
|
);
|
||||||
|
|
||||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Blended_Wrapped", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr TTF_RenderUTF8_Blended_Wrapped(
|
private static extern IntPtr INTERNAL_TTF_RenderUTF8_Blended_Wrapped(
|
||||||
IntPtr font,
|
IntPtr font,
|
||||||
[In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))]
|
byte[] text,
|
||||||
string text,
|
|
||||||
SDL.SDL_Color fg,
|
SDL.SDL_Color fg,
|
||||||
uint wrapped
|
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* */
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
@ -70,12 +70,11 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AutofacModule.cs" />
|
<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="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="SDL2Font.cs" />
|
||||||
<Compile Include="SDL2Label.cs" />
|
<Compile Include="SDL2Label.cs" />
|
||||||
<Compile Include="SDL2MusicPlayer.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>
|
<packages>
|
||||||
<package id="Autofac" version="4.8.1" targetFramework="net461" />
|
<package id="Autofac" version="4.8.1" targetFramework="net461" />
|
||||||
<package id="log4net" version="2.0.8" targetFramework="net461" />
|
<package id="log4net" version="2.0.8" targetFramework="net461" />
|
||||||
<package id="SDL2-CS" version="2.0.0.0" targetFramework="net461" />
|
|
||||||
</packages>
|
</packages>
|
Loading…
Reference in New Issue
Block a user