Watch
2
0
Fork
You've already forked raylib-cs
0
Added new extension "byte.Lerp".
Added new extension "Log" for "TraceLogLevel".
Constructors on Color no longer just truncate the float value, but also round it (+ 0.5f).
New static method on Color, "Color.Lerp".
Added static method "FromHSV" to Color.
Added new getter method "GetHSV" on Color.
Added index security on the FilePathList indexer.
Merged Rectangle extensions with the type itself as read-only methods.
Merged Image extensions with the type itself.
Merged Texture2D extensions with the type itself.
New file "Raymath.Utils" with some useful methods taken from Unity.
Added "MoveTowards" extensions to RaylibExtensions.
Added "TranslateLocal" and "TranslateGlobal" to Transform.
Added "Load", "Export", "ExportAsCode", "Format", "Crop", and "Unload" shortcut methods to Wave.
Added "IsValid" property to Wave, Texture2D, Sound, Shader, RenderTexture2D, Music, Image, Model, Material, Font, and AudioStream.
Added "IsPlaying" and "IsProcessed" properties to AudioStream.
Added "Load", "Play", "Stop", "Pause", "Resume", "SetBufferSizeDefault", "SetPan", "SetPitch", "SetVolume", and "Unload" shortcut methods to AudioStream.
Added "Load", "Export", and "Unload" methods to AutomationEventList.
Added "Default" property to Font.
Added "Load", "GetMaterial", "GetTexture", "SetTexture", "SetShader", and "Unload" methods to material.
Added "Draw", "DrawInstanced", "Export", "ExportAsCode", "Upload", and "Unload" methods to Mesh.
Added "Load", "LoadFromMesh", "Unload", and a lot of "Draw" overloads.
Added "Load", "Play", "Pause", "Stop", "SetPan", "SetPitch", "SetVolume", "Seek", and "Unload" methods to Music.
Added "Load" and "Unload" methods to RenderTexture2D.
Added "Load", "LoadFromMemory", "GetLocationAttrib", "SetValue", "SetTexture", "SetMatrix", and "Unload" methods to Shader.
Removed unnecessary "partial" declarations.
This commit is contained in:
Matorio 2025-07-17 03:14:57 -05:00
commit b84a0d4f12
31 changed files with 1090 additions and 395 deletions

View file

@ -103,7 +103,7 @@ public enum CubemapLayout
/// NOTE: Data stored in GPU memory
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Texture2D
public struct Texture2D
{
/// <summary>
/// OpenGL texture id
@ -133,11 +133,124 @@ public partial struct Texture2D
/// <summary>
/// Get width and height packed in a Vector2
/// </summary>
public Vector2 Dimensions
public readonly Vector2 Dimensions => new Vector2(Width, Height);
public readonly CBool IsValid => Raylib.IsTextureValid(this);
public static Texture2D Load(string fileName)
{
get
{
return new Vector2(Width, Height);
}
return Raylib.LoadTexture(fileName);
}
public static Texture2D LoadFromImage(Image image)
{
return Raylib.LoadTextureFromImage(image);
}
public static Texture2D LoadFromMemory(string fileType, byte[] fileData)
{
Image img = Raylib.LoadImageFromMemory(fileType, fileData);
Texture2D texture = Raylib.LoadTextureFromImage(img);
Raylib.UnloadImage(img);
return texture;
}
public void Unload()
{
Raylib.UnloadTexture(this);
}
public void SetFilter(TextureFilter filter)
{
Raylib.SetTextureFilter(this, filter);
}
public void SetWrap(TextureWrap wrap)
{
Raylib.SetTextureWrap(this, wrap);
}
public void Update<T>(T[] pixels) where T : unmanaged
{
Raylib.UpdateTexture(this, pixels);
}
public readonly void Draw(int x, int y)
{
Raylib.DrawTexture(this, x, y, Color.White);
}
public readonly void Draw(int x, int y, Color color)
{
Raylib.DrawTexture(this, x, y, color);
}
public readonly void Draw(Vector2 position)
{
Raylib.DrawTexture(this, (int)position.X, (int)position.Y, Color.White);
}
public readonly void Draw(Vector2 position, Vector2 origin)
{
Vector2 size = this.Dimensions;
Rectangle source = new Rectangle(Vector2.Zero, size);
Rectangle target = new Rectangle(position, size);
Raylib.DrawTexturePro(this, source, target, origin, 0, Color.White);
}
public readonly void Draw(Vector2 position, Vector2 origin, Color color)
{
Vector2 size = this.Dimensions;
Rectangle source = new Rectangle(Vector2.Zero, size);
Rectangle target = new Rectangle(position, size);
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);
}
public readonly void Draw(Vector2 position, float rotation, float scale, Color color)
{
Raylib.DrawTextureEx(this, position, rotation, scale, color);
}
public readonly void Draw(Vector2 position, float rotation, Vector2 scale)
{
Draw(position, rotation, scale, Color.White);
}
public readonly void Draw(Vector2 position, float rotation, Vector2 scale, Color color)
{
Vector2 size = this.Dimensions;
Rectangle source = new Rectangle(Vector2.Zero, size);
Rectangle target = new Rectangle(position, size);
target.Size *= scale;
Raylib.DrawTexturePro(this, source, target, Vector2.Zero, rotation, color);
}
public readonly void Draw(Rectangle source, Rectangle dest)
{
Raylib.DrawTexturePro(this, source, dest, Vector2.Zero, 0, Color.White);
}
public readonly void Draw(Rectangle source, Rectangle dest, Vector2 origin)
{
Raylib.DrawTexturePro(this, source, dest, origin, 0, Color.White);
}
public readonly void Draw(Rectangle source, Rectangle dest, Vector2 origin, float rotation)
{
Raylib.DrawTexturePro(this, source, dest, origin, rotation, Color.White);
}
public readonly void Draw(Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color color)
{
Raylib.DrawTexturePro(this, source, dest, origin, rotation, color);
}
}