2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-04-05 11:19:39 -04:00

Add managed methods for updating textures (#177)

This commit is contained in:
Nickolas McDonald 2023-07-26 15:55:00 -04:00 committed by GitHub
parent 902bcebddc
commit 28bca27917
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -652,6 +652,36 @@ namespace Raylib_cs
return LoadTexture(str1.AsPointer()); 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> /// <summary>Generate GPU mipmaps for a texture</summary>
public static void GenTextureMipmaps(ref Texture2D texture) public static void GenTextureMipmaps(ref Texture2D texture)
{ {