From be91fe91209b0df63a896e73a2ef70c50d61c6c7 Mon Sep 17 00:00:00 2001 From: Chris Dill Date: Wed, 17 Sep 2025 19:16:39 +0100 Subject: [PATCH] Focus pr on explicit type and util changes --- README.md | 10 ++- Raylib-cs/types/AudioStream.cs | 71 +---------------- Raylib-cs/types/Automation.cs | 21 ----- Raylib-cs/types/Font.cs | 4 - Raylib-cs/types/Image.cs | 117 ---------------------------- Raylib-cs/types/Material.cs | 53 +------------ Raylib-cs/types/Mesh.cs | 30 ------- Raylib-cs/types/Model.cs | 117 ---------------------------- Raylib-cs/types/Music.cs | 66 +--------------- Raylib-cs/types/Rectangle.cs | 121 ++--------------------------- Raylib-cs/types/RenderTexture2D.cs | 12 --- Raylib-cs/types/Shader.cs | 42 ---------- Raylib-cs/types/Sound.cs | 57 -------------- Raylib-cs/types/Texture2D.cs | 119 ---------------------------- Raylib-cs/types/Wave.cs | 34 +------- 15 files changed, 18 insertions(+), 856 deletions(-) diff --git a/README.md b/README.md index 83a3428..7a47af3 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,13 @@ C# bindings for raylib, a simple and easy-to-use library to learn videogames pro [![GitHub stars](https://img.shields.io/github/stars/raylib-cs/raylib-cs?style=social)](https://github.com/raylib-cs/raylib-cs/stargazers) [![Build](https://github.com/raylib-cs/raylib-cs/workflows/Build/badge.svg)](https://github.com/raylib-cs/raylib-cs/actions?query=workflow%3ABuild) -Raylib-cs targets net6.0 net8.0 and uses the [official 5.5 release](https://github.com/raysan5/raylib/releases/tag/5.5) to build the native libraries. +Raylib-cs targets net6.0 net8.0 and uses the [official 5.5 release](https://github.com/raysan5/raylib/releases/tag/5.5) +to build the native libraries. ## Status -Raylib-cs is passively maintained. Occasional updates may be released from time to time. Pull requests may be accepted if they don't have a large maintainence burden. +Raylib-cs is passively maintained. Occasional updates may be released from time to time. Pull requests may be +accepted if they don't have a large maintainence burden. ## Installation - NuGet @@ -36,8 +38,8 @@ dotnet add package Raylib-cs If you need to edit Raylib-cs source then you will need to add the bindings as a project (see below). If you are new to using NuGet (or you've forgotten) and are trying to run the above command in the command prompt, -remember that you need to be *inside the intended project directory* (not just inside the solution directory) otherwise -the command won't work. +remember that you need to be *inside the intended project directory* (not just inside the solution directory) +otherwise the command won't work. ## Installation - Manual diff --git a/Raylib-cs/types/AudioStream.cs b/Raylib-cs/types/AudioStream.cs index 62f6fd5..2f7c024 100644 --- a/Raylib-cs/types/AudioStream.cs +++ b/Raylib-cs/types/AudioStream.cs @@ -10,7 +10,7 @@ namespace Raylib_cs; [StructLayout(LayoutKind.Sequential)] public struct AudioStream { - //TODO: convert + // TODO: convert /// /// Pointer to internal data(rAudioBuffer *) used by the audio system /// @@ -35,73 +35,4 @@ public struct AudioStream /// Number of channels (1-mono, 2-stereo) /// public uint Channels; - - public readonly CBool IsValid => Raylib.IsAudioStreamValid(this); - public readonly CBool IsPlaying => Raylib.IsAudioStreamPlaying(this); - public readonly CBool IsProcessed => Raylib.IsAudioStreamProcessed(this); - - public static AudioStream Load(uint sampleRate, uint sampleSize, uint channels) - { - return Raylib.LoadAudioStream(sampleRate, sampleSize, channels); - } - - public readonly void Play() - { - Raylib.PlayAudioStream(this); - } - - public readonly void Pause() - { - Raylib.PauseAudioStream(this); - } - - public readonly void Resume() - { - Raylib.ResumeAudioStream(this); - } - - public unsafe void Update(void* data, int frameCount) - { - Raylib.UpdateAudioStream(this, data, frameCount); - } - - public readonly void Stop() - { - Raylib.StopAudioStream(this); - } - - public static void SetBufferSizeDefault(int size) - { - Raylib.SetAudioStreamBufferSizeDefault(size); - } - - /// - /// Set pan for this audio stream where 0.5 is centered - /// - /// - public void SetPan(float pan) - { - Raylib.SetAudioStreamPan(this, pan); - } - - /// - /// Set pitch for this audio stream where 1.0 si base level - /// - public void SetPitch(float pitch) - { - Raylib.SetAudioStreamPitch(this, pitch); - } - - /// - /// Set the volume from 0.0 to 1.0 - /// - public void SetVolume(float volume) - { - Raylib.SetAudioStreamVolume(this, volume); - } - - public void Unload() - { - Raylib.UnloadAudioStream(this); - } } diff --git a/Raylib-cs/types/Automation.cs b/Raylib-cs/types/Automation.cs index 0fcb178..00ddff7 100644 --- a/Raylib-cs/types/Automation.cs +++ b/Raylib-cs/types/Automation.cs @@ -15,11 +15,6 @@ public unsafe struct AutomationEvent /// Event parameters (if required) public fixed int Params[4]; - - public readonly void Play() - { - Raylib.PlayAutomationEvent(this); - } } /// Automation event list @@ -37,20 +32,4 @@ public unsafe struct AutomationEventList /// public readonly ReadOnlySpan EventsAsSpan => new ReadOnlySpan(Events, (int)Count); - - public static AutomationEventList Load(string fileName) - { - return Raylib.LoadAutomationEventList(fileName); - } - - public readonly CBool Export(string fileName) - { - return Raylib.ExportAutomationEventList(this, fileName); - } - - public void Unload() - { - Raylib.UnloadAutomationEventList(this); - } - } diff --git a/Raylib-cs/types/Font.cs b/Raylib-cs/types/Font.cs index 1524de2..0cb478f 100644 --- a/Raylib-cs/types/Font.cs +++ b/Raylib-cs/types/Font.cs @@ -90,8 +90,4 @@ public unsafe struct Font /// Glyphs info data /// public GlyphInfo* Glyphs; - - public readonly CBool IsValid => Raylib.IsFontValid(this); - - public static Font Default => Raylib.GetFontDefault(); } diff --git a/Raylib-cs/types/Image.cs b/Raylib-cs/types/Image.cs index 7190382..b86accf 100644 --- a/Raylib-cs/types/Image.cs +++ b/Raylib-cs/types/Image.cs @@ -165,121 +165,4 @@ public unsafe struct Image /// Get width and height packed in a Vector2 /// public readonly Vector2 Dimensions => new Vector2(Width, Height); - public readonly CBool IsValid => Raylib.IsImageValid(this); - - public static Image Load(string fileName) - { - return Raylib.LoadImage(fileName); - } - - public static Image LoadAnim(string fileName, out int frames) - { - return Raylib.LoadImageAnim(fileName, out frames); - } - - /// - /// Create an image from text using the default font - /// - public static Image CreateFromText(string text, int fontSize, Color color) - { - return Raylib.ImageText(text, fontSize, color); - } - - public static Image CreateFromText(Font font, string text, int fontSize, float spacing, Color color) - { - return Raylib.ImageTextEx(font, text, fontSize, spacing, color); - } - - public static Image LoadFromMemory(string fileType, byte[] data) - { - return Raylib.LoadImageFromMemory(fileType, data); - } - - public static Image LoadFromTexture(Texture2D texture) - { - return Raylib.LoadImageFromTexture(texture); - } - - public static Image LoadRaw(string fileName, int width, int height, PixelFormat format, int headerSize) - { - return Raylib.LoadImageRaw(fileName, width, height, format, headerSize); - } - - public readonly void Unload() - { - Raylib.UnloadImage(this); - } - - public readonly unsafe Color[] GetPalette(int maxPaletteSize) - { - int colorCount = 0; - Color* colors = Raylib.LoadImagePalette(this, maxPaletteSize, &colorCount); - Color[] palette = new Color[colorCount]; - for (int i = 0; i < colorCount; i++) - { - palette[i] = colors[i]; - } - Raylib.UnloadImagePalette(colors); - return palette; - } - - public static Image LoadFromScreen() - { - return Raylib.LoadImageFromScreen(); - } - - public void DrawLine(Vector2 start, Vector2 end, Color color) - { - Raylib.ImageDrawLineV(ref this, start, end, color); - } - - public void DrawLine(Vector2 start, Vector2 end, int thickness, Color color) - { - Raylib.ImageDrawLineEx(ref this, start, end, thickness, color); - } - - public void DrawCircle(Vector2 position, float radius, Color color) - { - Raylib.ImageDrawCircle(ref this, (int)position.X, (int)position.Y, (int)radius, color); - } - - public void DrawRectangle(Rectangle rectangle, Color color) - { - Raylib.ImageDrawRectangleRec(ref this, rectangle, color); - } - - public void DrawText(string text, Vector2 position, int fontSize, Color color) - { - Raylib.ImageDrawText(ref this, text, (int)position.X, (int)position.Y, fontSize, color); - } - - public void DrawText(Font font, string text, Vector2 position, int fontSize, float spacing, Color color) - { - Raylib.ImageDrawTextEx(ref this, font, text, position, fontSize, spacing, color); - } - - public unsafe void DrawCircleLines(Vector2 position, float radius, Color color) - { - Raylib.ImageDrawCircleLinesV(ref this, position, (int)radius, color); - } - - public void DrawTriangle(Vector2 p1, Vector2 p2, Vector2 p3, Color color) - { - Raylib.ImageDrawTriangle(ref this, p1, p2, p3, color); - } - - public void DrawTriangle(Vector2 p1, Vector2 p2, Vector2 p3, Color c1, Color c2, Color c3) - { - Raylib.ImageDrawTriangleEx(ref this, p1, p2, p3, c1, c2, c3); - } - - public void DrawRectangleLines(Rectangle rectangle, Color color) - { - Raylib.ImageDrawRectangleLines(ref this, rectangle, 1, color); - } - - public void DrawRectangleLines(Rectangle rectangle, int thickness, Color color) - { - Raylib.ImageDrawRectangleLines(ref this, rectangle, thickness, color); - } } diff --git a/Raylib-cs/types/Material.cs b/Raylib-cs/types/Material.cs index 56d3ba0..6d30e64 100644 --- a/Raylib-cs/types/Material.cs +++ b/Raylib-cs/types/Material.cs @@ -77,7 +77,7 @@ public unsafe struct Material /// public Shader Shader; - //TODO: convert + // TODO: convert /// /// Material maps /// @@ -87,55 +87,4 @@ public unsafe struct Material /// Material generic parameters (if required) /// public fixed float Param[4]; - - public readonly CBool IsValid => Raylib.IsMaterialValid(this); - - /// - /// Load default material - /// - public static Material Load() - { - return Raylib.LoadMaterialDefault(); - } - - /// - /// Load materials from model file - /// - public static Material[] Load(string fileName) - { - using AnsiBuffer buffer = fileName.ToAnsiBuffer(); - int count = 0; - Material* materials = Raylib.LoadMaterials(buffer.AsPointer(), &count); - Material[] output = new Material[count]; - for (int i = 0; i < count; i++) - { - output[i] = materials[i]; - } - return output; - } - - public static Material GetMaterial(ref Model model, int materialIndex) - { - return Raylib.GetMaterial(ref model, materialIndex); - } - - public static Texture2D GetTexture(ref Model model, int materialIndex, MaterialMapIndex mapIndex) - { - return Raylib.GetMaterialTexture(ref model, materialIndex, mapIndex); - } - - public void SetTexture(MaterialMapIndex mapIndex, Texture2D texture) - { - Raylib.SetMaterialTexture(ref this, mapIndex, texture); - } - - public static void SetShader(ref Model model, int materialIndex, ref Shader shader) - { - Raylib.SetMaterialShader(ref model, materialIndex, ref shader); - } - - public void Unload() - { - Raylib.UnloadMaterial(this); - } } diff --git a/Raylib-cs/types/Mesh.cs b/Raylib-cs/types/Mesh.cs index 0ee5020..926647d 100644 --- a/Raylib-cs/types/Mesh.cs +++ b/Raylib-cs/types/Mesh.cs @@ -30,36 +30,6 @@ public unsafe struct Mesh /// public int TriangleCount; - public readonly void Draw(Material material, Matrix4x4 transform) - { - Raylib.DrawMesh(this, material, transform); - } - - public readonly void DrawInstanced(Material material, Matrix4x4[] transforms, int instances) - { - Raylib.DrawMeshInstanced(this, material, transforms, instances); - } - - public readonly void Export(string fileName) - { - Raylib.ExportMesh(this, fileName); - } - - public readonly void ExportAsCode(string fileName) - { - Raylib.ExportMeshAsCode(this, fileName); - } - - public void Upload(CBool dynamic) - { - Raylib.UploadMesh(ref this, dynamic); - } - - public void Unload() - { - Raylib.UnloadMesh(this); - } - #region Default vertex data /// diff --git a/Raylib-cs/types/Model.cs b/Raylib-cs/types/Model.cs index f36ab35..75fd00f 100644 --- a/Raylib-cs/types/Model.cs +++ b/Raylib-cs/types/Model.cs @@ -73,98 +73,6 @@ public unsafe struct Model /// Bones base transformation (pose, Transform *) /// public Transform* BindPose; - - public readonly CBool IsValid => Raylib.IsModelValid(this); - - public static Model Load(string fileName) - { - return Raylib.LoadModel(fileName); - } - - public static Model LoadFromMesh(Mesh mesh) - { - return Raylib.LoadModelFromMesh(mesh); - } - - public readonly void Draw(Vector3 position) - { - Raylib.DrawModel(this, position, 1.0f, Color.White); - } - - public readonly void Draw(Vector3 position, float scale) - { - Raylib.DrawModel(this, position, scale, Color.White); - } - - public readonly void Draw(Vector3 position, float scale, Color color) - { - Raylib.DrawModel(this, position, scale, color); - } - - public readonly void Draw(Vector3 position, Vector3 rotationAxis, float rotationAngle) - { - Raylib.DrawModelEx(this, position, rotationAxis, rotationAngle, Vector3.One, Color.White); - } - - public readonly void Draw(Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale) - { - Raylib.DrawModelEx(this, position, rotationAxis, rotationAngle, scale, Color.White); - } - - public readonly void Draw(Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color color) - { - Raylib.DrawModelEx(this, position, rotationAxis, rotationAngle, scale, color); - } - - public readonly void DrawWires(Vector3 position, Color color) - { - Raylib.DrawModelWires(this, position, 1.0f, color); - } - - public readonly void DrawWires(Vector3 position, float scale) - { - Raylib.DrawModelWires(this, position, scale, Color.White); - } - - public readonly void DrawWires(Vector3 position, float scale, Color color) - { - Raylib.DrawModelWires(this, position, scale, color); - } - - public readonly void DrawWires(Vector3 position, Vector3 rotationAxis, float rotationAngle, Color color) - { - Raylib.DrawModelWiresEx(this, position, rotationAxis, rotationAngle, Vector3.One, color); - } - - public readonly void DrawWires(Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color color) - { - Raylib.DrawModelWiresEx(this, position, rotationAxis, rotationAngle, scale, color); - } - - public readonly void DrawPoints(Vector3 position, Color color) - { - Raylib.DrawModelPoints(this, position, 1.0f, color); - } - - public readonly void DrawPoints(Vector3 position, float scale, Color color) - { - Raylib.DrawModelPoints(this, position, scale, color); - } - - public readonly void DrawPoints(Vector3 position, Vector3 rotationAxis, float rotationAngle, Color color) - { - Raylib.DrawModelPointsEx(this, position, rotationAxis, rotationAngle, Vector3.One, color); - } - - public readonly void DrawPoints(Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color color) - { - Raylib.DrawModelPointsEx(this, position, rotationAxis, rotationAngle, scale, color); - } - - public void Unload() - { - Raylib.UnloadModel(this); - } } /// @@ -223,31 +131,6 @@ public unsafe struct ModelAnimation this._boneCount = boneCount; } } - - public static ModelAnimation[] LoadAnimations(string fileName) - { - int count = 0; - ModelAnimation* animations = Raylib.LoadModelAnimations(fileName, ref count); - ModelAnimation[] output = new ModelAnimation[count]; - for (int i = 0; i < count; i++) - { - output[i] = animations[i]; - } - return output; - } - - public static void UnloadAnimations(ModelAnimation[] modelAnimations) - { - fixed (ModelAnimation* ptr = modelAnimations) - { - Raylib.UnloadModelAnimations(ptr, modelAnimations.Length); - } - } - - public void Unload() - { - Raylib.UnloadModelAnimation(this); - } } public readonly unsafe struct FramePoses diff --git a/Raylib-cs/types/Music.cs b/Raylib-cs/types/Music.cs index be098d7..8cc17a8 100644 --- a/Raylib-cs/types/Music.cs +++ b/Raylib-cs/types/Music.cs @@ -29,73 +29,9 @@ public unsafe struct Music /// public int CtxType; - //TODO span + // TODO span /// /// Audio context data, depends on type /// public void* CtxData; - - public readonly CBool IsValid => Raylib.IsMusicValid(this); - - public static Music Load(string fileName) - { - return Raylib.LoadMusicStream(fileName); - } - - public readonly void Play() - { - Raylib.PlayMusicStream(this); - } - - public readonly void Pause() - { - Raylib.PauseMusicStream(this); - } - - public void Update() - { - Raylib.UpdateMusicStream(this); - } - - public readonly void Stop() - { - Raylib.StopMusicStream(this); - } - - /// - /// Set pan of this music where 0.5 is centered - /// - public void SetPan(float pan) - { - Raylib.SetMusicPan(this, pan); - } - - /// - /// Set pitch for this music where 1.0 is base level - /// } - public void SetPitch(float pitch) - { - Raylib.SetMusicPitch(this, pitch); - } - - /// - /// Set music volume from 0.0 to 1.0 - /// - public void SetVolume(float volume) - { - Raylib.SetMusicVolume(this, volume); - } - - /// - /// Seek music to a position (in seconds) - /// - public void Seek(float position) - { - Raylib.SeekMusicStream(this, position); - } - - public void Unload() - { - Raylib.UnloadMusicStream(this); - } } diff --git a/Raylib-cs/types/Rectangle.cs b/Raylib-cs/types/Rectangle.cs index d2ec02a..d78275b 100644 --- a/Raylib-cs/types/Rectangle.cs +++ b/Raylib-cs/types/Rectangle.cs @@ -14,24 +14,6 @@ public struct Rectangle public float Width; public float Height; - public static Rectangle Grow(Rectangle rec, float growth) - { - rec.X -= growth; - rec.Y -= growth; - rec.Width += growth * 2.0f; - rec.Height += growth * 2.0f; - return rec; - } - - public static Rectangle Shrink(Rectangle rec, float shrink) - { - rec.X += shrink; - rec.Y += shrink; - rec.Width-= shrink * 2.0f; - rec.Height -= shrink * 2.0f; - return rec; - } - public Rectangle(float x, float y, float width, float height) { this.X = x; @@ -101,21 +83,6 @@ public struct Rectangle } } - public readonly void Draw(Color color) - { - Raylib.DrawRectangleRec(this, color); - } - - public readonly void Draw(Vector2 origin, Color color) - { - Draw(origin, 0.0f, color); - } - - public readonly void Draw(Vector2 origin, float rotation, Color color) - { - Raylib.DrawRectanglePro(this, origin, rotation, color); - } - public readonly void GetIntegerValues(out int x, out int y, out int width, out int height) { x = (int)this.X; @@ -124,92 +91,20 @@ public struct Rectangle height = (int)this.Height; } - public readonly void DrawLines(Color color) - { - GetIntegerValues(out int x, out int y, out int w, out int h); - Raylib.DrawRectangleLines(x, y, w, h, color); - } - - public readonly void DrawLines(float thickness, Color color) - { - Raylib.DrawRectangleLinesEx(this, thickness, color); - } - - public readonly void DrawGradient(Color topLeft, Color bottomLeft, Color topRight, Color bottomRight) - { - Raylib.DrawRectangleGradientEx(this, topLeft, bottomLeft, topRight, bottomRight); - } - - public readonly void DrawGradientV(Color top, Color bottom) - { - GetIntegerValues(out int x, out int y, out int w, out int h); - Raylib.DrawRectangleGradientV(x, y, w, h, top, bottom); - } - - public readonly void DrawGradientH(Color left, Color right) - { - GetIntegerValues(out int x, out int y, out int w, out int h); - Raylib.DrawRectangleGradientH(x, y, w, h, left, right); - } - - public readonly void DrawRounded(float roundness, Color color) - { - Raylib.DrawRectangleRounded(this, roundness, 10, color); - } - - public readonly void DrawRounded(float roundness, int segments, Color color) - { - Raylib.DrawRectangleRounded(this, roundness, segments, color); - } - - public readonly void DrawRoundedLines(float roundness, Color color) - { - Raylib.DrawRectangleRoundedLines(this, roundness, 10, color); - } - - public readonly void DrawRoundedLines(float roundness, int segments, Color color) - { - Raylib.DrawRectangleRoundedLines(this, roundness, segments, color); - } - - public readonly void DrawRoundedLines(float roundness, float thickness, Color color) - { - Raylib.DrawRectangleRoundedLinesEx(this, roundness, 10, thickness, color); - } - - public readonly void DrawRoundedLines(float roundness, int segments, float thickness, Color color) - { - Raylib.DrawRectangleRoundedLinesEx(this, roundness, segments, thickness, color); - } - - public readonly CBool CheckCollisionRec(Rectangle rectangle) - { - return Raylib.CheckCollisionRecs(this, rectangle); - } - - public readonly CBool CheckCollisionPoint(Vector2 point) - { - return Raylib.CheckCollisionPointRec(point, this); - } - - public readonly CBool CheckCollisionCircle(Vector2 center, float radius) - { - return Raylib.CheckCollisionCircleRec(center, radius, this); - } - - public readonly Rectangle GetCollisionRectangle(Rectangle rectangle2) - { - return Raylib.GetCollisionRec(this, rectangle2); - } - public void Grow(float growth) { - this = Rectangle.Grow(this, growth); + X -= growth; + Y -= growth; + Width += growth * 2.0f; + Height += growth * 2.0f; } public void Shrink(float shrink) { - this = Rectangle.Shrink(this, shrink); + X += shrink; + Y += shrink; + Width -= shrink * 2.0f; + Height -= shrink * 2.0f; } public readonly override string ToString() diff --git a/Raylib-cs/types/RenderTexture2D.cs b/Raylib-cs/types/RenderTexture2D.cs index 20279b0..ccbb23d 100644 --- a/Raylib-cs/types/RenderTexture2D.cs +++ b/Raylib-cs/types/RenderTexture2D.cs @@ -22,16 +22,4 @@ public struct RenderTexture2D /// Depth buffer attachment texture /// public Texture2D Depth; - - public readonly CBool IsValid => Raylib.IsRenderTextureValid(this); - - public static RenderTexture2D Load(int width, int height) - { - return Raylib.LoadRenderTexture(width, height); - } - - public void Unload() - { - Raylib.UnloadRenderTexture(this); - } } diff --git a/Raylib-cs/types/Shader.cs b/Raylib-cs/types/Shader.cs index 4ddc31c..892e18a 100644 --- a/Raylib-cs/types/Shader.cs +++ b/Raylib-cs/types/Shader.cs @@ -87,46 +87,4 @@ public unsafe struct Shader /// Shader locations array (MAX_SHADER_LOCATIONS, int *) /// public int* Locs; - - public readonly CBool IsValid => Raylib.IsShaderValid(this); - - public static Shader Load(string vsFileName, string fsFileName) - { - return Raylib.LoadShader(vsFileName, fsFileName); - } - - public static Shader LoadFromMemory(string vsCode, string fsCode) - { - return Raylib.LoadShaderFromMemory(vsCode, fsCode); - } - - public void GetLocationAttrib(string attribName) - { - Raylib.GetShaderLocationAttrib(this, attribName); - } - - public void SetValue(int locationIndex, T value, ShaderUniformDataType uniformDataType) where T : unmanaged - { - Raylib.SetShaderValue(this, locationIndex, &value, uniformDataType); - } - - public void SetValues(int locationIndex, T[] values, ShaderUniformDataType uniformDataType) where T : unmanaged - { - Raylib.SetShaderValueV(this, locationIndex, values, uniformDataType, values.Length); - } - - public void SetTexture(int locationIndex, Texture2D texture) - { - Raylib.SetShaderValueTexture(this, locationIndex, texture); - } - - public void SetMatrix(int locationIndex, System.Numerics.Matrix4x4 matrix) - { - Raylib.SetShaderValueMatrix(this, locationIndex, matrix); - } - - public void Unload() - { - Raylib.UnloadShader(this); - } } diff --git a/Raylib-cs/types/Sound.cs b/Raylib-cs/types/Sound.cs index 75af04b..6bf3b9a 100644 --- a/Raylib-cs/types/Sound.cs +++ b/Raylib-cs/types/Sound.cs @@ -17,61 +17,4 @@ public struct Sound /// Total number of frames (considering channels) /// public uint FrameCount; - - public readonly CBool IsValid => Raylib.IsSoundValid(this); - public readonly CBool IsPlaying => Raylib.IsSoundPlaying(this); - - public static Sound Load(string fileName) - { - return Raylib.LoadSound(fileName); - } - - public static Sound LoadFromWave(Wave wave) - { - return Raylib.LoadSoundFromWave(wave); - } - - public readonly void Play() - { - Raylib.PlaySound(this); - } - - public readonly void Pause() - { - Raylib.PauseSound(this); - } - - public readonly void Resume() - { - Raylib.ResumeSound(this); - } - - /// - /// Set pan where 0.5 is center - /// - public void SetPan(float pan) - { - Raylib.SetSoundPan(this, pan); - } - - /// - /// Set pitch where 1.0 is base level - /// - public void SetPitch(float pitch) - { - Raylib.SetSoundPitch(this, pitch); - } - - /// - /// Set volume from 0.0 to 1.0 - /// - public void SetVolume(float volume) - { - Raylib.SetSoundVolume(this, volume); - } - - public void Unload() - { - Raylib.UnloadSound(this); - } } diff --git a/Raylib-cs/types/Texture2D.cs b/Raylib-cs/types/Texture2D.cs index aa245e0..65e3d2f 100644 --- a/Raylib-cs/types/Texture2D.cs +++ b/Raylib-cs/types/Texture2D.cs @@ -134,123 +134,4 @@ public struct Texture2D /// Get width and height packed in a Vector2 /// public readonly Vector2 Dimensions => new Vector2(Width, Height); - public readonly CBool IsValid => Raylib.IsTextureValid(this); - - public static Texture2D Load(string fileName) - { - 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[] 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.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) - { - 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, 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); - } } diff --git a/Raylib-cs/types/Wave.cs b/Raylib-cs/types/Wave.cs index bb03a82..ddcd75c 100644 --- a/Raylib-cs/types/Wave.cs +++ b/Raylib-cs/types/Wave.cs @@ -28,41 +28,9 @@ public unsafe struct Wave /// public uint Channels; - //TODO: SPAN ? + // TODO: SPAN? /// /// Buffer data pointer /// public void* Data; - - public readonly CBool IsValid => Raylib.IsWaveValid(this); - - public static Wave Load(string fileName) - { - return Raylib.LoadWave(fileName); - } - - public CBool Export(string fileName) - { - return Raylib.ExportWave(this, fileName); - } - - public CBool ExportAsCode(string fileName) - { - return Raylib.ExportWaveAsCode(this, fileName); - } - - public void Format(int sampleRate, int sampleSize, int channels) - { - Raylib.WaveFormat(ref this, sampleRate, sampleSize, channels); - } - - public void Crop(int initFrame, int finalFrame) - { - Raylib.WaveCrop(ref this, initFrame, finalFrame); - } - - public void Unload() - { - Raylib.UnloadWave(this); - } }