From 46f2968d6ea9f873316131f98699474d4780c9ae Mon Sep 17 00:00:00 2001 From: Chris Dill Date: Thu, 23 Apr 2026 21:40:29 +0100 Subject: [PATCH] Switch from DllImport to LibraryImport --- Raylib-cs/interop/Raylib.cs | 2959 ++++++++++++++++++++-------------- Raylib-cs/interop/Raymath.cs | 600 ++++--- Raylib-cs/interop/Rlgl.cs | 773 +++++---- Raylib-cs/types/Logging.cs | 28 +- 4 files changed, 2617 insertions(+), 1743 deletions(-) diff --git a/Raylib-cs/interop/Raylib.cs b/Raylib-cs/interop/Raylib.cs index b1149fb..1082c0e 100644 --- a/Raylib-cs/interop/Raylib.cs +++ b/Raylib-cs/interop/Raylib.cs @@ -1,8 +1,11 @@ +using System; +using System.Numerics; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; -using System.Numerics; using System.Security; -using System; + +[assembly: DisableRuntimeMarshalling] namespace Raylib_cs; @@ -10,7 +13,7 @@ namespace Raylib_cs; public static unsafe partial class Raylib { /// - /// Used by DllImport to load the native library + /// Used by LibraryImport to load the native library /// public const string NativeLibName = "raylib"; @@ -32,201 +35,250 @@ public static unsafe partial class Raylib // Window-related functions /// Initialize window and OpenGL context - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void InitWindow(int width, int height, sbyte* title); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void InitWindow(int width, int height, sbyte* title); /// Check if KEY_ESCAPE pressed or Close icon pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool WindowShouldClose(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool WindowShouldClose(); /// Close window and unload OpenGL context - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CloseWindow(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CloseWindow(); /// Check if window has been initialized successfully - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowReady(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsWindowReady(); /// Check if window is currently fullscreen - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowFullscreen(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsWindowFullscreen(); /// Check if window is currently hidden - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowHidden(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsWindowHidden(); /// Check if window is currently minimized - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowMinimized(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsWindowMinimized(); /// Check if window is currently maximized - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowMaximized(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsWindowMaximized(); /// Check if window is currently focused - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowFocused(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsWindowFocused(); /// Check if window has been resized last frame - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowResized(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsWindowResized(); /// Check if one specific window flag is enabled - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowState(ConfigFlags flag); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsWindowState(ConfigFlags flag); /// Set window configuration state using flags - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool SetWindowState(ConfigFlags flag); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool SetWindowState(ConfigFlags flag); /// Clear window configuration state flags - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ClearWindowState(ConfigFlags flag); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ClearWindowState(ConfigFlags flag); /// Toggle window state: fullscreen/windowed, resizes monitor to match window resolution - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ToggleFullscreen(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ToggleFullscreen(); /// Toggle window state: borderless windowed, resizes window to match monitor resolution - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ToggleBorderlessWindowed(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ToggleBorderlessWindowed(); /// Set window state: maximized, if resizable - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void MaximizeWindow(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void MaximizeWindow(); /// Set window state: minimized, if resizable - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void MinimizeWindow(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void MinimizeWindow(); /// Set window state: not minimized/maximized - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void RestoreWindow(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RestoreWindow(); /// Set icon for window (single image, RGBA 32bit) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowIcon(Image image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetWindowIcon(Image image); /// Set icon for window (multiple images, RGBA 32bit) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowIcons(Image* images, int count); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetWindowIcons(Image* images, int count); /// Set title for window - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowTitle(sbyte* title); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetWindowTitle(sbyte* title); /// Set window position on screen - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowPosition(int x, int y); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetWindowPosition(int x, int y); /// Set monitor for the current window (fullscreen mode) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowMonitor(int monitor); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetWindowMonitor(int monitor); /// Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowMinSize(int width, int height); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetWindowMaxSize(int width, int height); /// Set window dimensions - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowSize(int width, int height); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetWindowSize(int width, int height); /// Set window opacity [0.0f..1.0f] - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowOpacity(float opacity); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetWindowOpacity(float opacity); /// Set window focused - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowFocused(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetWindowFocused(); /// Get native window handle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void* GetWindowHandle(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void* GetWindowHandle(); /// Get current screen width - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetScreenWidth(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetScreenWidth(); /// Get current screen height - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetScreenHeight(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetScreenHeight(); /// Get current render width (it considers HiDPI) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetRenderWidth(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetRenderWidth(); /// Get current render height (it considers HiDPI) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetRenderHeight(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetRenderHeight(); /// Get number of connected monitors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMonitorCount(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetMonitorCount(); /// Get current monitor where window is placed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetCurrentMonitor(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetCurrentMonitor(); /// Get specified monitor position - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetMonitorPosition(int monitor); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetMonitorPosition(int monitor); /// Get specified monitor width - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMonitorWidth(int monitor); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetMonitorWidth(int monitor); /// Get specified monitor height - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMonitorHeight(int monitor); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetMonitorHeight(int monitor); /// Get specified monitor physical width in millimetres - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMonitorPhysicalWidth(int monitor); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetMonitorPhysicalWidth(int monitor); /// Get specified monitor physical height in millimetres - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMonitorPhysicalHeight(int monitor); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetMonitorPhysicalHeight(int monitor); /// Get specified monitor refresh rate - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMonitorRefreshRate(int monitor); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetMonitorRefreshRate(int monitor); /// Get window position XY on monitor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetWindowPosition(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetWindowPosition(); /// Get window scale DPI factor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetWindowScaleDPI(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetWindowScaleDPI(); /// Get the human-readable, UTF-8 encoded name of the specified monitor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetMonitorName(int monitor); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetMonitorName(int monitor); /// Get clipboard text content - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetClipboardText(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetClipboardText(); /// Get clipboard image content (only works on Windows) [UnsupportedOSPlatform("browser")] - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GetClipboardImage(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image GetClipboardImage(); /// Set clipboard text content - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetClipboardText(sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetClipboardText(sbyte* text); /// Enable waiting for events on EndDrawing(), no automatic event polling - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableEventWaiting(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableEventWaiting(); /// Disable waiting for events on EndDrawing(), automatic events polling - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableEventWaiting(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableEventWaiting(); // Custom frame control functions // NOTE: Those functions are intended for advance users that want full control over the frame processing @@ -234,151 +286,185 @@ public static unsafe partial class Raylib // To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL /// Swap back buffer with front buffer (screen drawing) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SwapScreenBuffer(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SwapScreenBuffer(); /// Register all input events - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PollInputEvents(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void PollInputEvents(); /// Wait for some time (halt program execution) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void WaitTime(double seconds); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void WaitTime(double seconds); // Cursor-related functions /// Shows cursor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ShowCursor(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ShowCursor(); /// Hides cursor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void HideCursor(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void HideCursor(); /// Check if cursor is not visible - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsCursorHidden(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsCursorHidden(); /// Enables cursor (unlock cursor) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableCursor(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableCursor(); /// Disables cursor (lock cursor) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableCursor(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableCursor(); /// Check if cursor is on the screen - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsCursorOnScreen(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsCursorOnScreen(); // Drawing-related functions /// Set background color (framebuffer clear color) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ClearBackground(Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ClearBackground(Color color); /// Setup canvas (framebuffer) to start drawing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginDrawing(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void BeginDrawing(); /// End canvas drawing and swap buffers (double buffering) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndDrawing(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EndDrawing(); /// Initialize 2D mode with custom camera (2D) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginMode2D(Camera2D camera); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void BeginMode2D(Camera2D camera); /// Ends 2D mode with custom camera - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndMode2D(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EndMode2D(); /// Initializes 3D mode with custom camera (3D) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginMode3D(Camera3D camera); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void BeginMode3D(Camera3D camera); /// Ends 3D mode and returns to default 2D orthographic mode - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndMode3D(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EndMode3D(); /// Initializes render texture for drawing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginTextureMode(RenderTexture2D target); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void BeginTextureMode(RenderTexture2D target); /// Ends drawing to render texture - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndTextureMode(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EndTextureMode(); /// Begin custom shader drawing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginShaderMode(Shader shader); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void BeginShaderMode(Shader shader); /// End custom shader drawing (use default shader) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndShaderMode(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EndShaderMode(); /// Begin blending mode (alpha, additive, multiplied) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginBlendMode(BlendMode mode); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void BeginBlendMode(BlendMode mode); /// End blending mode (reset to default: alpha blending) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndBlendMode(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EndBlendMode(); /// Begin scissor mode (define screen area for following drawing) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginScissorMode(int x, int y, int width, int height); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void BeginScissorMode(int x, int y, int width, int height); /// End scissor mode - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndScissorMode(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EndScissorMode(); /// Begin stereo rendering (requires VR simulator) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginVrStereoMode(VrStereoConfig config); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void BeginVrStereoMode(VrStereoConfig config); /// End stereo rendering (requires VR simulator) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndVrStereoMode(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EndVrStereoMode(); // VR stereo config functions for VR simulator /// Load VR stereo config for VR simulator device parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device); /// Unload VR stereo configs - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadVrStereoConfig(VrStereoConfig config); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadVrStereoConfig(VrStereoConfig config); // Shader management functions /// Load shader from files and bind default locations - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Shader LoadShader(sbyte* vsFileName, sbyte* fsFileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Shader LoadShader(sbyte* vsFileName, sbyte* fsFileName); /// Load shader from code strings and bind default locations - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Shader LoadShaderFromMemory(sbyte* vsCode, sbyte* fsCode); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Shader LoadShaderFromMemory(sbyte* vsCode, sbyte* fsCode); /// Check if a shader is valid (loaded on GPU) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsShaderValid(Shader shader); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsShaderValid(Shader shader); /// Get shader uniform location - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetShaderLocation(Shader shader, sbyte* uniformName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetShaderLocation(Shader shader, sbyte* uniformName); /// Get shader attribute location - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetShaderLocationAttrib(Shader shader, sbyte* attribName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetShaderLocationAttrib(Shader shader, sbyte* attribName); /// Set shader uniform value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValue( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetShaderValue( Shader shader, int locIndex, void* value, @@ -386,8 +472,9 @@ public static unsafe partial class Raylib ); /// Set shader uniform value vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValueV( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetShaderValueV( Shader shader, int locIndex, void* value, @@ -396,331 +483,407 @@ public static unsafe partial class Raylib ); /// Set shader uniform value (matrix 4x4) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValueMatrix(Shader shader, int locIndex, Matrix4x4 mat); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetShaderValueMatrix(Shader shader, int locIndex, Matrix4x4 mat); /// Set shader uniform value for texture (sampler2d) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture); /// Unload shader from GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadShader(Shader shader); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadShader(Shader shader); // Screen-space-related functions /// Get a ray trace from screen position (i.e mouse) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Ray GetScreenToWorldRay(Vector2 position, Camera3D camera); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Ray GetScreenToWorldRay(Vector2 position, Camera3D camera); /// Get a ray trace from screen position (i.e mouse) in a viewport - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Ray GetScreenToWorldRayEx(Vector2 position, Camera3D camera, int width, int height); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Ray GetScreenToWorldRayEx(Vector2 position, Camera3D camera, int width, int height); /// Get camera transform matrix (view matrix) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetCameraMatrix(Camera3D camera); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 GetCameraMatrix(Camera3D camera); /// Get camera 2d transform matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetCameraMatrix2D(Camera2D camera); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 GetCameraMatrix2D(Camera2D camera); /// Get the screen space position for a 3d world space position - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetWorldToScreen(Vector3 position, Camera3D camera); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetWorldToScreen(Vector3 position, Camera3D camera); /// Get size position for a 3d world space position - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetWorldToScreenEx(Vector3 position, Camera3D camera, int width, int height); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetWorldToScreenEx(Vector3 position, Camera3D camera, int width, int height); /// Get the screen space position for a 2d camera world space position - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); /// Get the world space position for a 2d camera screen space position - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Timing-related functions /// Set target FPS (maximum) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetTargetFPS(int fps); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetTargetFPS(int fps); /// Get current FPS - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetFPS(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetFPS(); /// Get time in seconds for last frame drawn - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetFrameTime(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float GetFrameTime(); /// Get elapsed time in seconds since InitWindow() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern double GetTime(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetTime(); // Misc. functions /// Get a random value between min and max (both included) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetRandomValue(int min, int max); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetRandomValue(int min, int max); /// Set the seed for the random number generator - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SetRandomSeed(uint seed); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int SetRandomSeed(uint seed); /// Load random values sequence, no values repeated - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int* LoadRandomSequence(uint count, int min, int max); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int* LoadRandomSequence(uint count, int min, int max); /// Unload random values sequence - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadRandomSequence(int* sequence); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void TakeScreenshot(sbyte* fileName); /// Setup window configuration flags (view FLAGS) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetConfigFlags(ConfigFlags flags); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetConfigFlags(ConfigFlags flags); /// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void TraceLog(TraceLogLevel logLevel, sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void TraceLog(TraceLogLevel logLevel, sbyte* text); /// Set the current threshold (minimum) log level - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetTraceLogLevel(TraceLogLevel logLevel); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetTraceLogLevel(TraceLogLevel logLevel); /// Internal memory allocator - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void* MemAlloc(uint size); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void* MemAlloc(uint size); /// Internal memory reallocator - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void* MemRealloc(void* ptr, uint size); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void* MemRealloc(void* ptr, uint size); /// Internal memory free - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void MemFree(void* ptr); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void MemFree(void* ptr); // Set custom callbacks // WARNING: Callbacks setup is intended for advance users /// Set custom trace log - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetTraceLogCallback(delegate* unmanaged[Cdecl] callback); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetTraceLogCallback(delegate* unmanaged[Cdecl] callback); /// Set custom file binary data loader - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetLoadFileDataCallback(delegate* unmanaged[Cdecl] callback); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetLoadFileDataCallback(delegate* unmanaged[Cdecl] callback); /// Set custom file binary data saver - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetSaveFileDataCallback( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSaveFileDataCallback( delegate* unmanaged[Cdecl] callback ); /// Set custom file text data loader - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetLoadFileTextCallback(delegate* unmanaged[Cdecl] callback); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetLoadFileTextCallback(delegate* unmanaged[Cdecl] callback); /// Set custom file text data saver - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetSaveFileTextCallback(delegate* unmanaged[Cdecl] callback); + [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) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern byte* LoadFileData(sbyte* fileName, int* dataSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial byte* LoadFileData(sbyte* fileName, int* dataSize); /// Unload file data allocated by LoadFileData() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadFileData(byte* data); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadFileData(byte* data); /// Save data to file from byte array (write), returns true on success - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool SaveFileData(sbyte* fileName, void* data, int dataSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool SaveFileData(sbyte* fileName, void* data, int dataSize); /// Export data to code (.h), returns true on success - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportDataAsCode(byte* data, int dataSize, sbyte* fileName); + [LibraryImport(NativeLibName)] + [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 - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* LoadFileText(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* LoadFileText(sbyte* fileName); // Unload file text data allocated by LoadFileText() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadFileText(sbyte* text); + [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 - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool SaveFileText(sbyte* fileName, sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool SaveFileText(sbyte* fileName, sbyte* text); // Check if file exists - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool FileExists(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool FileExists(sbyte* fileName); // Check if a directory path exists - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool DirectoryExists(sbyte* dirPath); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool DirectoryExists(sbyte* dirPath); /// Check file extension (including point: .png, .wav) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsFileExtension(sbyte* fileName, sbyte* ext); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsFileExtension(sbyte* fileName, sbyte* ext); /// Get file length in bytes - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetFileLength(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetFileLength(sbyte* fileName); /// Get pointer to extension for a filename string (includes dot: '.png') - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetFileExtension(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetFileExtension(sbyte* fileName); /// Get pointer to filename for a path string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetFileName(sbyte* filePath); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetFileName(sbyte* filePath); /// Get filename string without extension (uses static string) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetFileNameWithoutExt(sbyte* filePath); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetFileNameWithoutExt(sbyte* filePath); /// Get full path for a given fileName with path (uses static string) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetDirectoryPath(sbyte* filePath); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetDirectoryPath(sbyte* filePath); /// Get previous directory path for a given path (uses static string) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetPrevDirectoryPath(sbyte* dirPath); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetPrevDirectoryPath(sbyte* dirPath); /// Get current working directory (uses static string) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetWorkingDirectory(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetWorkingDirectory(); /// Get the directory of the running application (uses static string) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetApplicationDirectory(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetApplicationDirectory(); /// Create directories (including full path requested), returns 0 on success - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int MakeDirectory(sbyte* dirPath); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int MakeDirectory(sbyte* dirPath); /// Load directory filepaths - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern FilePathList LoadDirectoryFiles(sbyte* dirPath, int* count); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial FilePathList LoadDirectoryFiles(sbyte* dirPath, int* count); /// Load directory filepaths with extension filtering and recursive directory scan. Use 'DIR' in the filter string to include directories in the result - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern FilePathList LoadDirectoryFilesEx(sbyte* basePath, sbyte* filter, CBool scanSubdirs); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial FilePathList LoadDirectoryFilesEx(sbyte* basePath, sbyte* filter, CBool scanSubdirs); /// Unload filepaths - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadDirectoryFiles(FilePathList files); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadDirectoryFiles(FilePathList files); /// Check if a given path is a file or a directory - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsPathFile(sbyte* path); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsPathFile(sbyte* path); /// Check if fileName is valid for the platform/OS - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsFileNameValid(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsFileNameValid(sbyte* fileName); /// Change working directory, return true on success - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ChangeDirectory(sbyte* dir); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool ChangeDirectory(sbyte* dir); /// Check if a file has been dropped into window - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsFileDropped(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsFileDropped(); /// Load dropped filepaths - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern FilePathList LoadDroppedFiles(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial FilePathList LoadDroppedFiles(); /// Unload dropped filepaths - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadDroppedFiles(FilePathList files); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadDroppedFiles(FilePathList files); /// Get file modification time (last write time) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern long GetFileModTime(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial long GetFileModTime(sbyte* fileName); // Compression/Encoding functionality /// Compress data (DEFLATE algorithm), memory must be MemFree() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern byte* CompressData(byte* data, int dataSize, int* compDataSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial byte* CompressData(byte* data, int dataSize, int* compDataSize); /// Decompress data (DEFLATE algorithm), memory must be MemFree() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern byte* DecompressData(byte* compData, int compDataSize, int* dataSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial byte* DecompressData(byte* compData, int compDataSize, int* dataSize); /// Encode data to Base64 string, memory must be MemFree() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* EncodeDataBase64(byte* data, int dataSize, int* outputSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* EncodeDataBase64(byte* data, int dataSize, int* outputSize); /// Decode Base64 string data, memory must be MemFree() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern byte* DecodeDataBase64(byte* data, int* outputSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial byte* DecodeDataBase64(byte* data, int* outputSize); /// Compute CRC32 hash code - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern uint ComputeCRC32(byte* data, int dataSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint ComputeCRC32(byte* data, int dataSize); /// Compute MD5 hash code, returns static int[4] (16 bytes) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern uint* ComputeMD5(byte* data, int dataSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint* ComputeMD5(byte* data, int dataSize); /// Compute SHA1 hash code, returns static int[5] (20 bytes) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern uint* ComputeSHA1(byte* data, int dataSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint* ComputeSHA1(byte* data, int dataSize); /// Open URL with default system browser (if available) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void OpenURL(sbyte* url); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void OpenURL(sbyte* url); // Automation events functionality /// Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern AutomationEventList LoadAutomationEventList(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial AutomationEventList LoadAutomationEventList(sbyte* fileName); /// Unload automation events list from file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadAutomationEventList(AutomationEventList list); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadAutomationEventList(AutomationEventList list); /// Export automation events list as text file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportAutomationEventList(AutomationEventList list, sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool ExportAutomationEventList(AutomationEventList list, sbyte* fileName); /// Set automation event list to record to - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetAutomationEventList(AutomationEventList* list); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAutomationEventList(AutomationEventList* list); /// Set automation event internal base frame to start recording - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetAutomationEventBaseFrame(int frame); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAutomationEventBaseFrame(int frame); /// Start recording automation events (AutomationEventList must be set) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void StartAutomationEventRecording(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void StartAutomationEventRecording(); /// Stop recording automation events - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void StopAutomationEventRecording(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void StopAutomationEventRecording(); /// Play a recorded automation event - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PlayAutomationEvent(AutomationEvent ev); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void PlayAutomationEvent(AutomationEvent ev); //------------------------------------------------------------------------------------ // Input Handling Functions (Module: core) @@ -729,204 +892,250 @@ public static unsafe partial class Raylib // Input-related functions: keyboard /// Detect if a key has been pressed once - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsKeyPressed(KeyboardKey key); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsKeyPressed(KeyboardKey key); /// Detect if a key has been pressed again - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsKeyPressedRepeat(KeyboardKey key); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsKeyPressedRepeat(KeyboardKey key); /// Detect if a key is being pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsKeyDown(KeyboardKey key); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsKeyDown(KeyboardKey key); /// Detect if a key has been released once - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsKeyReleased(KeyboardKey key); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsKeyReleased(KeyboardKey key); /// Detect if a key is NOT being pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsKeyUp(KeyboardKey key); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsKeyUp(KeyboardKey key); /// Set a custom key to exit program (default is ESC) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetExitKey(KeyboardKey key); + [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 /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetKeyPressed(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetKeyPressed(); /// /// Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetCharPressed(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetCharPressed(); // Input-related functions: gamepads /// Detect if a gamepad is available - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsGamepadAvailable(int gamepad); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsGamepadAvailable(int gamepad); /// Get gamepad internal name id - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetGamepadName(int gamepad); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetGamepadName(int gamepad); /// Detect if a gamepad button has been pressed once - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsGamepadButtonPressed(int gamepad, GamepadButton button); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsGamepadButtonPressed(int gamepad, GamepadButton button); /// Detect if a gamepad button is being pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsGamepadButtonDown(int gamepad, GamepadButton button); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsGamepadButtonDown(int gamepad, GamepadButton button); /// Detect if a gamepad button has been released once - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsGamepadButtonReleased(int gamepad, GamepadButton button); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsGamepadButtonReleased(int gamepad, GamepadButton button); /// Detect if a gamepad button is NOT being pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsGamepadButtonUp(int gamepad, GamepadButton button); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsGamepadButtonUp(int gamepad, GamepadButton button); /// Get the last gamepad button pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetGamepadButtonPressed(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetGamepadButtonPressed(); /// Get gamepad axis count for a gamepad - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetGamepadAxisCount(int gamepad); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetGamepadAxisCount(int gamepad); /// Get axis movement value for a gamepad axis - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetGamepadAxisMovement(int gamepad, GamepadAxis axis); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float GetGamepadAxisMovement(int gamepad, GamepadAxis axis); /// Set internal gamepad mappings (SDL_GameControllerDB) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SetGamepadMappings(sbyte* mappings); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int SetGamepadMappings(sbyte* mappings); /// Set gamepad vibration for both motors (duration in seconds) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration); // Input-related functions: mouse /// Detect if a mouse button has been pressed once - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMouseButtonPressed(MouseButton button); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsMouseButtonPressed(MouseButton button); /// Detect if a mouse button is being pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMouseButtonDown(MouseButton button); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsMouseButtonDown(MouseButton button); /// Detect if a mouse button has been released once - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMouseButtonReleased(MouseButton button); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsMouseButtonReleased(MouseButton button); /// Detect if a mouse button is NOT being pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMouseButtonUp(MouseButton button); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsMouseButtonUp(MouseButton button); /// Get mouse position X - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMouseX(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetMouseX(); /// Get mouse position Y - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMouseY(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetMouseY(); /// Get mouse position XY - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetMousePosition(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetMousePosition(); /// Get mouse delta between frames - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetMouseDelta(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetMouseDelta(); /// Set mouse position XY - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMousePosition(int x, int y); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMousePosition(int x, int y); /// Set mouse offset - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMouseOffset(int offsetX, int offsetY); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMouseOffset(int offsetX, int offsetY); /// Set mouse scaling - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMouseScale(float scaleX, float scaleY); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMouseScale(float scaleX, float scaleY); /// Get mouse wheel movement for X or Y, whichever is larger - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetMouseWheelMove(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float GetMouseWheelMove(); /// Get mouse wheel movement for both X and Y - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetMouseWheelMoveV(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetMouseWheelMoveV(); /// Set mouse cursor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMouseCursor(MouseCursor cursor); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMouseCursor(MouseCursor cursor); // Input-related functions: touch /// Get touch position X for touch point 0 (relative to screen size) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetTouchX(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetTouchX(); /// Get touch position Y for touch point 0 (relative to screen size) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetTouchY(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetTouchY(); /// Get touch position XY for a touch point index (relative to screen size) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetTouchPosition(int index); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetTouchPosition(int index); /// Get touch point identifier for given index - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetTouchPointId(int index); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetTouchPointId(int index); /// Get number of touch points - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetTouchPointCount(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetTouchPointCount(); //------------------------------------------------------------------------------------ // Gestures and Touch Handling Functions (Module: gestures) //------------------------------------------------------------------------------------ /// Enable a set of gestures using flags - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetGesturesEnabled(Gesture flags); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetGesturesEnabled(Gesture flags); /// Check if a gesture has been detected - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsGestureDetected(Gesture gesture); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsGestureDetected(Gesture gesture); /// Get latest detected gesture - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Gesture GetGestureDetected(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Gesture GetGestureDetected(); /// Get gesture hold time in seconds - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetGestureHoldDuration(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float GetGestureHoldDuration(); /// Get gesture drag vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetGestureDragVector(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetGestureDragVector(); /// Get gesture drag angle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetGestureDragAngle(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float GetGestureDragAngle(); /// Get gesture pinch delta - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetGesturePinchVector(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetGesturePinchVector(); /// Get gesture pinch angle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetGesturePinchAngle(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float GetGesturePinchAngle(); //------------------------------------------------------------------------------------ @@ -934,46 +1143,55 @@ public static unsafe partial class Raylib //------------------------------------------------------------------------------------ /// Update camera position for selected mode - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateCamera(Camera3D* camera, CameraMode mode); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateCamera(Camera3D* camera, CameraMode mode); /// Update camera movement/rotation - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateCameraPro(Camera3D* camera, Vector3 movement, Vector3 rotation, float zoom); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateCameraPro(Camera3D* camera, Vector3 movement, Vector3 rotation, float zoom); /// Returns the cameras forward vector (normalized) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 GetCameraForward(Camera3D* camera); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 GetCameraForward(Camera3D* camera); /// /// Returns the cameras up vector (normalized)
/// NOTE: The up vector might not be perpendicular to the forward vector ///
- [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 GetCameraUp(Camera3D* camera); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 GetCameraUp(Camera3D* camera); /// Returns the cameras right vector (normalized) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 GetCameraRight(Camera3D* camera); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 GetCameraRight(Camera3D* camera); // Camera movement /// Moves the camera in its forward direction - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CameraMoveForward(Camera3D* camera, float distance, CBool moveInWorldPlane); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CameraMoveForward(Camera3D* camera, float distance, CBool moveInWorldPlane); /// Moves the camera in its up direction - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CameraMoveUp(Camera3D* camera, float distance); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CameraMoveUp(Camera3D* camera, float distance); /// Moves the camera target in its current right direction - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CameraMoveRight(Camera3D* camera, float distance, CBool moveInWorldPlane); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CameraMoveRight(Camera3D* camera, float distance, CBool moveInWorldPlane); /// Moves the camera position closer/farther to/from the camera target - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CameraMoveToTarget(Camera3D* camera, float delta); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CameraMoveToTarget(Camera3D* camera, float delta); // Camera rotation @@ -982,14 +1200,16 @@ public static unsafe partial class Raylib /// Rotates the camera around its up vector
/// If rotateAroundTarget is false, the camera rotates around its position /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CameraYaw(Camera3D* camera, float angle, CBool rotateAroundTarget); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CameraYaw(Camera3D* camera, float angle, CBool rotateAroundTarget); /// /// Rotates the camera around its right vector /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CameraPitch( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CameraPitch( Camera3D* camera, float angle, CBool lockView, @@ -998,16 +1218,19 @@ public static unsafe partial class Raylib ); /// Rotates the camera around its forward vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CameraRoll(Camera3D* camera, float angle); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CameraRoll(Camera3D* camera, float angle); /// Returns the camera view matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetCameraViewMatrix(Camera3D* camera); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 GetCameraViewMatrix(Camera3D* camera); /// Returns the camera projection matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetCameraProjectionMatrix(Camera3D* camera, float aspect); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 GetCameraProjectionMatrix(Camera3D* camera, float aspect); //------------------------------------------------------------------------------------ @@ -1019,54 +1242,66 @@ public static unsafe partial class Raylib /// NOTE: It can be useful when using basic shapes and one single font.
/// Defining a white rectangle would allow drawing everything in a single draw call. /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShapesTexture(Texture2D texture, Rectangle source); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetShapesTexture(Texture2D texture, Rectangle source); /// Get texture that is used for shapes drawing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Texture2D GetShapesTexture(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Texture2D GetShapesTexture(); /// Get texture source rectangle that is used for shapes drawing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Rectangle GetShapesTextureRectangle(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Rectangle GetShapesTextureRectangle(); // Basic shapes drawing functions /// Draw a pixel using geometry [Can be slow, use with care] - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawPixel(int posX, int posY, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawPixel(int posX, int posY, Color color); /// Draw a pixel using geometry (Vector version) [Can be slow, use with care] - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawPixelV(Vector2 position, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawPixelV(Vector2 position, Color color); /// Draw a line - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); /// Draw a line (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); /// Draw a line defining thickness - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); + [LibraryImport(NativeLibName)] + [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 - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); /// Draw lines sequence - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawLineStrip(Vector2* points, int pointCount, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawLineStrip(Vector2* points, int pointCount, Color color); /// Draw a color-filled circle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCircle(int centerX, int centerY, float radius, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCircle(int centerX, int centerY, float radius, Color color); /// Draw a piece of a circle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCircleSector( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCircleSector( Vector2 center, float radius, float startAngle, @@ -1076,8 +1311,9 @@ public static unsafe partial class Raylib ); /// Draw circle sector outline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCircleSectorLines( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCircleSectorLines( Vector2 center, float radius, float startAngle, @@ -1087,8 +1323,9 @@ public static unsafe partial class Raylib ); /// Draw a gradient-filled circle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCircleGradient( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCircleGradient( int centerX, int centerY, float radius, @@ -1097,28 +1334,34 @@ public static unsafe partial class Raylib ); /// Draw a color-filled circle (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCircleV(Vector2 center, float radius, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCircleV(Vector2 center, float radius, Color color); /// Draw circle outline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCircleLines(int centerX, int centerY, float radius, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color); /// Draw ellipse outline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color); /// Draw ring - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRing( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRing( Vector2 center, float innerRadius, float outerRadius, @@ -1129,8 +1372,9 @@ public static unsafe partial class Raylib ); /// Draw ring outline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRingLines( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRingLines( Vector2 center, float innerRadius, float outerRadius, @@ -1141,24 +1385,29 @@ public static unsafe partial class Raylib ); /// Draw a color-filled rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangle(int posX, int posY, int width, int height, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRectangle(int posX, int posY, int width, int height, Color color); /// Draw a color-filled rectangle (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleV(Vector2 position, Vector2 size, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRectangleV(Vector2 position, Vector2 size, Color color); /// Draw a color-filled rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleRec(Rectangle rec, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRectangleRec(Rectangle rec, Color color); /// Draw a color-filled rectangle with pro parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); /// Draw a vertical-gradient-filled rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleGradientV( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRectangleGradientV( int posX, int posY, int width, @@ -1168,8 +1417,9 @@ public static unsafe partial class Raylib ); /// Draw a horizontal-gradient-filled rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleGradientH( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRectangleGradientH( int posX, int posY, int width, @@ -1179,8 +1429,9 @@ public static unsafe partial class Raylib ); /// Draw a gradient-filled rectangle with custom vertex colors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleGradientEx( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRectangleGradientEx( Rectangle rec, Color topLeft, Color bottomLeft, @@ -1189,20 +1440,24 @@ public static unsafe partial class Raylib ); /// Draw rectangle outline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleLines(int posX, int posY, int width, int height, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRectangleLines(int posX, int posY, int width, int height, Color color); /// Draw rectangle outline with extended parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleLinesEx(Rectangle rec, float lineThick, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRectangleLinesEx(Rectangle rec, float lineThick, Color color); /// Draw rectangle with rounded edges - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color); /// Draw rectangle lines with rounded edges - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleRoundedLines( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRectangleRoundedLines( Rectangle rec, float roundness, int segments, @@ -1210,8 +1465,9 @@ public static unsafe partial class Raylib ); /// Draw rectangle with rounded edges outline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleRoundedLinesEx( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRectangleRoundedLinesEx( Rectangle rec, float roundness, int segments, @@ -1220,32 +1476,39 @@ public static unsafe partial class Raylib ); /// Draw a color-filled triangle (vertex in counter-clockwise order!) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); /// Draw triangle outline (vertex in counter-clockwise order!) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); /// Draw a triangle fan defined by points (first vertex is the center) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTriangleFan(Vector2* points, int pointCount, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTriangleFan(Vector2* points, int pointCount, Color color); /// Draw a triangle strip defined by points - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTriangleStrip(Vector2* points, int pointCount, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTriangleStrip(Vector2* points, int pointCount, Color color); /// Draw a regular polygon (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); /// Draw a polygon outline of n sides - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color); /// Draw a polygon outline of n sides with extended parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawPolyLinesEx( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawPolyLinesEx( Vector2 center, int sides, float radius, @@ -1257,76 +1520,93 @@ public static unsafe partial class Raylib // 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 GetSplinePointBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vector2 p4, float t); // Basic shapes collision detection functions /// Check collision between two rectangles - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); /// Check collision between two circles - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionCircles( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionCircles( Vector2 center1, float radius1, Vector2 center2, @@ -1334,34 +1614,41 @@ public static unsafe partial class Raylib ); /// Check collision between circle and rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); /// Check if circle collides with a line created betweeen two points [p1] and [p2] - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionCircleLine(Vector2 center, float radius, Vector2 p1, Vector2 p2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionCircleLine(Vector2 center, float radius, Vector2 p1, Vector2 p2); /// Check if point is inside rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionPointRec(Vector2 point, Rectangle rec); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionPointRec(Vector2 point, Rectangle rec); /// Check if point is inside circle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); /// Check if point is inside a triangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); /// Check if point is within a polygon described by array of vertices - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionPointPoly(Vector2 point, Vector2* points, int pointCount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionPointPoly(Vector2 point, Vector2* points, int pointCount); /// /// Check the collision between two lines defined by two points each, returns collision point by reference /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionLines( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionLines( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, @@ -1372,12 +1659,14 @@ public static unsafe partial class Raylib /// /// Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshold); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshold); /// Get collision rectangle for two rectangles collision - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); //------------------------------------------------------------------------------------ @@ -1388,12 +1677,14 @@ public static unsafe partial class Raylib // NOTE: This functions do not require GPU access /// Load image from file into CPU memory (RAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image LoadImage(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image LoadImage(sbyte* fileName); /// Load image from RAW file data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image LoadImageRaw( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image LoadImageRaw( sbyte* fileName, int width, int height, @@ -1402,55 +1693,67 @@ public static unsafe partial class Raylib ); /// Load image sequence from file (frames appended to image.data) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image LoadImageAnim(sbyte* fileName, int* frames); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image LoadImageAnim(sbyte* fileName, int* frames); /// Load image from memory buffer, fileType refers to extension: i.e. ".png" - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image LoadImageFromMemory(sbyte* fileType, byte* fileData, int dataSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image LoadImageFromMemory(sbyte* fileType, byte* fileData, int dataSize); /// Load image from GPU texture data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image LoadImageFromTexture(Texture2D texture); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image LoadImageFromTexture(Texture2D texture); /// Load image from screen buffer and (screenshot) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image LoadImageFromScreen(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image LoadImageFromScreen(); /// Check if an image is valid (data and parameters) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsImageValid(Image image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsImageValid(Image image); /// Unload image from CPU memory (RAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadImage(Image image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadImage(Image image); /// Export image data to file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportImage(Image image, sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool ExportImage(Image image, sbyte* fileName); /// Export image to memory buffer - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern byte* ExportImageToMemory(Image image, sbyte* fileType, int* fileSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial byte* ExportImageToMemory(Image image, sbyte* 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool ExportImageAsCode(Image image, sbyte* fileName); // Image generation functions /// Generate image: plain color - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageColor(int width, int height, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image GenImageColor(int width, int height, Color color); /// Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageGradientLinear(int width, int height, int direction, Color start, Color end); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image GenImageGradientLinear(int width, int height, int direction, Color start, Color end); /// Generate image: radial gradient - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageGradientRadial( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image GenImageGradientRadial( int width, int height, float density, @@ -1459,8 +1762,9 @@ public static unsafe partial class Raylib ); /// Generate image: square gradient - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageGradientSquare( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image GenImageGradientSquare( int width, int height, float density, @@ -1468,8 +1772,9 @@ public static unsafe partial class Raylib Color outer); /// Generate image: checked - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageChecked( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image GenImageChecked( int width, int height, int checksX, @@ -1479,91 +1784,112 @@ public static unsafe partial class Raylib ); /// Generate image: white noise - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageWhiteNoise(int width, int height, float factor); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image GenImageWhiteNoise(int width, int height, float factor); /// Generate image: perlin noise - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); /// Generate image: cellular algorithm, bigger tileSize means bigger cells - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageCellular(int width, int height, int tileSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image GenImageCellular(int width, int height, int tileSize); /// Generate image: grayscale image from text data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageText(int width, int height, sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image GenImageText(int width, int height, sbyte* text); // Image manipulation functions /// Create an image duplicate (useful for transformations) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image ImageCopy(Image image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image ImageCopy(Image image); /// Create an image from another image piece - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image ImageFromImage(Image image, Rectangle rec); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image ImageFromImage(Image image, Rectangle rec); /// Create an image from a selected channel of another image (GRAYSCALE) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image ImageFromChannel(Image image, int selectedChannel); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image ImageFromChannel(Image image, int selectedChannel); /// Create an image from text (default font) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image ImageText(sbyte* text, int fontSize, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image ImageText(sbyte* text, int fontSize, Color color); /// Create an image from text (custom sprite font) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image ImageTextEx(Font font, sbyte* text, float fontSize, float spacing, Color tint); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image ImageTextEx(Font font, sbyte* text, float fontSize, float spacing, Color tint); /// Convert image data to desired format - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageFormat(Image* image, PixelFormat newFormat); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageFormat(Image* image, PixelFormat newFormat); /// Convert image to POT (power-of-two) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageToPOT(Image* image, Color fill); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageToPOT(Image* image, Color fill); /// Crop an image to a defined rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageCrop(Image* image, Rectangle crop); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageCrop(Image* image, Rectangle crop); /// Crop image depending on alpha value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageAlphaCrop(Image* image, float threshold); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageAlphaCrop(Image* image, float threshold); /// Clear alpha channel to desired color - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageAlphaClear(Image* image, Color color, float threshold); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageAlphaClear(Image* image, Color color, float threshold); /// Apply alpha mask to image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageAlphaMask(Image* image, Image alphaMask); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageAlphaMask(Image* image, Image alphaMask); /// Premultiply alpha channel - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageAlphaPremultiply(Image* image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageAlphaPremultiply(Image* image); /// Apply Gaussian blur using a box blur approximation - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageBlurGaussian(Image* image, int blurSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageBlurGaussian(Image* image, int blurSize); /// Apply custom square convolution kernel to image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageKernelConvolution(Image* image, float* kernel, int kernelSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageKernelConvolution(Image* image, float* kernel, int kernelSize); /// Resize image (Bicubic scaling algorithm) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageResize(Image* image, int newWidth, int newHeight); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageResize(Image* image, int newWidth, int newHeight); /// Resize image (Nearest-Neighbor scaling algorithm) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageResizeNN(Image* image, int newWidth, int newHeight); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageResizeNN(Image* image, int newWidth, int newHeight); /// Resize canvas and fill with color - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageResizeCanvas( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageResizeCanvas( Image* image, int newWidth, int newHeight, @@ -1573,100 +1899,123 @@ public static unsafe partial class Raylib ); /// Generate all mipmap levels for a provided image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageMipmaps(Image* image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageMipmaps(Image* image); /// Dither image data to 16bpp or lower (Floyd-Steinberg dithering) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDither(Image* image, int rBpp, int gBpp, int bBpp, int aBpp); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDither(Image* image, int rBpp, int gBpp, int bBpp, int aBpp); /// Flip image vertically - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageFlipVertical(Image* image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageFlipVertical(Image* image); /// Flip image horizontally - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageFlipHorizontal(Image* image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageRotate(Image* image, int degrees); /// Rotate image clockwise 90deg - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageRotateCW(Image* image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageRotateCW(Image* image); /// Rotate image counter-clockwise 90deg - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageRotateCCW(Image* image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageRotateCCW(Image* image); /// Modify image color: tint - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorTint(Image* image, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageColorTint(Image* image, Color color); /// Modify image color: invert - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorInvert(Image* image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageColorInvert(Image* image); /// Modify image color: grayscale - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorGrayscale(Image* image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageColorGrayscale(Image* image); /// Modify image color: contrast (-100 to 100) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorContrast(Image* image, float contrast); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageColorContrast(Image* image, float contrast); /// Modify image color: brightness (-255 to 255) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorBrightness(Image* image, int brightness); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageColorBrightness(Image* image, int brightness); /// Modify image color: replace color - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorReplace(Image* image, Color color, Color replace); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageColorReplace(Image* image, Color color, Color replace); /// Load color data from image as a Color array (RGBA - 32bit) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color* LoadImageColors(Image image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color* LoadImageColors(Image image); /// Load colors palette from image as a Color array (RGBA - 32bit) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color* LoadImagePalette(Image image, int maxPaletteSize, int* colorCount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color* LoadImagePalette(Image image, int maxPaletteSize, int* colorCount); /// Unload color data loaded with LoadImageColors() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadImageColors(Color* colors); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadImageColors(Color* colors); /// Unload colors palette loaded with LoadImagePalette() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadImagePalette(Color* colors); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadImagePalette(Color* colors); /// Get image alpha border rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Rectangle GetImageAlphaBorder(Image image, float threshold); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Rectangle GetImageAlphaBorder(Image image, float threshold); /// Get image pixel color at (x, y) position - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color GetImageColor(Image image, int x, int y); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color GetImageColor(Image image, int x, int y); // Image drawing functions // NOTE: Image software-rendering functions (CPU) /// Clear image background with given color - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageClearBackground(Image* dst, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageClearBackground(Image* dst, Color color); /// Draw pixel within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawPixel(Image* dst, int posX, int posY, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawPixel(Image* dst, int posX, int posY, Color color); /// Draw pixel within an image (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawPixelV(Image* dst, Vector2 position, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawPixelV(Image* dst, Vector2 position, Color color); /// Draw line within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawLine( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawLine( Image* dst, int startPosX, int startPosY, @@ -1676,32 +2025,39 @@ public static unsafe partial class Raylib ); /// Draw line within an image (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawLineV(Image* dst, Vector2 start, Vector2 end, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawLineV(Image* dst, Vector2 start, Vector2 end, Color color); /// Draw a line defining thickness within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawLineEx(Image* dst, Vector2 start, Vector2 end, int thick, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawLineEx(Image* dst, Vector2 start, Vector2 end, int thick, Color color); /// Draw circle within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawCircle(Image* dst, int centerX, int centerY, int radius, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawCircle(Image* dst, int centerX, int centerY, int radius, Color color); /// Draw circle within an image (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawCircleV(Image* dst, Vector2 center, int radius, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawCircleV(Image* dst, Vector2 center, int radius, Color color); /// Draw circle outline within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawCircleLines(Image* dst, int centerX, int centerY, int radius, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawCircleLines(Image* dst, int centerX, int centerY, int radius, Color color); /// Draw circle outline within an image (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawCircleLinesV(Image* dst, Vector2 center, int radius, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawCircleLinesV(Image* dst, Vector2 center, int radius, Color color); /// Draw rectangle within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawRectangle( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawRectangle( Image* dst, int posX, int posY, @@ -1711,48 +2067,59 @@ public static unsafe partial class Raylib ); /// Draw rectangle within an image (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawRectangleV(Image* dst, Vector2 position, Vector2 size, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawRectangleV(Image* dst, Vector2 position, Vector2 size, Color color); /// Draw rectangle within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawRectangleRec(Image* dst, Rectangle rec, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawRectangleRec(Image* dst, Rectangle rec, Color color); /// Draw rectangle lines within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawRectangleLines(Image* dst, Rectangle rec, int thick, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawRectangleLines(Image* dst, Rectangle rec, int thick, Color color); /// Draw triangle within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawTriangle(Image* dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawTriangle(Image* dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color); /// Draw triangle with interpolated colors within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawTriangleEx(Image* dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawTriangleEx(Image* dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3); /// Draw triangle outline within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawTriangleLines(Image* dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawTriangleLines(Image* dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color); /// Draw a triangle fan defined by points within an image (first vertex is the center) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawTriangleFan(Image* dst, Vector2* points, int pointCount, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawTriangleFan(Image* dst, Vector2* points, int pointCount, Color color); /// Draw a triangle strip defined by points within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawTriangleStrip(Image* dst, Vector2* points, int pointCount, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawTriangleStrip(Image* dst, Vector2* points, int pointCount, Color color); /// Draw a source image within a destination image (tint applied to source) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDraw(Image* dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDraw(Image* dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint); /// Draw text (using default font) within an image (destination) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawText(Image* dst, sbyte* text, int x, int y, int fontSize, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawText(Image* dst, sbyte* text, int x, int y, int fontSize, Color color); /// Draw text (custom sprite font) within an image (destination) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawTextEx( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ImageDrawTextEx( Image* dst, Font font, sbyte* text, @@ -1767,74 +2134,90 @@ public static unsafe partial class Raylib // NOTE: These functions require GPU access /// Load texture from file into GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Texture2D LoadTexture(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Texture2D LoadTexture(sbyte* fileName); /// Load texture from image data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Texture2D LoadTextureFromImage(Image image); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Texture2D LoadTextureFromImage(Image image); /// Load cubemap from image, multiple image cubemap layouts supported - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Texture2D LoadTextureCubemap(Image image, CubemapLayout layout); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Texture2D LoadTextureCubemap(Image image, CubemapLayout layout); /// Load texture for rendering (framebuffer) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern RenderTexture2D LoadRenderTexture(int width, int height); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial RenderTexture2D LoadRenderTexture(int width, int height); /// Check if a texture is valid (loaded in GPU) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsTextureValid(Texture2D texture); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsTextureValid(Texture2D texture); /// Unload texture from GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadTexture(Texture2D texture); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadTexture(Texture2D texture); /// Check if a render texture is valid (loaded in GPU) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsRenderTextureValid(RenderTexture2D target); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsRenderTextureValid(RenderTexture2D target); /// Unload render texture from GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadRenderTexture(RenderTexture2D target); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadRenderTexture(RenderTexture2D target); /// Update GPU texture with new data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateTexture(Texture2D texture, void* pixels); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateTexture(Texture2D texture, void* pixels); /// Update GPU texture rectangle with new data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateTextureRec(Texture2D texture, Rectangle rec, void* pixels); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateTextureRec(Texture2D texture, Rectangle rec, void* pixels); // Texture configuration functions /// Generate GPU mipmaps for a texture - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void GenTextureMipmaps(Texture2D* texture); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GenTextureMipmaps(Texture2D* texture); /// Set texture scaling filter mode - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetTextureFilter(Texture2D texture, TextureFilter filter); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetTextureFilter(Texture2D texture, TextureFilter filter); /// Set texture wrapping mode - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetTextureWrap(Texture2D texture, TextureWrap wrap); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetTextureWrap(Texture2D texture, TextureWrap wrap); // Texture drawing functions /// Draw a Texture2D - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTexture(Texture2D texture, int posX, int posY, Color tint); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTexture(Texture2D texture, int posX, int posY, Color tint); /// Draw a Texture2D with position defined as Vector2 - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextureV(Texture2D texture, Vector2 position, Color tint); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTextureV(Texture2D texture, Vector2 position, Color tint); /// Draw a Texture2D with extended parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextureEx( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTextureEx( Texture2D texture, Vector2 position, float rotation, @@ -1843,12 +2226,14 @@ public static unsafe partial class Raylib ); /// Draw a part of a texture defined by a rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint); /// Draw a part of a texture defined by a rectangle with 'pro' parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTexturePro( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTexturePro( Texture2D texture, Rectangle source, Rectangle dest, @@ -1858,8 +2243,9 @@ public static unsafe partial class Raylib ); /// Draws a texture (or part of it) that stretches or shrinks nicely - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextureNPatch( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTextureNPatch( Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, @@ -1872,64 +2258,79 @@ public static unsafe partial class Raylib // Color/pixel related functions /// Get hexadecimal value for a Color (0xRRGGBBAA) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int ColorToInt(Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int ColorToInt(Color color); /// Get color normalized as float [0..1] - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector4 ColorNormalize(Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector4 ColorNormalize(Color color); /// Get color from normalized values [0..1] - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color ColorFromNormalized(Vector4 normalized); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color ColorFromNormalized(Vector4 normalized); /// Get HSV values for a Color, hue [0..360], saturation/value [0..1] - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 ColorToHSV(Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 ColorToHSV(Color color); /// Get a Color from HSV values, hue [0..360], saturation/value [0..1] - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color ColorFromHSV(float hue, float saturation, float value); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color ColorFromHSV(float hue, float saturation, float value); /// Get color multiplied with another color - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color ColorTint(Color color, Color tint); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color ColorTint(Color color, Color tint); /// Get color with brightness correction, brightness factor goes from -1.0f to 1.0f - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color ColorBrightness(Color color, float factor); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color ColorBrightness(Color color, float factor); /// Get color with contrast correction, contrast values between -1.0f and 1.0f - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color ColorContrast(Color color, float contrast); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color ColorContrast(Color color, float contrast); /// Get color with alpha applied, alpha goes from 0.0f to 1.0f - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color ColorAlpha(Color color, float alpha); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color ColorAlpha(Color color, float alpha); /// Get src alpha-blended into dst color with tint - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color ColorAlphaBlend(Color dst, Color src, Color tint); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color ColorAlphaBlend(Color dst, Color src, Color tint); /// Get color lerp interpolation between two colors, factor [0.0f..1.0f] - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color ColorLerp(Color color1, Color color2, float factor); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color ColorLerp(Color color1, Color color2, float factor); /// Get Color structure from hexadecimal value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color GetColor(uint hexValue); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color GetColor(uint hexValue); /// Get Color from a source pixel pointer of certain format - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color GetPixelColor(void* srcPtr, PixelFormat format); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Color GetPixelColor(void* srcPtr, PixelFormat format); /// Set color formatted into destination pixel pointer - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetPixelColor(void* dstPtr, Color color, PixelFormat format); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPixelColor(void* dstPtr, Color color, PixelFormat format); /// Get pixel data size in bytes for certain format - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetPixelDataSize(int width, int height, PixelFormat format); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetPixelDataSize(int width, int height, PixelFormat format); //------------------------------------------------------------------------------------ @@ -1939,27 +2340,32 @@ public static unsafe partial class Raylib // Font loading/unloading functions /// Get the default Font - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Font GetFontDefault(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Font GetFontDefault(); /// Load font from file into GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Font LoadFont(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Font LoadFont(sbyte* fileName); /// /// Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load /// the default character set, font size is provided in pixels height /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Font LoadFontEx(sbyte* fileName, int fontSize, int* codepoints, int codepointCount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Font LoadFontEx(sbyte* fileName, int fontSize, int* codepoints, int codepointCount); /// Load font from Image (XNA style) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Font LoadFontFromImage(Image image, Color key, int firstChar); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Font LoadFontFromImage(Image image, Color key, int firstChar); /// Load font from memory buffer, fileType refers to extension: i.e. ".ttf" - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Font LoadFontFromMemory( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Font LoadFontFromMemory( sbyte* fileType, byte* fileData, int dataSize, @@ -1969,12 +2375,14 @@ public static unsafe partial class Raylib ); /// Check if a font is valid (font data loaded, WARNING: GPU texture not checked) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsFontValid(Font font); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsFontValid(Font font); /// Load font data for further use - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern GlyphInfo* LoadFontData( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial GlyphInfo* LoadFontData( byte* fileData, int dataSize, int fontSize, @@ -1984,8 +2392,9 @@ public static unsafe partial class Raylib ); /// Generate image font atlas using chars info - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageFontAtlas( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Image GenImageFontAtlas( GlyphInfo* chars, Rectangle** recs, int glyphCount, @@ -1995,31 +2404,37 @@ public static unsafe partial class Raylib ); /// Unload font chars info data (RAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadFontData(GlyphInfo* chars, int glyphCount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadFontData(GlyphInfo* chars, int glyphCount); /// Unload Font from GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadFont(Font font); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadFont(Font font); /// Export font as code file, returns true on success - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportFontAsCode(Font font, sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool ExportFontAsCode(Font font, sbyte* fileName); // Text drawing functions /// Shows current FPS - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawFPS(int posX, int posY); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawFPS(int posX, int posY); /// Draw text (using default font) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawText(sbyte* text, int posX, int posY, int fontSize, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawText(sbyte* text, int posX, int posY, int fontSize, Color color); /// Draw text using font and additional parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextEx( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTextEx( Font font, sbyte* text, Vector2 position, @@ -2029,8 +2444,9 @@ public static unsafe partial class Raylib ); /// Draw text using Font and pro parameters (rotation) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextPro( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTextPro( Font font, sbyte* text, Vector2 position, @@ -2042,8 +2458,9 @@ public static unsafe partial class Raylib ); /// Draw one character (codepoint) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextCodepoint( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTextCodepoint( Font font, int codepoint, Vector2 position, @@ -2052,8 +2469,9 @@ public static unsafe partial class Raylib ); /// Draw multiple characters (codepoint) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextCodepoints( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTextCodepoints( Font font, int* codepoints, int count, @@ -2066,149 +2484,182 @@ 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetTextLineSpacing(int spacing); /// Measure string width for default font - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int MeasureText(sbyte* text, int fontSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int MeasureText(sbyte* text, int fontSize); /// Measure string size for Font - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 MeasureTextEx(Font font, sbyte* text, float fontSize, float spacing); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 MeasureTextEx(Font font, sbyte* text, float fontSize, float spacing); /// /// Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetGlyphIndex(Font font, int character); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetGlyphIndex(Font font, int character); /// /// Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern GlyphInfo GetGlyphInfo(Font font, int codepoint); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial GlyphInfo GetGlyphInfo(Font font, int codepoint); /// /// Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Rectangle GetGlyphAtlasRec(Font font, int codepoint); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Rectangle GetGlyphAtlasRec(Font font, int codepoint); // Text codepoints management functions (unicode characters) /// Load UTF-8 text encoded from codepoints array - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* LoadUTF8(int* codepoints, int length); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* LoadUTF8(int* codepoints, int length); /// Unload UTF-8 text encoded from codepoints array - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadUTF8(sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadUTF8(sbyte* text); /// Load all codepoints from a UTF-8 text string, codepoints count returned by parameter - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int* LoadCodepoints(sbyte* text, int* count); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int* LoadCodepoints(sbyte* text, int* count); /// Unload codepoints data from memory - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadCodepoints(int* codepoints); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadCodepoints(int* codepoints); /// Get total number of codepoints in a UTF8 encoded string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetCodepointCount(sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetCodepointCount(sbyte* text); /// Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetCodepoint(sbyte* text, int* codepointSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetCodepoint(sbyte* text, int* codepointSize); /// Get next codepoint in a UTF-8 encoded string; 0x3f('?') is returned on failure - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetCodepointNext(sbyte* text, int* codepointSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetCodepointNext(sbyte* text, int* codepointSize); /// Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetCodepointPrevious(sbyte* text, int* codepointSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetCodepointPrevious(sbyte* text, int* codepointSize); /// Encode one codepoint into UTF-8 byte array (array length returned as parameter) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* CodepointToUTF8(int codepoint, int* utf8Size); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* CodepointToUTF8(int codepoint, int* utf8Size); // Text strings management functions (no UTF-8 strings, only byte chars) // NOTE: Some strings allocate memory internally for returned strings, just be careful! /// Copy one string to another, returns bytes copied - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int TextCopy(sbyte* dst, sbyte* src); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int TextCopy(sbyte* dst, sbyte* src); /// Check if two text string are equal - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool TextIsEqual(sbyte* text1, sbyte* text2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool TextIsEqual(sbyte* text1, sbyte* text2); /// Get text length, checks for '\0' ending - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern uint TextLength(sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint TextLength(sbyte* text); /// Text formatting with variables (sprintf style) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextFormat(sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextFormat(sbyte* text); /// Get a piece of a text string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextSubtext(sbyte* text, int position, int length); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextSubtext(sbyte* text, int position, int length); /// Replace text string (WARNING: memory must be freed!) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextReplace(sbyte* text, sbyte* replace, sbyte* by); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextReplace(sbyte* text, sbyte* replace, sbyte* by); /// Insert text in a position (WARNING: memory must be freed!) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextInsert(sbyte* text, sbyte* insert, int position); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextInsert(sbyte* text, sbyte* insert, int position); /// Join text strings with delimiter - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextJoin(sbyte** textList, int count, sbyte* delimiter); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextJoin(sbyte** textList, int count, sbyte* delimiter); /// Split text into multiple strings - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte** TextSplit(sbyte* text, char delimiter, int* count); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte** TextSplit(sbyte* text, char delimiter, int* count); /// Append text at specific position and move cursor! - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void TextAppend(sbyte* text, sbyte* append, int* position); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void TextAppend(sbyte* text, sbyte* append, int* position); /// Find first text occurrence within a string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int TextFindIndex(sbyte* text, sbyte* find); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int TextFindIndex(sbyte* text, sbyte* find); /// Get upper case version of provided string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextToUpper(sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextToUpper(sbyte* text); /// Get lower case version of provided string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextToLower(sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextToLower(sbyte* text); /// Get Pascal case notation version of provided string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextToPascal(sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextToPascal(sbyte* text); /// Get Snake case notation version of provided string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextToSnake(sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextToSnake(sbyte* text); /// Get Camel case notation version of provided string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextToCamel(sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* TextToCamel(sbyte* text); /// Get integer value from text (negative values not supported) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int TextToInteger(sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int TextToInteger(sbyte* text); /// Get float value from text (negative values not supported) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float TextToFloat(sbyte* text); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float TextToFloat(sbyte* text); //------------------------------------------------------------------------------------ // Basic 3d Shapes Drawing Functions (Module: models) @@ -2217,16 +2668,19 @@ public static unsafe partial class Raylib // Basic geometric 3D shapes drawing functions /// Draw a line in 3D world space - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); /// Draw a point in 3D space, actually a small line - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawPoint3D(Vector3 position, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawPoint3D(Vector3 position, Color color); /// Draw a circle in 3D world space - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCircle3D( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCircle3D( Vector3 center, float radius, Vector3 rotationAxis, @@ -2235,44 +2689,54 @@ public static unsafe partial class Raylib ); /// Draw a color-filled triangle (vertex in counter-clockwise order!) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color); /// Draw a triangle strip defined by points - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTriangleStrip3D(Vector3* points, int pointCount, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawTriangleStrip3D(Vector3* points, int pointCount, Color color); /// Draw cube - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCube(Vector3 position, float width, float height, float length, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCube(Vector3 position, float width, float height, float length, Color color); /// Draw cube (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCubeV(Vector3 position, Vector3 size, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCubeV(Vector3 position, Vector3 size, Color color); /// Draw cube wires - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); /// Draw cube wires (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCubeWiresV(Vector3 position, Vector3 size, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCubeWiresV(Vector3 position, Vector3 size, Color color); /// Draw sphere - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawSphere(Vector3 centerPos, float radius, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawSphere(Vector3 centerPos, float radius, Color color); /// Draw sphere with extended parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); /// Draw sphere wires - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); /// Draw a cylinder/cone - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCylinder( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCylinder( Vector3 position, float radiusTop, float radiusBottom, @@ -2282,8 +2746,9 @@ public static unsafe partial class Raylib ); /// Draw a cylinder with base at startPos and top at endPos - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCylinderEx( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCylinderEx( Vector3 startPos, Vector3 endPos, float startRadius, @@ -2293,8 +2758,9 @@ public static unsafe partial class Raylib ); /// Draw a cylinder/cone wires - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCylinderWires( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCylinderWires( Vector3 position, float radiusTop, float radiusBottom, @@ -2304,8 +2770,9 @@ public static unsafe partial class Raylib ); /// Draw a cylinder wires with base at startPos and top at endPos - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCylinderWiresEx( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCylinderWiresEx( Vector3 startPos, Vector3 endPos, float startRadius, @@ -2315,8 +2782,9 @@ public static unsafe partial class Raylib ); /// Draw a capsule with the center of its sphere caps at startPos and endPos - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCapsule( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCapsule( Vector3 startPos, Vector3 endPos, float radius, @@ -2326,8 +2794,9 @@ public static unsafe partial class Raylib ); /// Draw capsule wireframe with the center of its sphere caps at startPos and endPos - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCapsuleWires( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawCapsuleWires( Vector3 startPos, Vector3 endPos, float radius, @@ -2337,16 +2806,19 @@ public static unsafe partial class Raylib ); /// Draw a plane XZ - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawPlane(Vector3 centerPos, Vector2 size, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawPlane(Vector3 centerPos, Vector2 size, Color color); /// Draw a ray line - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRay(Ray ray, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRay(Ray ray, Color color); /// Draw a grid (centered at (0, 0, 0)) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawGrid(int slices, float spacing); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawGrid(int slices, float spacing); //------------------------------------------------------------------------------------ @@ -2356,35 +2828,42 @@ public static unsafe partial class Raylib // Model management functions /// Load model from files (meshes and materials) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Model LoadModel(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Model LoadModel(sbyte* fileName); /// Load model from generated mesh (default material) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Model LoadModelFromMesh(Mesh mesh); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Model LoadModelFromMesh(Mesh mesh); /// Check if a model is valid (loaded in GPU, VAO/VBOs) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsModelValid(Model model); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsModelValid(Model model); /// Unload model from memory (RAM and/or VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadModel(Model model); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadModel(Model model); /// Compute model bounding box limits (considers all meshes) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern BoundingBox GetModelBoundingBox(Model model); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial BoundingBox GetModelBoundingBox(Model model); // Model drawing functions /// Draw a model (with texture if set) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawModel(Model model, Vector3 position, float scale, Color tint); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawModel(Model model, Vector3 position, float scale, Color tint); /// Draw a model with extended parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawModelEx( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawModelEx( Model model, Vector3 position, Vector3 rotationAxis, @@ -2394,12 +2873,14 @@ public static unsafe partial class Raylib ); /// Draw a model wires (with texture if set) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawModelWires(Model model, Vector3 position, float scale, Color tint); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawModelWires(Model model, Vector3 position, float scale, Color tint); /// Draw a model wires (with texture if set) with extended parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawModelWiresEx( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawModelWiresEx( Model model, Vector3 position, Vector3 rotationAxis, @@ -2409,12 +2890,14 @@ public static unsafe partial class Raylib ); /// Draw a model as points - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawModelPoints(Model model, Vector3 position, float scale, Color tint); + [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 - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawModelPointsEx( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawModelPointsEx( Model model, Vector3 position, Vector3 rotationAxis, @@ -2424,12 +2907,14 @@ public static unsafe partial class Raylib ); /// Draw bounding box (wires) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawBoundingBox(BoundingBox box, Color color); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawBoundingBox(BoundingBox box, Color color); /// Draw a billboard texture - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawBillboard( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawBillboard( Camera3D camera, Texture2D texture, Vector3 center, @@ -2438,8 +2923,9 @@ public static unsafe partial class Raylib ); /// Draw a billboard texture defined by source - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawBillboardRec( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawBillboardRec( Camera3D camera, Texture2D texture, Rectangle source, @@ -2449,8 +2935,9 @@ public static unsafe partial class Raylib ); /// Draw a billboard texture defined by source and rotation - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawBillboardPro( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawBillboardPro( Camera3D camera, Texture2D texture, Rectangle source, @@ -2466,147 +2953,180 @@ public static unsafe partial class Raylib // Mesh management functions /// Upload vertex data into GPU and provided VAO/VBO ids - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UploadMesh(Mesh* mesh, CBool dynamic); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UploadMesh(Mesh* mesh, CBool dynamic); /// Update mesh vertex data in GPU for a specific buffer index - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateMeshBuffer(Mesh mesh, int index, void* data, int dataSize, int offset); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateMeshBuffer(Mesh mesh, int index, void* data, int dataSize, int offset); /// Unload mesh from memory (RAM and/or VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadMesh(Mesh mesh); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadMesh(Mesh mesh); /// Draw a 3d mesh with material and transform - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawMesh(Mesh mesh, Material material, Matrix4x4 transform); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawMesh(Mesh mesh, Material material, Matrix4x4 transform); /// Draw multiple mesh instances with material and different transforms - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawMeshInstanced(Mesh mesh, Material material, Matrix4x4* transforms, int instances); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawMeshInstanced(Mesh mesh, Material material, Matrix4x4* transforms, int instances); /// Compute mesh bounding box limits - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern BoundingBox GetMeshBoundingBox(Mesh mesh); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial BoundingBox GetMeshBoundingBox(Mesh mesh); /// Compute mesh tangents - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void GenMeshTangents(Mesh* mesh); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GenMeshTangents(Mesh* mesh); /// Export mesh data to file, returns true on success - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportMesh(Mesh mesh, sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool ExportMesh(Mesh mesh, sbyte* fileName); /// Export mesh as code file (.h) defining multiple arrays of vertex attributes - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportMeshAsCode(Mesh mesh, sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool ExportMeshAsCode(Mesh mesh, sbyte* fileName); // Mesh generation functions /// Generate polygonal mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshPoly(int sides, float radius); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Mesh GenMeshPoly(int sides, float radius); /// Generate plane mesh (with subdivisions) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshPlane(float width, float length, int resX, int resZ); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Mesh GenMeshPlane(float width, float length, int resX, int resZ); /// Generate cuboid mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshCube(float width, float height, float length); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Mesh GenMeshCube(float width, float height, float length); /// Generate sphere mesh (standard sphere) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshSphere(float radius, int rings, int slices); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Mesh GenMeshSphere(float radius, int rings, int slices); /// Generate half-sphere mesh (no bottom cap) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshHemiSphere(float radius, int rings, int slices); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Mesh GenMeshHemiSphere(float radius, int rings, int slices); /// Generate cylinder mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshCylinder(float radius, float height, int slices); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Mesh GenMeshCylinder(float radius, float height, int slices); /// Generate cone/pyramid mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshCone(float radius, float height, int slices); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Mesh GenMeshCone(float radius, float height, int slices); /// Generate torus mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshTorus(float radius, float size, int radSeg, int sides); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Mesh GenMeshTorus(float radius, float size, int radSeg, int sides); /// Generate trefoil knot mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshKnot(float radius, float size, int radSeg, int sides); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Mesh GenMeshKnot(float radius, float size, int radSeg, int sides); /// Generate heightmap mesh from image data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshHeightmap(Image heightmap, Vector3 size); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Mesh GenMeshHeightmap(Image heightmap, Vector3 size); /// Generate cubes-based map mesh from image data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); // Material loading/unloading functions //TODO: safe Helper method /// Load materials from model file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Material* LoadMaterials(sbyte* fileName, int* materialCount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Material* LoadMaterials(sbyte* fileName, int* materialCount); /// Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Material LoadMaterialDefault(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Material LoadMaterialDefault(); /// Check if a material is valid (shader assigned, map textures loaded in GPU) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMaterialValid(Material material); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsMaterialValid(Material material); /// Unload material from GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadMaterial(Material material); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadMaterial(Material material); /// Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMaterialTexture(Material* material, MaterialMapIndex mapType, Texture2D texture); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMaterialTexture(Material* material, MaterialMapIndex mapType, Texture2D texture); /// Set material for a mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetModelMeshMaterial(Model* model, int meshId, int materialId); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetModelMeshMaterial(Model* model, int meshId, int materialId); // Model animations loading/unloading functions /// Load model animations from file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern ModelAnimation* LoadModelAnimations(sbyte* fileName, int* animCount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial ModelAnimation* LoadModelAnimations(sbyte* fileName, int* animCount); /// Update model animation pose (CPU) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); /// Update model animation mesh bone matrices (GPU skinning) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame); /// Unload animation data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadModelAnimation(ModelAnimation anim); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadModelAnimation(ModelAnimation anim); /// Unload animation array data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadModelAnimations(ModelAnimation* animations, int animCount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadModelAnimations(ModelAnimation* animations, int animCount); /// Check model animation skeleton match - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsModelAnimationValid(Model model, ModelAnimation anim); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsModelAnimationValid(Model model, ModelAnimation anim); // Collision detection functions /// Detect collision between two spheres - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionSpheres( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionSpheres( Vector3 center1, float radius1, Vector3 center2, @@ -2614,32 +3134,39 @@ public static unsafe partial class Raylib ); /// Detect collision between two bounding boxes - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); /// Detect collision between box and sphere - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); /// Detect collision between ray and sphere - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); /// Detect collision between ray and box - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); /// Get collision info between ray and mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix4x4 transform); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix4x4 transform); /// Get collision info between ray and triangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); /// Get collision info between ray and quad - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); //------------------------------------------------------------------------------------ @@ -2649,290 +3176,356 @@ public static unsafe partial class Raylib // Audio device management functions /// Initialize audio device and context - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void InitAudioDevice(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void InitAudioDevice(); /// Close the audio device and context - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CloseAudioDevice(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CloseAudioDevice(); /// Check if audio device has been initialized successfully - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsAudioDeviceReady(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsAudioDeviceReady(); /// Set master volume (listener) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMasterVolume(float volume); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMasterVolume(float volume); /// Get master volume (listener) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetMasterVolume(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float GetMasterVolume(); // Wave/Sound loading/unloading functions /// Load wave data from file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Wave LoadWave(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Wave LoadWave(sbyte* fileName); /// Load wave from memory buffer, fileType refers to extension: i.e. ".wav" - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Wave LoadWaveFromMemory(sbyte* fileType, byte* fileData, int dataSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Wave LoadWaveFromMemory(sbyte* fileType, byte* fileData, int dataSize); /// Checks if wave data is valid (data loaded and parameters) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWaveValid(Wave wave); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsWaveValid(Wave wave); /// Load sound from file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Sound LoadSound(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Sound LoadSound(sbyte* fileName); /// Load sound from wave data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Sound LoadSoundFromWave(Wave wave); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Sound LoadSoundAlias(Sound source); /// Checks if a sound is valid (data loaded and buffers initialized) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsSoundValid(Sound sound); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsSoundValid(Sound sound); /// Update sound buffer with new data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateSound(Sound sound, void* data, int sampleCount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateSound(Sound sound, void* data, int sampleCount); /// Unload wave data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadWave(Wave wave); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadWave(Wave wave); /// Unload sound - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadSound(Sound sound); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadSoundAlias(Sound alias); /// Export wave data to file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportWave(Wave wave, sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool ExportWave(Wave wave, sbyte* fileName); /// Export wave sample data to code (.h) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportWaveAsCode(Wave wave, sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool ExportWaveAsCode(Wave wave, sbyte* fileName); // Wave/Sound management functions /// Play a sound - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PlaySound(Sound sound); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void PlaySound(Sound sound); /// Stop playing a sound - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void StopSound(Sound sound); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void StopSound(Sound sound); /// Pause a sound - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PauseSound(Sound sound); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void PauseSound(Sound sound); /// Resume a paused sound - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ResumeSound(Sound sound); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResumeSound(Sound sound); /// Check if a sound is currently playing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsSoundPlaying(Sound sound); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsSoundPlaying(Sound sound); /// Set volume for a sound (1.0 is max level) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetSoundVolume(Sound sound, float volume); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSoundVolume(Sound sound, float volume); /// Set pitch for a sound (1.0 is base level) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetSoundPitch(Sound sound, float pitch); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSoundPitch(Sound sound, float pitch); /// Set pan for a sound (0.5 is center) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetSoundPan(Sound sound, float pan); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSoundPan(Sound sound, float pan); /// Copy a wave to a new wave - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Wave WaveCopy(Wave wave); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Wave WaveCopy(Wave wave); /// Crop a wave to defined frames range - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void WaveCrop(Wave* wave, int initFrame, int finalFrame); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void WaveCrop(Wave* wave, int initFrame, int finalFrame); /// Convert wave data to desired format - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void WaveFormat(Wave* wave, int sampleRate, int sampleSize, int channels); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void WaveFormat(Wave* wave, int sampleRate, int sampleSize, int channels); /// Get samples data from wave as a floats array - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float* LoadWaveSamples(Wave wave); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float* LoadWaveSamples(Wave wave); /// Unload samples data loaded with LoadWaveSamples() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadWaveSamples(float* samples); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadWaveSamples(float* samples); // Music management functions /// Load music stream from file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Music LoadMusicStream(sbyte* fileName); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Music LoadMusicStream(sbyte* fileName); /// Load music stream from memory buffer, fileType refers to extension: i.e. ".wav" - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Music LoadMusicStreamFromMemory(sbyte* fileType, byte* data, int dataSize); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Music LoadMusicStreamFromMemory(sbyte* fileType, byte* data, int dataSize); /// Checks if a music stream is valid (context and buffers initialized) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMusicValid(Music music); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsMusicValid(Music music); /// Unload music stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadMusicStream(Music music); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadMusicStream(Music music); /// Start music playing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PlayMusicStream(Music music); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void PlayMusicStream(Music music); /// Check if music is playing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMusicStreamPlaying(Music music); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsMusicStreamPlaying(Music music); /// Updates buffers for music streaming - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateMusicStream(Music music); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateMusicStream(Music music); /// Stop music playing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void StopMusicStream(Music music); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void StopMusicStream(Music music); /// Pause music playing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PauseMusicStream(Music music); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void PauseMusicStream(Music music); /// Resume playing paused music - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ResumeMusicStream(Music music); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResumeMusicStream(Music music); /// Seek music to a position (in seconds) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SeekMusicStream(Music music, float position); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SeekMusicStream(Music music, float position); /// Set volume for music (1.0 is max level) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMusicVolume(Music music, float volume); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMusicVolume(Music music, float volume); /// Set pitch for a music (1.0 is base level) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMusicPitch(Music music, float pitch); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMusicPitch(Music music, float pitch); /// Set pan for a music (0.5 is center) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMusicPan(Music music, float pan); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMusicPan(Music music, float pan); /// Get music time length (in seconds) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetMusicTimeLength(Music music); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float GetMusicTimeLength(Music music); /// Get current music time played (in seconds) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetMusicTimePlayed(Music music); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float GetMusicTimePlayed(Music music); // AudioStream management functions /// Init audio stream (to stream raw audio pcm data) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern AudioStream LoadAudioStream(uint sampleRate, uint sampleSize, uint channels); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial AudioStream LoadAudioStream(uint sampleRate, uint sampleSize, uint channels); /// Checks if an audio stream is valid (buffers initialized) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsAudioStreamValid(AudioStream stream); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsAudioStreamValid(AudioStream stream); /// Unload audio stream and free memory - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadAudioStream(AudioStream stream); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadAudioStream(AudioStream stream); /// Update audio stream buffers with data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateAudioStream(AudioStream stream, void* data, int frameCount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateAudioStream(AudioStream stream, void* data, int frameCount); /// Check if any audio stream buffers requires refill - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsAudioStreamProcessed(AudioStream stream); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsAudioStreamProcessed(AudioStream stream); /// Play audio stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PlayAudioStream(AudioStream stream); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void PlayAudioStream(AudioStream stream); /// Pause audio stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PauseAudioStream(AudioStream stream); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void PauseAudioStream(AudioStream stream); /// Resume audio stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ResumeAudioStream(AudioStream stream); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResumeAudioStream(AudioStream stream); /// Check if audio stream is playing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsAudioStreamPlaying(AudioStream stream); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsAudioStreamPlaying(AudioStream stream); /// Stop audio stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void StopAudioStream(AudioStream stream); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void StopAudioStream(AudioStream stream); /// Set volume for audio stream (1.0 is max level) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetAudioStreamVolume(AudioStream stream, float volume); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAudioStreamVolume(AudioStream stream, float volume); /// Set pitch for audio stream (1.0 is base level) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetAudioStreamPitch(AudioStream stream, float pitch); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAudioStreamPitch(AudioStream stream, float pitch); /// Set pan for audio stream (0.5 is centered) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetAudioStreamPan(AudioStream stream, float pan); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAudioStreamPan(AudioStream stream, float pan); /// Default size for new audio streams - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetAudioStreamBufferSizeDefault(int size); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAudioStreamBufferSizeDefault(int size); /// Audio thread callback to request new data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetAudioStreamCallback( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAudioStreamCallback( AudioStream stream, delegate* unmanaged[Cdecl] callback ); /// Attach audio stream processor to stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void AttachAudioStreamProcessor( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void AttachAudioStreamProcessor( AudioStream stream, delegate* unmanaged[Cdecl] processor ); /// Detach audio stream processor from stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DetachAudioStreamProcessor( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DetachAudioStreamProcessor( AudioStream stream, delegate* unmanaged[Cdecl] processor ); /// Attach audio stream processor to the entire audio pipeline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void AttachAudioMixedProcessor( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void AttachAudioMixedProcessor( delegate* unmanaged[Cdecl] processor ); /// Detach audio stream processor from the entire audio pipeline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DetachAudioMixedProcessor( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DetachAudioMixedProcessor( delegate* unmanaged[Cdecl] processor ); } diff --git a/Raylib-cs/interop/Raymath.cs b/Raylib-cs/interop/Raymath.cs index 1435898..80d6d1d 100644 --- a/Raylib-cs/interop/Raymath.cs +++ b/Raylib-cs/interop/Raymath.cs @@ -1,5 +1,6 @@ -using System.Runtime.InteropServices; using System.Numerics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using System.Security; namespace Raylib_cs; @@ -19,153 +20,186 @@ public unsafe struct Float16 public static unsafe partial class Raymath { /// - /// Used by DllImport to load the native library + /// Used by LibraryImport to load the native library /// public const string NativeLibName = Raylib.NativeLibName; /// Clamp float value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Clamp(float value, float min, float max); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Clamp(float value, float min, float max); /// Calculate linear interpolation between two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Lerp(float start, float end, float amount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Lerp(float start, float end, float amount); /// Normalize input value within input range - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Normalize(float value, float start, float end); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Normalize(float value, float start, float end); /// Remap input value within input range to output range - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Remap(float value, + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Remap(float value, float inputStart, float inputEnd, float outputStart, float outputEnd ); /// Wrap input value from min to max - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Wrap(float value, float min, float max); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Wrap(float value, float min, float max); /// Check whether two given floats are almost equal - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int FloatEquals(float x, float y); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int FloatEquals(float x, float y); /// Vector with components value 0.0f - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Zero(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Zero(); /// Vector with components value 1.0f - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2One(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2One(); /// Add two vectors (v1 + v2) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Add(Vector2 v1, Vector2 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Add(Vector2 v1, Vector2 v2); /// Add vector and float value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2AddValue(Vector2 v, float add); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2AddValue(Vector2 v, float add); /// Subtract two vectors (v1 - v2) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Subtract(Vector2 v1, Vector2 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Subtract(Vector2 v1, Vector2 v2); /// Subtract vector by float value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2SubtractValue(Vector2 v, float sub); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2SubtractValue(Vector2 v, float sub); /// Calculate vector length - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector2Length(Vector2 v); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector2Length(Vector2 v); /// Calculate vector square length - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector2LengthSqr(Vector2 v); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector2LengthSqr(Vector2 v); /// Calculate two vectors dot product - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector2DotProduct(Vector2 v1, Vector2 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector2DotProduct(Vector2 v1, Vector2 v2); /// Calculate distance between two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector2Distance(Vector2 v1, Vector2 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector2Distance(Vector2 v1, Vector2 v2); /// Calculate square distance between two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector2DistanceSqr(Vector2 v1, Vector2 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector2DistanceSqr(Vector2 v1, Vector2 v2); /// /// Calculate angle between two vectors /// NOTE: Angle is calculated from origin point (0, 0) /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector2Angle(Vector2 v1, Vector2 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector2Angle(Vector2 v1, Vector2 v2); /// /// Calculate angle defined by a two vectors line /// NOTE: Parameters need to be normalized /// Current implementation should be aligned with glm::angle /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector2LineAngle(Vector2 start, Vector2 end); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector2LineAngle(Vector2 start, Vector2 end); /// Scale vector (multiply by value) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Scale(Vector2 v, float scale); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Scale(Vector2 v, float scale); /// Multiply vector by vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Multiply(Vector2 v1, Vector2 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Multiply(Vector2 v1, Vector2 v2); /// Negate vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Negate(Vector2 v); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Negate(Vector2 v); /// Divide vector by vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Divide(Vector2 v1, Vector2 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Divide(Vector2 v1, Vector2 v2); /// Normalize provided vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Normalize(Vector2 v); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Normalize(Vector2 v); /// Transforms a Vector2 by a given Matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Transform(Vector2 v, Matrix4x4 mat); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Transform(Vector2 v, Matrix4x4 mat); /// Calculate linear interpolation between two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount); /// Calculate reflected vector to normal - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Reflect(Vector2 v, Vector2 normal); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Reflect(Vector2 v, Vector2 normal); /// Rotate vector by angle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Rotate(Vector2 v, float angle); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Rotate(Vector2 v, float angle); /// Move Vector towards target - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2MoveTowards(Vector2 v, Vector2 target, float maxDistance); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2MoveTowards(Vector2 v, Vector2 target, float maxDistance); /// Invert the given vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Invert(Vector2 v); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Invert(Vector2 v); /// /// Clamp the components of the vector between min and max values specified by the given vectors /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Clamp(Vector2 v, Vector2 min, Vector2 max); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Clamp(Vector2 v, Vector2 min, Vector2 max); /// Clamp the magnitude of the vector between two min and max values - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2ClampValue(Vector2 v, float min, float max); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2ClampValue(Vector2 v, float min, float max); /// Check whether two given vectors are almost equal - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int Vector2Equals(Vector2 p, Vector2 q); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int Vector2Equals(Vector2 p, Vector2 q); /// Compute the direction of a refracted ray /// normalized direction of the incoming ray @@ -174,176 +208,215 @@ public static unsafe partial class Raymath /// ratio of the refractive index of the medium from where the ray comes /// to the refractive index of the medium on the other side of the surface /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Refract(Vector2 v, Vector2 n, float r); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector2Refract(Vector2 v, Vector2 n, float r); /// Vector with components value 0.0f - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Zero(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Zero(); /// Vector with components value 1.0f - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3One(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3One(); /// Add two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Add(Vector3 v1, Vector3 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Add(Vector3 v1, Vector3 v2); /// Add vector and float value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3AddValue(Vector3 v, float add); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3AddValue(Vector3 v, float add); /// Subtract two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Subtract(Vector3 v1, Vector3 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Subtract(Vector3 v1, Vector3 v2); /// Subtract vector and float value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3SubtractValue(Vector3 v, float sub); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3SubtractValue(Vector3 v, float sub); /// Multiply vector by scalar - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Scale(Vector3 v, float scalar); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Scale(Vector3 v, float scalar); /// Multiply vector by vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Multiply(Vector3 v1, Vector3 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Multiply(Vector3 v1, Vector3 v2); /// Calculate two vectors cross product - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2); /// Calculate one vector perpendicular vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Perpendicular(Vector3 v); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Perpendicular(Vector3 v); /// Calculate vector length - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector3Length(Vector3 v); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector3Length(Vector3 v); /// Calculate vector square length - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector3LengthSqr(Vector3 v); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector3LengthSqr(Vector3 v); /// Calculate two vectors dot product - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector3DotProduct(Vector3 v1, Vector3 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector3DotProduct(Vector3 v1, Vector3 v2); /// Calculate distance between two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector3Distance(Vector3 v1, Vector3 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector3Distance(Vector3 v1, Vector3 v2); /// Calculate square distance between two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector3DistanceSqr(Vector3 v1, Vector3 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float Vector3DistanceSqr(Vector3 v1, Vector3 v2); /// Calculate angle between two vectors in XY and XZ - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector3Angle(Vector3 v1, Vector3 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector2 Vector3Angle(Vector3 v1, Vector3 v2); /// Negate provided vector (invert direction) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Negate(Vector3 v); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Negate(Vector3 v); /// Divide vector by vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Divide(Vector3 v1, Vector3 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Divide(Vector3 v1, Vector3 v2); /// Normalize provided vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Normalize(Vector3 v); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial 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); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Reject(Vector3 v1, Vector3 v2); /// /// Orthonormalize provided vectors
/// Makes vectors normalized and orthogonal to each other
/// Gram-Schmidt function implementation ///
- [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void Vector3OrthoNormalize(Vector3* v1, Vector3* v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Vector3OrthoNormalize(Vector3* v1, Vector3* v2); /// Transforms a Vector3 by a given Matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Transform(Vector3 v, Matrix4x4 mat); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Transform(Vector3 v, Matrix4x4 mat); /// Transform a vector by quaternion rotation - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q); /// Rotates a vector around an axis - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle); /// Move Vector towards target - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3MoveTowards(Vector3 v, Vector3 target, float maxDistance); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3MoveTowards(Vector3 v, Vector3 target, float maxDistance); /// Calculate linear interpolation between two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount); /// /// Calculate cubic hermite interpolation between two vectors and their tangents /// as described in the GLTF 2.0 specification: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#interpolation-cubic /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3CubicHermite(Vector3 v1, Vector3 tangent1, Vector3 v2, Vector3 tangent2, float amount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3CubicHermite(Vector3 v1, Vector3 tangent1, Vector3 v2, Vector3 tangent2, float amount); /// Calculate reflected vector to normal - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Reflect(Vector3 v, Vector3 normal); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Reflect(Vector3 v, Vector3 normal); /// Get min value for each pair of components - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Min(Vector3 v1, Vector3 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Min(Vector3 v1, Vector3 v2); /// Get max value for each pair of components - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Max(Vector3 v1, Vector3 v2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Max(Vector3 v1, Vector3 v2); /// /// Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c)
/// NOTE: Assumes P is on the plane of the triangle ///
- [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c); /// /// Projects a Vector3 from screen space into object space
/// NOTE: We are avoiding calling other raymath functions despite available ///
- [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Unproject(Vector3 source, Matrix4x4 projection, Matrix4x4 view); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Unproject(Vector3 source, Matrix4x4 projection, Matrix4x4 view); /// Get Vector3 as float array - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Float3 Vector3ToFloatV(Vector3 v); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Float3 Vector3ToFloatV(Vector3 v); /// Invert the given vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Invert(Vector3 v); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Invert(Vector3 v); /// /// Clamp the components of the vector between /// min and max values specified by the given vectors /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Clamp(Vector3 v, Vector3 min, Vector3 max); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Clamp(Vector3 v, Vector3 min, Vector3 max); /// Clamp the magnitude of the vector between two values - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3ClampValue(Vector3 v, float min, float max); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3ClampValue(Vector3 v, float min, float max); /// Check whether two given vectors are almost equal - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int Vector3Equals(Vector3 p, Vector3 q); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int Vector3Equals(Vector3 p, Vector3 q); /// /// Compute the direction of a refracted ray where v specifies the @@ -353,83 +426,101 @@ public static unsafe partial class Raymath /// from where the ray comes to the refractive index of the medium /// on the other side of the surface /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Refract(Vector3 v, Vector3 n, float r); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 Vector3Refract(Vector3 v, Vector3 n, float r); /// Compute matrix determinant - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float MatrixDeterminant(Matrix4x4 mat); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float MatrixDeterminant(Matrix4x4 mat); /// Get the trace of the matrix (sum of the values along the diagonal) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float MatrixTrace(Matrix4x4 mat); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float MatrixTrace(Matrix4x4 mat); /// Transposes provided matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixTranspose(Matrix4x4 mat); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixTranspose(Matrix4x4 mat); /// Invert provided matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixInvert(Matrix4x4 mat); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixInvert(Matrix4x4 mat); /// Get identity matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixIdentity(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixIdentity(); /// Add two matrices - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixAdd(Matrix4x4 left, Matrix4x4 right); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixAdd(Matrix4x4 left, Matrix4x4 right); /// Subtract two matrices (left - right) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixSubtract(Matrix4x4 left, Matrix4x4 right); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixSubtract(Matrix4x4 left, Matrix4x4 right); /// /// Get two matrix multiplication
/// NOTE: When multiplying matrices... the order matters! ///
- [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixMultiply(Matrix4x4 left, Matrix4x4 right); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixMultiply(Matrix4x4 left, Matrix4x4 right); /// Get translation matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixTranslate(float x, float y, float z); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixTranslate(float x, float y, float z); /// /// Create rotation matrix from axis and angle
/// NOTE: Angle should be provided in radians ///
- [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixRotate(Vector3 axis, float angle); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixRotate(Vector3 axis, float angle); /// Get x-rotation matrix (angle in radians) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixRotateX(float angle); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixRotateX(float angle); /// Get y-rotation matrix (angle in radians) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixRotateY(float angle); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixRotateY(float angle); /// Get z-rotation matrix (angle in radians) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixRotateZ(float angle); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixRotateZ(float angle); /// Get xyz-rotation matrix (angles in radians) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixRotateXYZ(Vector3 ang); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixRotateXYZ(Vector3 ang); /// Get zyx-rotation matrix (angles in radians) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixRotateZYX(Vector3 ang); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixRotateZYX(Vector3 ang); /// Get scaling matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixScale(float x, float y, float z); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixScale(float x, float y, float z); /// Get perspective projection matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixFrustum( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixFrustum( double left, double right, double bottom, @@ -442,12 +533,14 @@ public static unsafe partial class Raymath /// Get perspective projection matrix
/// NOTE: Angle should be provided in radians /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixPerspective(double fovy, double aspect, double near, double far); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixPerspective(double fovy, double aspect, double near, double far); /// Get orthographic projection matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixOrtho( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixOrtho( double left, double right, double bottom, @@ -457,76 +550,93 @@ public static unsafe partial class Raymath ); /// Get camera look-at matrix (view matrix) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up); /// Get float array of matrix data - [DllImport(Raylib.NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Float16 MatrixToFloatV(Matrix4x4 m); + [LibraryImport(Raylib.NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Float16 MatrixToFloatV(Matrix4x4 m); /// Add 2 quaternions - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionAdd(Quaternion q1, Quaternion q2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionAdd(Quaternion q1, Quaternion q2); /// Add quaternion and float value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionAddValue(Quaternion q, float add); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionAddValue(Quaternion q, float add); /// Subtract 2 quaternions - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionSubtract(Quaternion q1, Quaternion q2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionSubtract(Quaternion q1, Quaternion q2); /// Subtract quaternion and float value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionSubtractValue(Quaternion q, float add); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionSubtractValue(Quaternion q, float add); /// Get identity quaternion - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionIdentity(); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionIdentity(); /// Computes the length of a quaternion - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float QuaternionLength(Quaternion q); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float QuaternionLength(Quaternion q); /// Normalize provided quaternion - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionNormalize(Quaternion q); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionNormalize(Quaternion q); /// Invert provided quaternion - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionInvert(Quaternion q); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionInvert(Quaternion q); /// Calculate two quaternion multiplication - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionMultiply(Quaternion q1, Quaternion q2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionMultiply(Quaternion q1, Quaternion q2); /// Scale quaternion by float value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionScale(Quaternion q, float mul); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionScale(Quaternion q, float mul); /// Divide two quaternions - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionDivide(Quaternion q1, Quaternion q2); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionDivide(Quaternion q1, Quaternion q2); /// Calculate linear interpolation between two quaternions - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount); /// Calculate slerp-optimized interpolation between two quaternions - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount); /// Calculates spherical linear interpolation between two quaternions - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount); /// /// Calculate quaternion cubic spline interpolation using Cubic Hermite Spline algorithm /// as described in the GLTF 2.0 specification: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#interpolation-cubic /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionCubicHermiteSpline( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionCubicHermiteSpline( Quaternion q1, Quaternion outTangent1, Quaternion q2, @@ -535,53 +645,63 @@ public static unsafe partial class Raymath ); /// Calculate quaternion based on the rotation from one vector to another - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to); /// Get a quaternion for a given rotation matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionFromMatrix(Matrix4x4 mat); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionFromMatrix(Matrix4x4 mat); /// Get a matrix for a given quaternion - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 QuaternionToMatrix(Quaternion q); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 QuaternionToMatrix(Quaternion q); /// /// Get rotation quaternion for an angle and axis
/// NOTE: angle must be provided in radians ///
- [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle); /// Get the rotation angle and axis for a given quaternion - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void QuaternionToAxisAngle(Quaternion q, Vector3* outAxis, float* outAngle); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void QuaternionToAxisAngle(Quaternion q, Vector3* outAxis, float* outAngle); /// /// Get the quaternion equivalent to Euler angles
/// NOTE: Rotation order is ZYX ///
- [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionFromEuler(float pitch, float yaw, float roll); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionFromEuler(float pitch, float yaw, float roll); /// /// Get the Euler angles equivalent to quaternion (roll, pitch, yaw)
/// NOTE: Angles are returned in a Vector3 struct in radians ///
- [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 QuaternionToEuler(Quaternion q); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Vector3 QuaternionToEuler(Quaternion q); /// Transform a quaternion given a transformation matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionTransform(Quaternion q, Matrix4x4 mat); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Quaternion QuaternionTransform(Quaternion q, Matrix4x4 mat); /// Check whether two given quaternions are almost equal - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int QuaternionEquals(Quaternion p, Quaternion q); + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int QuaternionEquals(Quaternion p, Quaternion q); /// Decompose a transformation matrix into its rotational, translational and scaling components - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void MatrixDecompose( + [LibraryImport(NativeLibName)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void MatrixDecompose( Matrix4x4 mat, Vector3* translation, Quaternion* rotation, diff --git a/Raylib-cs/interop/Rlgl.cs b/Raylib-cs/interop/Rlgl.cs index 238cfab..ee7a0ce 100644 --- a/Raylib-cs/interop/Rlgl.cs +++ b/Raylib-cs/interop/Rlgl.cs @@ -1,4 +1,5 @@ using System.Numerics; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; @@ -8,7 +9,7 @@ namespace Raylib_cs; public static unsafe partial class Rlgl { /// - /// Used by DllImport to load the native library + /// Used by LibraryImport to load the native library /// public const string NativeLibName = "raylib"; @@ -92,8 +93,9 @@ public static unsafe partial class Rlgl // ------------------------------------------------------------------------------------ /// Choose the current matrix to be transformed - [DllImport(NativeLibName, EntryPoint = "rlMatrixMode", CallingConvention = CallingConvention.Cdecl)] - public static extern void MatrixMode(int mode); + [LibraryImport(NativeLibName, EntryPoint = "rlMatrixMode")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void MatrixMode(int mode); /// public static void MatrixMode(MatrixMode mode) @@ -102,35 +104,42 @@ public static unsafe partial class Rlgl } /// Push the current matrix to stack - [DllImport(NativeLibName, EntryPoint = "rlPushMatrix", CallingConvention = CallingConvention.Cdecl)] - public static extern void PushMatrix(); + [LibraryImport(NativeLibName, EntryPoint = "rlPushMatrix")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void PushMatrix(); /// Pop lattest inserted matrix from stack - [DllImport(NativeLibName, EntryPoint = "rlPopMatrix", CallingConvention = CallingConvention.Cdecl)] - public static extern void PopMatrix(); + [LibraryImport(NativeLibName, EntryPoint = "rlPopMatrix")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void PopMatrix(); /// Reset current matrix to identity matrix - [DllImport(NativeLibName, EntryPoint = "rlLoadIdentity", CallingConvention = CallingConvention.Cdecl)] - public static extern void LoadIdentity(); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadIdentity")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void LoadIdentity(); /// Multiply the current matrix by a translation matrix - [DllImport(NativeLibName, EntryPoint = "rlTranslatef", CallingConvention = CallingConvention.Cdecl)] - public static extern void Translatef(float x, float y, float z); + [LibraryImport(NativeLibName, EntryPoint = "rlTranslatef")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Translatef(float x, float y, float z); /// Multiply the current matrix by a rotation matrix - [DllImport(NativeLibName, EntryPoint = "rlRotatef", CallingConvention = CallingConvention.Cdecl)] - public static extern void Rotatef(float angle, float x, float y, float z); + [LibraryImport(NativeLibName, EntryPoint = "rlRotatef")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Rotatef(float angle, float x, float y, float z); /// Multiply the current matrix by a scaling matrix - [DllImport(NativeLibName, EntryPoint = "rlScalef", CallingConvention = CallingConvention.Cdecl)] - public static extern void Scalef(float x, float y, float z); + [LibraryImport(NativeLibName, EntryPoint = "rlScalef")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Scalef(float x, float y, float z); /// /// Multiply the current matrix by another matrix
/// Current Matrix can be set via ///
- [DllImport(NativeLibName, EntryPoint = "rlMultMatrixf", CallingConvention = CallingConvention.Cdecl)] - public static extern void MultMatrixf(float* matf); + [LibraryImport(NativeLibName, EntryPoint = "rlMultMatrixf")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void MultMatrixf(float* matf); /// public static void MultMatrixf(Matrix4x4 matf) @@ -139,8 +148,9 @@ public static unsafe partial class Rlgl MultMatrixf(f.v); } - [DllImport(NativeLibName, EntryPoint = "rlFrustum", CallingConvention = CallingConvention.Cdecl)] - public static extern void Frustum( + [LibraryImport(NativeLibName, EntryPoint = "rlFrustum")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Frustum( double left, double right, double bottom, @@ -149,8 +159,9 @@ public static unsafe partial class Rlgl double zfar ); - [DllImport(NativeLibName, EntryPoint = "rlOrtho", CallingConvention = CallingConvention.Cdecl)] - public static extern void Ortho( + [LibraryImport(NativeLibName, EntryPoint = "rlOrtho")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Ortho( double left, double right, double bottom, @@ -160,20 +171,24 @@ public static unsafe partial class Rlgl ); /// Set the viewport area - [DllImport(NativeLibName, EntryPoint = "rlViewport", CallingConvention = CallingConvention.Cdecl)] - public static extern void Viewport(int x, int y, int width, int height); + [LibraryImport(NativeLibName, EntryPoint = "rlViewport")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Viewport(int x, int y, int width, int height); /// Set clip planes distances - [DllImport(NativeLibName, EntryPoint = "rlSetClipPlanes", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetClipPlanes(double nearPlane, double farPlane); + [LibraryImport(NativeLibName, EntryPoint = "rlSetClipPlanes")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetClipPlanes(double nearPlane, double farPlane); /// Get cull plane distance near - [DllImport(NativeLibName, EntryPoint = "rlGetCullDistanceNear", CallingConvention = CallingConvention.Cdecl)] - public static extern double GetCullDistanceNear(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetCullDistanceNear")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetCullDistanceNear(); /// Get cull plane distance far - [DllImport(NativeLibName, EntryPoint = "rlGetCullDistanceFar", CallingConvention = CallingConvention.Cdecl)] - public static extern double GetCullDistanceFar(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetCullDistanceFar")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetCullDistanceFar(); // ------------------------------------------------------------------------------------ @@ -181,8 +196,9 @@ public static unsafe partial class Rlgl // ------------------------------------------------------------------------------------ /// Initialize drawing mode (how to organize vertex) - [DllImport(NativeLibName, EntryPoint = "rlBegin", CallingConvention = CallingConvention.Cdecl)] - public static extern void Begin(int mode); + [LibraryImport(NativeLibName, EntryPoint = "rlBegin")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Begin(int mode); public static void Begin(DrawMode mode) { @@ -190,40 +206,49 @@ public static unsafe partial class Rlgl } /// Finish vertex providing - [DllImport(NativeLibName, EntryPoint = "rlEnd", CallingConvention = CallingConvention.Cdecl)] - public static extern void End(); + [LibraryImport(NativeLibName, EntryPoint = "rlEnd")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void End(); /// Define one vertex (position) - 2 int - [DllImport(NativeLibName, EntryPoint = "rlVertex2i", CallingConvention = CallingConvention.Cdecl)] - public static extern void Vertex2i(int x, int y); + [LibraryImport(NativeLibName, EntryPoint = "rlVertex2i")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Vertex2i(int x, int y); /// Define one vertex (position) - 2 float - [DllImport(NativeLibName, EntryPoint = "rlVertex2f", CallingConvention = CallingConvention.Cdecl)] - public static extern void Vertex2f(float x, float y); + [LibraryImport(NativeLibName, EntryPoint = "rlVertex2f")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Vertex2f(float x, float y); /// Define one vertex (position) - 3 float - [DllImport(NativeLibName, EntryPoint = "rlVertex3f", CallingConvention = CallingConvention.Cdecl)] - public static extern void Vertex3f(float x, float y, float z); + [LibraryImport(NativeLibName, EntryPoint = "rlVertex3f")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Vertex3f(float x, float y, float z); /// Define one vertex (texture coordinate) - 2 float - [DllImport(NativeLibName, EntryPoint = "rlTexCoord2f", CallingConvention = CallingConvention.Cdecl)] - public static extern void TexCoord2f(float x, float y); + [LibraryImport(NativeLibName, EntryPoint = "rlTexCoord2f")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void TexCoord2f(float x, float y); /// Define one vertex (normal) - 3 float - [DllImport(NativeLibName, EntryPoint = "rlNormal3f", CallingConvention = CallingConvention.Cdecl)] - public static extern void Normal3f(float x, float y, float z); + [LibraryImport(NativeLibName, EntryPoint = "rlNormal3f")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Normal3f(float x, float y, float z); /// Define one vertex (color) - 4 byte - [DllImport(NativeLibName, EntryPoint = "rlColor4ub", CallingConvention = CallingConvention.Cdecl)] - public static extern void Color4ub(byte r, byte g, byte b, byte a); + [LibraryImport(NativeLibName, EntryPoint = "rlColor4ub")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Color4ub(byte r, byte g, byte b, byte a); /// Define one vertex (color) - 3 float - [DllImport(NativeLibName, EntryPoint = "rlColor3f", CallingConvention = CallingConvention.Cdecl)] - public static extern void Color3f(float x, float y, float z); + [LibraryImport(NativeLibName, EntryPoint = "rlColor3f")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Color3f(float x, float y, float z); /// Define one vertex (color) - 4 float - [DllImport(NativeLibName, EntryPoint = "rlColor4f", CallingConvention = CallingConvention.Cdecl)] - public static extern void Color4f(float x, float y, float z, float w); + [LibraryImport(NativeLibName, EntryPoint = "rlColor4f")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Color4f(float x, float y, float z, float w); // ------------------------------------------------------------------------------------ @@ -234,234 +259,288 @@ public static unsafe partial class Rlgl /// Vertex buffers state /// Enable vertex array (VAO, if supported) - [DllImport(NativeLibName, EntryPoint = "rlEnableVertexArray", CallingConvention = CallingConvention.Cdecl)] - public static extern CBool EnableVertexArray(uint vaoId); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableVertexArray")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool EnableVertexArray(uint vaoId); /// Disable vertex array (VAO, if supported) - [DllImport(NativeLibName, EntryPoint = "rlDisableVertexArray", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableVertexArray(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableVertexArray")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableVertexArray(); /// Enable vertex buffer (VBO) - [DllImport(NativeLibName, EntryPoint = "rlEnableVertexBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableVertexBuffer(uint id); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableVertexBuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableVertexBuffer(uint id); /// Disable vertex buffer (VBO) - [DllImport(NativeLibName, EntryPoint = "rlDisableVertexBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableVertexBuffer(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableVertexBuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableVertexBuffer(); /// Enable vertex buffer element (VBO element) - [DllImport(NativeLibName, EntryPoint = "rlEnableVertexBufferElement", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableVertexBufferElement(uint id); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableVertexBufferElement")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableVertexBufferElement(uint id); /// Disable vertex buffer element (VBO element) - [DllImport(NativeLibName, EntryPoint = "rlDisableVertexBufferElement", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableVertexBufferElement(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableVertexBufferElement")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableVertexBufferElement(); /// Enable vertex attribute index - [DllImport(NativeLibName, EntryPoint = "rlEnableVertexAttribute", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableVertexAttribute(uint index); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableVertexAttribute")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableVertexAttribute(uint index); /// Disable vertex attribute index - [DllImport(NativeLibName, EntryPoint = "rlDisableVertexAttribute", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableVertexAttribute(uint index); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableVertexAttribute")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableVertexAttribute(uint index); /// Enable attribute state pointer
/// NOTE: Only available for GRAPHICS_API_OPENGL_11
- [DllImport(NativeLibName, EntryPoint = "rlEnableStatePointer", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableStatePointer(int vertexAttribType, void* buffer); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableStatePointer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableStatePointer(int vertexAttribType, void* buffer); /// Disable attribute state pointer
/// NOTE: Only available for GRAPHICS_API_OPENGL_11
- [DllImport(NativeLibName, EntryPoint = "rlDisableStatePointer", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableStatePointer(int vertexAttribType); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableStatePointer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableStatePointer(int vertexAttribType); // Textures state /// Select and active a texture slot - [DllImport(NativeLibName, EntryPoint = "rlActiveTextureSlot", CallingConvention = CallingConvention.Cdecl)] - public static extern void ActiveTextureSlot(int slot); + [LibraryImport(NativeLibName, EntryPoint = "rlActiveTextureSlot")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ActiveTextureSlot(int slot); /// Enable texture - [DllImport(NativeLibName, EntryPoint = "rlEnableTexture", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableTexture(uint id); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableTexture")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableTexture(uint id); /// Disable texture - [DllImport(NativeLibName, EntryPoint = "rlDisableTexture", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableTexture(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableTexture")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableTexture(); /// Enable texture cubemap - [DllImport(NativeLibName, EntryPoint = "rlEnableTextureCubemap", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableTextureCubemap(uint id); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableTextureCubemap")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableTextureCubemap(uint id); /// Disable texture cubemap - [DllImport(NativeLibName, EntryPoint = "rlDisableTextureCubemap", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableTextureCubemap(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableTextureCubemap")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableTextureCubemap(); /// Set texture parameters (filter, wrap) - [DllImport(NativeLibName, EntryPoint = "rlTextureParameters", CallingConvention = CallingConvention.Cdecl)] - public static extern void TextureParameters(uint id, int param, int value); + [LibraryImport(NativeLibName, EntryPoint = "rlTextureParameters")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void TextureParameters(uint id, int param, int value); /// Set cubemap parameters (filter, wrap) - [DllImport(NativeLibName, EntryPoint = "rlCubemapParameters", CallingConvention = CallingConvention.Cdecl)] - public static extern void CubemapParameters(uint id, int param, int value); + [LibraryImport(NativeLibName, EntryPoint = "rlCubemapParameters")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CubemapParameters(uint id, int param, int value); // Shader state /// Enable shader program - [DllImport(NativeLibName, EntryPoint = "rlEnableShader", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableShader(uint id); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableShader")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableShader(uint id); /// Disable shader program - [DllImport(NativeLibName, EntryPoint = "rlDisableShader", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableShader(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableShader")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableShader(); // Framebuffer state /// Enable render texture (fbo) - [DllImport(NativeLibName, EntryPoint = "rlEnableFramebuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableFramebuffer(uint id); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableFramebuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableFramebuffer(uint id); /// Disable render texture (fbo), return to default framebuffer - [DllImport(NativeLibName, EntryPoint = "rlDisableFramebuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableFramebuffer(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableFramebuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableFramebuffer(); /// Get the currently active render texture (fbo), 0 for default framebuffer - [DllImport(NativeLibName, EntryPoint = "rlGetActiveFramebuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern uint GetActiveFramebuffer(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetActiveFramebuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint GetActiveFramebuffer(); /// Blit active framebuffer to main framebuffer - [DllImport(NativeLibName, EntryPoint = "rlBlitFramebuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void BlitFramebuffer(); + [LibraryImport(NativeLibName, EntryPoint = "rlBlitFramebuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void BlitFramebuffer(); /// Bind framebuffer (FBO) - [DllImport(NativeLibName, EntryPoint = "rlBindFramebuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void BindFramebuffer(uint target, uint framebuffer); + [LibraryImport(NativeLibName, EntryPoint = "rlBindFramebuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void BindFramebuffer(uint target, uint framebuffer); /// Activate multiple draw color buffers - [DllImport(NativeLibName, EntryPoint = "rlActiveDrawBuffers", CallingConvention = CallingConvention.Cdecl)] - public static extern void ActiveDrawBuffers(int count); + [LibraryImport(NativeLibName, EntryPoint = "rlActiveDrawBuffers")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ActiveDrawBuffers(int count); // General render state /// Enable color blending - [DllImport(NativeLibName, EntryPoint = "rlEnableColorBlend", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableColorBlend(); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableColorBlend")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableColorBlend(); /// Disable color blending - [DllImport(NativeLibName, EntryPoint = "rlDisableColorBlend", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableColorBlend(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableColorBlend")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableColorBlend(); /// Enable depth test - [DllImport(NativeLibName, EntryPoint = "rlEnableDepthTest", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableDepthTest(); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableDepthTest")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableDepthTest(); /// Disable depth test - [DllImport(NativeLibName, EntryPoint = "rlDisableDepthTest", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableDepthTest(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableDepthTest")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableDepthTest(); /// Enable depth write - [DllImport(NativeLibName, EntryPoint = "rlEnableDepthMask", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableDepthMask(); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableDepthMask")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableDepthMask(); /// Disable depth write - [DllImport(NativeLibName, EntryPoint = "rlDisableDepthMask", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableDepthMask(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableDepthMask")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableDepthMask(); /// Enable backface culling - [DllImport(NativeLibName, EntryPoint = "rlEnableBackfaceCulling", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableBackfaceCulling(); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableBackfaceCulling")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableBackfaceCulling(); /// Disable backface culling - [DllImport(NativeLibName, EntryPoint = "rlDisableBackfaceCulling", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableBackfaceCulling(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableBackfaceCulling")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableBackfaceCulling(); /// Color mask control - [DllImport(NativeLibName, EntryPoint = "rlColorMask", CallingConvention = CallingConvention.Cdecl)] - public static extern void ColorMask(CBool r, CBool g, CBool b, CBool a); + [LibraryImport(NativeLibName, EntryPoint = "rlColorMask")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ColorMask(CBool r, CBool g, CBool b, CBool a); /// Set face culling mode - [DllImport(NativeLibName, EntryPoint = "rlSetCullFace", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetCullFace(int mode); + [LibraryImport(NativeLibName, EntryPoint = "rlSetCullFace")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetCullFace(int mode); /// Enable scissor test - [DllImport(NativeLibName, EntryPoint = "rlEnableScissorTest", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableScissorTest(); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableScissorTest")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableScissorTest(); /// Disable scissor test - [DllImport(NativeLibName, EntryPoint = "rlDisableScissorTest", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableScissorTest(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableScissorTest")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableScissorTest(); /// Scissor test - [DllImport(NativeLibName, EntryPoint = "rlScissor", CallingConvention = CallingConvention.Cdecl)] - public static extern void Scissor(int x, int y, int width, int height); + [LibraryImport(NativeLibName, EntryPoint = "rlScissor")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void Scissor(int x, int y, int width, int height); /// Enable wire mode - [DllImport(NativeLibName, EntryPoint = "rlEnableWireMode", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableWireMode(); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableWireMode")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableWireMode(); /// Enable point mode - [DllImport(NativeLibName, EntryPoint = "rlEnablePointMode", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnablePointMode(); + [LibraryImport(NativeLibName, EntryPoint = "rlEnablePointMode")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnablePointMode(); /// Disable wire mode - [DllImport(NativeLibName, EntryPoint = "rlDisableWireMode", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableWireMode(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableWireMode")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableWireMode(); /// Set the line drawing width - [DllImport(NativeLibName, EntryPoint = "rlSetLineWidth", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetLineWidth(float width); + [LibraryImport(NativeLibName, EntryPoint = "rlSetLineWidth")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetLineWidth(float width); /// Get the line drawing width - [DllImport(NativeLibName, EntryPoint = "rlGetLineWidth", CallingConvention = CallingConvention.Cdecl)] - public static extern float GetLineWidth(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetLineWidth")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial float GetLineWidth(); /// Enable line aliasing - [DllImport(NativeLibName, EntryPoint = "rlEnableSmoothLines", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableSmoothLines(); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableSmoothLines")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableSmoothLines(); /// Disable line aliasing - [DllImport(NativeLibName, EntryPoint = "rlDisableSmoothLines", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableSmoothLines(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableSmoothLines")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableSmoothLines(); /// Enable stereo rendering - [DllImport(NativeLibName, EntryPoint = "rlEnableStereoRender", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableStereoRender(); + [LibraryImport(NativeLibName, EntryPoint = "rlEnableStereoRender")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnableStereoRender(); /// Disable stereo rendering - [DllImport(NativeLibName, EntryPoint = "rlDisableStereoRender", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableStereoRender(); + [LibraryImport(NativeLibName, EntryPoint = "rlDisableStereoRender")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DisableStereoRender(); /// Check if stereo render is enabled - [DllImport(NativeLibName, EntryPoint = "rlIsStereoRenderEnabled", CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsStereoRenderEnabled(); + [LibraryImport(NativeLibName, EntryPoint = "rlIsStereoRenderEnabled")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool IsStereoRenderEnabled(); /// Clear color buffer with color - [DllImport(NativeLibName, EntryPoint = "rlClearColor", CallingConvention = CallingConvention.Cdecl)] - public static extern void ClearColor(byte r, byte g, byte b, byte a); + [LibraryImport(NativeLibName, EntryPoint = "rlClearColor")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ClearColor(byte r, byte g, byte b, byte a); /// Clear used screen buffers (color and depth) - [DllImport(NativeLibName, EntryPoint = "rlClearScreenBuffers", CallingConvention = CallingConvention.Cdecl)] - public static extern void ClearScreenBuffers(); + [LibraryImport(NativeLibName, EntryPoint = "rlClearScreenBuffers")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ClearScreenBuffers(); /// Check and log OpenGL error codes - [DllImport(NativeLibName, EntryPoint = "rlCheckErrors", CallingConvention = CallingConvention.Cdecl)] - public static extern void CheckErrors(); + [LibraryImport(NativeLibName, EntryPoint = "rlCheckErrors")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CheckErrors(); /// Set blending mode - [DllImport(NativeLibName, EntryPoint = "rlSetBlendMode", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetBlendMode(BlendMode mode); + [LibraryImport(NativeLibName, EntryPoint = "rlSetBlendMode")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetBlendMode(BlendMode mode); /// Set blending mode factor and equation (using OpenGL factors) - [DllImport(NativeLibName, EntryPoint = "rlSetBlendFactors", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation); + [LibraryImport(NativeLibName, EntryPoint = "rlSetBlendFactors")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation); /// Set blending mode factors and equations separately (using OpenGL factors) - [DllImport(NativeLibName, EntryPoint = "rlSetBlendFactorsSeparate", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetBlendFactorsSeparate( + [LibraryImport(NativeLibName, EntryPoint = "rlSetBlendFactorsSeparate")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetBlendFactorsSeparate( int glSrcRGB, int glDstRGB, int glSrcAlpha, @@ -476,105 +555,129 @@ public static unsafe partial class Rlgl // ------------------------------------------------------------------------------------ /// Initialize rlgl (buffers, shaders, textures, states) - [DllImport(NativeLibName, EntryPoint = "rlglInit", CallingConvention = CallingConvention.Cdecl)] - public static extern void GlInit(int width, int height); + [LibraryImport(NativeLibName, EntryPoint = "rlglInit")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GlInit(int width, int height); /// De-inititialize rlgl (buffers, shaders, textures) - [DllImport(NativeLibName, EntryPoint = "rlglClose", CallingConvention = CallingConvention.Cdecl)] - public static extern void GlClose(); + [LibraryImport(NativeLibName, EntryPoint = "rlglClose")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GlClose(); /// Load OpenGL extensions - [DllImport(NativeLibName, EntryPoint = "rlLoadExtensions", CallingConvention = CallingConvention.Cdecl)] - public static extern void LoadExtensions(void* loader); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadExtensions")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void LoadExtensions(void* loader); /// Get current OpenGL version - [DllImport(NativeLibName, EntryPoint = "rlGetVersion", CallingConvention = CallingConvention.Cdecl)] - public static extern GlVersion GetVersion(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetVersion")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial GlVersion GetVersion(); /// Get default framebuffer width - [DllImport(NativeLibName, EntryPoint = "rlGetFramebufferWidth", CallingConvention = CallingConvention.Cdecl)] - public static extern int GetFramebufferWidth(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetFramebufferWidth")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetFramebufferWidth(); /// Get default framebuffer height - [DllImport(NativeLibName, EntryPoint = "rlGetFramebufferHeight", CallingConvention = CallingConvention.Cdecl)] - public static extern int GetFramebufferHeight(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetFramebufferHeight")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetFramebufferHeight(); /// Get default texture - [DllImport(NativeLibName, EntryPoint = "rlGetTextureIdDefault", CallingConvention = CallingConvention.Cdecl)] - public static extern uint GetTextureIdDefault(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetTextureIdDefault")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint GetTextureIdDefault(); /// Get default shader - [DllImport(NativeLibName, EntryPoint = "rlGetShaderIdDefault", CallingConvention = CallingConvention.Cdecl)] - public static extern uint GetShaderIdDefault(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetShaderIdDefault")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint GetShaderIdDefault(); /// Get default shader locations - [DllImport(NativeLibName, EntryPoint = "rlGetShaderLocsDefault", CallingConvention = CallingConvention.Cdecl)] - public static extern int* GetShaderLocsDefault(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetShaderLocsDefault")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int* GetShaderLocsDefault(); // Render batch management /// Load a render batch system
/// NOTE: rlgl provides a default render batch to behave like OpenGL 1.1 immediate mode
/// but this render batch API is exposed in case custom batches are required
- [DllImport(NativeLibName, EntryPoint = "rlLoadRenderBatch", CallingConvention = CallingConvention.Cdecl)] - public static extern RenderBatch LoadRenderBatch(int numBuffers, int bufferElements); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadRenderBatch")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial RenderBatch LoadRenderBatch(int numBuffers, int bufferElements); /// Unload render batch system - [DllImport(NativeLibName, EntryPoint = "rlUnloadRenderBatch", CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadRenderBatch(RenderBatch batch); + [LibraryImport(NativeLibName, EntryPoint = "rlUnloadRenderBatch")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadRenderBatch(RenderBatch batch); /// Draw render batch data (Update->Draw->Reset) - [DllImport(NativeLibName, EntryPoint = "rlDrawRenderBatch", CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRenderBatch(RenderBatch* batch); + [LibraryImport(NativeLibName, EntryPoint = "rlDrawRenderBatch")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRenderBatch(RenderBatch* batch); /// Set the active render batch for rlgl (NULL for default internal) - [DllImport(NativeLibName, EntryPoint = "rlSetRenderBatchActive", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetRenderBatchActive(RenderBatch* batch); + [LibraryImport(NativeLibName, EntryPoint = "rlSetRenderBatchActive")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRenderBatchActive(RenderBatch* batch); /// Update and draw internal render batch - [DllImport(NativeLibName, EntryPoint = "rlDrawRenderBatchActive", CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRenderBatchActive(); + [LibraryImport(NativeLibName, EntryPoint = "rlDrawRenderBatchActive")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawRenderBatchActive(); /// Check internal buffer overflow for a given number of vertex - [DllImport(NativeLibName, EntryPoint = "rlCheckRenderBatchLimit", CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckRenderBatchLimit(int vCount); + [LibraryImport(NativeLibName, EntryPoint = "rlCheckRenderBatchLimit")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool CheckRenderBatchLimit(int vCount); /// Set current texture for render batch and check buffers limits - [DllImport(NativeLibName, EntryPoint = "rlSetTexture", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetTexture(uint id); + [LibraryImport(NativeLibName, EntryPoint = "rlSetTexture")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetTexture(uint id); // Vertex buffers management /// Load vertex array (vao) if supported - [DllImport(NativeLibName, EntryPoint = "rlLoadVertexArray", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadVertexArray(); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadVertexArray")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadVertexArray(); /// Load a vertex buffer attribute - [DllImport(NativeLibName, EntryPoint = "rlLoadVertexBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadVertexBuffer(void* buffer, int size, CBool dynamic); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadVertexBuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadVertexBuffer(void* buffer, int size, CBool dynamic); /// Load a new attributes element buffer - [DllImport(NativeLibName, EntryPoint = "rlLoadVertexBufferElement", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadVertexBufferElement(void* buffer, int size, CBool dynamic); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadVertexBufferElement")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadVertexBufferElement(void* buffer, int size, CBool dynamic); /// Update GPU buffer with new data - [DllImport(NativeLibName, EntryPoint = "rlUpdateVertexBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateVertexBuffer(uint bufferId, void* data, int dataSize, int offset); + [LibraryImport(NativeLibName, EntryPoint = "rlUpdateVertexBuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateVertexBuffer(uint bufferId, void* data, int dataSize, int offset); /// Update vertex buffer elements with new data - [DllImport(NativeLibName, EntryPoint = "rlUpdateVertexBufferElements", CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateVertexBufferElements(uint id, void* data, int dataSize, int offset); + [LibraryImport(NativeLibName, EntryPoint = "rlUpdateVertexBufferElements")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateVertexBufferElements(uint id, void* data, int dataSize, int offset); - [DllImport(NativeLibName, EntryPoint = "rlUnloadVertexArray", CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadVertexArray(uint vaoId); + [LibraryImport(NativeLibName, EntryPoint = "rlUnloadVertexArray")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadVertexArray(uint vaoId); - [DllImport(NativeLibName, EntryPoint = "rlUnloadVertexBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadVertexBuffer(uint vboId); + [LibraryImport(NativeLibName, EntryPoint = "rlUnloadVertexBuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadVertexBuffer(uint vboId); /// Set vertex attribute data configuration - [DllImport(NativeLibName, EntryPoint = "rlSetVertexAttribute", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetVertexAttribute( + [LibraryImport(NativeLibName, EntryPoint = "rlSetVertexAttribute")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetVertexAttribute( uint index, int compSize, int type, @@ -583,24 +686,30 @@ public static unsafe partial class Rlgl int offset ); - [DllImport(NativeLibName, EntryPoint = "rlSetVertexAttributeDivisor", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetVertexAttributeDivisor(uint index, int divisor); + [LibraryImport(NativeLibName, EntryPoint = "rlSetVertexAttributeDivisor")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetVertexAttributeDivisor(uint index, int divisor); /// Set vertex attribute default value - [DllImport(NativeLibName, EntryPoint = "rlSetVertexAttributeDefault", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetVertexAttributeDefault(int locIndex, void* value, int attribType, int count); + [LibraryImport(NativeLibName, EntryPoint = "rlSetVertexAttributeDefault")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetVertexAttributeDefault(int locIndex, void* value, int attribType, int count); - [DllImport(NativeLibName, EntryPoint = "rlDrawVertexArray", CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawVertexArray(int offset, int count); + [LibraryImport(NativeLibName, EntryPoint = "rlDrawVertexArray")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawVertexArray(int offset, int count); - [DllImport(NativeLibName, EntryPoint = "rlDrawVertexArrayElements", CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawVertexArrayElements(int offset, int count, void* buffer); + [LibraryImport(NativeLibName, EntryPoint = "rlDrawVertexArrayElements")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawVertexArrayElements(int offset, int count, void* buffer); - [DllImport(NativeLibName, EntryPoint = "rlDrawVertexArrayInstanced", CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawVertexArrayInstanced(int offset, int count, int instances); + [LibraryImport(NativeLibName, EntryPoint = "rlDrawVertexArrayInstanced")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawVertexArrayInstanced(int offset, int count, int instances); - [DllImport(NativeLibName, EntryPoint = "rlDrawVertexArrayElementsInstanced", CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawVertexArrayElementsInstanced( + [LibraryImport(NativeLibName, EntryPoint = "rlDrawVertexArrayElementsInstanced")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void DrawVertexArrayElementsInstanced( int offset, int count, void* buffer, @@ -611,20 +720,24 @@ public static unsafe partial class Rlgl // Textures data management /// Load texture in GPU - [DllImport(NativeLibName, EntryPoint = "rlLoadTexture", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadTexture(void* data, int width, int height, PixelFormat format, int mipmapCount); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadTexture")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadTexture(void* data, int width, int height, PixelFormat format, int mipmapCount); /// Load depth texture/renderbuffer (to be attached to fbo) - [DllImport(NativeLibName, EntryPoint = "rlLoadTextureDepth", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadTextureDepth(int width, int height, CBool useRenderBuffer); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureDepth")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadTextureDepth(int width, int height, CBool useRenderBuffer); /// Load texture cubemap data - [DllImport(NativeLibName, EntryPoint = "rlLoadTextureCubemap", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadTextureCubemap(void* data, int size, PixelFormat format, int mipmapCount); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureCubemap")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadTextureCubemap(void* data, int size, PixelFormat format, int mipmapCount); /// Update GPU texture with new data - [DllImport(NativeLibName, EntryPoint = "rlUpdateTexture", CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateTexture( + [LibraryImport(NativeLibName, EntryPoint = "rlUpdateTexture")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateTexture( uint id, int offsetX, int offsetY, @@ -635,8 +748,9 @@ public static unsafe partial class Rlgl ); /// Get OpenGL internal formats - [DllImport(NativeLibName, EntryPoint = "rlGetGlTextureFormats", CallingConvention = CallingConvention.Cdecl)] - public static extern void GetGlTextureFormats( + [LibraryImport(NativeLibName, EntryPoint = "rlGetGlTextureFormats")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GetGlTextureFormats( PixelFormat format, uint* glInternalFormat, uint* glFormat, @@ -644,35 +758,42 @@ public static unsafe partial class Rlgl ); /// Get OpenGL internal formats - [DllImport(NativeLibName, EntryPoint = "rlGetPixelFormatName", CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetPixelFormatName(PixelFormat format); + [LibraryImport(NativeLibName, EntryPoint = "rlGetPixelFormatName")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial sbyte* GetPixelFormatName(PixelFormat format); /// Unload texture from GPU memory - [DllImport(NativeLibName, EntryPoint = "rlUnloadTexture", CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadTexture(uint id); + [LibraryImport(NativeLibName, EntryPoint = "rlUnloadTexture")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadTexture(uint id); /// Generate mipmap data for selected texture - [DllImport(NativeLibName, EntryPoint = "rlGenTextureMipmaps", CallingConvention = CallingConvention.Cdecl)] - public static extern void GenTextureMipmaps(uint id, int width, int height, PixelFormat format, int* mipmaps); + [LibraryImport(NativeLibName, EntryPoint = "rlGenTextureMipmaps")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GenTextureMipmaps(uint id, int width, int height, PixelFormat format, int* mipmaps); /// Read texture pixel data - [DllImport(NativeLibName, EntryPoint = "rlReadTexturePixels", CallingConvention = CallingConvention.Cdecl)] - public static extern void* ReadTexturePixels(uint id, int width, int height, PixelFormat format); + [LibraryImport(NativeLibName, EntryPoint = "rlReadTexturePixels")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void* ReadTexturePixels(uint id, int width, int height, PixelFormat format); /// Read screen pixel data (color buffer) - [DllImport(NativeLibName, EntryPoint = "rlReadScreenPixels", CallingConvention = CallingConvention.Cdecl)] - public static extern byte* ReadScreenPixels(int width, int height); + [LibraryImport(NativeLibName, EntryPoint = "rlReadScreenPixels")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial byte* ReadScreenPixels(int width, int height); // Framebuffer management (fbo) /// Load an empty framebuffer - [DllImport(NativeLibName, EntryPoint = "rlLoadFramebuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadFramebuffer(); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadFramebuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadFramebuffer(); /// Attach texture/renderbuffer to a framebuffer - [DllImport(NativeLibName, EntryPoint = "rlFramebufferAttach", CallingConvention = CallingConvention.Cdecl)] - public static extern void FramebufferAttach( + [LibraryImport(NativeLibName, EntryPoint = "rlFramebufferAttach")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void FramebufferAttach( uint fboId, uint texId, FramebufferAttachType attachType, @@ -681,98 +802,119 @@ public static unsafe partial class Rlgl ); /// Verify framebuffer is complete - [DllImport(NativeLibName, EntryPoint = "rlFramebufferComplete", CallingConvention = CallingConvention.Cdecl)] - public static extern CBool FramebufferComplete(uint id); + [LibraryImport(NativeLibName, EntryPoint = "rlFramebufferComplete")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial CBool FramebufferComplete(uint id); /// Delete framebuffer from GPU - [DllImport(NativeLibName, EntryPoint = "rlUnloadFramebuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadFramebuffer(uint id); + [LibraryImport(NativeLibName, EntryPoint = "rlUnloadFramebuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadFramebuffer(uint id); // Shaders management /// Load shader from code strings - [DllImport(NativeLibName, EntryPoint = "rlLoadShaderCode", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadShaderCode(sbyte* vsCode, sbyte* fsCode); + [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)
- [DllImport(NativeLibName, EntryPoint = "rlCompileShader", CallingConvention = CallingConvention.Cdecl)] - public static extern uint CompileShader(sbyte* shaderCode, int type); + [LibraryImport(NativeLibName, EntryPoint = "rlCompileShader")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint CompileShader(sbyte* shaderCode, int type); /// Load custom shader program - [DllImport(NativeLibName, EntryPoint = "rlLoadShaderProgram", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadShaderProgram(uint vShaderId, uint fShaderId); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadShaderProgram")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadShaderProgram(uint vShaderId, uint fShaderId); /// Unload shader program - [DllImport(NativeLibName, EntryPoint = "rlUnloadShaderProgram", CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadShaderProgram(uint id); + [LibraryImport(NativeLibName, EntryPoint = "rlUnloadShaderProgram")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadShaderProgram(uint id); /// Get shader location uniform - [DllImport(NativeLibName, EntryPoint = "rlGetLocationUniform", CallingConvention = CallingConvention.Cdecl)] - public static extern int GetLocationUniform(uint shaderId, sbyte* uniformName); + [LibraryImport(NativeLibName, EntryPoint = "rlGetLocationUniform")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetLocationUniform(uint shaderId, sbyte* uniformName); /// Get shader location attribute - [DllImport(NativeLibName, EntryPoint = "rlGetLocationAttrib", CallingConvention = CallingConvention.Cdecl)] - public static extern int GetLocationAttrib(uint shaderId, sbyte* attribName); + [LibraryImport(NativeLibName, EntryPoint = "rlGetLocationAttrib")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetLocationAttrib(uint shaderId, sbyte* attribName); /// Set shader value uniform - [DllImport(NativeLibName, EntryPoint = "rlSetUniform", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetUniform(int locIndex, void* value, int uniformType, int count); + [LibraryImport(NativeLibName, EntryPoint = "rlSetUniform")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetUniform(int locIndex, void* value, int uniformType, int count); /// Set shader value matrix - [DllImport(NativeLibName, EntryPoint = "rlSetUniformMatrix", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetUniformMatrix(int locIndex, Matrix4x4 mat); + [LibraryImport(NativeLibName, EntryPoint = "rlSetUniformMatrix")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetUniformMatrix(int locIndex, Matrix4x4 mat); /// Set shader value matrices - [DllImport(NativeLibName, EntryPoint = "rlSetUniformMatrices", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetUniformMatrices(int locIndex, Matrix4x4* mat, int count); + [LibraryImport(NativeLibName, EntryPoint = "rlSetUniformMatrices")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetUniformMatrices(int locIndex, Matrix4x4* mat, int count); /// Set shader value sampler - [DllImport(NativeLibName, EntryPoint = "rlSetUniformSampler", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetUniformSampler(int locIndex, uint textureId); + [LibraryImport(NativeLibName, EntryPoint = "rlSetUniformSampler")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetUniformSampler(int locIndex, uint textureId); /// Set shader currently active (id and locations) - [DllImport(NativeLibName, EntryPoint = "rlSetShader", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShader(uint id, int* locs); + [LibraryImport(NativeLibName, EntryPoint = "rlSetShader")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetShader(uint id, int* locs); // Compute shader management /// Load compute shader program - [DllImport(NativeLibName, EntryPoint = "rlLoadComputeShaderProgram", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadComputeShaderProgram(uint shaderId); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadComputeShaderProgram")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadComputeShaderProgram(uint shaderId); /// Dispatch compute shader (equivalent to *draw* for graphics pilepine) - [DllImport(NativeLibName, EntryPoint = "rlComputeShaderDispatch", CallingConvention = CallingConvention.Cdecl)] - public static extern void ComputeShaderDispatch(uint groupX, uint groupY, uint groupZ); + [LibraryImport(NativeLibName, EntryPoint = "rlComputeShaderDispatch")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ComputeShaderDispatch(uint groupX, uint groupY, uint groupZ); // Shader buffer storage object management (ssbo) /// Load shader storage buffer object (SSBO) - [DllImport(NativeLibName, EntryPoint = "rlLoadShaderBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadShaderBuffer(uint size, void* data, int usageHint); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadShaderBuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint LoadShaderBuffer(uint size, void* data, int usageHint); /// Unload shader storage buffer object (SSBO) - [DllImport(NativeLibName, EntryPoint = "rlUnloadShaderBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadShaderBuffer(uint ssboId); + [LibraryImport(NativeLibName, EntryPoint = "rlUnloadShaderBuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UnloadShaderBuffer(uint ssboId); /// Update SSBO buffer data - [DllImport(NativeLibName, EntryPoint = "rlUpdateShaderBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateShaderBuffer(uint id, void* data, uint dataSize, uint offset); + [LibraryImport(NativeLibName, EntryPoint = "rlUpdateShaderBuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void UpdateShaderBuffer(uint id, void* data, uint dataSize, uint offset); /// Bind SSBO buffer data - [DllImport(NativeLibName, EntryPoint = "rlBindShaderBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void BindShaderBuffer(uint id, uint index); + [LibraryImport(NativeLibName, EntryPoint = "rlBindShaderBuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void BindShaderBuffer(uint id, uint index); /// Read SSBO buffer data (GPU->CPU) - [DllImport(NativeLibName, EntryPoint = "rlReadShaderBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void ReadShaderBuffer(uint id, void* dest, uint count, uint offset); + [LibraryImport(NativeLibName, EntryPoint = "rlReadShaderBuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ReadShaderBuffer(uint id, void* dest, uint count, uint offset); /// Copy SSBO data between buffers - [DllImport(NativeLibName, EntryPoint = "rlCopyShaderBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void CopyShaderBuffer( + [LibraryImport(NativeLibName, EntryPoint = "rlCopyShaderBuffer")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CopyShaderBuffer( uint destId, uint srcId, uint destOffset, @@ -781,63 +923,76 @@ public static unsafe partial class Rlgl ); /// Get SSBO buffer size - [DllImport(NativeLibName, EntryPoint = "rlGetShaderBufferSize", CallingConvention = CallingConvention.Cdecl)] - public static extern uint GetShaderBufferSize(uint id); + [LibraryImport(NativeLibName, EntryPoint = "rlGetShaderBufferSize")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial uint GetShaderBufferSize(uint id); // Buffer management /// Bind image texture - [DllImport(NativeLibName, EntryPoint = "rlBindImageTexture", CallingConvention = CallingConvention.Cdecl)] - public static extern void BindImageTexture(uint id, uint index, int format, CBool readOnly); + [LibraryImport(NativeLibName, EntryPoint = "rlBindImageTexture")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void BindImageTexture(uint id, uint index, int format, CBool readOnly); // Matrix state management /// Get internal modelview matrix - [DllImport(NativeLibName, EntryPoint = "rlGetMatrixModelview", CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetMatrixModelview(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetMatrixModelview")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 GetMatrixModelview(); /// Get internal projection matrix - [DllImport(NativeLibName, EntryPoint = "rlGetMatrixProjection", CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetMatrixProjection(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetMatrixProjection")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 GetMatrixProjection(); /// Get internal accumulated transform matrix - [DllImport(NativeLibName, EntryPoint = "rlGetMatrixTransform", CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetMatrixTransform(); + [LibraryImport(NativeLibName, EntryPoint = "rlGetMatrixTransform")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 GetMatrixTransform(); /// Get internal projection matrix for stereo render (selected eye) - [DllImport(NativeLibName, EntryPoint = "rlGetMatrixProjectionStereo", CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetMatrixProjectionStereo(int eye); + [LibraryImport(NativeLibName, EntryPoint = "rlGetMatrixProjectionStereo")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 GetMatrixProjectionStereo(int eye); /// Get internal view offset matrix for stereo render (selected eye) - [DllImport(NativeLibName, EntryPoint = "rlGetMatrixViewOffsetStereo", CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetMatrixViewOffsetStereo(int eye); + [LibraryImport(NativeLibName, EntryPoint = "rlGetMatrixViewOffsetStereo")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial Matrix4x4 GetMatrixViewOffsetStereo(int eye); /// Set a custom projection matrix (replaces internal projection matrix) - [DllImport(NativeLibName, EntryPoint = "rlSetMatrixProjection", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMatrixProjection(Matrix4x4 view); + [LibraryImport(NativeLibName, EntryPoint = "rlSetMatrixProjection")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMatrixProjection(Matrix4x4 view); /// Set a custom modelview matrix (replaces internal modelview matrix) - [DllImport(NativeLibName, EntryPoint = "rlSetMatrixModelview", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMatrixModelView(Matrix4x4 proj); + [LibraryImport(NativeLibName, EntryPoint = "rlSetMatrixModelview")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMatrixModelView(Matrix4x4 proj); /// Set eyes projection matrices for stereo rendering - [DllImport(NativeLibName, EntryPoint = "rlSetMatrixProjectionStereo", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMatrixProjectionStereo(Matrix4x4 left, Matrix4x4 right); + [LibraryImport(NativeLibName, EntryPoint = "rlSetMatrixProjectionStereo")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMatrixProjectionStereo(Matrix4x4 left, Matrix4x4 right); /// Set eyes view offsets matrices for stereo rendering - [DllImport(NativeLibName, EntryPoint = "rlSetMatrixViewOffsetStereo", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMatrixViewOffsetStereo(Matrix4x4 left, Matrix4x4 right); + [LibraryImport(NativeLibName, EntryPoint = "rlSetMatrixViewOffsetStereo")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMatrixViewOffsetStereo(Matrix4x4 left, Matrix4x4 right); // Quick and dirty cube/quad buffers load->draw->unload /// Load and draw a cube - [DllImport(NativeLibName, EntryPoint = "rlLoadDrawCube", CallingConvention = CallingConvention.Cdecl)] - public static extern void LoadDrawCube(); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadDrawCube")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void LoadDrawCube(); /// Load and draw a quad - [DllImport(NativeLibName, EntryPoint = "rlLoadDrawQuad", CallingConvention = CallingConvention.Cdecl)] - public static extern void LoadDrawQuad(); + [LibraryImport(NativeLibName, EntryPoint = "rlLoadDrawQuad")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void LoadDrawQuad(); } diff --git a/Raylib-cs/types/Logging.cs b/Raylib-cs/types/Logging.cs index 3c51234..b65ffd6 100644 --- a/Raylib-cs/types/Logging.cs +++ b/Raylib-cs/types/Logging.cs @@ -2,30 +2,36 @@ // For more information see the dotnet issue: https://github.com/dotnet/runtime/issues/9316 // Example of va_list interop: https://github.com/jeremyVignelles/va-list-interop-demo using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace Raylib_cs; -internal readonly struct Native +internal readonly partial struct Native { internal const string Msvcrt = "msvcrt"; internal const string Libc = "libc"; internal const string LibSystem = "libSystem"; - [DllImport(LibSystem, EntryPoint = "vasprintf", CallingConvention = CallingConvention.Cdecl)] - public static extern int VasPrintfApple(ref IntPtr buffer, IntPtr format, IntPtr args); + [LibraryImport(LibSystem, EntryPoint = "vasprintf")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int VasPrintfApple(ref IntPtr buffer, IntPtr format, IntPtr args); - [DllImport(Libc, EntryPoint = "vsprintf", CallingConvention = CallingConvention.Cdecl)] - public static extern int VsPrintfLinux(IntPtr buffer, IntPtr format, IntPtr args); + [LibraryImport(Libc, EntryPoint = "vsprintf")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int VsPrintfLinux(IntPtr buffer, IntPtr format, IntPtr args); - [DllImport(Msvcrt, EntryPoint = "vsprintf", CallingConvention = CallingConvention.Cdecl)] - public static extern int VsPrintfWindows(IntPtr buffer, IntPtr format, IntPtr args); + [LibraryImport(Msvcrt, EntryPoint = "vsprintf")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int VsPrintfWindows(IntPtr buffer, IntPtr format, IntPtr args); - [DllImport(Libc, EntryPoint = "vsnprintf", CallingConvention = CallingConvention.Cdecl)] - public static extern int VsnPrintfLinux(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args); + [LibraryImport(Libc, EntryPoint = "vsnprintf")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int VsnPrintfLinux(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args); - [DllImport(Msvcrt, EntryPoint = "vsnprintf", CallingConvention = CallingConvention.Cdecl)] - public static extern int VsnPrintfWindows(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args); + [LibraryImport(Msvcrt, EntryPoint = "vsnprintf")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int VsnPrintfWindows(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args); } [StructLayout(LayoutKind.Sequential, Pack = 4)]