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
|
|
@ -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;
|
||||
|
||||
/// <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
|
||||
{
|
||||
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
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public partial struct AudioStream
|
||||
public struct AudioStream
|
||||
{
|
||||
//TODO: convert
|
||||
/// <summary>
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an image from text using the default font
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ public unsafe struct Mesh
|
|||
/// </summary>
|
||||
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>
|
||||
|
|
@ -174,7 +174,7 @@ public unsafe struct Mesh
|
|||
/// </summary>
|
||||
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>
|
||||
|
|
@ -182,7 +182,7 @@ public unsafe struct Mesh
|
|||
/// </summary>
|
||||
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>
|
||||
|
|
@ -190,7 +190,7 @@ public unsafe struct Mesh
|
|||
/// </summary>
|
||||
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>
|
||||
|
|
@ -198,7 +198,7 @@ public unsafe struct Mesh
|
|||
/// </summary>
|
||||
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>
|
||||
|
|
@ -206,7 +206,7 @@ public unsafe struct Mesh
|
|||
/// </summary>
|
||||
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
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ public unsafe struct ModelAnimation
|
|||
public readonly BoneInfo* Bones;
|
||||
|
||||
/// <inheritdoc cref="Bones"/>
|
||||
public ReadOnlySpan<BoneInfo> BoneInfo => new(Bones, BoneCount);
|
||||
public readonly ReadOnlySpan<BoneInfo> BoneInfo => new ReadOnlySpan<BoneInfo>(Bones, BoneCount);
|
||||
|
||||
/// <summary>
|
||||
/// Poses array by frame (Transform **)
|
||||
|
|
@ -204,7 +204,7 @@ public unsafe struct ModelAnimation
|
|||
/// <inheritdoc cref="FramePoses"/>
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ public unsafe struct Music
|
|||
Raylib.PauseMusicStream(this);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
Raylib.UpdateMusicStream(this);
|
||||
}
|
||||
|
||||
public readonly void Stop()
|
||||
{
|
||||
Raylib.StopMusicStream(this);
|
||||
|
|
|
|||
|
|
@ -107,8 +107,7 @@ public unsafe struct Shader
|
|||
|
||||
public void SetValue<T>(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<T>(int locationIndex, T[] values, ShaderUniformDataType uniformDataType) where T : unmanaged
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue