From e009520be33b4f903df8566559750f3ce1b0b3be Mon Sep 17 00:00:00 2001 From: MrScautHD Date: Sun, 19 Nov 2023 12:04:39 +0100 Subject: [PATCH] Start to port to 5.0.0 --- Raylib-cs/Build.props | 2 +- Raylib-cs/interop/Raylib.cs | 141 ++++++++++++++++++++++++++++++++--- Raylib-cs/interop/Raymath.cs | 8 ++ Raylib-cs/interop/Rlgl.cs | 8 ++ Raylib-cs/types/Core.cs | 5 ++ Raylib-cs/types/Model.cs | 5 ++ Raylib-cs/types/Sound.cs | 1 - Raylib-cs/types/Wave.cs | 1 - 8 files changed, 158 insertions(+), 13 deletions(-) diff --git a/Raylib-cs/Build.props b/Raylib-cs/Build.props index b6d4ad1..d196667 100644 --- a/Raylib-cs/Build.props +++ b/Raylib-cs/Build.props @@ -1,7 +1,7 @@ - 4.5.0 + 5.0.0 5.0.0 5.0.0 diff --git a/Raylib-cs/interop/Raylib.cs b/Raylib-cs/interop/Raylib.cs index f417774..32ef55c 100644 --- a/Raylib-cs/interop/Raylib.cs +++ b/Raylib-cs/interop/Raylib.cs @@ -13,7 +13,7 @@ public static unsafe partial class Raylib /// public const string NativeLibName = "raylib"; - public const string RAYLIB_VERSION = "4.5"; + public const string RAYLIB_VERSION = "5.0"; public const float DEG2RAD = MathF.PI / 180.0f; public const float RAD2DEG = 180.0f / MathF.PI; @@ -86,6 +86,10 @@ public static unsafe partial class Raylib [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void ToggleFullscreen(); + /// Toggle window state: borderless windowed (only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ToggleBorderlessWindowed(); + /// Set window state: maximized, if resizable (only PLATFORM_DESKTOP) [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void MaximizeWindow(); @@ -122,6 +126,10 @@ public static unsafe partial class Raylib [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SetWindowMinSize(int width, int height); + /// Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetWindowMaxSize(int width, int height); + /// Set window dimensions [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SetWindowSize(int width, int height); @@ -450,6 +458,14 @@ public static unsafe partial class Raylib [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int SetRandomSeed(uint seed); + /// Load random values sequence, no values repeated + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int* LoadRandomSequence(int count, int min, int max); + + /// Unload random values sequence + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadRandomSequence(int *sequence); + /// Takes a screenshot of current screen (saved a .png) [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void TakeScreenshot(sbyte* fileName); @@ -648,6 +664,10 @@ public static unsafe partial class Raylib [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern CBool IsKeyPressed(KeyboardKey key); + /// Detect if a key has been pressed again + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsKeyPressedRepeat(KeyboardKey key); + /// Detect if a key is being pressed [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern CBool IsKeyDown(KeyboardKey key); @@ -1026,6 +1046,10 @@ public static unsafe partial class Raylib [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void DrawCircleLines(int centerX, int centerY, float radius, Color color); + /// Draw circle outline (Vector version) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawCircleLinesV(Vector2 center, float radius, Color color); + /// Draw ellipse [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color); @@ -1163,6 +1187,70 @@ public static unsafe partial class Raylib Color color ); + // Splines drawing functions + + /// Draw spline: Linear, minimum 2 points + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawSplineLinear(Vector2 *points, int pointCount, float thick, Color color); + + /// Draw spline: B-Spline, minimum 4 points + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawSplineBasis(Vector2 *points, int pointCount, float thick, Color color); + + /// Draw spline: Catmull-Rom, minimum 4 points + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawSplineCatmullRom(Vector2 *points, int pointCount, float thick, Color color); + + /// Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...] + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawSplineBezierQuadratic(Vector2 *points, int pointCount, float thick, Color color); + + /// Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...] + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawSplineBezierCubic(Vector2 *points, int pointCount, float thick, Color color); + + /// Draw spline segment: Linear, 2 points + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawSplineSegmentLinear(Vector2 p1, Vector2 p2, float thick, Color color); + + /// Draw spline segment: B-Spline, 4 points + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawSplineSegmentBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color); + + /// Draw spline segment: Catmull-Rom, 4 points + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawSplineSegmentCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color); + + /// Draw spline segment: Quadratic Bezier, 2 points, 1 control point + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawSplineSegmentBezierQuadratic(Vector2 p1, Vector2 c2, Vector2 p3, float thick, Color color); + + /// Draw spline segment: Cubic Bezier, 2 points, 2 control points + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawSplineSegmentBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vector2 p4, float thick, Color color); + + // Spline segment point evaluation functions, for a given t [0.0f .. 1.0f] + + /// Get (evaluate) spline point: Linear + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetSplinePointLinear(Vector2 startPos, Vector2 endPos, float t); + + /// Get (evaluate) spline point: B-Spline + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetSplinePointBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t); + + /// Get (evaluate) spline point: Catmull-Rom + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetSplinePointCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t); + + /// Get (evaluate) spline point: Quadratic Bezier + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetSplinePointBezierQuad(Vector2 p1, Vector2 c2, Vector2 p3, float t); + + /// Get (evaluate) spline point: Cubic Bezier + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetSplinePointBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vector2 p4, float t); + // Basic shapes collision detection functions /// Check collision between two rectangles @@ -1242,6 +1330,10 @@ public static unsafe partial class Raylib int headerSize ); + /// Load image from SVG file data or string with specified size + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image LoadImageSvg(char *fileNameOrString, int width, int height); + /// Load image sequence from file (frames appended to image.data) [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Image LoadImageAnim(sbyte* fileName, int* frames); @@ -1270,6 +1362,10 @@ public static unsafe partial class Raylib [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern CBool ExportImage(Image image, sbyte* fileName); + /// Export image to memory buffer + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern char* ExportImageToMemory(Image image, char *fileType, int *fileSize); + /// Export image as code file defining an array of bytes [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern CBool ExportImageAsCode(Image image, sbyte* fileName); @@ -1281,13 +1377,9 @@ public static unsafe partial class Raylib [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Image GenImageColor(int width, int height, Color color); - /// Generate image: vertical gradient + /// Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageGradientV(int width, int height, Color top, Color bottom); - - /// Generate image: horizontal gradient - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageGradientH(int width, int height, Color left, Color right); + public static extern Image GenImageGradientLinear(int width, int height, int direction, Color start, Color end); /// Generate image: radial gradient [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1299,6 +1391,15 @@ public static unsafe partial class Raylib Color outer ); + /// Generate image: square gradient + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image GenImageGradientSquare( + int width, + int height, + float density, + Color inner, + Color outer); + /// Generate image: checked [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Image GenImageChecked( @@ -1412,6 +1513,10 @@ public static unsafe partial class Raylib [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void ImageFlipHorizontal(Image* image); + /// Rotate image by input angle in degrees (-359 to 359) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageRotate(Image *image, int degrees); + /// Rotate image clockwise 90deg [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void ImageRotateCW(Image* image); @@ -1743,7 +1848,7 @@ public static unsafe partial class Raylib /// the default character set /// [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Font LoadFontEx(sbyte* fileName, int fontSize, int* fontChars, int glyphCount); + public static extern Font LoadFontEx(sbyte* fileName, int fontSize, int* codepoints, int codepointCount); /// Load font from Image (XNA style) [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1756,8 +1861,8 @@ public static unsafe partial class Raylib byte* fileData, int dataSize, int fontSize, - int* fontChars, - int glyphCount + int* codepoints, + int codepointCount ); /// Check if a font is ready @@ -1857,6 +1962,10 @@ public static unsafe partial class Raylib // Text font info functions + /// Set vertical line spacing when drawing with line-breaks + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetTextLineSpacing(int spacing); + /// Measure string width for default font [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int MeasureText(sbyte* text, int fontSize); @@ -2419,6 +2528,10 @@ public static unsafe partial class Raylib [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SetMasterVolume(float volume); + /// Set master volume (listener) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float GetMasterVolume(); + // Wave/Sound loading/unloading functions @@ -2442,6 +2555,10 @@ public static unsafe partial class Raylib [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Sound LoadSoundFromWave(Wave wave); + /// Create a new sound that shares the same sample data as the source sound, does not own the sound data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Sound LoadSoundAlias(Sound source); + /// Checks if a sound is ready [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern CBool IsSoundReady(Sound sound); @@ -2458,6 +2575,10 @@ public static unsafe partial class Raylib [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void UnloadSound(Sound sound); + /// Unload a sound alias (does not deallocate sample data) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadSoundAlias(Sound alias); + /// Export wave data to file [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern CBool ExportWave(Wave wave, sbyte* fileName); diff --git a/Raylib-cs/interop/Raymath.cs b/Raylib-cs/interop/Raymath.cs index 2e76098..eca6671 100644 --- a/Raylib-cs/interop/Raymath.cs +++ b/Raylib-cs/interop/Raymath.cs @@ -247,6 +247,14 @@ public static unsafe partial class Raymath [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Vector3 Vector3Normalize(Vector3 v); + /// Calculate the projection of the vector v1 on to v2 + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3Project(Vector3 v1, Vector3 v2); + + /// Calculate the rejection of the vector v1 on to v2 + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3Reject(Vector3 v1, Vector3 v2); + /// /// Orthonormalize provided vectors
/// Makes vectors normalized and orthogonal to each other
diff --git a/Raylib-cs/interop/Rlgl.cs b/Raylib-cs/interop/Rlgl.cs index 5cb3fc8..d3f0279 100644 --- a/Raylib-cs/interop/Rlgl.cs +++ b/Raylib-cs/interop/Rlgl.cs @@ -316,6 +316,10 @@ public static unsafe partial class Rlgl [DllImport(NativeLibName, EntryPoint = "rlDisableFramebuffer", CallingConvention = CallingConvention.Cdecl)] public static extern void DisableFramebuffer(); + /// Blit active framebuffer to main framebuffer + [DllImport(NativeLibName, EntryPoint = "rlBlitFramebuffer", CallingConvention = CallingConvention.Cdecl)] + public static extern void BlitFramebuffer(); + /// Activate multiple draw color buffers [DllImport(NativeLibName, EntryPoint = "rlActiveDrawBuffers", CallingConvention = CallingConvention.Cdecl)] public static extern void ActiveDrawBuffers(int count); @@ -375,6 +379,10 @@ public static unsafe partial class Rlgl [DllImport(NativeLibName, EntryPoint = "rlEnableWireMode", CallingConvention = CallingConvention.Cdecl)] public static extern void EnableWireMode(); + /// Enable point mode + [DllImport(NativeLibName, EntryPoint = "rlEnablePointMode", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnablePointMode(); + /// Disable wire mode [DllImport(NativeLibName, EntryPoint = "rlDisableWireMode", CallingConvention = CallingConvention.Cdecl)] public static extern void DisableWireMode(); diff --git a/Raylib-cs/types/Core.cs b/Raylib-cs/types/Core.cs index 664a8c8..ada1a5f 100644 --- a/Raylib-cs/types/Core.cs +++ b/Raylib-cs/types/Core.cs @@ -75,6 +75,11 @@ public enum ConfigFlags : uint ///
FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, + /// + /// Set to run program in borderless windowed mode + /// + FLAG_BORDERLESS_WINDOWED_MODE = 0x00008000, + /// /// Set to try enabling MSAA 4X /// diff --git a/Raylib-cs/types/Model.cs b/Raylib-cs/types/Model.cs index d4d041b..6e2b714 100644 --- a/Raylib-cs/types/Model.cs +++ b/Raylib-cs/types/Model.cs @@ -104,6 +104,11 @@ public readonly unsafe partial struct ModelAnimation /// public readonly Transform** FramePoses; + /// + /// Animation name + /// + public readonly string Name; // TODO (CHECK IF IT REALLY OK TO USE STRING) + /// public FramePosesCollection FramePosesColl => new(FramePoses, FrameCount, BoneCount); diff --git a/Raylib-cs/types/Sound.cs b/Raylib-cs/types/Sound.cs index ee40597..b537fc1 100644 --- a/Raylib-cs/types/Sound.cs +++ b/Raylib-cs/types/Sound.cs @@ -1,4 +1,3 @@ -using System; using System.Runtime.InteropServices; namespace Raylib_cs; diff --git a/Raylib-cs/types/Wave.cs b/Raylib-cs/types/Wave.cs index ec27cf0..adcd390 100644 --- a/Raylib-cs/types/Wave.cs +++ b/Raylib-cs/types/Wave.cs @@ -1,4 +1,3 @@ -using System; using System.Runtime.InteropServices; namespace Raylib_cs;