Skip to content

Commit

Permalink
Working on restructure the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrScautHD committed May 28, 2024
1 parent 9f2cc31 commit eeef771
Show file tree
Hide file tree
Showing 13 changed files with 1,348 additions and 1,291 deletions.
30 changes: 30 additions & 0 deletions src/Raylib-CSharp/Audio/AudioStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public static partial class AudioStreamExtensions {
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
[return: MarshalAs(UnmanagedType.I1)]
private static partial bool IsReady_(AudioStream stream);

/// <inheritdoc cref="AudioStreamExtensions.IsReady_"/>
public static bool IsReady(this AudioStream stream) => IsReady_(stream);

/// <summary>
Expand All @@ -90,6 +92,8 @@ public static partial class AudioStreamExtensions {
[LibraryImport(Raylib.Name, EntryPoint = "UnloadAudioStream")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static partial void Unload_(AudioStream stream);

/// <inheritdoc cref="AudioStreamExtensions.Unload_"/>
public static void Unload(this AudioStream stream) => Unload_(stream);

/// <summary>
Expand All @@ -101,6 +105,8 @@ public static partial class AudioStreamExtensions {
[LibraryImport(Raylib.Name, EntryPoint = "UpdateAudioStream")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static partial void Update_(AudioStream stream, nint data, int frameCount);

/// <inheritdoc cref="AudioStreamExtensions.Update_"/>
public static void Update(this AudioStream stream, nint data, int frameCount) => Update_(stream, data, frameCount);

/// <summary>
Expand All @@ -112,6 +118,8 @@ public static partial class AudioStreamExtensions {
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
[return: MarshalAs(UnmanagedType.I1)]
private static partial bool IsProcessed_(AudioStream stream);

/// <inheritdoc cref="AudioStreamExtensions.IsProcessed_"/>
public static bool IsProcessed(this AudioStream stream) => IsProcessed_(stream);

/// <summary>
Expand All @@ -121,6 +129,8 @@ public static partial class AudioStreamExtensions {
[LibraryImport(Raylib.Name, EntryPoint = "PlayAudioStream")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static partial void Play_(AudioStream stream);

/// <inheritdoc cref="AudioStreamExtensions.Play_"/>
public static void Play(this AudioStream stream) => Play_(stream);

/// <summary>
Expand All @@ -130,6 +140,8 @@ public static partial class AudioStreamExtensions {
[LibraryImport(Raylib.Name, EntryPoint = "PauseAudioStream")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static partial void Pause_(AudioStream stream);

/// <inheritdoc cref="AudioStreamExtensions.Pause_"/>
public static void Pause(this AudioStream stream) => Pause_(stream);

/// <summary>
Expand All @@ -139,6 +151,8 @@ public static partial class AudioStreamExtensions {
[LibraryImport(Raylib.Name, EntryPoint = "ResumeAudioStream")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static partial void Resume_(AudioStream stream);

/// <inheritdoc cref="AudioStreamExtensions.Resume_"/>
public static void Resume(this AudioStream stream) => Resume_(stream);

/// <summary>
Expand All @@ -150,6 +164,8 @@ public static partial class AudioStreamExtensions {
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
[return: MarshalAs(UnmanagedType.I1)]
private static partial bool IsPlaying_(AudioStream stream);

/// <inheritdoc cref="AudioStreamExtensions.IsPlaying_"/>
public static bool IsPlaying(this AudioStream stream) => IsPlaying_(stream);

/// <summary>
Expand All @@ -159,6 +175,8 @@ public static partial class AudioStreamExtensions {
[LibraryImport(Raylib.Name, EntryPoint = "StopAudioStream")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static partial void Stop_(AudioStream stream);

/// <inheritdoc cref="AudioStreamExtensions.Stop_"/>
public static void Stop(this AudioStream stream) => Stop_(stream);

/// <summary>
Expand All @@ -169,6 +187,8 @@ public static partial class AudioStreamExtensions {
[LibraryImport(Raylib.Name, EntryPoint = "SetAudioStreamVolume")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static partial void SetVolume_(AudioStream stream, float volume);

/// <inheritdoc cref="AudioStreamExtensions.SetVolume_"/>
public static void SetVolume(this AudioStream stream, float volume) => SetVolume_(stream, volume);

/// <summary>
Expand All @@ -179,6 +199,8 @@ public static partial class AudioStreamExtensions {
[LibraryImport(Raylib.Name, EntryPoint = "SetAudioStreamPitch")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static partial void SetPitch_(AudioStream stream, float pitch);

/// <inheritdoc cref="AudioStreamExtensions.SetPitch_"/>
public static void SetPitch(this AudioStream stream, float pitch) => SetPitch_(stream, pitch);

/// <summary>
Expand All @@ -189,6 +211,8 @@ public static partial class AudioStreamExtensions {
[LibraryImport(Raylib.Name, EntryPoint = "SetAudioStreamPan")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static partial void SetPan_(AudioStream stream, float pan);

/// <inheritdoc cref="AudioStreamExtensions.SetPan_"/>
public static void SetPan(this AudioStream stream, float pan) => SetPan_(stream, pan);

/// <summary>
Expand All @@ -199,6 +223,8 @@ public static partial class AudioStreamExtensions {
[LibraryImport(Raylib.Name, EntryPoint = "SetAudioStreamCallback")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static unsafe partial void SetCallback_(AudioStream stream, delegate* unmanaged[Cdecl]<nint, uint, void> callback);

/// <inheritdoc cref="AudioStreamExtensions.SetCallback_"/>
public static unsafe void SetCallback(this AudioStream stream, delegate* unmanaged[Cdecl]<nint, uint, void> callback) => SetCallback_(stream, callback);

/// <summary>
Expand All @@ -209,6 +235,8 @@ public static partial class AudioStreamExtensions {
[LibraryImport(Raylib.Name, EntryPoint = "AttachAudioStreamProcessor")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static unsafe partial void AttachProcessor_(AudioStream stream, delegate* unmanaged[Cdecl]<nint, uint, void> processor);

/// <inheritdoc cref="AudioStreamExtensions.AttachProcessor_"/>
public static unsafe void AttachProcessor(this AudioStream stream, delegate* unmanaged[Cdecl]<nint, uint, void> callback) => AttachProcessor_(stream, callback);

/// <summary>
Expand All @@ -219,5 +247,7 @@ public static partial class AudioStreamExtensions {
[LibraryImport(Raylib.Name, EntryPoint = "DetachAudioStreamProcessor")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static unsafe partial void DetachProcessor_(AudioStream stream, delegate* unmanaged[Cdecl]<nint, uint, void> processor);

/// <inheritdoc cref="AudioStreamExtensions.DetachProcessor_"/>
public static unsafe void DetachProcessor(this AudioStream stream, delegate* unmanaged[Cdecl]<nint, uint, void> callback) => DetachProcessor_(stream, callback);
}
2 changes: 1 addition & 1 deletion src/Raylib-CSharp/Camera/Cam2D/Camera2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static partial class Camera2DExtensions {
/// <param name="camera">The Camera2D to get the transformation matrix for.</param>
/// <returns>The 2D transformation matrix.</returns>
[LibraryImport(Raylib.Name, EntryPoint = "GetCameraMatrix2D")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] // TODO CHECK IF IT WOULD POSSIBLE TO DONE THE "THIS" With a custom marshaler or something like that...
private static partial Matrix4x4 GetMatrix_(Camera2D camera);
public static Matrix4x4 GetMatrix(this Camera2D camera) => GetMatrix_(camera);
}
82 changes: 43 additions & 39 deletions src/Raylib-CSharp/Images/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,45 +254,6 @@ public static unsafe Image LoadFromMemory(string fileType, ReadOnlySpan<byte> fi
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial Image FromTextEx(Font font, string text, float fontSize, float spacing, Color tint);

/// <summary>
/// Load color data from image as a Color array (RGBA - 32bit).
/// </summary>
/// <param name="image">The image to load the color data from.</param>
/// <returns>The color data of the loaded image.</returns>
[LibraryImport(Raylib.Name, EntryPoint = "LoadImageColors")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static unsafe partial Color* LoadColors(Image image);

/// <summary>
/// Load color data from image as a Color array (RGBA - 32bit).
/// </summary>
/// <param name="image">The image to load the color data from.</param>
/// <returns>The color data of the loaded image.</returns>
public static unsafe ReadOnlySpan<Color> LoadColorsSpan(Image image) {
return new ReadOnlySpan<Color>(LoadColors(image), image.Width * image.Height);
}

/// <summary>
/// Load colors palette from image as a Color array (RGBA - 32bit).
/// </summary>
/// <param name="image">The image to load the color palette from.</param>
/// <param name="maxPaletteSize">The maximum number of colors in the palette.</param>
/// <param name="colorCount">The actual number of colors in the palette.</param>
/// <returns>A pointer to the loaded color palette.</returns>
[LibraryImport(Raylib.Name, EntryPoint = "LoadImagePalette")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static unsafe partial Color* LoadPalette(Image image, int maxPaletteSize, out int colorCount);

/// <summary>
/// Load colors palette from image as a Color array (RGBA - 32bit).
/// </summary>
/// <param name="image">The image to load the color palette from.</param>
/// <param name="maxPaletteSize">The maximum number of colors in the palette.</param>
/// <returns>A pointer to the loaded color palette.</returns>
public static unsafe ReadOnlySpan<Color> LoadPalette(Image image, int maxPaletteSize) {
return new ReadOnlySpan<Color>(LoadPalette(image, maxPaletteSize, out int colorCount), colorCount);
}

/// <summary>
/// Unload color data loaded with LoadImageColors().
/// </summary>
Expand Down Expand Up @@ -656,6 +617,49 @@ public static partial class ImageExtensions {
private static partial void ReplaceColor_(ref Image image, Color color, Color replace);
public static void ReplaceColor(this ref Image image, Color color, Color replace) => ReplaceColor_(ref image, color, replace);

/// <summary>
/// Load color data from image as a Color array (RGBA - 32bit).
/// </summary>
/// <param name="image">The image to load the color data from.</param>
/// <returns>The color data of the loaded image.</returns>
[LibraryImport(Raylib.Name, EntryPoint = "LoadImageColors")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static unsafe partial Color* LoadColors_(Image image);
public static unsafe Color* LoadColors(this Image image) => LoadColors_(image);

/// <summary>
/// Load color data from image as a Color array (RGBA - 32bit).
/// </summary>
/// <param name="image">The image to load the color data from.</param>
/// <returns>The color data of the loaded image.</returns>
private static unsafe ReadOnlySpan<Color> LoadColorsSpan_(Image image) {
return new ReadOnlySpan<Color>(LoadColors(image), image.Width * image.Height);
}
public static ReadOnlySpan<Color> LoadColorsSpan(this Image image) => LoadColorsSpan_(image);

/// <summary>
/// Load colors palette from image as a Color array (RGBA - 32bit).
/// </summary>
/// <param name="image">The image to load the color palette from.</param>
/// <param name="maxPaletteSize">The maximum number of colors in the palette.</param>
/// <param name="colorCount">The actual number of colors in the palette.</param>
/// <returns>A pointer to the loaded color palette.</returns>
[LibraryImport(Raylib.Name, EntryPoint = "LoadImagePalette")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static unsafe partial Color* LoadPalette_(Image image, int maxPaletteSize, out int colorCount);
public static unsafe Color* LoadPalette(this Image image, int maxPaletteSize, out int colorCount) => LoadPalette_(image, maxPaletteSize, out colorCount);

/// <summary>
/// Load colors palette from image as a Color array (RGBA - 32bit).
/// </summary>
/// <param name="image">The image to load the color palette from.</param>
/// <param name="maxPaletteSize">The maximum number of colors in the palette.</param>
/// <returns>A pointer to the loaded color palette.</returns>
private static unsafe ReadOnlySpan<Color> LoadPalette_(Image image, int maxPaletteSize) {
return new ReadOnlySpan<Color>(LoadPalette_(image, maxPaletteSize, out int colorCount), colorCount);
}
public static ReadOnlySpan<Color> LoadPalette(this Image image, int maxPaletteSize) => LoadPalette_(image, maxPaletteSize);

/// <summary>
/// Get image alpha border rectangle.
/// </summary>
Expand Down
Loading

0 comments on commit eeef771

Please sign in to comment.