Updating calls and docs
Moved the "AudioCallback" delegate into the "AudioMixed.cs" File. Added a "Update" method to AudioStream. Added "LoadAnim" static method to Image. Added a "Update" method to Music. Explicit constructors on the "Mesh.cs" file. Properties and structs marked as read-only on the "Model.cs" file. Updated the "README.md" to mentions Raylib-cs targets net6.0 and net8.0 (and also explicitly added that the "STAThread" attribute comes from the "System" namespace). Changed redundant calls on some "Draw" methods from Texture2D.
This commit is contained in:
parent
b84a0d4f12
commit
762641e296
11 changed files with 46 additions and 39 deletions
|
|
@ -10,12 +10,11 @@ C# bindings for raylib, a simple and easy-to-use library to learn videogames pro
|
||||||
[](https://github.com/raylib-cs/raylib-cs/stargazers)
|
[](https://github.com/raylib-cs/raylib-cs/stargazers)
|
||||||
[](https://github.com/raylib-cs/raylib-cs/actions?query=workflow%3ABuild)
|
[](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
|
## Status
|
||||||
|
|
||||||
Raylib-cs is passively maintained. Occasional updates may be released from time to time. Pull requests may be
|
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.
|
||||||
accepted if they don't have a large maintainence burden.
|
|
||||||
|
|
||||||
## Installation - NuGet
|
## Installation - NuGet
|
||||||
|
|
||||||
|
|
@ -60,10 +59,10 @@ using Raylib_cs;
|
||||||
|
|
||||||
namespace HelloWorld;
|
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 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()
|
public static void Main()
|
||||||
{
|
{
|
||||||
Raylib.InitWindow(800, 480, "Hello World");
|
Raylib.InitWindow(800, 480, "Hello World");
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
|
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
|
||||||
<EnableDefaultItems>false</EnableDefaultItems>
|
<EnableDefaultItems>false</EnableDefaultItems>
|
||||||
|
|
@ -49,9 +49,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<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\*.cs" />
|
||||||
<Compile Include="types\native\AnsiBuffer.cs" />
|
|
||||||
<Compile Include="types\native\Utf8Buffer.cs" />
|
|
||||||
<Compile Include="types\native\FilePathList.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Raylib_cs;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Audio stream processor.
|
|
||||||
/// Used with Raylib.AttachAudioMixedProcessor()
|
|
||||||
/// and Raylib.DetachAudioMixedProcessor()
|
|
||||||
/// </summary>
|
|
||||||
public delegate void AudioCallback<T>(Span<T> buffer);
|
|
||||||
|
|
@ -4,6 +4,13 @@ using System;
|
||||||
|
|
||||||
namespace Raylib_cs;
|
namespace Raylib_cs;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Audio stream processor.
|
||||||
|
/// Used with <see cref="Raylib.AttachAudioMixedProcessor(AudioCallback{float})"/>
|
||||||
|
/// and <see cref="Raylib.DetachAudioMixedProcessor(AudioCallback{float})"/>
|
||||||
|
/// </summary>
|
||||||
|
public delegate void AudioCallback<T>(Span<T> buffer);
|
||||||
|
|
||||||
internal static unsafe class AudioMixed
|
internal static unsafe class AudioMixed
|
||||||
{
|
{
|
||||||
public static AudioCallback<float> Callback = null;
|
public static AudioCallback<float> Callback = null;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ namespace Raylib_cs;
|
||||||
/// NOTE: Useful to create custom audio streams not bound to a specific file
|
/// NOTE: Useful to create custom audio streams not bound to a specific file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public partial struct AudioStream
|
public struct AudioStream
|
||||||
{
|
{
|
||||||
//TODO: convert
|
//TODO: convert
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -60,6 +60,11 @@ public partial struct AudioStream
|
||||||
Raylib.ResumeAudioStream(this);
|
Raylib.ResumeAudioStream(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public unsafe void Update(void* data, int frameCount)
|
||||||
|
{
|
||||||
|
Raylib.UpdateAudioStream(this, data, frameCount);
|
||||||
|
}
|
||||||
|
|
||||||
public readonly void Stop()
|
public readonly void Stop()
|
||||||
{
|
{
|
||||||
Raylib.StopAudioStream(this);
|
Raylib.StopAudioStream(this);
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,11 @@ public unsafe struct Image
|
||||||
return Raylib.LoadImage(fileName);
|
return Raylib.LoadImage(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Image LoadAnim(string fileName, out int frames)
|
||||||
|
{
|
||||||
|
return Raylib.LoadImageAnim(fileName, out frames);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create an image from text using the default font
|
/// Create an image from text using the default font
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ public unsafe struct Mesh
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Span<T> TexCoordsAs<T>() where T : unmanaged
|
public readonly Span<T> TexCoordsAs<T>() where T : unmanaged
|
||||||
{
|
{
|
||||||
return new(TexCoords, 2 * VertexCount * sizeof(float) / sizeof(T));
|
return new Span<T>(TexCoords, 2 * VertexCount * sizeof(float) / sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -174,7 +174,7 @@ public unsafe struct Mesh
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Span<T> TexCoords2As<T>() where T : unmanaged
|
public readonly Span<T> TexCoords2As<T>() where T : unmanaged
|
||||||
{
|
{
|
||||||
return new(TexCoords2, 2 * VertexCount * sizeof(float) / sizeof(T));
|
return new Span<T>(TexCoords2, 2 * VertexCount * sizeof(float) / sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -182,7 +182,7 @@ public unsafe struct Mesh
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Span<T> NormalsAs<T>() where T : unmanaged
|
public readonly Span<T> NormalsAs<T>() where T : unmanaged
|
||||||
{
|
{
|
||||||
return new(Normals, 3 * VertexCount * sizeof(float) / sizeof(T));
|
return new Span<T>(Normals, 3 * VertexCount * sizeof(float) / sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -190,7 +190,7 @@ public unsafe struct Mesh
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Span<T> TangentsAs<T>() where T : unmanaged
|
public readonly Span<T> TangentsAs<T>() where T : unmanaged
|
||||||
{
|
{
|
||||||
return new(Tangents, 4 * VertexCount * sizeof(float) / sizeof(T));
|
return new Span<T>(Tangents, 4 * VertexCount * sizeof(float) / sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -198,7 +198,7 @@ public unsafe struct Mesh
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Span<T> ColorsAs<T>() where T : unmanaged
|
public readonly Span<T> ColorsAs<T>() where T : unmanaged
|
||||||
{
|
{
|
||||||
return new(Colors, 4 * VertexCount * sizeof(byte) / sizeof(T));
|
return new Span<T>(Colors, 4 * VertexCount * sizeof(byte) / sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -206,7 +206,7 @@ public unsafe struct Mesh
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Span<T> IndicesAs<T>() where T : unmanaged
|
public readonly Span<T> IndicesAs<T>() where T : unmanaged
|
||||||
{
|
{
|
||||||
return new(Indices, 3 * TriangleCount * sizeof(ushort) / sizeof(T));
|
return new Span<T>(Indices, 3 * TriangleCount * sizeof(ushort) / sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ public unsafe struct ModelAnimation
|
||||||
public readonly BoneInfo* Bones;
|
public readonly BoneInfo* Bones;
|
||||||
|
|
||||||
/// <inheritdoc cref="Bones"/>
|
/// <inheritdoc cref="Bones"/>
|
||||||
public ReadOnlySpan<BoneInfo> BoneInfo => new(Bones, BoneCount);
|
public readonly ReadOnlySpan<BoneInfo> BoneInfo => new ReadOnlySpan<BoneInfo>(Bones, BoneCount);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Poses array by frame (Transform **)
|
/// Poses array by frame (Transform **)
|
||||||
|
|
@ -204,7 +204,7 @@ public unsafe struct ModelAnimation
|
||||||
/// <inheritdoc cref="FramePoses"/>
|
/// <inheritdoc cref="FramePoses"/>
|
||||||
public readonly FramePosesCollection FramePosesColl => new FramePosesCollection(FramePoses, FrameCount, BoneCount);
|
public readonly FramePosesCollection FramePosesColl => new FramePosesCollection(FramePoses, FrameCount, BoneCount);
|
||||||
|
|
||||||
public struct FramePosesCollection
|
public readonly struct FramePosesCollection
|
||||||
{
|
{
|
||||||
readonly Transform** _framePoses;
|
readonly Transform** _framePoses;
|
||||||
|
|
||||||
|
|
@ -250,13 +250,13 @@ public unsafe struct ModelAnimation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe struct FramePoses
|
public readonly unsafe struct FramePoses
|
||||||
{
|
{
|
||||||
readonly Transform* _poses;
|
readonly Transform* _poses;
|
||||||
|
|
||||||
readonly int _count;
|
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)
|
internal FramePoses(Transform* poses, int count)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,11 @@ public unsafe struct Music
|
||||||
Raylib.PauseMusicStream(this);
|
Raylib.PauseMusicStream(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
Raylib.UpdateMusicStream(this);
|
||||||
|
}
|
||||||
|
|
||||||
public readonly void Stop()
|
public readonly void Stop()
|
||||||
{
|
{
|
||||||
Raylib.StopMusicStream(this);
|
Raylib.StopMusicStream(this);
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,7 @@ public unsafe struct Shader
|
||||||
|
|
||||||
public void SetValue<T>(int locationIndex, T value, ShaderUniformDataType uniformDataType) where T : unmanaged
|
public void SetValue<T>(int locationIndex, T value, ShaderUniformDataType uniformDataType) where T : unmanaged
|
||||||
{
|
{
|
||||||
void* val = &value;
|
Raylib.SetShaderValue(this, locationIndex, &value, uniformDataType);
|
||||||
Raylib.SetShaderValue(this, locationIndex, val, uniformDataType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetValues<T>(int locationIndex, T[] values, ShaderUniformDataType uniformDataType) where T : unmanaged
|
public void SetValues<T>(int locationIndex, T[] values, ShaderUniformDataType uniformDataType) where T : unmanaged
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,12 @@ public struct Texture2D
|
||||||
|
|
||||||
public readonly void Draw(Vector2 position)
|
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)
|
public readonly void Draw(Vector2 position, Vector2 origin)
|
||||||
|
|
@ -205,11 +210,6 @@ public struct Texture2D
|
||||||
Raylib.DrawTexturePro(this, source, target, origin, 0, color);
|
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)
|
public readonly void Draw(Vector2 position, float rotation, float scale)
|
||||||
{
|
{
|
||||||
Raylib.DrawTextureEx(this, position, rotation, scale, Color.White);
|
Raylib.DrawTextureEx(this, position, rotation, scale, Color.White);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue