Skip to content

Commit

Permalink
Add managed methods for updating textures (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickyMcDonald authored Jul 26, 2023
1 parent 902bceb commit 28bca27
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Raylib-cs/types/Raylib.Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,36 @@ public static Texture2D LoadTexture(string fileName)
return LoadTexture(str1.AsPointer());
}

/// <summary>Update GPU texture with new data</summary>
public static void UpdateTexture<T>(Texture2D texture, T[] pixels) where T : unmanaged
{
UpdateTexture(texture, (ReadOnlySpan<T>)pixels);
}

/// <summary>Update GPU texture with new data</summary>
public static void UpdateTexture<T>(Texture2D texture, ReadOnlySpan<T> pixels) where T : unmanaged
{
fixed (void* pixelPtr = pixels)
{
UpdateTexture(texture, pixelPtr);
}
}

/// <summary>Update GPU texture rectangle with new data</summary>
public static void UpdateTextureRec<T>(Texture2D texture, Rectangle rec, T[] pixels) where T : unmanaged
{
UpdateTextureRec(texture, rec, (ReadOnlySpan<T>)pixels);
}

/// <summary>Update GPU texture rectangle with new data</summary>
public static void UpdateTextureRec<T>(Texture2D texture, Rectangle rec, ReadOnlySpan<T> pixels) where T : unmanaged
{
fixed (void* pixelPtr = pixels)
{
UpdateTextureRec(texture, rec, pixelPtr);
}
}

/// <summary>Generate GPU mipmaps for a texture</summary>
public static void GenTextureMipmaps(ref Texture2D texture)
{
Expand Down

0 comments on commit 28bca27

Please sign in to comment.