diff --git a/Examples/Examples.csproj b/Examples/Examples.csproj index 1c343cd..dde1b88 100644 --- a/Examples/Examples.csproj +++ b/Examples/Examples.csproj @@ -1,7 +1,7 @@ Exe - net8.0 + net8.0;net10.0 true Examples.Program $(MSBuildThisFileDirectory) diff --git a/Raylib-cs.Native/Raylib-cs.Native.csproj b/Raylib-cs.Native/Raylib-cs.Native.csproj index 92415c8..18e0544 100644 --- a/Raylib-cs.Native/Raylib-cs.Native.csproj +++ b/Raylib-cs.Native/Raylib-cs.Native.csproj @@ -1,6 +1,6 @@ - net8.0 + net8.0;net10.0 false none false diff --git a/Raylib-cs.Tests/Raylib-cs.Tests.csproj b/Raylib-cs.Tests/Raylib-cs.Tests.csproj index 30c1a6d..eb14162 100644 --- a/Raylib-cs.Tests/Raylib-cs.Tests.csproj +++ b/Raylib-cs.Tests/Raylib-cs.Tests.csproj @@ -1,6 +1,6 @@ - net8.0 + net10.0 true 12 diff --git a/Raylib-cs/Build.props b/Raylib-cs/Build.props index 8f2213c..1603a20 100644 --- a/Raylib-cs/Build.props +++ b/Raylib-cs/Build.props @@ -1,6 +1,6 @@ - 5.5 + 6.0 8.0.0 8.0.0 diff --git a/Raylib-cs/Raylib-cs.csproj b/Raylib-cs/Raylib-cs.csproj index c1432a9..c7f551a 100644 --- a/Raylib-cs/Raylib-cs.csproj +++ b/Raylib-cs/Raylib-cs.csproj @@ -1,6 +1,6 @@  - net8.0 + net8.0;net10.0 false Raylib-cs Raylib_cs diff --git a/Raylib-cs/interop/Raylib.cs b/Raylib-cs/interop/Raylib.cs index 30e4fc3..aa0f962 100644 --- a/Raylib-cs/interop/Raylib.cs +++ b/Raylib-cs/interop/Raylib.cs @@ -19,7 +19,7 @@ public static unsafe partial class Raylib /// public const string NativeLibName = "raylib"; - public const string RAYLIB_VERSION = "5.5"; + public const string RAYLIB_VERSION = "6.0"; public const float DEG2RAD = MathF.PI / 180.0f; public const float RAD2DEG = 180.0f / MathF.PI; @@ -701,6 +701,8 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadRandomSequence(int* sequence); + // Misc. functions + /// Takes a screenshot of current screen (saved a .png) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -711,6 +713,13 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetConfigFlags(ConfigFlags flags); + /// Open URL with default system browser (if available) + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void OpenURL(sbyte* url); + + // Logging system + /// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -721,6 +730,8 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetTraceLogLevel(TraceLogLevel logLevel); + // Memory management, using internal allocators + /// Internal memory allocator [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -745,29 +756,6 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetTraceLogCallback(delegate* unmanaged[Cdecl] callback); - /// Set custom file binary data loader - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void SetLoadFileDataCallback(delegate* unmanaged[Cdecl] callback); - - /// Set custom file binary data saver - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void SetSaveFileDataCallback( - delegate* unmanaged[Cdecl] callback - ); - - /// Set custom file text data loader - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void SetLoadFileTextCallback(delegate* unmanaged[Cdecl] callback); - - /// Set custom file text data saver - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void SetSaveFileTextCallback(delegate* unmanaged[Cdecl] callback); - - // Files management functions /// Load file data as byte array (read) @@ -790,27 +778,81 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial CBool ExportDataAsCode(byte* data, int dataSize, sbyte* fileName); - // Load text data from file (read), returns a '\0' terminated string + /// Load text data from file (read), returns a '\0' terminated string [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial sbyte* LoadFileText(sbyte* fileName); - // Unload file text data allocated by LoadFileText() + /// Unload file text data allocated by LoadFileText() [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadFileText(sbyte* text); - // Save text data to file (write), string must be '\0' terminated, returns true on success + /// Save text data to file (write), string must be '\0' terminated, returns true on success [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial CBool SaveFileText(sbyte* fileName, sbyte* text); - // Check if file exists + // File access custom callbacks + // WARNING: Callbacks setup is intended for advanced users + /// Set custom file binary data loader + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetLoadFileDataCallback(delegate* unmanaged[Cdecl] callback); + + /// Set custom file binary data saver + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSaveFileDataCallback( + delegate* unmanaged[Cdecl] callback + ); + + /// Set custom file text data loader + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetLoadFileTextCallback(delegate* unmanaged[Cdecl] callback); + + /// Set custom file text data saver + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSaveFileTextCallback(delegate* unmanaged[Cdecl] callback); + + /// Rename file (if exists) + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool FileRename(sbyte* fileName, sbyte* fileRename); + + /// Remove file (if exists) + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool FileRemove(sbyte* fileName); + + /// Copy file from one path to another, dstPath created if it doesn't exist + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool FileCopy(sbyte* srcPath, sbyte* dstPath); + + /// Move file from one path to another, dstPath created if it doesn't exist + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool FileMove(sbyte* srcPath, sbyte* dstPath); + + /// Replace text in an existing file + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool FileTextReplace(sbyte* fileName, sbyte* search, sbyte* replacement); + + /// Find text in existing file + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool FileTextFindIndex(sbyte* fileName, sbyte* search); + + /// Check if file exists [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial CBool FileExists(sbyte* fileName); - // Check if a directory path exists + /// Check if a directory path exists [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial CBool DirectoryExists(sbyte* dirPath); @@ -825,6 +867,11 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int GetFileLength(sbyte* fileName); + /// Get file modification time (last write time) + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial long GetFileModTime(sbyte* fileName); + /// Get pointer to extension for a filename string (includes dot: '.png') [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -865,6 +912,21 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int MakeDirectory(sbyte* dirPath); + /// Change working directory, return true on success + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool ChangeDirectory(sbyte* dirPath); + + /// Check if a given path is a file or a directory + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsPathFile(sbyte* path); + + /// Check if fileName is valid for the platform/OS + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsFileNameValid(sbyte* fileName); + /// Load directory filepaths [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -880,21 +942,6 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadDirectoryFiles(FilePathList files); - /// Check if a given path is a file or a directory - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial CBool IsPathFile(sbyte* path); - - /// Check if fileName is valid for the platform/OS - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial CBool IsFileNameValid(sbyte* fileName); - - /// Change working directory, return true on success - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial CBool ChangeDirectory(sbyte* dir); - /// Check if a file has been dropped into window [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -910,11 +957,15 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadDroppedFiles(FilePathList files); - /// Get file modification time (last write time) + /// Get the file count in a directory [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial long GetFileModTime(sbyte* fileName); + public static partial FilePathList GetDirectoryFileCount(sbyte* dirPath); + /// Get the file count in a directory + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial FilePathList GetDirectoryFileCountEx(sbyte* dirPath, sbyte* filter, CBool scanSubdirs); // Compression/Encoding functionality @@ -953,10 +1004,10 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint* ComputeSHA1(byte* data, int dataSize); - /// Open URL with default system browser (if available) + /// Compute SHA256 hash code, returns static int[8] (32 bytes) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void OpenURL(sbyte* url); + public static partial uint* ComputeSHA256(byte* data, int dataSize); // Automation events functionality @@ -1031,11 +1082,6 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial CBool IsKeyUp(KeyboardKey key); - /// Set a custom key to exit program (default is ESC) - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void SetExitKey(KeyboardKey key); - /// /// Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty /// @@ -1050,6 +1096,16 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int GetCharPressed(); + /// Get gamepad internal name id + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetKeyName(KeyboardKey key); + + /// Set a custom key to exit program (default is ESC) + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetExitKey(KeyboardKey key); + // Input-related functions: gamepads @@ -1398,21 +1454,38 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); - /// Draw a line using cubic-bezier curves in-out - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); - /// Draw lines sequence [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DrawLineStrip(Vector2* points, int pointCount, Color color); + /// Draw a line using cubic-bezier curves in-out + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); + /// Draw a color-filled circle [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DrawCircle(int centerX, int centerY, float radius, Color color); + + /// Draw a color-filled circle (Vector version) + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCircleV(Vector2 center, float radius, Color color); + + /// Draw a gradient-filled circle + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCircleGradient( + int centerX, + int centerY, + float radius, + Color inner, + Color outer + ); + /// Draw a piece of a circle [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -1437,22 +1510,6 @@ public static unsafe partial class Raylib Color color ); - /// Draw a gradient-filled circle - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void DrawCircleGradient( - int centerX, - int centerY, - float radius, - Color inner, - Color outer - ); - - /// Draw a color-filled circle (Vector version) - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void DrawCircleV(Vector2 center, float radius, Color color); - /// Draw circle outline [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -1468,11 +1525,21 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color); + /// Draw ellipse (Vector version) + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawEllipseV(Vector2 center, float radiusH, float radiusV, Color color); + /// Draw ellipse outline [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color); + /// Draw ellipse outline (Vector version) + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawEllipseLinesV(Vector2 center, float radiusH, float radiusV, Color color); + /// Draw ring [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -2372,6 +2439,11 @@ public static unsafe partial class Raylib // Color/pixel related functions + /// Check if two colors are equal + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool ColorIsEqual(Color col1, Color col2); + /// Get hexadecimal value for a Color (0xRRGGBBAA) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -2684,8 +2756,21 @@ public static unsafe partial class Raylib // Text strings management functions (no UTF-8 strings, only byte chars) + // WARNING 1: Most of these functions use internal static buffers[], it's recommended to store returned data on user-side for re-use + // WARNING 2: Some functions allocate memory internally for the returned strings, those strings must be freed by user using MemFree() // NOTE: Some strings allocate memory internally for returned strings, just be careful! + + /// Load text as separate lines ('\n') + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte** LoadTextLines(sbyte* text, int* count); + + /// Unload text lines + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadTextLines(sbyte** text, int* lineCount); + /// Copy one string to another, returns bytes copied [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -2711,15 +2796,35 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial sbyte* TextSubtext(sbyte* text, int position, int length); + /// Remove text spaces, concat words + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextRemoveSpaces(sbyte* text); + + /// Get text between two strings + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetTextBetween(sbyte* text, sbyte* begin, sbyte* end); + + /// Replace text string + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextReplace(sbyte* text, sbyte* search, sbyte* replacement); + /// Replace text string (WARNING: memory must be freed!) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial sbyte* TextReplace(sbyte* text, sbyte* replace, sbyte* by); + public static partial sbyte* TextReplaceAlloc(sbyte* text, sbyte* search, sbyte* replacement); + + /// Insert text in a position + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextInsert(sbyte* text, sbyte* insert, int position); /// Insert text in a position (WARNING: memory must be freed!) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial sbyte* TextInsert(sbyte* text, sbyte* insert, int position); + public static partial sbyte* TextInsertAlloc(sbyte* text, sbyte* insert, int position); /// Join text strings with delimiter [LibraryImport(NativeLibName)] @@ -3004,23 +3109,6 @@ public static unsafe partial class Raylib Color tint ); - /// Draw a model as points - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void DrawModelPoints(Model model, Vector3 position, float scale, Color tint); - - /// Draw a model as points with extended parameters - [LibraryImport(NativeLibName)] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void DrawModelPointsEx( - Model model, - Vector3 position, - Vector3 rotationAxis, - float rotationAngle, - Vector3 scale, - Color tint - ); - /// Draw bounding box (wires) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -3211,15 +3299,15 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial ModelAnimation* LoadModelAnimations(sbyte* fileName, int* animCount); - /// Update model animation pose (CPU) + /// Update model animation pose (vertex buffers and bone matrices) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); + public static partial void UpdateModelAnimation(Model model, ModelAnimation anim, float frame); - /// Update model animation mesh bone matrices (GPU skinning) + /// // Update model animation pose, blending two animations [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame); + public static partial void UpdateModelAnimationEx(Model model, ModelAnimation anim, float frame, ModelAnimation animB, float frameB, float blend); /// Unload animation data [LibraryImport(NativeLibName)] @@ -3247,7 +3335,6 @@ public static unsafe partial class Raylib Vector3 center2, float radius2 ); - /// Detect collision between two bounding boxes [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -3421,7 +3508,7 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetSoundPitch(Sound sound, float pitch); - /// Set pan for a sound (0.5 is center) + /// Set pan for a sound (-1.0 left, 0.0 center, 1.0 right) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetSoundPan(Sound sound, float pan); @@ -3518,7 +3605,7 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetMusicPitch(Music music, float pitch); - /// Set pan for a music (0.5 is center) + /// Set pan for a music (-1.0 left, 0.0 center, 1.0 right) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetMusicPan(Music music, float pan); @@ -3596,7 +3683,7 @@ public static unsafe partial class Raylib [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetAudioStreamPitch(AudioStream stream, float pitch); - /// Set pan for audio stream (0.5 is centered) + /// Set pan for audio stream (-1.0 to 1.0 range, 0.0 is centered) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetAudioStreamPan(AudioStream stream, float pan); @@ -3614,7 +3701,7 @@ public static unsafe partial class Raylib delegate* unmanaged[Cdecl] callback ); - /// Attach audio stream processor to stream + /// Attach audio stream processor to stream, receives frames x 2 samples as 'float' (stereo) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void AttachAudioStreamProcessor( @@ -3630,7 +3717,7 @@ public static unsafe partial class Raylib delegate* unmanaged[Cdecl] processor ); - /// Attach audio stream processor to the entire audio pipeline + /// Attach audio stream processor to the entire audio pipeline, receives frames x 2 samples as 'float' (stereo) [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void AttachAudioMixedProcessor( diff --git a/Raylib-cs/interop/Raymath.cs b/Raylib-cs/interop/Raymath.cs index 80d6d1d..b8af0ca 100644 --- a/Raylib-cs/interop/Raymath.cs +++ b/Raylib-cs/interop/Raymath.cs @@ -102,6 +102,11 @@ public static unsafe partial class Raymath [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial float Vector2DotProduct(Vector2 v1, Vector2 v2); + /// Calculate two vectors cross product + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector2CrossProduct(Vector2 v1, Vector2 v2); + /// Calculate distance between two vectors [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -113,8 +118,9 @@ public static unsafe partial class Raymath public static partial float Vector2DistanceSqr(Vector2 v1, Vector2 v2); /// - /// Calculate angle between two vectors - /// NOTE: Angle is calculated from origin point (0, 0) + /// Calculate the signed angle from v1 to v2, relative to the origin (0, 0) + /// NOTE: Coordinate system convention: positive X right, positive Y down + /// positive angles appear clockwise, and negative angles appear counterclockwise /// [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -474,6 +480,13 @@ public static unsafe partial class Raymath [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial Matrix4x4 MatrixMultiply(Matrix4x4 left, Matrix4x4 right); + /// + /// Multiply matrix components by value + /// + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixMultiplyValue(Matrix4x4 left, float value); + /// Get translation matrix [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -698,6 +711,14 @@ public static unsafe partial class Raymath [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int QuaternionEquals(Quaternion p, Quaternion q); + /// + /// Compose a transformation matrix from rotational, translational and scaling components + /// TODO: This function is not following raymath conventions defined in header: NOT self-contained + /// + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixCompose(Vector3 translation, Quaternion rotation, Vector3 scale); + /// Decompose a transformation matrix into its rotational, translational and scaling components [LibraryImport(NativeLibName)] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] diff --git a/Raylib-cs/interop/Rlgl.cs b/Raylib-cs/interop/Rlgl.cs index ee7a0ce..c010a63 100644 --- a/Raylib-cs/interop/Rlgl.cs +++ b/Raylib-cs/interop/Rlgl.cs @@ -462,16 +462,31 @@ public static unsafe partial class Rlgl [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Scissor(int x, int y, int width, int height); - /// Enable wire mode - [LibraryImport(NativeLibName, EntryPoint = "rlEnableWireMode")] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void EnableWireMode(); - /// Enable point mode [LibraryImport(NativeLibName, EntryPoint = "rlEnablePointMode")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnablePointMode(); + /// Disable point mode + [LibraryImport(NativeLibName, EntryPoint = "rlDisablePointMode")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisablePointMode(); + + /// Set the point drawing size + [LibraryImport(NativeLibName, EntryPoint = "rlSetPointSize")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPointSize(float size); + + /// Set the point drawing size + [LibraryImport(NativeLibName, EntryPoint = "rlGetPointSize")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float GetPointSize(); + + /// Disable wire mode + [LibraryImport(NativeLibName, EntryPoint = "rlEnableWireMode")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableWireMode(); + /// Disable wire mode [LibraryImport(NativeLibName, EntryPoint = "rlDisableWireMode")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -569,6 +584,11 @@ public static unsafe partial class Rlgl [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void LoadExtensions(void* loader); + /// Get OpenGL procedure address + [LibraryImport(NativeLibName, EntryPoint = "rlGetProcAddress")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void* GetProcAddress(sbyte* procName); + /// Get current OpenGL version [LibraryImport(NativeLibName, EntryPoint = "rlGetVersion")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] @@ -811,24 +831,43 @@ public static unsafe partial class Rlgl [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadFramebuffer(uint id); + /// Copy framebuffer pixel data to internal buffer + [LibraryImport(NativeLibName, EntryPoint = "rlCopyFramebuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void rlCopyFramebuffer(int x, int y, int width, int height, int format, void* pixels); + + /// Copy framebuffer pixel data to internal buffer + [LibraryImport(NativeLibName, EntryPoint = "rlResizeFramebuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void rlResizeFramebuffer(int width, int height); // Shaders management + /// Load (compile) shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER) + [LibraryImport(NativeLibName, EntryPoint = "rlLoadShader")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadShader(sbyte* vsCode, int type); + /// Load shader from code strings - [LibraryImport(NativeLibName, EntryPoint = "rlLoadShaderCode")] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial uint LoadShaderCode(sbyte* vsCode, sbyte* fsCode); - - /// Compile custom shader and return shader id
- /// (type: VERTEX_SHADER, FRAGMENT_SHADER, COMPUTE_SHADER)
- [LibraryImport(NativeLibName, EntryPoint = "rlCompileShader")] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial uint CompileShader(sbyte* shaderCode, int type); - - /// Load custom shader program [LibraryImport(NativeLibName, EntryPoint = "rlLoadShaderProgram")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial uint LoadShaderProgram(uint vShaderId, uint fShaderId); + public static partial uint LoadShaderProgram(sbyte* vsCode, sbyte* fsCode); + + /// Load shader from code strings + [LibraryImport(NativeLibName, EntryPoint = "rlLoadShaderProgramEx")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadShaderProgramEx(uint vsId, uint fsId); + + /// Load shader from code strings + [LibraryImport(NativeLibName, EntryPoint = "rlLoadShaderProgramCompute")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadShaderProgramCompute(uint csId); + + + /// Unload shader program + [LibraryImport(NativeLibName, EntryPoint = "rlUnloadShader")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadShader(uint id); /// Unload shader program [LibraryImport(NativeLibName, EntryPoint = "rlUnloadShaderProgram")] @@ -873,11 +912,6 @@ public static unsafe partial class Rlgl // Compute shader management - /// Load compute shader program - [LibraryImport(NativeLibName, EntryPoint = "rlLoadComputeShaderProgram")] - [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial uint LoadComputeShaderProgram(uint shaderId); - /// Dispatch compute shader (equivalent to *draw* for graphics pilepine) [LibraryImport(NativeLibName, EntryPoint = "rlComputeShaderDispatch")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] diff --git a/Raylib-cs/types/Mesh.cs b/Raylib-cs/types/Mesh.cs index 926647d..10c389c 100644 --- a/Raylib-cs/types/Mesh.cs +++ b/Raylib-cs/types/Mesh.cs @@ -181,38 +181,23 @@ public unsafe struct Mesh #endregion - #region Animation vertex data + #region Skin data for animation /// - /// Animated vertex positions (after bones transformations) + /// Number of bones (MAX: 256 bones) /// - public float* AnimVertices = default; - - /// - /// Animated normals (after bones transformations) - /// - public float* AnimNormals = default; + public int BoneCount; /// /// Vertex bone ids, up to 4 bones influence by vertex (skinning) /// - public byte* BoneIds = default; + public byte* boneIndices = default; /// /// Vertex bone weight, up to 4 bones influence by vertex (skinning) /// public float* BoneWeights = default; - /// - /// Bones animated transformation matrices - /// - public Matrix4x4* BoneMatrices = default; - - /// - /// Number of bones - /// - public int BoneCount; - #endregion #region OpenGL identifiers diff --git a/Raylib-cs/types/Model.cs b/Raylib-cs/types/Model.cs index 75fd00f..945db48 100644 --- a/Raylib-cs/types/Model.cs +++ b/Raylib-cs/types/Model.cs @@ -21,6 +21,32 @@ public unsafe struct BoneInfo public int Parent; } +/// +/// Skeleton, animation bones hierarchy +/// +[StructLayout(LayoutKind.Sequential)] +public unsafe struct ModelSkeleton +{ + /// + /// Number of bones + /// + public int BoneCount; + + /// + /// Bones information (skeleton) + /// + public BoneInfo* Bones; + + /// + /// Bones base transformation (Transform[]) + /// + public Transform* ModelAnimPose; +} + +// Note: +// Anim pose, an array of Transform[] +// typedef Transform *ModelAnimPose; It's just an pointer array. + /// /// Model type /// diff --git a/Raylib-cs/types/Shader.cs b/Raylib-cs/types/Shader.cs index 892e18a..e5e0d89 100644 --- a/Raylib-cs/types/Shader.cs +++ b/Raylib-cs/types/Shader.cs @@ -35,7 +35,8 @@ public enum ShaderLocationIndex MapBrdf, VertexBoneIds, VertexBoneWeights, - BoneMatrices, + BoneTransforms, + BoneInstanceTransform, MapDiffuse = MapAlbedo, MapSpecular = MapMetalness,