Apply master changes and fix utf8 buffer naming
@@ -1,4 +1,4 @@
|
|||||||

|

|
||||||
|
|
||||||
# Raylib-cs
|
# Raylib-cs
|
||||||
|
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ApplicationIcon>../Logo/raylib-cs.ico</ApplicationIcon>
|
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="../Logo/raylib-cs_64x64.png" Pack="true" PackagePath="" />
|
<None Include="logo/raylib-cs_64x64.png" Pack="true" PackagePath="" />
|
||||||
<None Include="../README.md" Pack="true" PackagePath="" />
|
<None Include="../README.md" Pack="true" PackagePath="" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -53,7 +53,8 @@
|
|||||||
<Compile Include="interop\*.cs" />
|
<Compile Include="interop\*.cs" />
|
||||||
<Compile Include="types\*.cs" />
|
<Compile Include="types\*.cs" />
|
||||||
<Compile Include="types\native\CBool.cs" />
|
<Compile Include="types\native\CBool.cs" />
|
||||||
<Compile Include="types\native\UTF8Buffer.cs" />
|
<Compile Include="types\native\AnsiBuffer.cs" />
|
||||||
|
<Compile Include="types\native\Utf8Buffer.cs" />
|
||||||
<Compile Include="types\native\FilePathList.cs" />
|
<Compile Include="types\native\FilePathList.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 139 KiB |
Before Width: | Height: | Size: 1016 B After Width: | Height: | Size: 1016 B |
Before Width: | Height: | Size: 243 B After Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 256 B After Width: | Height: | Size: 256 B |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 507 B |
Before Width: | Height: | Size: 464 B After Width: | Height: | Size: 464 B |
Before Width: | Height: | Size: 446 B After Width: | Height: | Size: 446 B |
Before Width: | Height: | Size: 832 B After Width: | Height: | Size: 832 B |
@@ -9,14 +9,14 @@ namespace Raylib_cs
|
|||||||
/// <summary>Initialize window and OpenGL context</summary>
|
/// <summary>Initialize window and OpenGL context</summary>
|
||||||
public static void InitWindow(int width, int height, string title)
|
public static void InitWindow(int width, int height, string title)
|
||||||
{
|
{
|
||||||
using var str1 = title.ToUTF8Buffer();
|
using var str1 = title.ToUtf8Buffer();
|
||||||
InitWindow(width, height, str1.AsPointer());
|
InitWindow(width, height, str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Set title for window (only PLATFORM_DESKTOP)</summary>
|
/// <summary>Set title for window (only PLATFORM_DESKTOP)</summary>
|
||||||
public static void SetWindowTitle(string title)
|
public static void SetWindowTitle(string title)
|
||||||
{
|
{
|
||||||
using var str1 = title.ToUTF8Buffer();
|
using var str1 = title.ToUtf8Buffer();
|
||||||
SetWindowTitle(str1.AsPointer());
|
SetWindowTitle(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,94 +35,94 @@ namespace Raylib_cs
|
|||||||
/// <summary>Set clipboard text content</summary>
|
/// <summary>Set clipboard text content</summary>
|
||||||
public static void SetClipboardText(string text)
|
public static void SetClipboardText(string text)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
SetClipboardText(str1.AsPointer());
|
SetClipboardText(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Open URL with default system browser (if available)</summary>
|
/// <summary>Open URL with default system browser (if available)</summary>
|
||||||
public static void OpenURL(string url)
|
public static void OpenURL(string url)
|
||||||
{
|
{
|
||||||
using var str1 = url.ToUTF8Buffer();
|
using var str1 = url.ToUtf8Buffer();
|
||||||
OpenURL(str1.AsPointer());
|
OpenURL(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Set internal gamepad mappings (SDL_GameControllerDB)</summary>
|
/// <summary>Set internal gamepad mappings (SDL_GameControllerDB)</summary>
|
||||||
public static int SetGamepadMappings(string mappings)
|
public static int SetGamepadMappings(string mappings)
|
||||||
{
|
{
|
||||||
using var str1 = mappings.ToUTF8Buffer();
|
using var str1 = mappings.ToUtf8Buffer();
|
||||||
return SetGamepadMappings(str1.AsPointer());
|
return SetGamepadMappings(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Load shader from files and bind default locations</summary>
|
/// <summary>Load shader from files and bind default locations</summary>
|
||||||
public static Shader LoadShader(string vsFileName, string fsFileName)
|
public static Shader LoadShader(string vsFileName, string fsFileName)
|
||||||
{
|
{
|
||||||
using var str1 = vsFileName.ToUTF8Buffer();
|
using var str1 = vsFileName.ToAnsiBuffer();
|
||||||
using var str2 = fsFileName.ToUTF8Buffer();
|
using var str2 = fsFileName.ToAnsiBuffer();
|
||||||
return LoadShader(str1.AsPointer(), str2.AsPointer());
|
return LoadShader(str1.AsPointer(), str2.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Load shader from code string and bind default locations</summary>
|
/// <summary>Load shader from code string and bind default locations</summary>
|
||||||
public static Shader LoadShaderFromMemory(string vsCode, string fsCode)
|
public static Shader LoadShaderFromMemory(string vsCode, string fsCode)
|
||||||
{
|
{
|
||||||
using var str1 = vsCode.ToUTF8Buffer();
|
using var str1 = vsCode.ToUtf8Buffer();
|
||||||
using var str2 = fsCode.ToUTF8Buffer();
|
using var str2 = fsCode.ToUtf8Buffer();
|
||||||
return LoadShaderFromMemory(str1.AsPointer(), str2.AsPointer());
|
return LoadShaderFromMemory(str1.AsPointer(), str2.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Get shader uniform location</summary>
|
/// <summary>Get shader uniform location</summary>
|
||||||
public static int GetShaderLocation(Shader shader, string uniformName)
|
public static int GetShaderLocation(Shader shader, string uniformName)
|
||||||
{
|
{
|
||||||
using var str1 = uniformName.ToUTF8Buffer();
|
using var str1 = uniformName.ToUtf8Buffer();
|
||||||
return GetShaderLocation(shader, str1.AsPointer());
|
return GetShaderLocation(shader, str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Get shader attribute location</summary>
|
/// <summary>Get shader attribute location</summary>
|
||||||
public static int GetShaderLocationAttrib(Shader shader, string attribName)
|
public static int GetShaderLocationAttrib(Shader shader, string attribName)
|
||||||
{
|
{
|
||||||
using var str1 = attribName.ToUTF8Buffer();
|
using var str1 = attribName.ToUtf8Buffer();
|
||||||
return GetShaderLocationAttrib(shader, str1.AsPointer());
|
return GetShaderLocationAttrib(shader, str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Takes a screenshot of current screen (saved a .png)</summary>
|
/// <summary>Takes a screenshot of current screen (saved a .png)</summary>
|
||||||
public static void TakeScreenshot(string fileName)
|
public static void TakeScreenshot(string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
TakeScreenshot(str1.AsPointer());
|
TakeScreenshot(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Check file extension</summary>
|
/// <summary>Check file extension</summary>
|
||||||
public static CBool IsFileExtension(string fileName, string ext)
|
public static CBool IsFileExtension(string fileName, string ext)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
using var str2 = ext.ToUTF8Buffer();
|
using var str2 = ext.ToAnsiBuffer();
|
||||||
return IsFileExtension(str1.AsPointer(), str2.AsPointer());
|
return IsFileExtension(str1.AsPointer(), str2.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Get file modification time (last write time)</summary>
|
/// <summary>Get file modification time (last write time)</summary>
|
||||||
public static long GetFileModTime(string fileName)
|
public static long GetFileModTime(string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return GetFileModTime(str1.AsPointer());
|
return GetFileModTime(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Load image from file into CPU memory (RAM)</summary>
|
/// <summary>Load image from file into CPU memory (RAM)</summary>
|
||||||
public static Image LoadImage(string fileName)
|
public static Image LoadImage(string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return LoadImage(str1.AsPointer());
|
return LoadImage(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Load image from RAW file data</summary>
|
/// <summary>Load image from RAW file data</summary>
|
||||||
public static Image LoadImageRaw(string fileName, int width, int height, PixelFormat format, int headerSize)
|
public static Image LoadImageRaw(string fileName, int width, int height, PixelFormat format, int headerSize)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return LoadImageRaw(str1.AsPointer(), width, height, format, headerSize);
|
return LoadImageRaw(str1.AsPointer(), width, height, format, headerSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Load image sequence from file (frames appended to image.data)</summary>
|
/// <summary>Load image sequence from file (frames appended to image.data)</summary>
|
||||||
public static Image LoadImageAnim(string fileName, out int frames)
|
public static Image LoadImageAnim(string fileName, out int frames)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
fixed (int* p = &frames)
|
fixed (int* p = &frames)
|
||||||
{
|
{
|
||||||
return LoadImageAnim(str1.AsPointer(), p);
|
return LoadImageAnim(str1.AsPointer(), p);
|
||||||
@@ -134,7 +134,7 @@ namespace Raylib_cs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static Image LoadImageFromMemory(string fileType, byte[] fileData)
|
public static Image LoadImageFromMemory(string fileType, byte[] fileData)
|
||||||
{
|
{
|
||||||
using var fileTypeNative = fileType.ToUTF8Buffer();
|
using var fileTypeNative = fileType.ToAnsiBuffer();
|
||||||
fixed (byte* fileDataNative = fileData)
|
fixed (byte* fileDataNative = fileData)
|
||||||
{
|
{
|
||||||
Image image = LoadImageFromMemory(fileTypeNative.AsPointer(), fileDataNative, fileData.Length);
|
Image image = LoadImageFromMemory(fileTypeNative.AsPointer(), fileDataNative, fileData.Length);
|
||||||
@@ -145,21 +145,21 @@ namespace Raylib_cs
|
|||||||
/// <summary>Export image data to file</summary>
|
/// <summary>Export image data to file</summary>
|
||||||
public static CBool ExportImage(Image image, string fileName)
|
public static CBool ExportImage(Image image, string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return ExportImage(image, str1.AsPointer());
|
return ExportImage(image, str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Export image as code file defining an array of bytes</summary>
|
/// <summary>Export image as code file defining an array of bytes</summary>
|
||||||
public static CBool ExportImageAsCode(Image image, string fileName)
|
public static CBool ExportImageAsCode(Image image, string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return ExportImageAsCode(image, str1.AsPointer());
|
return ExportImageAsCode(image, str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR)</summary>
|
/// <summary>Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR)</summary>
|
||||||
public static void TraceLog(TraceLogLevel logLevel, string text)
|
public static void TraceLog(TraceLogLevel logLevel, string text)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
TraceLog(logLevel, str1.AsPointer());
|
TraceLog(logLevel, str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ namespace Raylib_cs
|
|||||||
/// <summary>Load file data as byte array (read)</summary>
|
/// <summary>Load file data as byte array (read)</summary>
|
||||||
public static byte* LoadFileData(string fileName, ref uint bytesRead)
|
public static byte* LoadFileData(string fileName, ref uint bytesRead)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
fixed (uint* p = &bytesRead)
|
fixed (uint* p = &bytesRead)
|
||||||
{
|
{
|
||||||
return LoadFileData(str1.AsPointer(), p);
|
return LoadFileData(str1.AsPointer(), p);
|
||||||
@@ -291,14 +291,14 @@ namespace Raylib_cs
|
|||||||
/// <summary>Create an image from text (default font)</summary>
|
/// <summary>Create an image from text (default font)</summary>
|
||||||
public static Image ImageText(string text, int fontSize, Color color)
|
public static Image ImageText(string text, int fontSize, Color color)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
return ImageText(str1.AsPointer(), fontSize, color);
|
return ImageText(str1.AsPointer(), fontSize, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Create an image from text (custom sprite font)</summary>
|
/// <summary>Create an image from text (custom sprite font)</summary>
|
||||||
public static Image ImageTextEx(Font font, string text, float fontSize, float spacing, Color tint)
|
public static Image ImageTextEx(Font font, string text, float fontSize, float spacing, Color tint)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
return ImageTextEx(font, str1.AsPointer(), fontSize, spacing, tint);
|
return ImageTextEx(font, str1.AsPointer(), fontSize, spacing, tint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,7 +634,7 @@ 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>
|
||||||
public static void ImageDrawText(ref Image dst, string text, int x, int y, int fontSize, Color color)
|
public static void ImageDrawText(ref Image dst, string text, int x, int y, int fontSize, Color color)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
fixed (Image* p = &dst)
|
fixed (Image* p = &dst)
|
||||||
{
|
{
|
||||||
ImageDrawText(p, str1.AsPointer(), x, y, fontSize, color);
|
ImageDrawText(p, str1.AsPointer(), x, y, fontSize, color);
|
||||||
@@ -652,7 +652,7 @@ namespace Raylib_cs
|
|||||||
Color color
|
Color color
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
fixed (Image* p = &dst)
|
fixed (Image* p = &dst)
|
||||||
{
|
{
|
||||||
ImageDrawTextEx(p, font, str1.AsPointer(), position, fontSize, spacing, color);
|
ImageDrawTextEx(p, font, str1.AsPointer(), position, fontSize, spacing, color);
|
||||||
@@ -662,7 +662,7 @@ namespace Raylib_cs
|
|||||||
/// <summary>Load texture from file into GPU memory (VRAM)</summary>
|
/// <summary>Load texture from file into GPU memory (VRAM)</summary>
|
||||||
public static Texture2D LoadTexture(string fileName)
|
public static Texture2D LoadTexture(string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return LoadTexture(str1.AsPointer());
|
return LoadTexture(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -708,14 +708,14 @@ namespace Raylib_cs
|
|||||||
/// <summary>Load font from file into GPU memory (VRAM)</summary>
|
/// <summary>Load font from file into GPU memory (VRAM)</summary>
|
||||||
public static Font LoadFont(string fileName)
|
public static Font LoadFont(string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return LoadFont(str1.AsPointer());
|
return LoadFont(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Load font from file with extended parameters</summary>
|
/// <summary>Load font from file with extended parameters</summary>
|
||||||
public static Font LoadFontEx(string fileName, int fontSize, int[] fontChars, int glyphCount)
|
public static Font LoadFontEx(string fileName, int fontSize, int[] fontChars, int glyphCount)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
fixed (int* p = fontChars)
|
fixed (int* p = fontChars)
|
||||||
{
|
{
|
||||||
return LoadFontEx(str1.AsPointer(), fontSize, p, glyphCount);
|
return LoadFontEx(str1.AsPointer(), fontSize, p, glyphCount);
|
||||||
@@ -733,7 +733,7 @@ namespace Raylib_cs
|
|||||||
int glyphCount
|
int glyphCount
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
using var fileTypeNative = fileType.ToUTF8Buffer();
|
using var fileTypeNative = fileType.ToAnsiBuffer();
|
||||||
fixed (byte* fileDataNative = fileData)
|
fixed (byte* fileDataNative = fileData)
|
||||||
{
|
{
|
||||||
fixed (int* fontCharsNative = fontChars)
|
fixed (int* fontCharsNative = fontChars)
|
||||||
@@ -791,7 +791,7 @@ namespace Raylib_cs
|
|||||||
/// <summary>Load model animations from file</summary>
|
/// <summary>Load model animations from file</summary>
|
||||||
public static ReadOnlySpan<ModelAnimation> LoadModelAnimations(string fileName, ref uint animCount)
|
public static ReadOnlySpan<ModelAnimation> LoadModelAnimations(string fileName, ref uint animCount)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
fixed (uint* p = &animCount)
|
fixed (uint* p = &animCount)
|
||||||
{
|
{
|
||||||
ModelAnimation* modelAnimations = LoadModelAnimations(str1.AsPointer(), p);
|
ModelAnimation* modelAnimations = LoadModelAnimations(str1.AsPointer(), p);
|
||||||
@@ -862,7 +862,7 @@ namespace Raylib_cs
|
|||||||
/// <summary>Draw text (using default font)</summary>
|
/// <summary>Draw text (using default font)</summary>
|
||||||
public static void DrawText(string text, int posX, int posY, int fontSize, Color color)
|
public static void DrawText(string text, int posX, int posY, int fontSize, Color color)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
DrawText(str1.AsPointer(), posX, posY, fontSize, color);
|
DrawText(str1.AsPointer(), posX, posY, fontSize, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -876,7 +876,7 @@ namespace Raylib_cs
|
|||||||
Color tint
|
Color tint
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
DrawTextEx(font, str1.AsPointer(), position, fontSize, spacing, tint);
|
DrawTextEx(font, str1.AsPointer(), position, fontSize, spacing, tint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,28 +892,28 @@ namespace Raylib_cs
|
|||||||
Color tint
|
Color tint
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
DrawTextPro(font, str1.AsPointer(), position, origin, rotation, fontSize, spacing, tint);
|
DrawTextPro(font, str1.AsPointer(), position, origin, rotation, fontSize, spacing, tint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Measure string width for default font</summary>
|
/// <summary>Measure string width for default font</summary>
|
||||||
public static int MeasureText(string text, int fontSize)
|
public static int MeasureText(string text, int fontSize)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
return MeasureText(str1.AsPointer(), fontSize);
|
return MeasureText(str1.AsPointer(), fontSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Measure string size for Font</summary>
|
/// <summary>Measure string size for Font</summary>
|
||||||
public static Vector2 MeasureTextEx(Font font, string text, float fontSize, float spacing)
|
public static Vector2 MeasureTextEx(Font font, string text, float fontSize, float spacing)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
return MeasureTextEx(font, str1.AsPointer(), fontSize, spacing);
|
return MeasureTextEx(font, str1.AsPointer(), fontSize, spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <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>
|
||||||
public static int[] LoadCodepoints(string text, ref int count)
|
public static int[] LoadCodepoints(string text, ref int count)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
fixed (int* c = &count)
|
fixed (int* c = &count)
|
||||||
{
|
{
|
||||||
var pointsPtr = LoadCodepoints(str1.AsPointer(), c);
|
var pointsPtr = LoadCodepoints(str1.AsPointer(), c);
|
||||||
@@ -926,14 +926,14 @@ namespace Raylib_cs
|
|||||||
/// <summary>Get total number of codepoints in a UTF8 encoded string</summary>
|
/// <summary>Get total number of codepoints in a UTF8 encoded string</summary>
|
||||||
public static int GetCodepointCount(string text)
|
public static int GetCodepointCount(string text)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
return GetCodepointCount(str1.AsPointer());
|
return GetCodepointCount(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure</summary>
|
/// <summary>Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure</summary>
|
||||||
public static int GetCodepoint(string text, ref int codepointSize)
|
public static int GetCodepoint(string text, ref int codepointSize)
|
||||||
{
|
{
|
||||||
using var str1 = text.ToUTF8Buffer();
|
using var str1 = text.ToUtf8Buffer();
|
||||||
fixed (int* p = &codepointSize)
|
fixed (int* p = &codepointSize)
|
||||||
{
|
{
|
||||||
return GetCodepoint(str1.AsPointer(), p);
|
return GetCodepoint(str1.AsPointer(), p);
|
||||||
@@ -965,14 +965,14 @@ namespace Raylib_cs
|
|||||||
/// <summary>Draw a model (with texture if set)</summary>
|
/// <summary>Draw a model (with texture if set)</summary>
|
||||||
public static Model LoadModel(string fileName)
|
public static Model LoadModel(string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return LoadModel(str1.AsPointer());
|
return LoadModel(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Export mesh data to file, returns true on success</summary>
|
/// <summary>Export mesh data to file, returns true on success</summary>
|
||||||
public static CBool ExportMesh(Mesh mesh, string fileName)
|
public static CBool ExportMesh(Mesh mesh, string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return ExportMesh(mesh, str1.AsPointer());
|
return ExportMesh(mesh, str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -997,7 +997,7 @@ namespace Raylib_cs
|
|||||||
/// <summary>Load wave data from file</summary>
|
/// <summary>Load wave data from file</summary>
|
||||||
public static Wave LoadWave(string fileName)
|
public static Wave LoadWave(string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return LoadWave(str1.AsPointer());
|
return LoadWave(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1009,7 +1009,7 @@ namespace Raylib_cs
|
|||||||
byte[] fileData
|
byte[] fileData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
using var fileTypeNative = fileType.ToUTF8Buffer();
|
using var fileTypeNative = fileType.ToAnsiBuffer();
|
||||||
|
|
||||||
fixed (byte* fileDataNative = fileData)
|
fixed (byte* fileDataNative = fileData)
|
||||||
{
|
{
|
||||||
@@ -1026,28 +1026,28 @@ namespace Raylib_cs
|
|||||||
/// <summary>Load sound from file</summary>
|
/// <summary>Load sound from file</summary>
|
||||||
public static Sound LoadSound(string fileName)
|
public static Sound LoadSound(string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return LoadSound(str1.AsPointer());
|
return LoadSound(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Export wave data to file</summary>
|
/// <summary>Export wave data to file</summary>
|
||||||
public static CBool ExportWave(Wave wave, string fileName)
|
public static CBool ExportWave(Wave wave, string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return ExportWave(wave, str1.AsPointer());
|
return ExportWave(wave, str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Export wave sample data to code (.h)</summary>
|
/// <summary>Export wave sample data to code (.h)</summary>
|
||||||
public static CBool ExportWaveAsCode(Wave wave, string fileName)
|
public static CBool ExportWaveAsCode(Wave wave, string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return ExportWaveAsCode(wave, str1.AsPointer());
|
return ExportWaveAsCode(wave, str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Load music stream from file</summary>
|
/// <summary>Load music stream from file</summary>
|
||||||
public static Music LoadMusicStream(string fileName)
|
public static Music LoadMusicStream(string fileName)
|
||||||
{
|
{
|
||||||
using var str1 = fileName.ToUTF8Buffer();
|
using var str1 = fileName.ToAnsiBuffer();
|
||||||
return LoadMusicStream(str1.AsPointer());
|
return LoadMusicStream(str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1059,7 +1059,7 @@ namespace Raylib_cs
|
|||||||
byte[] fileData
|
byte[] fileData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
using var fileTypeNative = fileType.ToUTF8Buffer();
|
using var fileTypeNative = fileType.ToAnsiBuffer();
|
||||||
|
|
||||||
fixed (byte* fileDataNative = fileData)
|
fixed (byte* fileDataNative = fileData)
|
||||||
{
|
{
|
||||||
|
@@ -13,7 +13,8 @@ namespace Raylib_cs
|
|||||||
public float Width;
|
public float Width;
|
||||||
public float Height;
|
public float Height;
|
||||||
|
|
||||||
public Rectangle(float x, float y, float width, float height) {
|
public Rectangle(float x, float y, float width, float height)
|
||||||
|
{
|
||||||
this.X = x;
|
this.X = x;
|
||||||
this.Y = y;
|
this.Y = y;
|
||||||
this.Width = width;
|
this.Width = width;
|
||||||
|
36
Raylib-cs/types/native/AnsiBuffer.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Raylib_cs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Converts text to a Ansi buffer for passing to native code
|
||||||
|
/// </summary>
|
||||||
|
public readonly ref struct AnsiBuffer
|
||||||
|
{
|
||||||
|
private readonly IntPtr data;
|
||||||
|
|
||||||
|
public AnsiBuffer(string text)
|
||||||
|
{
|
||||||
|
data = Marshal.StringToHGlobalAnsi(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe sbyte* AsPointer()
|
||||||
|
{
|
||||||
|
return (sbyte*)data.ToPointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AnsiStringUtils
|
||||||
|
{
|
||||||
|
public static AnsiBuffer ToAnsiBuffer(this string text)
|
||||||
|
{
|
||||||
|
return new AnsiBuffer(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,19 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Raylib_cs
|
namespace Raylib_cs
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts text to a UTF8 buffer for passing to native code
|
/// Converts text to a UTF8 buffer for passing to native code
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ref struct UTF8Buffer
|
public readonly ref struct Utf8Buffer
|
||||||
{
|
{
|
||||||
private IntPtr _data;
|
private readonly IntPtr _data;
|
||||||
|
|
||||||
public UTF8Buffer(string text)
|
public Utf8Buffer(string text)
|
||||||
{
|
{
|
||||||
_data = Marshal.StringToHGlobalAnsi(text);
|
_data = Marshal.StringToCoTaskMemUTF8(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe sbyte* AsPointer()
|
public unsafe sbyte* AsPointer()
|
||||||
@@ -23,15 +23,15 @@ namespace Raylib_cs
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Marshal.FreeHGlobal(_data);
|
Marshal.ZeroFreeCoTaskMemUTF8(_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Utf8StringUtils
|
public static class Utf8StringUtils
|
||||||
{
|
{
|
||||||
public static UTF8Buffer ToUTF8Buffer(this string text)
|
public static Utf8Buffer ToUtf8Buffer(this string text)
|
||||||
{
|
{
|
||||||
return new UTF8Buffer(text);
|
return new Utf8Buffer(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] ToUtf8String(this string text)
|
public static byte[] ToUtf8String(this string text)
|