mirror of
https://github.com/Ryujinx/SDL2-CS.git
synced 2024-12-23 04:25:34 +00:00
Merge branch '2.0.18'
This commit is contained in:
commit
0c6e7ac1a2
275
src/SDL2.cs
275
src/SDL2.cs
|
@ -711,9 +711,23 @@ namespace SDL2
|
|||
public const string SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR =
|
||||
"SDL_VIDEO_WAYLAND_ALLOW_LIBDECOR";
|
||||
|
||||
/* Only available in 2.0.18 or higher. Non-exhaustive list. */
|
||||
/* Only available in 2.0.18 or higher. */
|
||||
public const string SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY =
|
||||
"SDL_VIDEO_EGL_ALLOW_TRANSPARENCY";
|
||||
public const string SDL_HINT_APP_NAME =
|
||||
"SDL_APP_NAME";
|
||||
public const string SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME =
|
||||
"SDL_SCREENSAVER_INHIBIT_ACTIVITY_NAME";
|
||||
public const string SDL_HINT_IME_SHOW_UI =
|
||||
"SDL_IME_SHOW_UI";
|
||||
public const string SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN =
|
||||
"SDL_WINDOW_NO_ACTIVATION_WHEN_SHOWN";
|
||||
public const string SDL_HINT_POLL_SENTINEL =
|
||||
"SDL_POLL_SENTINEL";
|
||||
public const string SDL_HINT_JOYSTICK_DEVICE =
|
||||
"SDL_JOYSTICK_DEVICE";
|
||||
public const string SDL_HINT_LINUX_JOYSTICK_CLASSIC =
|
||||
"SDL_LINUX_JOYSTICK_CLASSIC";
|
||||
|
||||
public enum SDL_HintPriority
|
||||
{
|
||||
|
@ -1288,7 +1302,7 @@ namespace SDL2
|
|||
*/
|
||||
public const int SDL_MAJOR_VERSION = 2;
|
||||
public const int SDL_MINOR_VERSION = 0;
|
||||
public const int SDL_PATCHLEVEL = 16;
|
||||
public const int SDL_PATCHLEVEL = 18;
|
||||
|
||||
public static readonly int SDL_COMPILEDVERSION = SDL_VERSIONNUM(
|
||||
SDL_MAJOR_VERSION,
|
||||
|
@ -1405,7 +1419,10 @@ namespace SDL2
|
|||
SDL_WINDOWEVENT_CLOSE,
|
||||
/* Only available in 2.0.5 or higher. */
|
||||
SDL_WINDOWEVENT_TAKE_FOCUS,
|
||||
SDL_WINDOWEVENT_HIT_TEST
|
||||
SDL_WINDOWEVENT_HIT_TEST,
|
||||
/* Only available in 2.0.18 or higher. */
|
||||
SDL_WINDOWEVENT_ICCPROF_CHANGED,
|
||||
SDL_WINDOWEVENT_DISPLAY_CHANGED
|
||||
}
|
||||
|
||||
public enum SDL_DisplayEventID : byte
|
||||
|
@ -1731,6 +1748,17 @@ namespace SDL2
|
|||
out SDL_DisplayMode mode
|
||||
);
|
||||
|
||||
/* IntPtr refers to a void*
|
||||
* window refers to an SDL_Window*
|
||||
* mode refers to a size_t*
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr SDL_GetWindowICCProfile(
|
||||
IntPtr window,
|
||||
out IntPtr mode
|
||||
);
|
||||
|
||||
/* window refers to an SDL_Window* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern uint SDL_GetWindowFlags(IntPtr window);
|
||||
|
@ -2196,6 +2224,35 @@ namespace SDL2
|
|||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr SDL_GetGrabbedWindow();
|
||||
|
||||
/* window refers to an SDL_Window*
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int SDL_SetWindowMouseRect(
|
||||
IntPtr window,
|
||||
ref SDL_Rect rect
|
||||
);
|
||||
|
||||
/* window refers to an SDL_Window*
|
||||
* rect refers to an SDL_Rect*
|
||||
* This overload allows for IntPtr.Zero (null) to be passed for rect.
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int SDL_SetWindowMouseRect(
|
||||
IntPtr window,
|
||||
IntPtr rect
|
||||
);
|
||||
|
||||
/* window refers to an SDL_Window*
|
||||
* IntPtr refers to an SDL_Rect*
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr SDL_GetWindowMouseRect(
|
||||
IntPtr window
|
||||
);
|
||||
|
||||
/* window refers to an SDL_Window*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
|
@ -2281,6 +2338,17 @@ namespace SDL2
|
|||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SDL_Vulkan_UnloadLibrary();
|
||||
|
||||
/* window refers to an SDL_Window*, pNames to a const char**.
|
||||
* Only available in 2.0.6 or higher.
|
||||
* This overload allows for IntPtr.Zero (null) to be passed for pNames.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern SDL_bool SDL_Vulkan_GetInstanceExtensions(
|
||||
IntPtr window,
|
||||
out uint pCount,
|
||||
IntPtr pNames
|
||||
);
|
||||
|
||||
/* window refers to an SDL_Window*, pNames to a const char**.
|
||||
* Only available in 2.0.6 or higher.
|
||||
*/
|
||||
|
@ -2401,6 +2469,15 @@ namespace SDL2
|
|||
SDL_ScaleModeBest
|
||||
}
|
||||
|
||||
/* Only available in 2.0.18 or higher. */
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SDL_Vertex
|
||||
{
|
||||
public SDL_FPoint position;
|
||||
public SDL_Color color;
|
||||
public SDL_FPoint tex_coord;
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Renderer*, window to an SDL_Window* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr SDL_CreateRenderer(
|
||||
|
@ -2469,6 +2546,22 @@ namespace SDL2
|
|||
out SDL_ScaleMode scaleMode
|
||||
);
|
||||
|
||||
/* texture refers to an SDL_Texture*
|
||||
* userdata refers to a void*
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int SDL_SetTextureUserData(
|
||||
IntPtr texture,
|
||||
IntPtr userdata
|
||||
);
|
||||
|
||||
/* IntPtr refers to a void*, texture refers to an SDL_Texture*
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr SDL_GetTextureUserData(IntPtr texture);
|
||||
|
||||
/* renderer refers to an SDL_Renderer* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int SDL_GetRenderDrawColor(
|
||||
|
@ -3024,6 +3117,41 @@ namespace SDL2
|
|||
SDL_RendererFlip flip
|
||||
);
|
||||
|
||||
/* renderer refers to an SDL_Renderer*
|
||||
* texture refers to an SDL_Texture*
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int SDL_RenderGeometry(
|
||||
IntPtr renderer,
|
||||
IntPtr texture,
|
||||
[In] SDL_Vertex[] vertices,
|
||||
int num_vertices,
|
||||
[In] int[] indices,
|
||||
int num_indices
|
||||
);
|
||||
|
||||
/* renderer refers to an SDL_Renderer*
|
||||
* texture refers to an SDL_Texture*
|
||||
* indices refers to a void*
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int SDL_RenderGeometryRaw(
|
||||
IntPtr renderer,
|
||||
IntPtr texture,
|
||||
[In] float[] xy,
|
||||
int xy_stride,
|
||||
[In] int[] color,
|
||||
int color_stride,
|
||||
[In] float[] uv,
|
||||
int uv_stride,
|
||||
int num_vertices,
|
||||
IntPtr indices,
|
||||
int num_indices,
|
||||
int size_indices
|
||||
);
|
||||
|
||||
/* renderer refers to an SDL_Renderer* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int SDL_RenderDrawPointF(
|
||||
|
@ -3131,6 +3259,30 @@ namespace SDL2
|
|||
out float scaleY
|
||||
);
|
||||
|
||||
/* renderer refers to an SDL_Renderer*
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SDL_RenderWindowToLogical(
|
||||
IntPtr renderer,
|
||||
int windowX,
|
||||
int windowY,
|
||||
out float logicalX,
|
||||
out float logicalY
|
||||
);
|
||||
|
||||
/* renderer refers to an SDL_Renderer*
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SDL_RenderLogicalToWindow(
|
||||
IntPtr renderer,
|
||||
float logicalX,
|
||||
float logicalY,
|
||||
out int windowX,
|
||||
out int windowY
|
||||
);
|
||||
|
||||
/* renderer refers to an SDL_Renderer* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int SDL_RenderGetViewport(
|
||||
|
@ -3324,6 +3476,12 @@ namespace SDL2
|
|||
IntPtr renderer
|
||||
);
|
||||
|
||||
/* renderer refers to an SDL_Renderer*
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int SDL_RenderSetVSync(IntPtr renderer, int vsync);
|
||||
|
||||
/* renderer refers to an SDL_Renderer*
|
||||
* Only available in 2.0.4 or higher.
|
||||
*/
|
||||
|
@ -4632,6 +4790,10 @@ namespace SDL2
|
|||
/* Only available in SDL 2.0.4 or higher. */
|
||||
SDL_RENDER_DEVICE_RESET,
|
||||
|
||||
/* Internal events */
|
||||
/* Only available in 2.0.18 or higher. */
|
||||
SDL_POLLSENTINEL = 0x7F00,
|
||||
|
||||
/* Events SDL_USEREVENT through SDL_LASTEVENT are for
|
||||
* your use, and should be allocated with
|
||||
* SDL_RegisterEvents()
|
||||
|
@ -4779,6 +4941,8 @@ namespace SDL2
|
|||
public Int32 x; /* amount scrolled horizontally */
|
||||
public Int32 y; /* amount scrolled vertically */
|
||||
public UInt32 direction; /* Set to one of the SDL_MOUSEWHEEL_* defines */
|
||||
public float preciseX; /* Requires >= 2.0.18 */
|
||||
public float preciseY; /* Requires >= 2.0.18 */
|
||||
}
|
||||
|
||||
// Ignore private members used for padding in this struct
|
||||
|
@ -5085,9 +5249,9 @@ namespace SDL2
|
|||
[FieldOffset(0)]
|
||||
public SDL_ControllerDeviceEvent cdevice;
|
||||
[FieldOffset(0)]
|
||||
public SDL_ControllerDeviceEvent ctouchpad;
|
||||
public SDL_ControllerTouchpadEvent ctouchpad;
|
||||
[FieldOffset(0)]
|
||||
public SDL_ControllerDeviceEvent csensor;
|
||||
public SDL_ControllerSensorEvent csensor;
|
||||
[FieldOffset(0)]
|
||||
public SDL_AudioDeviceEvent adevice;
|
||||
[FieldOffset(0)]
|
||||
|
@ -5825,13 +5989,15 @@ namespace SDL2
|
|||
KMOD_NUM = 0x1000,
|
||||
KMOD_CAPS = 0x2000,
|
||||
KMOD_MODE = 0x4000,
|
||||
KMOD_RESERVED = 0x8000,
|
||||
KMOD_SCROLL = 0x8000,
|
||||
|
||||
/* These are defines in the SDL headers */
|
||||
KMOD_CTRL = (KMOD_LCTRL | KMOD_RCTRL),
|
||||
KMOD_SHIFT = (KMOD_LSHIFT | KMOD_RSHIFT),
|
||||
KMOD_ALT = (KMOD_LALT | KMOD_RALT),
|
||||
KMOD_GUI = (KMOD_LGUI | KMOD_RGUI)
|
||||
KMOD_GUI = (KMOD_LGUI | KMOD_RGUI),
|
||||
|
||||
KMOD_RESERVED = KMOD_SCROLL
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -6527,6 +6693,18 @@ namespace SDL2
|
|||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern SDL_bool SDL_JoystickHasLED(IntPtr joystick);
|
||||
|
||||
/* IntPtr refers to an SDL_Joystick*.
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern SDL_bool SDL_JoystickHasRumble(IntPtr joystick);
|
||||
|
||||
/* IntPtr refers to an SDL_Joystick*.
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern SDL_bool SDL_JoystickHasRumbleTriggers(IntPtr joystick);
|
||||
|
||||
/* IntPtr refers to an SDL_Joystick*.
|
||||
* Only available in 2.0.14 or higher.
|
||||
*/
|
||||
|
@ -6968,6 +7146,40 @@ namespace SDL2
|
|||
IntPtr gamecontroller
|
||||
);
|
||||
|
||||
/* gamecontroller refers to an SDL_GameController*
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetAppleSFSymbolsNameForButton", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_SDL_GameControllerGetAppleSFSymbolsNameForButton(
|
||||
IntPtr gamecontroller,
|
||||
SDL_GameControllerButton button
|
||||
);
|
||||
public static string SDL_GameControllerGetAppleSFSymbolsNameForButton(
|
||||
IntPtr gamecontroller,
|
||||
SDL_GameControllerButton button
|
||||
) {
|
||||
return UTF8_ToManaged(
|
||||
INTERNAL_SDL_GameControllerGetAppleSFSymbolsNameForButton(gamecontroller, button)
|
||||
);
|
||||
}
|
||||
|
||||
/* gamecontroller refers to an SDL_GameController*
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetAppleSFSymbolsNameForAxis", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_SDL_GameControllerGetAppleSFSymbolsNameForAxis(
|
||||
IntPtr gamecontroller,
|
||||
SDL_GameControllerAxis axis
|
||||
);
|
||||
public static string SDL_GameControllerGetAppleSFSymbolsNameForAxis(
|
||||
IntPtr gamecontroller,
|
||||
SDL_GameControllerAxis axis
|
||||
) {
|
||||
return UTF8_ToManaged(
|
||||
INTERNAL_SDL_GameControllerGetAppleSFSymbolsNameForAxis(gamecontroller, axis)
|
||||
);
|
||||
}
|
||||
|
||||
/* int refers to an SDL_JoystickID, IntPtr to an SDL_GameController*.
|
||||
* Only available in 2.0.4 or higher.
|
||||
*/
|
||||
|
@ -7013,6 +7225,22 @@ namespace SDL2
|
|||
IntPtr gamecontroller
|
||||
);
|
||||
|
||||
/* gamecontroller refers to an SDL_GameController*.
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern SDL_bool SDL_GameControllerHasRumble(
|
||||
IntPtr gamecontroller
|
||||
);
|
||||
|
||||
/* gamecontroller refers to an SDL_GameController*.
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern SDL_bool SDL_GameControllerHasRumbleTriggers(
|
||||
IntPtr gamecontroller
|
||||
);
|
||||
|
||||
/* gamecontroller refers to an SDL_GameController*.
|
||||
* Only available in 2.0.14 or higher.
|
||||
*/
|
||||
|
@ -7781,6 +8009,17 @@ namespace SDL2
|
|||
int volume
|
||||
);
|
||||
|
||||
/* format refers to an SDL_AudioFormat */
|
||||
/* This overload allows raw pointers to be passed for dst and src. */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SDL_MixAudioFormat(
|
||||
IntPtr dst,
|
||||
IntPtr src,
|
||||
ushort format,
|
||||
uint len,
|
||||
int volume
|
||||
);
|
||||
|
||||
/* format refers to an SDL_AudioFormat */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SDL_MixAudioFormat(
|
||||
|
@ -7805,6 +8044,17 @@ namespace SDL2
|
|||
IntPtr obtained
|
||||
);
|
||||
|
||||
/* uint refers to an SDL_AudioDeviceID */
|
||||
/* This overload allows for IntPtr.Zero (null) to be passed for device. */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern unsafe uint SDL_OpenAudioDevice(
|
||||
IntPtr device,
|
||||
int iscapture,
|
||||
ref SDL_AudioSpec desired,
|
||||
out SDL_AudioSpec obtained,
|
||||
int allowed_changes
|
||||
);
|
||||
|
||||
/* uint refers to an SDL_AudioDeviceID */
|
||||
[DllImport(nativeLibName, EntryPoint = "SDL_OpenAudioDevice", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern unsafe uint INTERNAL_SDL_OpenAudioDevice(
|
||||
|
@ -7965,6 +8215,12 @@ namespace SDL2
|
|||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern UInt32 SDL_GetTicks();
|
||||
|
||||
/* Returns the milliseconds that have passed since SDL was initialized
|
||||
* Only available in 2.0.18 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern UInt64 SDL_GetTicks64();
|
||||
|
||||
/* Get the current value of the high resolution counter */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern UInt64 SDL_GetPerformanceCounter();
|
||||
|
@ -8019,7 +8275,7 @@ namespace SDL2
|
|||
|
||||
/* renderer refers to an SDL_Renderer*
|
||||
* IntPtr refers to an ID3D11Device*
|
||||
* Only available in 2.0.18 or higher.
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr SDL_RenderGetD3D11Device(IntPtr renderer);
|
||||
|
@ -8108,7 +8364,7 @@ namespace SDL2
|
|||
}
|
||||
|
||||
/* Only available in 2.0.16 or higher. */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[DllImport(nativeLibName, EntryPoint = "SDL_AndroidShowToast", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static unsafe extern int INTERNAL_SDL_AndroidShowToast(
|
||||
byte* message,
|
||||
int duration,
|
||||
|
@ -8226,6 +8482,7 @@ namespace SDL2
|
|||
public IntPtr shell_surface; // Refers to a wl_shell_surface*
|
||||
public IntPtr egl_window; // Refers to an egl_window*, requires >= 2.0.16
|
||||
public IntPtr xdg_surface; // Refers to an xdg_surface*, requires >= 2.0.16
|
||||
public IntPtr xdg_toplevel; // Referes to an xdg_toplevel*, requires >= 2.0.18
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
|
666
src/SDL2_mixer.cs
Normal file
666
src/SDL2_mixer.cs
Normal file
|
@ -0,0 +1,666 @@
|
|||
#region License
|
||||
/* SDL2# - C# Wrapper for SDL2
|
||||
*
|
||||
* Copyright (c) 2013-2021 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>
|
||||
*
|
||||
*/
|
||||
#endregion
|
||||
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
#endregion
|
||||
|
||||
namespace SDL2
|
||||
{
|
||||
public static class SDL_mixer
|
||||
{
|
||||
#region SDL2# Variables
|
||||
|
||||
/* Used by DllImport to load the native library. */
|
||||
private const string nativeLibName = "SDL2_mixer";
|
||||
|
||||
#endregion
|
||||
|
||||
#region SDL_mixer.h
|
||||
|
||||
/* Similar to the headers, this is the version we're expecting to be
|
||||
* running with. You will likely want to check this somewhere in your
|
||||
* program!
|
||||
*/
|
||||
public const int SDL_MIXER_MAJOR_VERSION = 2;
|
||||
public const int SDL_MIXER_MINOR_VERSION = 0;
|
||||
public const int SDL_MIXER_PATCHLEVEL = 5;
|
||||
|
||||
/* 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
|
||||
* variable is persistent and not dependent on preprocessor ordering.
|
||||
*/
|
||||
public const int MIX_CHANNELS = 8;
|
||||
|
||||
public static readonly int MIX_DEFAULT_FREQUENCY = 44100;
|
||||
public static readonly ushort MIX_DEFAULT_FORMAT =
|
||||
BitConverter.IsLittleEndian ? SDL.AUDIO_S16LSB : SDL.AUDIO_S16MSB;
|
||||
public static readonly int MIX_DEFAULT_CHANNELS = 2;
|
||||
public static readonly byte MIX_MAX_VOLUME = 128;
|
||||
|
||||
[Flags]
|
||||
public enum MIX_InitFlags
|
||||
{
|
||||
MIX_INIT_FLAC = 0x00000001,
|
||||
MIX_INIT_MOD = 0x00000002,
|
||||
MIX_INIT_MP3 = 0x00000008,
|
||||
MIX_INIT_OGG = 0x00000010,
|
||||
MIX_INIT_MID = 0x00000020,
|
||||
MIX_INIT_OPUS = 0x00000040
|
||||
}
|
||||
|
||||
public struct MIX_Chunk
|
||||
{
|
||||
public int allocated;
|
||||
public IntPtr abuf; /* Uint8* */
|
||||
public uint alen;
|
||||
public byte volume;
|
||||
}
|
||||
|
||||
public enum Mix_Fading
|
||||
{
|
||||
MIX_NO_FADING,
|
||||
MIX_FADING_OUT,
|
||||
MIX_FADING_IN
|
||||
}
|
||||
|
||||
public enum Mix_MusicType
|
||||
{
|
||||
MUS_NONE,
|
||||
MUS_CMD,
|
||||
MUS_WAV,
|
||||
MUS_MOD,
|
||||
MUS_MID,
|
||||
MUS_OGG,
|
||||
MUS_MP3,
|
||||
MUS_MP3_MAD_UNUSED,
|
||||
MUS_FLAC,
|
||||
MUS_MODPLUG_UNUSED,
|
||||
MUS_OPUS
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void MixFuncDelegate(
|
||||
IntPtr udata, // void*
|
||||
IntPtr stream, // Uint8*
|
||||
int len
|
||||
);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void Mix_EffectFunc_t(
|
||||
int chan,
|
||||
IntPtr stream, // void*
|
||||
int len,
|
||||
IntPtr udata // void*
|
||||
);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void Mix_EffectDone_t(
|
||||
int chan,
|
||||
IntPtr udata // void*
|
||||
);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void MusicFinishedDelegate();
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void ChannelFinishedDelegate(int channel);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate int SoundFontDelegate(
|
||||
IntPtr a, // const char*
|
||||
IntPtr b // void*
|
||||
);
|
||||
|
||||
public static void SDL_MIXER_VERSION(out SDL.SDL_version X)
|
||||
{
|
||||
X.major = SDL_MIXER_MAJOR_VERSION;
|
||||
X.minor = SDL_MIXER_MINOR_VERSION;
|
||||
X.patch = SDL_MIXER_PATCHLEVEL;
|
||||
}
|
||||
|
||||
[DllImport(nativeLibName, EntryPoint = "MIX_Linked_Version", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_MIX_Linked_Version();
|
||||
public static SDL.SDL_version MIX_Linked_Version()
|
||||
{
|
||||
SDL.SDL_version result;
|
||||
IntPtr result_ptr = INTERNAL_MIX_Linked_Version();
|
||||
result = (SDL.SDL_version) Marshal.PtrToStructure(
|
||||
result_ptr,
|
||||
typeof(SDL.SDL_version)
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_Init(MIX_InitFlags flags);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Mix_Quit();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_OpenAudio(
|
||||
int frequency,
|
||||
ushort format,
|
||||
int channels,
|
||||
int chunksize
|
||||
);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_AllocateChannels(int numchans);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_QuerySpec(
|
||||
out int frequency,
|
||||
out ushort format,
|
||||
out int channels
|
||||
);
|
||||
|
||||
/* src refers to an SDL_RWops*, IntPtr to a Mix_Chunk* */
|
||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr Mix_LoadWAV_RW(
|
||||
IntPtr src,
|
||||
int freesrc
|
||||
);
|
||||
|
||||
/* IntPtr refers to a Mix_Chunk* */
|
||||
/* This is an RWops macro in the C header. */
|
||||
public static IntPtr Mix_LoadWAV(string file)
|
||||
{
|
||||
IntPtr rwops = SDL.SDL_RWFromFile(file, "rb");
|
||||
return Mix_LoadWAV_RW(rwops, 1);
|
||||
}
|
||||
|
||||
/* IntPtr refers to a Mix_Music* */
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_LoadMUS", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern unsafe IntPtr INTERNAL_Mix_LoadMUS(
|
||||
byte* file
|
||||
);
|
||||
public static unsafe IntPtr Mix_LoadMUS(string file)
|
||||
{
|
||||
byte* utf8File = SDL.Utf8EncodeHeap(file);
|
||||
IntPtr handle = INTERNAL_Mix_LoadMUS(
|
||||
utf8File
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8File);
|
||||
return handle;
|
||||
}
|
||||
|
||||
/* IntPtr refers to a Mix_Chunk* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
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 IntPtr 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)]
|
||||
public static extern void Mix_FreeChunk(IntPtr chunk);
|
||||
|
||||
/* music refers to a Mix_Music* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Mix_FreeMusic(IntPtr music);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_GetNumChunkDecoders();
|
||||
|
||||
[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, 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)]
|
||||
public static extern Mix_MusicType Mix_GetMusicType(IntPtr music);
|
||||
|
||||
/* music refers to a Mix_Music*
|
||||
* Only available in 2.0.5 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicTitle", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr INTERNAL_Mix_GetMusicTitle(IntPtr music);
|
||||
public static string Mix_GetMusicTitle(IntPtr music)
|
||||
{
|
||||
return SDL.UTF8_ToManaged(
|
||||
INTERNAL_Mix_GetMusicTitle(music)
|
||||
);
|
||||
}
|
||||
|
||||
/* music refers to a Mix_Music*
|
||||
* Only available in 2.0.5 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicTitleTag", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr INTERNAL_Mix_GetMusicTitleTag(IntPtr music);
|
||||
public static string Mix_GetMusicTitleTag(IntPtr music)
|
||||
{
|
||||
return SDL.UTF8_ToManaged(
|
||||
INTERNAL_Mix_GetMusicTitleTag(music)
|
||||
);
|
||||
}
|
||||
|
||||
/* music refers to a Mix_Music*
|
||||
* Only available in 2.0.5 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicArtistTag", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr INTERNAL_Mix_GetMusicArtistTag(IntPtr music);
|
||||
public static string Mix_GetMusicArtistTag(IntPtr music)
|
||||
{
|
||||
return SDL.UTF8_ToManaged(
|
||||
INTERNAL_Mix_GetMusicArtistTag(music)
|
||||
);
|
||||
}
|
||||
|
||||
/* music refers to a Mix_Music*
|
||||
* Only available in 2.0.5 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicAlbumTag", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr INTERNAL_Mix_GetMusicAlbumTag(IntPtr music);
|
||||
public static string Mix_GetMusicAlbumTag(IntPtr music)
|
||||
{
|
||||
return SDL.UTF8_ToManaged(
|
||||
INTERNAL_Mix_GetMusicAlbumTag(music)
|
||||
);
|
||||
}
|
||||
|
||||
/* music refers to a Mix_Music*
|
||||
* Only available in 2.0.5 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicCopyrightTag", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr INTERNAL_Mix_GetMusicCopyrightTag(IntPtr music);
|
||||
public static string Mix_GetMusicCopyrightTag(IntPtr music)
|
||||
{
|
||||
return SDL.UTF8_ToManaged(
|
||||
INTERNAL_Mix_GetMusicCopyrightTag(music)
|
||||
);
|
||||
}
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Mix_SetPostMix(
|
||||
MixFuncDelegate mix_func,
|
||||
IntPtr arg // void*
|
||||
);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Mix_HookMusic(
|
||||
MixFuncDelegate mix_func,
|
||||
IntPtr arg // void*
|
||||
);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Mix_HookMusicFinished(
|
||||
MusicFinishedDelegate music_finished
|
||||
);
|
||||
|
||||
/* IntPtr refers to a void* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr Mix_GetMusicHookData();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Mix_ChannelFinished(
|
||||
ChannelFinishedDelegate channel_finished
|
||||
);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_RegisterEffect(
|
||||
int chan,
|
||||
Mix_EffectFunc_t f,
|
||||
Mix_EffectDone_t d,
|
||||
IntPtr arg // void*
|
||||
);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_UnregisterEffect(
|
||||
int channel,
|
||||
Mix_EffectFunc_t f
|
||||
);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_UnregisterAllEffects(int channel);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_SetPanning(
|
||||
int channel,
|
||||
byte left,
|
||||
byte right
|
||||
);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_SetPosition(
|
||||
int channel,
|
||||
short angle,
|
||||
byte distance
|
||||
);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_SetDistance(int channel, byte distance);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_SetReverseStereo(int channel, int flip);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_ReserveChannels(int num);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_GroupChannel(int which, int tag);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_GroupChannels(int from, int to, int tag);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_GroupAvailable(int tag);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_GroupCount(int tag);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_GroupOldest(int tag);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_GroupNewer(int tag);
|
||||
|
||||
/* chunk refers to a Mix_Chunk* */
|
||||
public static int Mix_PlayChannel(
|
||||
int channel,
|
||||
IntPtr chunk,
|
||||
int loops
|
||||
) {
|
||||
return Mix_PlayChannelTimed(channel, chunk, loops, -1);
|
||||
}
|
||||
|
||||
/* chunk refers to a Mix_Chunk* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_PlayChannelTimed(
|
||||
int channel,
|
||||
IntPtr chunk,
|
||||
int loops,
|
||||
int ticks
|
||||
);
|
||||
|
||||
/* music refers to a Mix_Music* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_PlayMusic(IntPtr music, int loops);
|
||||
|
||||
/* music refers to a Mix_Music* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_FadeInMusic(
|
||||
IntPtr music,
|
||||
int loops,
|
||||
int ms
|
||||
);
|
||||
|
||||
/* music refers to a Mix_Music* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_FadeInMusicPos(
|
||||
IntPtr music,
|
||||
int loops,
|
||||
int ms,
|
||||
double position
|
||||
);
|
||||
|
||||
/* chunk refers to a Mix_Chunk* */
|
||||
public static int Mix_FadeInChannel(
|
||||
int channel,
|
||||
IntPtr chunk,
|
||||
int loops,
|
||||
int ms
|
||||
) {
|
||||
return Mix_FadeInChannelTimed(channel, chunk, loops, ms, -1);
|
||||
}
|
||||
|
||||
/* chunk refers to a Mix_Chunk* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_FadeInChannelTimed(
|
||||
int channel,
|
||||
IntPtr chunk,
|
||||
int loops,
|
||||
int ms,
|
||||
int ticks
|
||||
);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_Volume(int channel, int volume);
|
||||
|
||||
/* chunk refers to a Mix_Chunk* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_VolumeChunk(
|
||||
IntPtr chunk,
|
||||
int volume
|
||||
);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_VolumeMusic(int volume);
|
||||
|
||||
/* music refers to a Mix_Music*
|
||||
* Only available in 2.0.5 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_GetVolumeMusicStream(IntPtr music);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_HaltChannel(int channel);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_HaltGroup(int tag);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_HaltMusic();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_ExpireChannel(int channel, int ticks);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_FadeOutChannel(int which, int ms);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_FadeOutGroup(int tag, int ms);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_FadeOutMusic(int ms);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Mix_Fading Mix_FadingMusic();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Mix_Fading Mix_FadingChannel(int which);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Mix_Pause(int channel);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Mix_Resume(int channel);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_Paused(int channel);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Mix_PauseMusic();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Mix_ResumeMusic();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Mix_RewindMusic();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_PausedMusic();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_SetMusicPosition(double position);
|
||||
|
||||
/* music refers to a Mix_Music*
|
||||
* Only available in 2.0.5 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern double Mix_GetMusicPosition(IntPtr music);
|
||||
|
||||
/* music refers to a Mix_Music*
|
||||
* Only available in 2.0.5 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern double Mix_MusicDuration(IntPtr music);
|
||||
|
||||
/* music refers to a Mix_Music*
|
||||
* Only available in 2.0.5 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern double Mix_GetMusicLoopStartTime(IntPtr music);
|
||||
|
||||
/* music refers to a Mix_Music*
|
||||
* Only available in 2.0.5 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern double Mix_GetMusicLoopEndTime(IntPtr music);
|
||||
|
||||
/* music refers to a Mix_Music*
|
||||
* Only available in 2.0.5 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern double Mix_GetMusicLoopLengthTime(IntPtr music);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_Playing(int channel);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_PlayingMusic();
|
||||
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_SetMusicCMD", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern unsafe int INTERNAL_Mix_SetMusicCMD(
|
||||
byte* command
|
||||
);
|
||||
public static unsafe int Mix_SetMusicCMD(string command)
|
||||
{
|
||||
byte* utf8Cmd = SDL.Utf8EncodeHeap(command);
|
||||
int result = INTERNAL_Mix_SetMusicCMD(
|
||||
utf8Cmd
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8Cmd);
|
||||
return result;
|
||||
}
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_SetSynchroValue(int value);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_GetSynchroValue();
|
||||
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_SetSoundFonts", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern unsafe int INTERNAL_Mix_SetSoundFonts(
|
||||
byte* paths
|
||||
);
|
||||
public static unsafe int Mix_SetSoundFonts(string paths)
|
||||
{
|
||||
byte* utf8Paths = SDL.Utf8EncodeHeap(paths);
|
||||
int result = INTERNAL_Mix_SetSoundFonts(
|
||||
utf8Paths
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8Paths);
|
||||
return result;
|
||||
}
|
||||
|
||||
[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(
|
||||
SoundFontDelegate function,
|
||||
IntPtr data // void*
|
||||
);
|
||||
|
||||
/* Only available in 2.0.5 or later. */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int Mix_SetTimidityCfg(
|
||||
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
||||
string path
|
||||
);
|
||||
|
||||
/* Only available in 2.0.5 or later. */
|
||||
[DllImport(nativeLibName, EntryPoint = "Mix_GetTimidityCfg", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr INTERNAL_Mix_GetTimidityCfg();
|
||||
public static string Mix_GetTimidityCfg()
|
||||
{
|
||||
return SDL.UTF8_ToManaged(
|
||||
INTERNAL_Mix_GetTimidityCfg()
|
||||
);
|
||||
}
|
||||
|
||||
/* IntPtr refers to a Mix_Chunk* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr Mix_GetChunk(int channel);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Mix_CloseAudio();
|
||||
|
||||
public static string Mix_GetError()
|
||||
{
|
||||
return SDL.SDL_GetError();
|
||||
}
|
||||
|
||||
public static void Mix_SetError(string fmtAndArglist)
|
||||
{
|
||||
SDL.SDL_SetError(fmtAndArglist);
|
||||
}
|
||||
|
||||
public static void Mix_ClearError()
|
||||
{
|
||||
SDL.SDL_ClearError();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
769
src/SDL2_ttf.cs
Normal file
769
src/SDL2_ttf.cs
Normal file
|
@ -0,0 +1,769 @@
|
|||
#region License
|
||||
/* SDL2# - C# Wrapper for SDL2
|
||||
*
|
||||
* Copyright (c) 2013-2021 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>
|
||||
*
|
||||
*/
|
||||
#endregion
|
||||
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
#endregion
|
||||
|
||||
namespace SDL2
|
||||
{
|
||||
public static class SDL_ttf
|
||||
{
|
||||
#region SDL2# Variables
|
||||
|
||||
/* Used by DllImport to load the native library. */
|
||||
private const string nativeLibName = "SDL2_ttf";
|
||||
|
||||
#endregion
|
||||
|
||||
#region SDL_ttf.h
|
||||
|
||||
/* Similar to the headers, this is the version we're expecting to be
|
||||
* running with. You will likely want to check this somewhere in your
|
||||
* program!
|
||||
*/
|
||||
public const int SDL_TTF_MAJOR_VERSION = 2;
|
||||
public const int SDL_TTF_MINOR_VERSION = 0;
|
||||
public const int SDL_TTF_PATCHLEVEL = 16;
|
||||
|
||||
public const int UNICODE_BOM_NATIVE = 0xFEFF;
|
||||
public const int UNICODE_BOM_SWAPPED = 0xFFFE;
|
||||
|
||||
public const int TTF_STYLE_NORMAL = 0x00;
|
||||
public const int TTF_STYLE_BOLD = 0x01;
|
||||
public const int TTF_STYLE_ITALIC = 0x02;
|
||||
public const int TTF_STYLE_UNDERLINE = 0x04;
|
||||
public const int TTF_STYLE_STRIKETHROUGH = 0x08;
|
||||
|
||||
public const int TTF_HINTING_NORMAL = 0;
|
||||
public const int TTF_HINTING_LIGHT = 1;
|
||||
public const int TTF_HINTING_MONO = 2;
|
||||
public const int TTF_HINTING_NONE = 3;
|
||||
public const int TTF_HINTING_LIGHT_SUBPIXEL = 4; /* >= 2.0.16 */
|
||||
|
||||
public static void SDL_TTF_VERSION(out SDL.SDL_version X)
|
||||
{
|
||||
X.major = SDL_TTF_MAJOR_VERSION;
|
||||
X.minor = SDL_TTF_MINOR_VERSION;
|
||||
X.patch = SDL_TTF_PATCHLEVEL;
|
||||
}
|
||||
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_LinkedVersion", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr INTERNAL_TTF_LinkedVersion();
|
||||
public static SDL.SDL_version TTF_LinkedVersion()
|
||||
{
|
||||
SDL.SDL_version result;
|
||||
IntPtr result_ptr = INTERNAL_TTF_LinkedVersion();
|
||||
result = (SDL.SDL_version) Marshal.PtrToStructure(
|
||||
result_ptr,
|
||||
typeof(SDL.SDL_version)
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void TTF_ByteSwappedUNICODE(int swapped);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_Init();
|
||||
|
||||
/* IntPtr refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_OpenFont", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern unsafe IntPtr INTERNAL_TTF_OpenFont(
|
||||
byte* file,
|
||||
int ptsize
|
||||
);
|
||||
public static unsafe IntPtr TTF_OpenFont(string file, int ptsize)
|
||||
{
|
||||
byte* utf8File = SDL.Utf8EncodeHeap(file);
|
||||
IntPtr handle = INTERNAL_TTF_OpenFont(
|
||||
utf8File,
|
||||
ptsize
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8File);
|
||||
return handle;
|
||||
}
|
||||
|
||||
/* src refers to an SDL_RWops*, IntPtr to a TTF_Font* */
|
||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_OpenFontRW(
|
||||
IntPtr src,
|
||||
int freesrc,
|
||||
int ptsize
|
||||
);
|
||||
|
||||
/* IntPtr refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_OpenFontIndex", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern unsafe IntPtr INTERNAL_TTF_OpenFontIndex(
|
||||
byte* file,
|
||||
int ptsize,
|
||||
long index
|
||||
);
|
||||
public static unsafe IntPtr TTF_OpenFontIndex(
|
||||
string file,
|
||||
int ptsize,
|
||||
long index
|
||||
) {
|
||||
byte* utf8File = SDL.Utf8EncodeHeap(file);
|
||||
IntPtr handle = INTERNAL_TTF_OpenFontIndex(
|
||||
utf8File,
|
||||
ptsize,
|
||||
index
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8File);
|
||||
return handle;
|
||||
}
|
||||
|
||||
/* src refers to an SDL_RWops*, IntPtr to a TTF_Font* */
|
||||
/* THIS IS A PUBLIC RWops FUNCTION! */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_OpenFontIndexRW(
|
||||
IntPtr src,
|
||||
int freesrc,
|
||||
int ptsize,
|
||||
long index
|
||||
);
|
||||
|
||||
/* font refers to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_SetFontSize(
|
||||
IntPtr font,
|
||||
int ptsize
|
||||
);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_GetFontStyle(IntPtr font);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void TTF_SetFontStyle(IntPtr font, int style);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_GetFontOutline(IntPtr font);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void TTF_SetFontOutline(IntPtr font, int outline);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_GetFontHinting(IntPtr font);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void TTF_SetFontHinting(IntPtr font, int hinting);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_FontHeight(IntPtr font);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_FontAscent(IntPtr font);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_FontDescent(IntPtr font);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_FontLineSkip(IntPtr font);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_GetFontKerning(IntPtr font);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void TTF_SetFontKerning(IntPtr font, int allowed);
|
||||
|
||||
/* font refers to a TTF_Font*.
|
||||
* IntPtr is actually a C long! This ignores Win64!
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_FontFaces(IntPtr font);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_FontFaceIsFixedWidth(IntPtr font);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[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, 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)]
|
||||
public static extern int TTF_GlyphIsProvided(IntPtr font, ushort ch);
|
||||
|
||||
/* font refers to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_GlyphIsProvided32(IntPtr font, uint ch);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_GlyphMetrics(
|
||||
IntPtr font,
|
||||
ushort ch,
|
||||
out int minx,
|
||||
out int maxx,
|
||||
out int miny,
|
||||
out int maxy,
|
||||
out int advance
|
||||
);
|
||||
|
||||
/* font refers to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_GlyphMetrics32(
|
||||
IntPtr font,
|
||||
uint ch,
|
||||
out int minx,
|
||||
out int maxx,
|
||||
out int miny,
|
||||
out int maxy,
|
||||
out int advance
|
||||
);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_SizeText(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
||||
string text,
|
||||
out int w,
|
||||
out int h
|
||||
);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_SizeUTF8", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern unsafe int INTERNAL_TTF_SizeUTF8(
|
||||
IntPtr font,
|
||||
byte* text,
|
||||
out int w,
|
||||
out int h
|
||||
);
|
||||
public static unsafe int TTF_SizeUTF8(
|
||||
IntPtr font,
|
||||
string text,
|
||||
out int w,
|
||||
out int h
|
||||
) {
|
||||
byte* utf8Text = SDL.Utf8EncodeHeap(text);
|
||||
int result = INTERNAL_TTF_SizeUTF8(
|
||||
font,
|
||||
utf8Text,
|
||||
out w,
|
||||
out h
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8Text);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_SizeUNICODE(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPWStr)]
|
||||
string text,
|
||||
out int w,
|
||||
out int h
|
||||
);
|
||||
|
||||
/* font refers to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_MeasureText(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
||||
string text,
|
||||
int measure_width,
|
||||
out int extent,
|
||||
out int count
|
||||
);
|
||||
|
||||
/* font refers to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_MeasureUTF8", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern unsafe int INTERNAL_TTF_MeasureUTF8(
|
||||
IntPtr font,
|
||||
byte* text,
|
||||
int measure_width,
|
||||
out int extent,
|
||||
out int count
|
||||
);
|
||||
public static unsafe int TTF_MeasureUTF8(
|
||||
IntPtr font,
|
||||
string text,
|
||||
int measure_width,
|
||||
out int extent,
|
||||
out int count
|
||||
) {
|
||||
byte* utf8Text = SDL.Utf8EncodeHeap(text);
|
||||
int result = INTERNAL_TTF_MeasureUTF8(
|
||||
font,
|
||||
utf8Text,
|
||||
measure_width,
|
||||
out extent,
|
||||
out count
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8Text);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* font refers to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_MeasureUNICODE(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPWStr)]
|
||||
string text,
|
||||
int measure_width,
|
||||
out int extent,
|
||||
out int count
|
||||
);
|
||||
|
||||
/* 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.LPStr)]
|
||||
string text,
|
||||
SDL.SDL_Color fg
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Solid", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern unsafe IntPtr INTERNAL_TTF_RenderUTF8_Solid(
|
||||
IntPtr font,
|
||||
byte* text,
|
||||
SDL.SDL_Color fg
|
||||
);
|
||||
public static unsafe IntPtr TTF_RenderUTF8_Solid(
|
||||
IntPtr font,
|
||||
string text,
|
||||
SDL.SDL_Color fg
|
||||
) {
|
||||
byte* utf8Text = SDL.Utf8EncodeHeap(text);
|
||||
IntPtr result = INTERNAL_TTF_RenderUTF8_Solid(
|
||||
font,
|
||||
utf8Text,
|
||||
fg
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8Text);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderUNICODE_Solid(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPWStr)]
|
||||
string text,
|
||||
SDL.SDL_Color fg
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderText_Solid_Wrapped(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
uint wrapLength
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Solid_Wrapped", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern unsafe IntPtr INTERNAL_TTF_RenderUTF8_Solid_Wrapped(
|
||||
IntPtr font,
|
||||
byte* text,
|
||||
SDL.SDL_Color fg,
|
||||
uint wrapLength
|
||||
);
|
||||
public static unsafe IntPtr TTF_RenderUTF8_Solid_Wrapped(
|
||||
IntPtr font,
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
uint wrapLength
|
||||
) {
|
||||
byte* utf8Text = SDL.Utf8EncodeHeap(text);
|
||||
IntPtr result = INTERNAL_TTF_RenderUTF8_Solid_Wrapped(
|
||||
font,
|
||||
utf8Text,
|
||||
fg,
|
||||
wrapLength
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8Text);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderUNICODE_Solid_Wrapped(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPWStr)]
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
uint wrapLength
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderGlyph_Solid(
|
||||
IntPtr font,
|
||||
ushort ch,
|
||||
SDL.SDL_Color fg
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderGlyph32_Solid(
|
||||
IntPtr font,
|
||||
uint ch,
|
||||
SDL.SDL_Color fg
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderText_Shaded(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
SDL.SDL_Color bg
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Shaded", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern unsafe IntPtr INTERNAL_TTF_RenderUTF8_Shaded(
|
||||
IntPtr font,
|
||||
byte* text,
|
||||
SDL.SDL_Color fg,
|
||||
SDL.SDL_Color bg
|
||||
);
|
||||
public static unsafe IntPtr TTF_RenderUTF8_Shaded(
|
||||
IntPtr font,
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
SDL.SDL_Color bg
|
||||
) {
|
||||
byte* utf8Text = SDL.Utf8EncodeHeap(text);
|
||||
IntPtr result = INTERNAL_TTF_RenderUTF8_Shaded(
|
||||
font,
|
||||
utf8Text,
|
||||
fg,
|
||||
bg
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8Text);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderUNICODE_Shaded(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPWStr)]
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
SDL.SDL_Color bg
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderText_Shaded_Wrapped(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
SDL.SDL_Color bg,
|
||||
uint wrapLength
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Shaded_Wrapped", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern unsafe IntPtr INTERNAL_TTF_RenderUTF8_Shaded_Wrapped(
|
||||
IntPtr font,
|
||||
byte* text,
|
||||
SDL.SDL_Color fg,
|
||||
SDL.SDL_Color bg,
|
||||
uint wrapLength
|
||||
);
|
||||
public static unsafe IntPtr TTF_RenderUTF8_Shaded_Wrapped(
|
||||
IntPtr font,
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
SDL.SDL_Color bg,
|
||||
uint wrapLength
|
||||
) {
|
||||
byte* utf8Text = SDL.Utf8EncodeHeap(text);
|
||||
IntPtr result = INTERNAL_TTF_RenderUTF8_Shaded_Wrapped(
|
||||
font,
|
||||
utf8Text,
|
||||
fg,
|
||||
bg,
|
||||
wrapLength
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8Text);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderUNICODE_Shaded_Wrapped(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPWStr)]
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
SDL.SDL_Color bg,
|
||||
uint wrapLength
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderGlyph_Shaded(
|
||||
IntPtr font,
|
||||
ushort ch,
|
||||
SDL.SDL_Color fg,
|
||||
SDL.SDL_Color bg
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderGlyph32_Shaded(
|
||||
IntPtr font,
|
||||
uint ch,
|
||||
SDL.SDL_Color fg,
|
||||
SDL.SDL_Color bg
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderText_Blended(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
||||
string text,
|
||||
SDL.SDL_Color fg
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Blended", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern unsafe IntPtr INTERNAL_TTF_RenderUTF8_Blended(
|
||||
IntPtr font,
|
||||
byte* text,
|
||||
SDL.SDL_Color fg
|
||||
);
|
||||
public static unsafe IntPtr TTF_RenderUTF8_Blended(
|
||||
IntPtr font,
|
||||
string text,
|
||||
SDL.SDL_Color fg
|
||||
) {
|
||||
byte* utf8Text = SDL.Utf8EncodeHeap(text);
|
||||
IntPtr result = INTERNAL_TTF_RenderUTF8_Blended(
|
||||
font,
|
||||
utf8Text,
|
||||
fg
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8Text);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderUNICODE_Blended(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPWStr)]
|
||||
string text,
|
||||
SDL.SDL_Color fg
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderText_Blended_Wrapped(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
uint wrapped
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Blended_Wrapped", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern unsafe IntPtr INTERNAL_TTF_RenderUTF8_Blended_Wrapped(
|
||||
IntPtr font,
|
||||
byte* text,
|
||||
SDL.SDL_Color fg,
|
||||
uint wrapped
|
||||
);
|
||||
public static unsafe IntPtr TTF_RenderUTF8_Blended_Wrapped(
|
||||
IntPtr font,
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
uint wrapped
|
||||
) {
|
||||
byte* utf8Text = SDL.Utf8EncodeHeap(text);
|
||||
IntPtr result = INTERNAL_TTF_RenderUTF8_Blended_Wrapped(
|
||||
font,
|
||||
utf8Text,
|
||||
fg,
|
||||
wrapped
|
||||
);
|
||||
Marshal.FreeHGlobal((IntPtr) utf8Text);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderUNICODE_Blended_Wrapped(
|
||||
IntPtr font,
|
||||
[In()] [MarshalAs(UnmanagedType.LPWStr)]
|
||||
string text,
|
||||
SDL.SDL_Color fg,
|
||||
uint wrapped
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderGlyph_Blended(
|
||||
IntPtr font,
|
||||
ushort ch,
|
||||
SDL.SDL_Color fg
|
||||
);
|
||||
|
||||
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr TTF_RenderGlyph32_Blended(
|
||||
IntPtr font,
|
||||
uint ch,
|
||||
SDL.SDL_Color fg
|
||||
);
|
||||
|
||||
/* Only available in 2.0.16 or higher. */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_SetDirection(int direction);
|
||||
|
||||
/* Only available in 2.0.16 or higher. */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_SetScript(int script);
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void TTF_CloseFont(IntPtr font);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void TTF_Quit();
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_WasInit();
|
||||
|
||||
/* font refers to a TTF_Font* */
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int SDL_GetFontKerningSize(
|
||||
IntPtr font,
|
||||
int prev_index,
|
||||
int index
|
||||
);
|
||||
|
||||
/* font refers to a TTF_Font*
|
||||
* Only available in 2.0.15 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_GetFontKerningSizeGlyphs(
|
||||
IntPtr font,
|
||||
ushort previous_ch,
|
||||
ushort ch
|
||||
);
|
||||
|
||||
/* font refers to a TTF_Font*
|
||||
* Only available in 2.0.16 or higher.
|
||||
*/
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int TTF_GetFontKerningSizeGlyphs32(
|
||||
IntPtr font,
|
||||
ushort previous_ch,
|
||||
ushort ch
|
||||
);
|
||||
|
||||
public static string TTF_GetError()
|
||||
{
|
||||
return SDL.SDL_GetError();
|
||||
}
|
||||
|
||||
public static void TTF_SetError(string fmtAndArglist)
|
||||
{
|
||||
SDL.SDL_SetError(fmtAndArglist);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue