diff --git a/README.md b/README.md index 6f0a1c7..83a3428 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,11 @@ C# bindings for raylib, a simple and easy-to-use library to learn videogames pro [![GitHub stars](https://img.shields.io/github/stars/raylib-cs/raylib-cs?style=social)](https://github.com/raylib-cs/raylib-cs/stargazers) [![Build](https://github.com/raylib-cs/raylib-cs/workflows/Build/badge.svg)](https://github.com/raylib-cs/raylib-cs/actions?query=workflow%3ABuild) -Raylib-cs targets net6.0 and uses the [official 5.5 release](https://github.com/raysan5/raylib/releases/tag/5.5) to build the native libraries. +Raylib-cs targets net6.0 net8.0 and uses the [official 5.5 release](https://github.com/raysan5/raylib/releases/tag/5.5) to build the native libraries. ## Status -Raylib-cs is passively maintained. Occasional updates may be released from time to time. Pull requests may be -accepted if they don't have a large maintainence burden. +Raylib-cs is passively maintained. Occasional updates may be released from time to time. Pull requests may be accepted if they don't have a large maintainence burden. ## Installation - NuGet @@ -60,10 +59,10 @@ using Raylib_cs; namespace HelloWorld; -class Program +internal static class Program { // STAThread is required if you deploy using NativeAOT on Windows - See https://github.com/raylib-cs/raylib-cs/issues/301 - [STAThread] + [System.STAThread] public static void Main() { Raylib.InitWindow(800, 480, "Hello World"); diff --git a/Raylib-cs/Raylib-cs.csproj b/Raylib-cs/Raylib-cs.csproj index 6f014f2..ea1167f 100644 --- a/Raylib-cs/Raylib-cs.csproj +++ b/Raylib-cs/Raylib-cs.csproj @@ -1,4 +1,4 @@ - + net6.0;net8.0 false @@ -49,9 +49,6 @@ - - - - + diff --git a/Raylib-cs/types/AudioCallback.cs b/Raylib-cs/types/AudioCallback.cs deleted file mode 100644 index 2f7b372..0000000 --- a/Raylib-cs/types/AudioCallback.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace Raylib_cs; - -/// -/// Audio stream processor. -/// Used with Raylib.AttachAudioMixedProcessor() -/// and Raylib.DetachAudioMixedProcessor() -/// -public delegate void AudioCallback(Span buffer); diff --git a/Raylib-cs/types/AudioMixed.cs b/Raylib-cs/types/AudioMixed.cs index cffc840..1e60348 100644 --- a/Raylib-cs/types/AudioMixed.cs +++ b/Raylib-cs/types/AudioMixed.cs @@ -4,6 +4,13 @@ using System; namespace Raylib_cs; +/// +/// Audio stream processor. +/// Used with +/// and +/// +public delegate void AudioCallback(Span buffer); + internal static unsafe class AudioMixed { public static AudioCallback Callback = null; diff --git a/Raylib-cs/types/AudioStream.cs b/Raylib-cs/types/AudioStream.cs index 8098018..62f6fd5 100644 --- a/Raylib-cs/types/AudioStream.cs +++ b/Raylib-cs/types/AudioStream.cs @@ -8,7 +8,7 @@ namespace Raylib_cs; /// NOTE: Useful to create custom audio streams not bound to a specific file /// [StructLayout(LayoutKind.Sequential)] -public partial struct AudioStream +public struct AudioStream { //TODO: convert /// @@ -60,6 +60,11 @@ public partial struct AudioStream Raylib.ResumeAudioStream(this); } + public unsafe void Update(void* data, int frameCount) + { + Raylib.UpdateAudioStream(this, data, frameCount); + } + public readonly void Stop() { Raylib.StopAudioStream(this); diff --git a/Raylib-cs/types/Image.cs b/Raylib-cs/types/Image.cs index e8baad3..7190382 100644 --- a/Raylib-cs/types/Image.cs +++ b/Raylib-cs/types/Image.cs @@ -172,6 +172,11 @@ public unsafe struct Image return Raylib.LoadImage(fileName); } + public static Image LoadAnim(string fileName, out int frames) + { + return Raylib.LoadImageAnim(fileName, out frames); + } + /// /// Create an image from text using the default font /// diff --git a/Raylib-cs/types/Mesh.cs b/Raylib-cs/types/Mesh.cs index 7001a32..0ee5020 100644 --- a/Raylib-cs/types/Mesh.cs +++ b/Raylib-cs/types/Mesh.cs @@ -166,7 +166,7 @@ public unsafe struct Mesh /// public readonly Span TexCoordsAs() where T : unmanaged { - return new(TexCoords, 2 * VertexCount * sizeof(float) / sizeof(T)); + return new Span(TexCoords, 2 * VertexCount * sizeof(float) / sizeof(T)); } /// @@ -174,7 +174,7 @@ public unsafe struct Mesh /// public readonly Span TexCoords2As() where T : unmanaged { - return new(TexCoords2, 2 * VertexCount * sizeof(float) / sizeof(T)); + return new Span(TexCoords2, 2 * VertexCount * sizeof(float) / sizeof(T)); } /// @@ -182,7 +182,7 @@ public unsafe struct Mesh /// public readonly Span NormalsAs() where T : unmanaged { - return new(Normals, 3 * VertexCount * sizeof(float) / sizeof(T)); + return new Span(Normals, 3 * VertexCount * sizeof(float) / sizeof(T)); } /// @@ -190,7 +190,7 @@ public unsafe struct Mesh /// public readonly Span TangentsAs() where T : unmanaged { - return new(Tangents, 4 * VertexCount * sizeof(float) / sizeof(T)); + return new Span(Tangents, 4 * VertexCount * sizeof(float) / sizeof(T)); } /// @@ -198,7 +198,7 @@ public unsafe struct Mesh /// public readonly Span ColorsAs() where T : unmanaged { - return new(Colors, 4 * VertexCount * sizeof(byte) / sizeof(T)); + return new Span(Colors, 4 * VertexCount * sizeof(byte) / sizeof(T)); } /// @@ -206,7 +206,7 @@ public unsafe struct Mesh /// public readonly Span IndicesAs() where T : unmanaged { - return new(Indices, 3 * TriangleCount * sizeof(ushort) / sizeof(T)); + return new Span(Indices, 3 * TriangleCount * sizeof(ushort) / sizeof(T)); } #endregion diff --git a/Raylib-cs/types/Model.cs b/Raylib-cs/types/Model.cs index 0373476..f36ab35 100644 --- a/Raylib-cs/types/Model.cs +++ b/Raylib-cs/types/Model.cs @@ -189,7 +189,7 @@ public unsafe struct ModelAnimation public readonly BoneInfo* Bones; /// - public ReadOnlySpan BoneInfo => new(Bones, BoneCount); + public readonly ReadOnlySpan BoneInfo => new ReadOnlySpan(Bones, BoneCount); /// /// Poses array by frame (Transform **) @@ -204,7 +204,7 @@ public unsafe struct ModelAnimation /// public readonly FramePosesCollection FramePosesColl => new FramePosesCollection(FramePoses, FrameCount, BoneCount); - public struct FramePosesCollection + public readonly struct FramePosesCollection { readonly Transform** _framePoses; @@ -250,13 +250,13 @@ public unsafe struct ModelAnimation } } -public unsafe struct FramePoses +public readonly unsafe struct FramePoses { readonly Transform* _poses; readonly int _count; - public ref Transform this[int index] => ref _poses[index]; + public readonly ref Transform this[int index] => ref _poses[index]; internal FramePoses(Transform* poses, int count) { diff --git a/Raylib-cs/types/Music.cs b/Raylib-cs/types/Music.cs index 49399ea..be098d7 100644 --- a/Raylib-cs/types/Music.cs +++ b/Raylib-cs/types/Music.cs @@ -52,6 +52,11 @@ public unsafe struct Music Raylib.PauseMusicStream(this); } + public void Update() + { + Raylib.UpdateMusicStream(this); + } + public readonly void Stop() { Raylib.StopMusicStream(this); diff --git a/Raylib-cs/types/Shader.cs b/Raylib-cs/types/Shader.cs index 95e69e8..4ddc31c 100644 --- a/Raylib-cs/types/Shader.cs +++ b/Raylib-cs/types/Shader.cs @@ -107,8 +107,7 @@ public unsafe struct Shader public void SetValue(int locationIndex, T value, ShaderUniformDataType uniformDataType) where T : unmanaged { - void* val = &value; - Raylib.SetShaderValue(this, locationIndex, val, uniformDataType); + Raylib.SetShaderValue(this, locationIndex, &value, uniformDataType); } public void SetValues(int locationIndex, T[] values, ShaderUniformDataType uniformDataType) where T : unmanaged diff --git a/Raylib-cs/types/Texture2D.cs b/Raylib-cs/types/Texture2D.cs index d0728dc..aa245e0 100644 --- a/Raylib-cs/types/Texture2D.cs +++ b/Raylib-cs/types/Texture2D.cs @@ -186,7 +186,12 @@ public struct Texture2D public readonly void Draw(Vector2 position) { - Raylib.DrawTexture(this, (int)position.X, (int)position.Y, Color.White); + Raylib.DrawTextureV(this, position, Color.White); + } + + public readonly void Draw(Vector2 position, Color color) + { + Raylib.DrawTextureV(this, position, color); } public readonly void Draw(Vector2 position, Vector2 origin) @@ -205,11 +210,6 @@ public struct Texture2D Raylib.DrawTexturePro(this, source, target, origin, 0, color); } - public readonly void Draw(Vector2 position, Color color) - { - Raylib.DrawTexture(this, (int)position.X, (int)position.Y, color); - } - public readonly void Draw(Vector2 position, float rotation, float scale) { Raylib.DrawTextureEx(this, position, rotation, scale, Color.White);