mirror of
https://github.com/raylib-cs/raylib-cs
synced 2025-09-09 03:01:41 -04:00
Move wrapper functions into Raylib.Utils
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Raylib_cs
|
namespace Raylib_cs
|
||||||
@@ -8,6 +9,205 @@ namespace Raylib_cs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static unsafe partial class Raylib
|
public static unsafe partial class Raylib
|
||||||
{
|
{
|
||||||
|
public static void InitWindow(int width, int height, Utf8String title)
|
||||||
|
{
|
||||||
|
fixed (byte* p = title)
|
||||||
|
{
|
||||||
|
InitWindow(width, height, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetWindowTitle(Utf8String title)
|
||||||
|
{
|
||||||
|
fixed (byte* p = title)
|
||||||
|
{
|
||||||
|
SetWindowTitle(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Get the human-readable, UTF-8 encoded name of the primary monitor</summary>
|
||||||
|
public static Utf8String GetMonitorName_(int monitor)
|
||||||
|
{
|
||||||
|
return Utf8String.FromPtr(GetMonitorName(monitor));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Get clipboard text content</summary>
|
||||||
|
public static Utf8String GetClipboardText_()
|
||||||
|
{
|
||||||
|
return Utf8String.FromPtr(GetClipboardText());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetClipboardText(Utf8String text)
|
||||||
|
{
|
||||||
|
fixed (byte* p = text)
|
||||||
|
{
|
||||||
|
SetClipboardText(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Set custom trace log</summary>
|
||||||
|
public static void SetTraceLogCallback_(TraceLogCallback callback)
|
||||||
|
{
|
||||||
|
SetTraceLogCallback(callback);
|
||||||
|
traceLogCallback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Return gamepad internal name id</summary>
|
||||||
|
public static Utf8String GetGamepadName_(int gamepad)
|
||||||
|
{
|
||||||
|
return Utf8String.FromPtr(GetGamepadName(gamepad));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ImageDrawText(ref Image dst, Utf8String text, int x, int y, int fontSize, Color color)
|
||||||
|
{
|
||||||
|
fixed (byte* p = text)
|
||||||
|
{
|
||||||
|
fixed (Image* i = &dst)
|
||||||
|
{
|
||||||
|
ImageDrawText(i, p, x, y, fontSize, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawText(Utf8String text, int posX, int posY, int fontSize, Color color)
|
||||||
|
{
|
||||||
|
fixed (byte* p = text)
|
||||||
|
{
|
||||||
|
DrawText(p, posX, posY, fontSize, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawTextEx(Font font, Utf8String text, Vector2 position, float fontSize, float spacing, Color tint)
|
||||||
|
{
|
||||||
|
fixed (byte* p = text)
|
||||||
|
{
|
||||||
|
DrawTextEx(font, p, position, fontSize, spacing, tint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawTextPro(Font font, Utf8String text, Vector2 position, float fontSize, float spacing, Color tint)
|
||||||
|
{
|
||||||
|
fixed (byte* p = text)
|
||||||
|
{
|
||||||
|
DrawTextEx(font, p, position, fontSize, spacing, tint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int MeasureText(Utf8String text, int fontSize)
|
||||||
|
{
|
||||||
|
fixed (byte* p = text)
|
||||||
|
{
|
||||||
|
return MeasureText(p, fontSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector2 MeasureTextEx(Font font, Utf8String text, float fontSize, float spacing)
|
||||||
|
{
|
||||||
|
fixed (byte* p = text)
|
||||||
|
{
|
||||||
|
return MeasureTextEx(font, p, fontSize, spacing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void TextAppend(Utf8String text, Utf8String append, int position)
|
||||||
|
{
|
||||||
|
fixed (byte* p1 = text)
|
||||||
|
{
|
||||||
|
fixed (byte* p2 = append)
|
||||||
|
{
|
||||||
|
TextAppend(p1, p2, &position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Utf8String TextToPascal(Utf8String text)
|
||||||
|
{
|
||||||
|
fixed (byte* p1 = text)
|
||||||
|
{
|
||||||
|
return Utf8String.FromPtr(TextToPascal(p1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int TextToInteger(Utf8String text)
|
||||||
|
{
|
||||||
|
fixed (byte* p1 = text)
|
||||||
|
{
|
||||||
|
return TextToInteger(p1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int[] LoadCodepoints(Utf8String text, ref int count)
|
||||||
|
{
|
||||||
|
fixed (byte* p1 = text)
|
||||||
|
{
|
||||||
|
fixed (int* c = &count)
|
||||||
|
{
|
||||||
|
var pointsPtr = LoadCodepoints(p1, c);
|
||||||
|
var codepoints = new ReadOnlySpan<int>(pointsPtr, count).ToArray();
|
||||||
|
UnloadCodepoints(pointsPtr);
|
||||||
|
return codepoints;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetCodepointCount(Utf8String text)
|
||||||
|
{
|
||||||
|
fixed (byte* p1 = text)
|
||||||
|
{
|
||||||
|
return GetCodepointCount(p1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Returns next codepoint in a UTF8 encoded string; 0x3f('?') is returned on failure</summary>
|
||||||
|
/// <returns>single codepoint / "char"</returns>
|
||||||
|
public static int GetCodepoint(Utf8String text, ref int bytesProcessed)
|
||||||
|
{
|
||||||
|
fixed (byte* p1 = text)
|
||||||
|
{
|
||||||
|
// this probably wont work
|
||||||
|
fixed (int* p = &bytesProcessed)
|
||||||
|
{
|
||||||
|
return GetCodepoint(p1, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Utf8String CodepointToUTF8(int codepoint, ref int byteSize)
|
||||||
|
{
|
||||||
|
fixed (int* l1 = &byteSize)
|
||||||
|
{
|
||||||
|
var ptr = CodepointToUTF8(codepoint, l1);
|
||||||
|
return Utf8String.FromPtr(ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Utf8String TextCodepointsToUTF8(int[] codepoints, int length)
|
||||||
|
{
|
||||||
|
fixed (int* c1 = codepoints)
|
||||||
|
{
|
||||||
|
var ptr = TextCodepointsToUTF8(c1, length);
|
||||||
|
return Utf8String.FromPtr(ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ReadOnlySpan<ModelAnimation> LoadModelAnimations(Utf8String fileName, ref int animsCount)
|
||||||
|
{
|
||||||
|
fixed (byte* p1 = fileName)
|
||||||
|
{
|
||||||
|
fixed (int* p2 = &animsCount)
|
||||||
|
{
|
||||||
|
var model = LoadModelAnimations(p1, p2);
|
||||||
|
|
||||||
|
if ((IntPtr)model == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
throw new ApplicationException("Failed to load animation");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ReadOnlySpan<ModelAnimation>(model, animsCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static string SubText(this string input, int position, int length)
|
public static string SubText(this string input, int position, int length)
|
||||||
{
|
{
|
||||||
return input.Substring(position, Math.Min(length, input.Length));
|
return input.Substring(position, Math.Min(length, input.Length));
|
||||||
|
@@ -77,14 +77,6 @@ namespace Raylib_cs
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void InitWindow(int width, int height, byte* title);
|
public static extern void InitWindow(int width, int height, byte* title);
|
||||||
|
|
||||||
public static void InitWindow(int width, int height, Utf8String title)
|
|
||||||
{
|
|
||||||
fixed (byte* p = title)
|
|
||||||
{
|
|
||||||
InitWindow(width, height, p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Check if KEY_ESCAPE pressed or Close icon pressed</summary>
|
/// <summary>Check if KEY_ESCAPE pressed or Close icon pressed</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern CBool WindowShouldClose();
|
public static extern CBool WindowShouldClose();
|
||||||
@@ -157,14 +149,6 @@ namespace Raylib_cs
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void SetWindowTitle(byte* title);
|
public static extern void SetWindowTitle(byte* title);
|
||||||
|
|
||||||
public static void SetWindowTitle(Utf8String title)
|
|
||||||
{
|
|
||||||
fixed (byte* p = title)
|
|
||||||
{
|
|
||||||
SetWindowTitle(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Set window position on screen (only PLATFORM_DESKTOP)</summary>
|
/// <summary>Set window position on screen (only PLATFORM_DESKTOP)</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void SetWindowPosition(int x, int y);
|
public static extern void SetWindowPosition(int x, int y);
|
||||||
@@ -237,34 +221,14 @@ namespace Raylib_cs
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern byte* GetMonitorName(int monitor);
|
public static extern byte* GetMonitorName(int monitor);
|
||||||
|
|
||||||
/// <summary>Get the human-readable, UTF-8 encoded name of the primary monitor</summary>
|
|
||||||
public static Utf8String GetMonitorName_(int monitor)
|
|
||||||
{
|
|
||||||
return Utf8String.FromPtr(GetMonitorName(monitor));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Get clipboard text content</summary>
|
/// <summary>Get clipboard text content</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern byte* GetClipboardText();
|
public static extern byte* GetClipboardText();
|
||||||
|
|
||||||
/// <summary>Get clipboard text content</summary>
|
|
||||||
public static Utf8String GetClipboardText_()
|
|
||||||
{
|
|
||||||
return Utf8String.FromPtr(GetClipboardText());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Set clipboard text content</summary>
|
/// <summary>Set clipboard text content</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void SetClipboardText(byte* text);
|
public static extern void SetClipboardText(byte* text);
|
||||||
|
|
||||||
public static void SetClipboardText(Utf8String text)
|
|
||||||
{
|
|
||||||
fixed (byte* p = text)
|
|
||||||
{
|
|
||||||
SetClipboardText(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom frame control functions
|
// Custom frame control functions
|
||||||
// NOTE: Those functions are intended for advance users that want full control over the frame processing
|
// NOTE: Those functions are intended for advance users that want full control over the frame processing
|
||||||
// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timming + PollInputEvents()
|
// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timming + PollInputEvents()
|
||||||
@@ -526,13 +490,6 @@ namespace Raylib_cs
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void SetTraceLogCallback(TraceLogCallback callback);
|
public static extern void SetTraceLogCallback(TraceLogCallback callback);
|
||||||
|
|
||||||
/// <summary>Set custom trace log</summary>
|
|
||||||
public static void SetTraceLogCallback_(TraceLogCallback callback)
|
|
||||||
{
|
|
||||||
SetTraceLogCallback(callback);
|
|
||||||
traceLogCallback = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Set custom file binary data loader</summary>
|
/// <summary>Set custom file binary data loader</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void SetLoadFileDataCallback(LoadFileDataCallback callback);
|
public static extern void SetLoadFileDataCallback(LoadFileDataCallback callback);
|
||||||
@@ -652,12 +609,6 @@ namespace Raylib_cs
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern byte* GetGamepadName(int gamepad);
|
public static extern byte* GetGamepadName(int gamepad);
|
||||||
|
|
||||||
/// <summary>Return gamepad internal name id</summary>
|
|
||||||
public static Utf8String GetGamepadName_(int gamepad)
|
|
||||||
{
|
|
||||||
return Utf8String.FromPtr(GetGamepadName(gamepad));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Detect if a gamepad button has been pressed once</summary>
|
/// <summary>Detect if a gamepad button has been pressed once</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern CBool IsGamepadButtonPressed(int gamepad, GamepadButton button);
|
public static extern CBool IsGamepadButtonPressed(int gamepad, GamepadButton button);
|
||||||
@@ -1311,27 +1262,12 @@ namespace Raylib_cs
|
|||||||
|
|
||||||
/// <summary>Draw text (using default font) within an image (destination)</summary>
|
/// <summary>Draw text (using default font) within an image (destination)</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void ImageDrawText(ref Image dst, byte* text, int x, int y, int fontSize, Color color);
|
public static extern void ImageDrawText(Image* dst, byte* text, int x, int y, int fontSize, Color color);
|
||||||
|
|
||||||
public static void ImageDrawText(ref Image dst, Utf8String text, int x, int y, int fontSize, Color color)
|
|
||||||
{
|
|
||||||
fixed (byte* p = text)
|
|
||||||
{
|
|
||||||
ImageDrawText(ref dst, p, x, y, fontSize, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Draw text (custom sprite font) within an image (destination)</summary>
|
/// <summary>Draw text (custom sprite font) within an image (destination)</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void ImageDrawTextEx(ref Image dst, Font font, byte* text, Vector2 position, float fontSize, float spacing, Color tint);
|
public static extern void ImageDrawTextEx(Image* dst, Font font, byte* text, Vector2 position, float fontSize, float spacing, Color tint);
|
||||||
|
|
||||||
public static void ImageDrawTextEx(ref Image dst, Font font, Utf8String text, Vector2 position, float fontSize, float spacing, Color tint)
|
|
||||||
{
|
|
||||||
fixed (byte* p = text)
|
|
||||||
{
|
|
||||||
ImageDrawTextEx(ref dst, font, p, position, fontSize, spacing, tint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Texture loading functions
|
// Texture loading functions
|
||||||
// NOTE: These functions require GPU access
|
// NOTE: These functions require GPU access
|
||||||
@@ -1524,41 +1460,14 @@ namespace Raylib_cs
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void DrawText(byte* text, int posX, int posY, int fontSize, Color color);
|
public static extern void DrawText(byte* text, int posX, int posY, int fontSize, Color color);
|
||||||
|
|
||||||
public static void DrawText(Utf8String text, int posX, int posY, int fontSize, Color color)
|
|
||||||
{
|
|
||||||
fixed (byte* p = text)
|
|
||||||
{
|
|
||||||
DrawText(p, posX, posY, fontSize, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Draw text using font and additional parameters</summary>
|
/// <summary>Draw text using font and additional parameters</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void DrawTextEx(Font font, byte* text, Vector2 position, float fontSize, float spacing, Color tint);
|
public static extern void DrawTextEx(Font font, byte* text, Vector2 position, float fontSize, float spacing, Color tint);
|
||||||
|
|
||||||
public static void DrawTextEx(Font font, Utf8String text, Vector2 position, float fontSize,
|
|
||||||
float spacing, Color tint)
|
|
||||||
{
|
|
||||||
fixed (byte* p = text)
|
|
||||||
{
|
|
||||||
DrawTextEx(font, p, position, fontSize, spacing, tint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Draw text using Font and pro parameters (rotation)</summary>
|
/// <summary>Draw text using Font and pro parameters (rotation)</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void DrawTextPro(Font font, byte* text, Vector2 position, float fontSize, float spacing, Color tint);
|
public static extern void DrawTextPro(Font font, byte* text, Vector2 position, float fontSize, float spacing, Color tint);
|
||||||
|
|
||||||
public static void DrawTextPro(Font font, Utf8String text, Vector2 position, float fontSize,
|
|
||||||
float spacing, Color tint)
|
|
||||||
{
|
|
||||||
fixed (byte* p = text)
|
|
||||||
{
|
|
||||||
DrawTextEx(font, p, position, fontSize, spacing, tint);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Draw one character (codepoint)</summary>
|
/// <summary>Draw one character (codepoint)</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float scale, Color tint);
|
public static extern void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float scale, Color tint);
|
||||||
@@ -1570,26 +1479,10 @@ namespace Raylib_cs
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int MeasureText(byte* text, int fontSize);
|
public static extern int MeasureText(byte* text, int fontSize);
|
||||||
|
|
||||||
public static int MeasureText(Utf8String text, int fontSize)
|
|
||||||
{
|
|
||||||
fixed (byte* p = text)
|
|
||||||
{
|
|
||||||
return MeasureText(p, fontSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Measure string size for Font</summary>
|
/// <summary>Measure string size for Font</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern Vector2 MeasureTextEx(Font font, byte* text, float fontSize, float spacing);
|
public static extern Vector2 MeasureTextEx(Font font, byte* text, float fontSize, float spacing);
|
||||||
|
|
||||||
public static Vector2 MeasureTextEx(Font font, Utf8String text, float fontSize, float spacing)
|
|
||||||
{
|
|
||||||
fixed (byte* p = text)
|
|
||||||
{
|
|
||||||
return MeasureTextEx(font, p, fontSize, spacing);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found</summary>
|
/// <summary>Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int GetGlyphIndex(Font font, int character);
|
public static extern int GetGlyphIndex(Font font, int character);
|
||||||
@@ -1617,61 +1510,20 @@ namespace Raylib_cs
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void TextAppend(byte* text, byte* append, int* position);
|
public static extern void TextAppend(byte* text, byte* append, int* position);
|
||||||
|
|
||||||
public static void TextAppend(Utf8String text, Utf8String append, int position)
|
|
||||||
{
|
|
||||||
fixed (byte* p1 = text)
|
|
||||||
{
|
|
||||||
fixed (byte* p2 = append)
|
|
||||||
{
|
|
||||||
TextAppend(p1, p2, &position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Get Pascal case notation version of provided string</summary>
|
/// <summary>Get Pascal case notation version of provided string</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern byte* TextToPascal(byte* text);
|
public static extern byte* TextToPascal(byte* text);
|
||||||
public static Utf8String TextToPascal(Utf8String text)
|
|
||||||
{
|
|
||||||
fixed (byte* p1 = text)
|
|
||||||
{
|
|
||||||
return Utf8String.FromPtr(TextToPascal(p1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Get integer value from text (negative values not supported)</summary>
|
/// <summary>Get integer value from text (negative values not supported)</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int TextToInteger(byte* text);
|
public static extern int TextToInteger(byte* text);
|
||||||
|
|
||||||
public static int TextToInteger(Utf8String text)
|
|
||||||
{
|
|
||||||
fixed (byte* p1 = text)
|
|
||||||
{
|
|
||||||
return TextToInteger(p1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// UTF8 text strings management functions
|
// UTF8 text strings management functions
|
||||||
|
|
||||||
/// <summary>Get all codepoints in a string, codepoints count returned by parameters</summary>
|
/// <summary>Get all codepoints in a string, codepoints count returned by parameters</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int* LoadCodepoints(byte* text, int* count);
|
public static extern int* LoadCodepoints(byte* text, int* count);
|
||||||
|
|
||||||
public static int[] LoadCodepoints(Utf8String text, ref int count)
|
|
||||||
{
|
|
||||||
fixed (byte* p1 = text)
|
|
||||||
{
|
|
||||||
fixed (int* c = &count)
|
|
||||||
{
|
|
||||||
var pointsPtr = LoadCodepoints(p1, c);
|
|
||||||
var codepoints = new ReadOnlySpan<int>(pointsPtr, count).ToArray();
|
|
||||||
UnloadCodepoints(pointsPtr);
|
|
||||||
return codepoints;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Unload codepoints data from memory</summary>
|
/// <summary>Unload codepoints data from memory</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void UnloadCodepoints(int* codepoints);
|
public static extern void UnloadCodepoints(int* codepoints);
|
||||||
@@ -1680,58 +1532,18 @@ namespace Raylib_cs
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int GetCodepointCount(byte* text);
|
public static extern int GetCodepointCount(byte* text);
|
||||||
|
|
||||||
public static int GetCodepointCount(Utf8String text)
|
|
||||||
{
|
|
||||||
fixed (byte* p1 = text)
|
|
||||||
{
|
|
||||||
return GetCodepointCount(p1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Returns next codepoint in a UTF8 encoded string; 0x3f('?') is returned on failure</summary>
|
/// <summary>Returns next codepoint in a UTF8 encoded string; 0x3f('?') is returned on failure</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int GetCodepoint(byte* text, int* bytesProcessed);
|
public static extern int GetCodepoint(byte* text, int* bytesProcessed);
|
||||||
|
|
||||||
/// <summary>Returns next codepoint in a UTF8 encoded string; 0x3f('?') is returned on failure</summary>
|
|
||||||
/// <returns>single codepoint / "char"</returns>
|
|
||||||
public static int GetCodepoint(Utf8String text, ref int bytesProcessed)
|
|
||||||
{
|
|
||||||
fixed (byte* p1 = text)
|
|
||||||
{
|
|
||||||
// this probably wont work
|
|
||||||
fixed (int* p = &bytesProcessed)
|
|
||||||
{
|
|
||||||
return GetCodepoint(p1, p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Encode codepoint into utf8 text (char array length returned as parameter)</summary>
|
/// <summary>Encode codepoint into utf8 text (char array length returned as parameter)</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern byte* CodepointToUTF8(int codepoint, int* byteSize);
|
public static extern byte* CodepointToUTF8(int codepoint, int* byteSize);
|
||||||
|
|
||||||
public static Utf8String CodepointToUTF8(int codepoint, ref int byteSize)
|
|
||||||
{
|
|
||||||
fixed (int* l1 = &byteSize)
|
|
||||||
{
|
|
||||||
var ptr = CodepointToUTF8(codepoint, l1);
|
|
||||||
return Utf8String.FromPtr(ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Encode codepoint into utf8 text (char array length returned as parameter)</summary>
|
/// <summary>Encode codepoint into utf8 text (char array length returned as parameter)</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern byte* TextCodepointsToUTF8(int* codepoints, int length);
|
public static extern byte* TextCodepointsToUTF8(int* codepoints, int length);
|
||||||
|
|
||||||
public static Utf8String TextCodepointsToUTF8(int[] codepoints, int length)
|
|
||||||
{
|
|
||||||
fixed (int* c1 = codepoints)
|
|
||||||
{
|
|
||||||
var ptr = TextCodepointsToUTF8(c1, length);
|
|
||||||
return Utf8String.FromPtr(ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Basic 3d Shapes Drawing Functions (Module: models)
|
// Basic 3d Shapes Drawing Functions (Module: models)
|
||||||
@@ -1999,24 +1811,6 @@ namespace Raylib_cs
|
|||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern ModelAnimation* LoadModelAnimations(byte* fileName, int* animsCount);
|
public static extern ModelAnimation* LoadModelAnimations(byte* fileName, int* animsCount);
|
||||||
|
|
||||||
public static ReadOnlySpan<ModelAnimation> LoadModelAnimations(Utf8String fileName, ref int animsCount)
|
|
||||||
{
|
|
||||||
fixed (byte* p1 = fileName)
|
|
||||||
{
|
|
||||||
fixed (int* p2 = &animsCount)
|
|
||||||
{
|
|
||||||
var model = LoadModelAnimations(p1, p2);
|
|
||||||
|
|
||||||
if ((IntPtr)model == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
throw new ApplicationException("Failed to load animation");
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ReadOnlySpan<ModelAnimation>(model, animsCount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Update model animation pose</summary>
|
/// <summary>Update model animation pose</summary>
|
||||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void UpdateModelAnimation(Model model, ModelAnimation anim, int frame);
|
public static extern void UpdateModelAnimation(Model model, ModelAnimation anim, int frame);
|
||||||
|
Reference in New Issue
Block a user