diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7a88c35 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,51 @@ +# EditorConfig is awesome: http://EditorConfig.org + +root = true + +[*] +indent_style = space + +# General +[*.{cs,csx,vb,vbx}] +indent_size = 4 +insert_final_newline = true +charset = utf-8 +trim_trailing_whitespace = true + +# C# styles +[*.cs] +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_switch_labels = true +csharp_indent_labels = flush_left +csharp_style_namespace_declarations = file_scoped:warning + +# Newline settings +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true + +# Spacing +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_around_binary_operators = before_and_after +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false + +# Blocks are allowed +csharp_prefer_braces = true:error +csharp_preserve_single_line_blocks = false +csharp_preserve_single_line_statements = false diff --git a/Raylib-cs.Tests/BlittableHelper.cs b/Raylib-cs.Tests/BlittableHelper.cs index 4b9e497..d8d6cfd 100644 --- a/Raylib-cs.Tests/BlittableHelper.cs +++ b/Raylib-cs.Tests/BlittableHelper.cs @@ -30,41 +30,40 @@ using System; using System.Runtime.InteropServices; using System.Runtime.Serialization; -namespace Raylib_cs.Tests +namespace Raylib_cs.Tests; + +public static class BlittableHelper { - public static class BlittableHelper + public static bool IsBlittable() { - public static bool IsBlittable() - { - return IsBlittableCache.VALUE; - } + return IsBlittableCache.VALUE; + } - public static bool IsBlittable(this Type type) + public static bool IsBlittable(this Type type) + { + if (type == typeof(decimal)) { - if (type == typeof(decimal)) - { - return false; - } - if (type.IsArray) - { - var elementType = type.GetElementType(); - return elementType != null && elementType.IsValueType && IsBlittable(elementType); - } - try - { - var instance = FormatterServices.GetUninitializedObject(type); - GCHandle.Alloc(instance, GCHandleType.Pinned).Free(); - return true; - } - catch - { - return false; - } + return false; } - - private static class IsBlittableCache + if (type.IsArray) { - public static readonly bool VALUE = IsBlittable(typeof(T)); + var elementType = type.GetElementType(); + return elementType != null && elementType.IsValueType && IsBlittable(elementType); + } + try + { + var instance = FormatterServices.GetUninitializedObject(type); + GCHandle.Alloc(instance, GCHandleType.Pinned).Free(); + return true; + } + catch + { + return false; } } + + private static class IsBlittableCache + { + public static readonly bool VALUE = IsBlittable(typeof(T)); + } } diff --git a/Raylib-cs.Tests/RaylibTests.cs b/Raylib-cs.Tests/RaylibTests.cs index 42b16ff..e3b7825 100644 --- a/Raylib-cs.Tests/RaylibTests.cs +++ b/Raylib-cs.Tests/RaylibTests.cs @@ -1,46 +1,45 @@ using System; using Xunit; -namespace Raylib_cs.Tests -{ - public class RaylibTests - { - private unsafe void CheckType() where T : unmanaged - { - Assert.True(BlittableHelper.IsBlittable()); - } +namespace Raylib_cs.Tests; - [Fact] - public void CheckTypes() - { - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - CheckType(); - } +public class RaylibTests +{ + private unsafe void CheckType() where T : unmanaged + { + Assert.True(BlittableHelper.IsBlittable()); + } + + [Fact] + public void CheckTypes() + { + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); + CheckType(); } } diff --git a/Raylib-cs/interop/Raylib.cs b/Raylib-cs/interop/Raylib.cs index be02d6f..71a1279 100644 --- a/Raylib-cs/interop/Raylib.cs +++ b/Raylib-cs/interop/Raylib.cs @@ -3,2684 +3,2683 @@ using System.Numerics; using System.Runtime.InteropServices; using System.Security; -namespace Raylib_cs +namespace Raylib_cs; + +[SuppressUnmanagedCodeSecurity] +public static unsafe partial class Raylib { - [SuppressUnmanagedCodeSecurity] - public static unsafe partial class Raylib - { - /// - /// Used by DllImport to load the native library - /// - public const string NativeLibName = "raylib"; - - public const string RAYLIB_VERSION = "4.5"; + /// + /// Used by DllImport to load the native library + /// + public const string NativeLibName = "raylib"; - public const float DEG2RAD = MathF.PI / 180.0f; - public const float RAD2DEG = 180.0f / MathF.PI; + public const string RAYLIB_VERSION = "4.5"; - /// - /// Get color with alpha applied, alpha goes from 0.0f to 1.0f
- /// NOTE: Added for compatability with previous versions - ///
- public static Color Fade(Color color, float alpha) => ColorAlpha(color, alpha); + public const float DEG2RAD = MathF.PI / 180.0f; + public const float RAD2DEG = 180.0f / MathF.PI; - //------------------------------------------------------------------------------------ - // Window and Graphics Device Functions (Module: core) - //------------------------------------------------------------------------------------ + /// + /// Get color with alpha applied, alpha goes from 0.0f to 1.0f
+ /// NOTE: Added for compatability with previous versions + ///
+ public static Color Fade(Color color, float alpha) => ColorAlpha(color, alpha); - // Window-related functions + //------------------------------------------------------------------------------------ + // Window and Graphics Device Functions (Module: core) + //------------------------------------------------------------------------------------ - /// Initialize window and OpenGL context - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void InitWindow(int width, int height, sbyte* title); + // Window-related functions - /// Check if KEY_ESCAPE pressed or Close icon pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool WindowShouldClose(); + /// Initialize window and OpenGL context + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void InitWindow(int width, int height, sbyte* title); - /// Close window and unload OpenGL context - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CloseWindow(); + /// Check if KEY_ESCAPE pressed or Close icon pressed + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool WindowShouldClose(); - /// Check if window has been initialized successfully - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowReady(); + /// Close window and unload OpenGL context + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void CloseWindow(); - /// Check if window is currently fullscreen - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowFullscreen(); + /// Check if window has been initialized successfully + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsWindowReady(); - /// Check if window is currently hidden (only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowHidden(); + /// Check if window is currently fullscreen + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsWindowFullscreen(); - /// Check if window is currently minimized (only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowMinimized(); + /// Check if window is currently hidden (only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsWindowHidden(); - /// Check if window is currently maximized (only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowMaximized(); + /// Check if window is currently minimized (only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsWindowMinimized(); - /// Check if window is currently focused (only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowFocused(); + /// Check if window is currently maximized (only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsWindowMaximized(); - /// Check if window has been resized last frame - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowResized(); + /// Check if window is currently focused (only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsWindowFocused(); - /// Check if one specific window flag is enabled - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWindowState(ConfigFlags flag); + /// Check if window has been resized last frame + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsWindowResized(); - /// Set window configuration state using flags - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool SetWindowState(ConfigFlags flag); + /// Check if one specific window flag is enabled + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsWindowState(ConfigFlags flag); - /// Clear window configuration state flags - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ClearWindowState(ConfigFlags flag); + /// Set window configuration state using flags + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool SetWindowState(ConfigFlags flag); - /// Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ToggleFullscreen(); + /// Clear window configuration state flags + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ClearWindowState(ConfigFlags flag); - /// Set window state: maximized, if resizable (only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void MaximizeWindow(); + /// Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ToggleFullscreen(); - /// Set window state: minimized, if resizable (only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void MinimizeWindow(); + /// Set window state: maximized, if resizable (only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MaximizeWindow(); - /// Set window state: not minimized/maximized (only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void RestoreWindow(); + /// Set window state: minimized, if resizable (only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MinimizeWindow(); - /// Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowIcon(Image image); + /// Set window state: not minimized/maximized (only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void RestoreWindow(); - /// Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowIcons(Image* images, int count); + /// Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetWindowIcon(Image image); - /// Set title for window (only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowTitle(sbyte* title); + /// Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetWindowIcons(Image* images, int count); - /// Set window position on screen (only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowPosition(int x, int y); + /// Set title for window (only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetWindowTitle(sbyte* title); - /// Set monitor for the current window (fullscreen mode) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowMonitor(int monitor); + /// Set window position on screen (only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetWindowPosition(int x, int y); - /// Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowMinSize(int width, int height); + /// Set monitor for the current window (fullscreen mode) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetWindowMonitor(int monitor); - /// Set window dimensions - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowSize(int width, int height); + /// Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetWindowMinSize(int width, int height); - /// Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetWindowOpacity(float opacity); + /// Set window dimensions + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetWindowSize(int width, int height); - /// Get native window handle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void* GetWindowHandle(); + /// Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetWindowOpacity(float opacity); - /// Get current screen width - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetScreenWidth(); + /// Get native window handle + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void* GetWindowHandle(); - /// Get current screen height - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetScreenHeight(); + /// Get current screen width + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetScreenWidth(); - /// Get current render width (it considers HiDPI) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetRenderWidth(); + /// Get current screen height + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetScreenHeight(); - /// Get current render height (it considers HiDPI) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetRenderHeight(); + /// Get current render width (it considers HiDPI) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetRenderWidth(); - /// Get number of connected monitors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMonitorCount(); + /// Get current render height (it considers HiDPI) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetRenderHeight(); - /// Get current connected monitor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetCurrentMonitor(); + /// Get number of connected monitors + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetMonitorCount(); - /// Get specified monitor position - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetMonitorPosition(int monitor); + /// Get current connected monitor + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetCurrentMonitor(); - /// Get specified monitor width - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMonitorWidth(int monitor); + /// Get specified monitor position + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetMonitorPosition(int monitor); - /// Get specified monitor height - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMonitorHeight(int monitor); + /// Get specified monitor width + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetMonitorWidth(int monitor); - /// Get specified monitor physical width in millimetres - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMonitorPhysicalWidth(int monitor); + /// Get specified monitor height + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetMonitorHeight(int monitor); - /// Get specified monitor physical height in millimetres - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMonitorPhysicalHeight(int monitor); + /// Get specified monitor physical width in millimetres + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetMonitorPhysicalWidth(int monitor); - /// Get specified monitor refresh rate - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMonitorRefreshRate(int monitor); + /// Get specified monitor physical height in millimetres + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetMonitorPhysicalHeight(int monitor); - /// Get window position XY on monitor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetWindowPosition(); + /// Get specified monitor refresh rate + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetMonitorRefreshRate(int monitor); - /// Get window scale DPI factor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetWindowScaleDPI(); + /// Get window position XY on monitor + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetWindowPosition(); - /// Get the human-readable, UTF-8 encoded name of the specified monitor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetMonitorName(int monitor); + /// Get window scale DPI factor + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetWindowScaleDPI(); - /// Get clipboard text content - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetClipboardText(); + /// Get the human-readable, UTF-8 encoded name of the specified monitor + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* GetMonitorName(int monitor); - /// Set clipboard text content - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetClipboardText(sbyte* text); + /// Get clipboard text content + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* GetClipboardText(); - /// Enable waiting for events on EndDrawing(), no automatic event polling - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableEventWaiting(); + /// Set clipboard text content + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetClipboardText(sbyte* text); - /// Disable waiting for events on EndDrawing(), automatic events polling - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableEventWaiting(); + /// Enable waiting for events on EndDrawing(), no automatic event polling + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableEventWaiting(); - // Custom frame control functions - // NOTE: Those functions are intended for advance users that want full control over the frame processing - // By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timming + PollInputEvents() - // To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL + /// Disable waiting for events on EndDrawing(), automatic events polling + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableEventWaiting(); - /// Swap back buffer with front buffer (screen drawing) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SwapScreenBuffer(); + // Custom frame control functions + // NOTE: Those functions are intended for advance users that want full control over the frame processing + // By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timming + PollInputEvents() + // To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL - /// Register all input events - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PollInputEvents(); + /// Swap back buffer with front buffer (screen drawing) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SwapScreenBuffer(); - /// Wait for some time (halt program execution) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void WaitTime(double seconds); + /// Register all input events + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void PollInputEvents(); - // Cursor-related functions + /// Wait for some time (halt program execution) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void WaitTime(double seconds); - /// Shows cursor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ShowCursor(); + // Cursor-related functions - /// Hides cursor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void HideCursor(); + /// Shows cursor + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ShowCursor(); - /// Check if cursor is not visible - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsCursorHidden(); + /// Hides cursor + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void HideCursor(); - /// Enables cursor (unlock cursor) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableCursor(); + /// Check if cursor is not visible + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsCursorHidden(); - /// Disables cursor (lock cursor) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableCursor(); + /// Enables cursor (unlock cursor) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableCursor(); - /// Check if cursor is on the screen - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsCursorOnScreen(); + /// Disables cursor (lock cursor) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableCursor(); + /// Check if cursor is on the screen + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsCursorOnScreen(); - // Drawing-related functions - /// Set background color (framebuffer clear color) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ClearBackground(Color color); + // Drawing-related functions - /// Setup canvas (framebuffer) to start drawing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginDrawing(); + /// Set background color (framebuffer clear color) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ClearBackground(Color color); - /// End canvas drawing and swap buffers (double buffering) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndDrawing(); + /// Setup canvas (framebuffer) to start drawing + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void BeginDrawing(); - /// Initialize 2D mode with custom camera (2D) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginMode2D(Camera2D camera); + /// End canvas drawing and swap buffers (double buffering) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void EndDrawing(); - /// Ends 2D mode with custom camera - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndMode2D(); + /// Initialize 2D mode with custom camera (2D) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void BeginMode2D(Camera2D camera); - /// Initializes 3D mode with custom camera (3D) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginMode3D(Camera3D camera); + /// Ends 2D mode with custom camera + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void EndMode2D(); - /// Ends 3D mode and returns to default 2D orthographic mode - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndMode3D(); + /// Initializes 3D mode with custom camera (3D) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void BeginMode3D(Camera3D camera); - /// Initializes render texture for drawing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginTextureMode(RenderTexture2D target); + /// Ends 3D mode and returns to default 2D orthographic mode + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void EndMode3D(); - /// Ends drawing to render texture - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndTextureMode(); + /// Initializes render texture for drawing + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void BeginTextureMode(RenderTexture2D target); - /// Begin custom shader drawing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginShaderMode(Shader shader); + /// Ends drawing to render texture + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void EndTextureMode(); - /// End custom shader drawing (use default shader) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndShaderMode(); + /// Begin custom shader drawing + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void BeginShaderMode(Shader shader); - /// Begin blending mode (alpha, additive, multiplied) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginBlendMode(BlendMode mode); + /// End custom shader drawing (use default shader) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void EndShaderMode(); - /// End blending mode (reset to default: alpha blending) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndBlendMode(); + /// Begin blending mode (alpha, additive, multiplied) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void BeginBlendMode(BlendMode mode); - /// 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); + /// End blending mode (reset to default: alpha blending) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void EndBlendMode(); - /// End scissor mode - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndScissorMode(); + /// 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); - /// Begin stereo rendering (requires VR simulator) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void BeginVrStereoMode(VrStereoConfig config); + /// End scissor mode + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void EndScissorMode(); - /// End stereo rendering (requires VR simulator) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void EndVrStereoMode(); + /// Begin stereo rendering (requires VR simulator) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void BeginVrStereoMode(VrStereoConfig config); + /// End stereo rendering (requires VR simulator) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + // VR stereo config functions for VR simulator - /// Unload VR stereo configs - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadVrStereoConfig(VrStereoConfig config); + /// Load VR stereo config for VR simulator device parameters + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device); + /// Unload VR stereo configs + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + // Shader management functions - /// Load shader from code strings and bind default locations - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Shader LoadShaderFromMemory(sbyte* vsCode, sbyte* fsCode); + /// Load shader from files and bind default locations + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Shader LoadShader(sbyte* vsFileName, sbyte* fsFileName); - /// Check if a shader is ready - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsShaderReady(Shader shader); + /// Load shader from code strings and bind default locations + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Shader LoadShaderFromMemory(sbyte* vsCode, sbyte* fsCode); - /// Get shader uniform location - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetShaderLocation(Shader shader, sbyte* uniformName); + /// Check if a shader is ready + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsShaderReady(Shader shader); - /// Get shader attribute location - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetShaderLocationAttrib(Shader shader, sbyte* attribName); + /// Get shader uniform location + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetShaderLocation(Shader shader, sbyte* uniformName); - /// Set shader uniform value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValue( - Shader shader, - int locIndex, - void* value, - ShaderUniformDataType uniformType - ); + /// Get shader attribute location + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetShaderLocationAttrib(Shader shader, sbyte* attribName); - /// Set shader uniform value vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValueV( - Shader shader, - int locIndex, - void* value, - ShaderUniformDataType uniformType, - int count - ); + /// Set shader uniform value + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetShaderValue( + Shader shader, + int locIndex, + void* value, + ShaderUniformDataType uniformType + ); - /// Set shader uniform value (matrix 4x4) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValueMatrix(Shader shader, int locIndex, Matrix4x4 mat); + /// Set shader uniform value vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetShaderValueV( + Shader shader, + int locIndex, + void* value, + ShaderUniformDataType uniformType, + int count + ); - /// Set shader uniform value for texture (sampler2d) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture); + /// Set shader uniform value (matrix 4x4) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetShaderValueMatrix(Shader shader, int locIndex, Matrix4x4 mat); - /// Unload shader from GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadShader(Shader shader); + /// Set shader uniform value for texture (sampler2d) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); - // Screen-space-related functions - /// Get a ray trace from mouse position - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Ray GetMouseRay(Vector2 mousePosition, Camera3D camera); + // Screen-space-related functions - /// Get camera transform matrix (view matrix) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetCameraMatrix(Camera3D camera); + /// Get a ray trace from mouse position + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Ray GetMouseRay(Vector2 mousePosition, Camera3D camera); - /// Get camera 2d transform matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetCameraMatrix2D(Camera2D camera); + /// Get camera transform matrix (view matrix) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 GetCameraMatrix(Camera3D 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); + /// Get camera 2d transform matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 GetCameraMatrix2D(Camera2D 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); + /// 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); - /// 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); + /// 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); - /// 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); + /// 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); + /// 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); - // Timing-related functions - /// Set target FPS (maximum) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetTargetFPS(int fps); + // Timing-related functions - /// Get current FPS - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetFPS(); + /// Set target FPS (maximum) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetTargetFPS(int fps); - /// Get time in seconds for last frame drawn - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetFrameTime(); + /// Get current FPS + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetFPS(); - /// Get elapsed time in seconds since InitWindow() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern double GetTime(); + /// Get time in seconds for last frame drawn + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float GetFrameTime(); + /// Get elapsed time in seconds since InitWindow() + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + // Misc. functions - /// Set the seed for the random number generator - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SetRandomSeed(uint seed); + /// Get a random value between min and max (both included) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetRandomValue(int min, int max); - /// Takes a screenshot of current screen (saved a .png) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void TakeScreenshot(sbyte* fileName); + /// Set the seed for the random number generator + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SetRandomSeed(uint seed); - /// Setup window configuration flags (view FLAGS) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetConfigFlags(ConfigFlags flags); + /// Takes a screenshot of current screen (saved a .png) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void TakeScreenshot(sbyte* fileName); - /// 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); + /// Setup window configuration flags (view FLAGS) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetConfigFlags(ConfigFlags flags); - /// Set the current threshold (minimum) log level - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetTraceLogLevel(TraceLogLevel logLevel); + /// 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); - /// Internal memory allocator - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void* MemAlloc(int size); + /// Set the current threshold (minimum) log level + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetTraceLogLevel(TraceLogLevel logLevel); - /// Internal memory reallocator - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void* MemRealloc(void* ptr, int size); + /// Internal memory allocator + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void* MemAlloc(int size); - /// Internal memory free - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void MemFree(void* ptr); + /// Internal memory reallocator + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void* MemRealloc(void* ptr, int size); + /// Internal memory free + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + // Set custom callbacks + // WARNING: Callbacks setup is intended for advance users - /// Set custom file binary data loader - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetLoadFileDataCallback(delegate* unmanaged[Cdecl] callback); + /// Set custom trace log + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetTraceLogCallback(delegate* unmanaged[Cdecl] callback); - /// Set custom file binary data saver - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetSaveFileDataCallback( - delegate* unmanaged[Cdecl] callback - ); + /// Set custom file binary data loader + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetLoadFileDataCallback(delegate* unmanaged[Cdecl] callback); - /// Set custom file text data loader - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetLoadFileTextCallback(delegate* unmanaged[Cdecl] callback); + /// Set custom file binary data saver + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetSaveFileDataCallback( + delegate* unmanaged[Cdecl] callback + ); - /// Set custom file text data saver - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetSaveFileTextCallback(delegate* unmanaged[Cdecl] callback); + /// Set custom file text data loader + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); - // Files management functions - /// Load file data as byte array (read) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern byte* LoadFileData(sbyte* fileName, uint* bytesRead); + // Files management functions - /// Unload file data allocated by LoadFileData() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadFileData(byte* data); + /// Load file data as byte array (read) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern byte* LoadFileData(sbyte* fileName, uint* bytesRead); - /// 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, uint bytesToWrite); + /// Unload file data allocated by LoadFileData() + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadFileData(byte* data); - /// Export data to code (.h), returns true on success - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportDataAsCode(byte* data, uint size, sbyte* fileName); + /// 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, uint bytesToWrite); - // Load text data from file (read), returns a '\0' terminated string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* LoadFileText(sbyte* fileName); + /// Export data to code (.h), returns true on success + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool ExportDataAsCode(byte* data, uint size, sbyte* fileName); - // Unload file text data allocated by LoadFileText() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadFileText(sbyte* text); + // Load text data from file (read), returns a '\0' terminated string + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* LoadFileText(sbyte* fileName); - // 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); + // Unload file text data allocated by LoadFileText() + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadFileText(sbyte* text); - // Check if file exists - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool FileExists(sbyte* fileName); + // 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); - // Check if a directory path exists - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool DirectoryExists(sbyte* dirPath); + // Check if file exists + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool FileExists(sbyte* fileName); - /// Check file extension (including point: .png, .wav) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsFileExtension(sbyte* fileName, sbyte* ext); + // Check if a directory path exists + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool DirectoryExists(sbyte* dirPath); - /// Get file length in bytes - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetFileLength(sbyte* fileName); + /// Check file extension (including point: .png, .wav) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsFileExtension(sbyte* fileName, sbyte* ext); - /// Get pointer to extension for a filename string (includes dot: '.png') - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetFileExtension(sbyte* fileName); + /// Get file length in bytes + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetFileLength(sbyte* fileName); - /// Get pointer to filename for a path string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetFileName(sbyte* filePath); + /// Get pointer to extension for a filename string (includes dot: '.png') + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* GetFileExtension(sbyte* fileName); - /// Get filename string without extension (uses static string) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetFileNameWithoutExt(sbyte* filePath); + /// Get pointer to filename for a path string + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* GetFileName(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); + /// Get filename string without extension (uses static string) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* GetFileNameWithoutExt(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); + /// Get full path for a given fileName with path (uses static string) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* GetDirectoryPath(sbyte* filePath); - /// Get current working directory (uses static string) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetWorkingDirectory(); + /// Get previous directory path for a given path (uses static string) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* GetPrevDirectoryPath(sbyte* dirPath); - /// Get the directory of the running application (uses static string) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetApplicationDirectory(); + /// Get current working directory (uses static string) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* GetWorkingDirectory(); - /// Load directory filepaths - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern FilePathList LoadDirectoryFiles(sbyte* dirPath, int* count); + /// Get the directory of the running application (uses static string) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* GetApplicationDirectory(); - /// Load directory filepaths with extension filtering and recursive directory scan - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern FilePathList LoadDirectoryFilesEx(sbyte* basePath, sbyte* filter, CBool scanSubdirs); + /// Load directory filepaths + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern FilePathList LoadDirectoryFiles(sbyte* dirPath, int* count); - /// Unload filepaths - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadDirectoryFiles(FilePathList files); + /// Load directory filepaths with extension filtering and recursive directory scan + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern FilePathList LoadDirectoryFilesEx(sbyte* basePath, sbyte* filter, CBool scanSubdirs); - /// Check if a given path is a file or a directory - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsPathFile(sbyte* path); + /// Unload filepaths + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadDirectoryFiles(FilePathList files); - /// Change working directory, return true on success - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ChangeDirectory(sbyte* dir); + /// Check if a given path is a file or a directory + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsPathFile(sbyte* path); - /// Check if a file has been dropped into window - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsFileDropped(); + /// Change working directory, return true on success + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool ChangeDirectory(sbyte* dir); - /// Load dropped filepaths - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern FilePathList LoadDroppedFiles(); + /// Check if a file has been dropped into window + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsFileDropped(); - /// Unload dropped filepaths - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadDroppedFiles(FilePathList files); + /// Load dropped filepaths + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern FilePathList LoadDroppedFiles(); - /// Get file modification time (last write time) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern long GetFileModTime(sbyte* fileName); + /// Unload dropped filepaths + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadDroppedFiles(FilePathList files); + /// Get file modification time (last write time) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + // Compression/Encoding functionality - /// Decompress data (DEFLATE algorithm), memory must be MemFree() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern byte* DecompressData(byte* compData, int compDataSize, int* dataSize); + /// Compress data (DEFLATE algorithm), memory must be MemFree() + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern byte* CompressData(byte* data, int dataSize, int* compDataSize); - /// 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); + /// Decompress data (DEFLATE algorithm), memory must be MemFree() + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern byte* DecompressData(byte* compData, int compDataSize, int* dataSize); - /// Decode Base64 string data, memory must be MemFree() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern byte* DecodeDataBase64(byte* data, int* outputSize); + /// 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); - /// Open URL with default system browser (if available) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void OpenURL(sbyte* url); + /// Decode Base64 string data, memory must be MemFree() + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern byte* DecodeDataBase64(byte* data, int* outputSize); - //------------------------------------------------------------------------------------ - // Input Handling Functions (Module: core) - //------------------------------------------------------------------------------------ + /// Open URL with default system browser (if available) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void OpenURL(sbyte* url); - // Input-related functions: keyboard + //------------------------------------------------------------------------------------ + // Input Handling Functions (Module: core) + //------------------------------------------------------------------------------------ - /// Detect if a key has been pressed once - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsKeyPressed(KeyboardKey key); + // Input-related functions: keyboard - /// Detect if a key is being pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsKeyDown(KeyboardKey key); + /// Detect if a key has been pressed once + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsKeyPressed(KeyboardKey key); - /// Detect if a key has been released once - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsKeyReleased(KeyboardKey key); + /// Detect if a key is being pressed + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsKeyDown(KeyboardKey key); - /// Detect if a key is NOT being pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsKeyUp(KeyboardKey key); + /// Detect if a key has been released once + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsKeyReleased(KeyboardKey key); - /// Set a custom key to exit program (default is ESC) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetExitKey(KeyboardKey key); + /// Detect if a key is NOT being pressed + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsKeyUp(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(); + /// Set a custom key to exit program (default is ESC) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetExitKey(KeyboardKey key); - /// - /// 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(); + /// + /// 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(); + /// + /// 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(); - // Input-related functions: gamepads - /// Detect if a gamepad is available - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsGamepadAvailable(int gamepad); + // Input-related functions: gamepads - /// Get gamepad internal name id - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetGamepadName(int gamepad); + /// Detect if a gamepad is available + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsGamepadAvailable(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); + /// Get gamepad internal name id + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* GetGamepadName(int gamepad); - /// Detect if a gamepad button is being pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsGamepadButtonDown(int gamepad, GamepadButton button); + /// Detect if a gamepad button has been pressed once + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsGamepadButtonPressed(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); + /// Detect if a gamepad button is being pressed + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsGamepadButtonDown(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); + /// Detect if a gamepad button has been released once + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsGamepadButtonReleased(int gamepad, GamepadButton button); - /// Get the last gamepad button pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetGamepadButtonPressed(); + /// Detect if a gamepad button is NOT being pressed + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsGamepadButtonUp(int gamepad, GamepadButton button); - /// Get gamepad axis count for a gamepad - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetGamepadAxisCount(int gamepad); + /// Get the last gamepad button pressed + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetGamepadButtonPressed(); - /// Get axis movement value for a gamepad axis - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetGamepadAxisMovement(int gamepad, GamepadAxis axis); + /// Get gamepad axis count for a gamepad + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetGamepadAxisCount(int gamepad); - /// Set internal gamepad mappings (SDL_GameControllerDB) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SetGamepadMappings(sbyte* mappings); + /// Get axis movement value for a gamepad axis + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float GetGamepadAxisMovement(int gamepad, GamepadAxis axis); + /// Set internal gamepad mappings (SDL_GameControllerDB) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SetGamepadMappings(sbyte* mappings); - // 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); + // Input-related functions: mouse - /// Detect if a mouse button is being pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMouseButtonDown(MouseButton button); + /// Detect if a mouse button has been pressed once + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsMouseButtonPressed(MouseButton button); - /// Detect if a mouse button has been released once - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMouseButtonReleased(MouseButton button); + /// Detect if a mouse button is being pressed + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsMouseButtonDown(MouseButton button); - /// Detect if a mouse button is NOT being pressed - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMouseButtonUp(MouseButton button); + /// Detect if a mouse button has been released once + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsMouseButtonReleased(MouseButton button); - /// Get mouse position X - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMouseX(); + /// Detect if a mouse button is NOT being pressed + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsMouseButtonUp(MouseButton button); - /// Get mouse position Y - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetMouseY(); + /// Get mouse position X + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetMouseX(); - /// Get mouse position XY - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetMousePosition(); + /// Get mouse position Y + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetMouseY(); - /// Get mouse delta between frames - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetMouseDelta(); + /// Get mouse position XY + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetMousePosition(); - /// Set mouse position XY - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMousePosition(int x, int y); + /// Get mouse delta between frames + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetMouseDelta(); - /// Set mouse offset - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMouseOffset(int offsetX, int offsetY); + /// Set mouse position XY + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetMousePosition(int x, int y); - /// Set mouse scaling - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMouseScale(float scaleX, float scaleY); + /// Set mouse offset + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetMouseOffset(int offsetX, int offsetY); - /// Get mouse wheel movement for X or Y, whichever is larger - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetMouseWheelMove(); + /// Set mouse scaling + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetMouseScale(float scaleX, float scaleY); - /// Get mouse wheel movement for both X and Y - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetMouseWheelMoveV(); + /// Get mouse wheel movement for X or Y, whichever is larger + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float GetMouseWheelMove(); - /// Set mouse cursor - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMouseCursor(MouseCursor cursor); + /// Get mouse wheel movement for both X and Y + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetMouseWheelMoveV(); + /// Set mouse cursor + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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(); + // Input-related functions: touch - /// Get touch position Y for touch point 0 (relative to screen size) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetTouchY(); + /// Get touch position X for touch point 0 (relative to screen size) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetTouchX(); - /// 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); + /// Get touch position Y for touch point 0 (relative to screen size) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetTouchY(); - /// Get touch point identifier for given index - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetTouchPointId(int index); + /// 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); - /// Get number of touch points - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetTouchPointCount(); + /// Get touch point identifier for given index + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetTouchPointId(int index); - //------------------------------------------------------------------------------------ - // Gestures and Touch Handling Functions (Module: gestures) - //------------------------------------------------------------------------------------ + /// Get number of touch points + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetTouchPointCount(); - /// Enable a set of gestures using flags - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetGesturesEnabled(Gesture flags); + //------------------------------------------------------------------------------------ + // Gestures and Touch Handling Functions (Module: gestures) + //------------------------------------------------------------------------------------ - /// Check if a gesture has been detected - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsGestureDetected(Gesture gesture); + /// Enable a set of gestures using flags + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetGesturesEnabled(Gesture flags); - /// Get latest detected gesture - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Gesture GetGestureDetected(); + /// Check if a gesture has been detected + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsGestureDetected(Gesture gesture); - /// Get gesture hold time in milliseconds - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetGestureHoldDuration(); + /// Get latest detected gesture + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Gesture GetGestureDetected(); - /// Get gesture drag vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetGestureDragVector(); + /// Get gesture hold time in milliseconds + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float GetGestureHoldDuration(); - /// Get gesture drag angle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetGestureDragAngle(); + /// Get gesture drag vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetGestureDragVector(); - /// Get gesture pinch delta - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 GetGesturePinchVector(); + /// Get gesture drag angle + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float GetGestureDragAngle(); - /// Get gesture pinch angle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetGesturePinchAngle(); + /// Get gesture pinch delta + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 GetGesturePinchVector(); + /// Get gesture pinch angle + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float GetGesturePinchAngle(); - //------------------------------------------------------------------------------------ - // Camera System Functions (Module: camera) - //------------------------------------------------------------------------------------ - /// Update camera position for selected mode - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateCamera(Camera3D* camera, CameraMode mode); + //------------------------------------------------------------------------------------ + // Camera System Functions (Module: camera) + //------------------------------------------------------------------------------------ - /// Update camera movement/rotation - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateCameraPro(Camera3D* camera, Vector3 movement, Vector3 rotation, float zoom); + /// Update camera position for selected mode + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UpdateCamera(Camera3D* camera, CameraMode mode); - /// Returns the cameras forward vector (normalized) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 GetCameraForward(Camera3D* camera); + /// Update camera movement/rotation + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UpdateCameraPro(Camera3D* camera, Vector3 movement, Vector3 rotation, float zoom); - /// - /// 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); + /// Returns the cameras forward vector (normalized) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 GetCameraForward(Camera3D* camera); - /// Returns the cameras right vector (normalized) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 GetCameraRight(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); + /// Returns the cameras right vector (normalized) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); - - /// Moves the camera in its up direction - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - - // Camera rotation - - /// - /// 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); - - /// - /// Rotates the camera around its right vector - /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CameraPitch( - Camera3D* camera, - float angle, - CBool lockView, - CBool rotateAroundTarget, - CBool rotateUp - ); - - /// Rotates the camera around its forward vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CameraRoll(Camera3D* camera, float angle); - - /// Returns the camera view matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetCameraViewMatrix(Camera3D* camera); - - /// Returns the camera projection matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetCameraProjectionMatrix(Camera3D* camera, float aspect); - - - //------------------------------------------------------------------------------------ - // Basic Shapes Drawing Functions (Module: shapes) - //------------------------------------------------------------------------------------ - - /// - /// Set texture and rectangle to be used on shapes drawing
- /// 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); - - // Basic shapes drawing functions - - /// Draw a pixel - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawPixel(int posX, int posY, Color color); - - /// Draw a pixel (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Draw a line (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// Draw line using quadratic bezier curves with a control point - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawLineBezierQuad( - Vector2 startPos, - Vector2 endPos, - Vector2 controlPos, - float thick, - Color color - ); - - /// Draw line using cubic bezier curves with 2 control points - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawLineBezierCubic( - Vector2 startPos, - Vector2 endPos, - Vector2 startControlPos, - Vector2 endControlPos, - float thick, - Color color - ); - - /// Draw lines sequence - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Draw a piece of a circle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCircleSector( - Vector2 center, - float radius, - float startAngle, - float endAngle, - int segments, - Color color - ); - - /// Draw circle sector outline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCircleSectorLines( - Vector2 center, - float radius, - float startAngle, - float endAngle, - int segments, - Color color - ); - - /// Draw a gradient-filled circle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCircleGradient( - int centerX, - int centerY, - float radius, - Color color1, - Color color2 - ); - - /// Draw a color-filled circle (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Draw ellipse - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Draw ring - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRing( - Vector2 center, - float innerRadius, - float outerRadius, - float startAngle, - float endAngle, - int segments, - Color color - ); - - /// Draw ring outline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRingLines( - Vector2 center, - float innerRadius, - float outerRadius, - float startAngle, - float endAngle, - int segments, - Color color - ); - - /// 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); - - /// Draw a color-filled rectangle (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// Draw a vertical-gradient-filled rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleGradientV( - int posX, - int posY, - int width, - int height, - Color color1, - Color color2 - ); - - /// Draw a horizontal-gradient-filled rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleGradientH( - int posX, - int posY, - int width, - int height, - Color color1, - Color color2 - ); - - /// Draw a gradient-filled rectangle with custom vertex colors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleGradientEx( - Rectangle rec, - Color col1, - Color col2, - Color col3, - Color col4 - ); - - /// Draw rectangle outline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Draw rectangle with rounded edges - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color); - - /// Draw rectangle with rounded edges outline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawRectangleRoundedLines( - Rectangle rec, - float roundness, - int segments, - float lineThick, - Color color - ); - - /// 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); - - /// 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); - - /// 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); - - /// Draw a triangle strip defined by points - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// Draw a polygon outline of n sides with extended parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawPolyLinesEx( - Vector2 center, - int sides, - float radius, - float rotation, - float lineThick, - Color color - ); - - // Basic shapes collision detection functions - - /// Check collision between two rectangles - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); - - /// Check collision between two circles - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionCircles( - Vector2 center1, - float radius1, - Vector2 center2, - float radius2 - ); - - /// Check collision between circle and rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); - - /// Check if point is inside rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// 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); - - /// - /// 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( - Vector2 startPos1, - Vector2 endPos1, - Vector2 startPos2, - Vector2 endPos2, - Vector2* collisionPoint - ); - - /// - /// 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); - - /// Get collision rectangle for two rectangles collision - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); - - - //------------------------------------------------------------------------------------ - // Texture Loading and Drawing Functions (Module: textures) - //------------------------------------------------------------------------------------ - - // Image loading functions - // 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); - - /// Load image from RAW file data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image LoadImageRaw( - sbyte* fileName, - int width, - int height, - PixelFormat format, - int headerSize - ); - - /// Load image sequence from file (frames appended to image.data) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Load image from GPU texture data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image LoadImageFromTexture(Texture2D texture); - - /// Load image from screen buffer and (screenshot) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image LoadImageFromScreen(); - - /// Check if an image is ready - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsImageReady(Image image); - - /// Unload image from CPU memory (RAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadImage(Image image); - - /// Export image data to file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportImage(Image image, sbyte* fileName); - - /// Export image as code file defining an array of bytes - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Generate image: vertical gradient - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageGradientV(int width, int height, Color top, Color bottom); - - /// Generate image: horizontal gradient - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageGradientH(int width, int height, Color left, Color right); - - /// Generate image: radial gradient - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageGradientRadial( - int width, - int height, - float density, - Color inner, - Color outer - ); - - /// Generate image: checked - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageChecked( - int width, - int height, - int checksX, - int checksY, - Color col1, - Color col2 - ); - - /// Generate image: white noise - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// Generate image: grayscale image from text data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageText(int width, int height, int tileSize); - - - // Image manipulation functions - - /// Create an image duplicate (useful for transformations) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Create an image from text (default font) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Convert image data to desired format - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Crop an image to a defined rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Clear alpha channel to desired color - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Premultiply alpha channel - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Resize image (Bicubic scaling algorithm) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Resize canvas and fill with color - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageResizeCanvas( - Image* image, - int newWidth, - int newHeight, - int offsetX, - int offsetY, - Color color - ); - - /// Generate all mipmap levels for a provided image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Flip image vertically - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageFlipVertical(Image* image); - - /// Flip image horizontally - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageFlipHorizontal(Image* image); - - /// Rotate image clockwise 90deg - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageRotateCW(Image* image); - - /// Rotate image counter-clockwise 90deg - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageRotateCCW(Image* image); - - /// Modify image color: tint - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorTint(Image* image, Color color); - - /// Modify image color: invert - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorInvert(Image* image); - - /// Modify image color: grayscale - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Modify image color: brightness (-255 to 255) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Load color data from image as a Color array (RGBA - 32bit) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Unload color data loaded with LoadImageColors() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadImageColors(Color* colors); - - /// Unload colors palette loaded with LoadImagePalette() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadImagePalette(Color* colors); - - /// Get image alpha border rectangle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - - // 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); - - /// Draw pixel within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Draw line within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawLine( - Image* dst, - int startPosX, - int startPosY, - int endPosX, - int endPosY, - Color color - ); - - /// 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); - - /// 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); - - /// 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); - - /// 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); - - /// 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); - - /// Draw rectangle within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawRectangle( - Image* dst, - int posX, - int posY, - int width, - int height, - Color color - ); - - /// 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); - - /// Draw rectangle within an image - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// 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); - - /// Draw text (custom sprite font) within an image (destination) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawTextEx( - Image* dst, - Font font, - sbyte* text, - Vector2 position, - float fontSize, - float spacing, - Color tint - ); - - - // Texture loading functions - // 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); - - /// Load texture from image data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Load texture for rendering (framebuffer) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern RenderTexture2D LoadRenderTexture(int width, int height); - - /// Check if a texture is ready - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsTextureReady(Texture2D texture); - - /// Unload texture from GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadTexture(Texture2D texture); - - /// Check if a render texture is ready - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsRenderTextureReady(RenderTexture2D target); - - /// Unload render texture from GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadRenderTexture(RenderTexture2D target); - - /// Update GPU texture with new data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - - // Texture configuration functions - - /// Generate GPU mipmaps for a texture - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void GenTextureMipmaps(Texture2D* texture); - - /// Set texture scaling filter mode - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetTextureFilter(Texture2D texture, TextureFilter filter); - - /// Set texture wrapping mode - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Draw a Texture2D with position defined as Vector2 - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextureV(Texture2D texture, Vector2 position, Color tint); - - /// Draw a Texture2D with extended parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextureEx( - Texture2D texture, - Vector2 position, - float rotation, - float scale, - Color tint - ); + // Camera movement - /// 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); - - /// Draw a part of a texture defined by a rectangle with 'pro' parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTexturePro( - Texture2D texture, - Rectangle source, - Rectangle dest, - Vector2 origin, - float rotation, - Color tint - ); - - /// Draws a texture (or part of it) that stretches or shrinks nicely - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextureNPatch( - Texture2D texture, - NPatchInfo nPatchInfo, - Rectangle dest, - Vector2 origin, - float rotation, - Color tint - ); - - - // Color/pixel related functions - - /// Get hexadecimal value for a Color - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int ColorToInt(Color color); - - /// Get color normalized as float [0..1] - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector4 ColorNormalize(Color color); - - /// Get color from normalized values [0..1] - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// Get color multiplied with another color - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// 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); - - /// 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); - - /// Get Color structure from hexadecimal value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Set color formatted into destination pixel pointer - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - - //------------------------------------------------------------------------------------ - // Font Loading and Text Drawing Functions (Module: text) - //------------------------------------------------------------------------------------ - - // Font loading/unloading functions - - /// Get the default Font - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Font GetFontDefault(); - - /// Load font from file into GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Font LoadFont(sbyte* fileName); - - /// - /// Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load - /// the default character set - /// - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Font LoadFontEx(sbyte* fileName, int fontSize, int* fontChars, int glyphCount); - - /// Load font from Image (XNA style) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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( - sbyte* fileType, - byte* fileData, - int dataSize, - int fontSize, - int* fontChars, - int glyphCount - ); - - /// Check if a font is ready - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsFontReady(Font font); - - /// Load font data for further use - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern GlyphInfo* LoadFontData( - byte* fileData, - int dataSize, - int fontSize, - int* fontChars, - int glyphCount, - FontType type - ); - - /// Generate image font atlas using chars info - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image GenImageFontAtlas( - GlyphInfo* chars, - Rectangle** recs, - int glyphCount, - int fontSize, - int padding, - int packMethod - ); - - /// Unload font chars info data (RAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadFontData(GlyphInfo* chars, int glyphCount); - - /// Unload Font from GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - - // Text drawing functions - - /// Shows current FPS - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Draw text using font and additional parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextEx( - Font font, - sbyte* text, - Vector2 position, - float fontSize, - float spacing, - Color tint - ); - - /// Draw text using Font and pro parameters (rotation) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextPro( - Font font, - sbyte* text, - Vector2 position, - Vector2 origin, - float rotation, - float fontSize, - float spacing, - Color tint - ); - - /// Draw one character (codepoint) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextCodepoint( - Font font, - int codepoint, - Vector2 position, - float fontSize, - Color tint - ); - - /// Draw multiple characters (codepoint) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextCodepoints( - Font font, - int* codepoints, - int count, - Vector2 position, - float fontSize, - float spacing, - Color tint - ); - - // Text font info functions - - /// Measure string width for default font - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// - /// 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); - - /// - /// 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); - - /// - /// 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); - - - // 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); - - /// Unload UTF-8 text encoded from codepoints array - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Unload codepoints data from memory - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// 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); - - /// 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); - - /// 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); - - - // 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); - - /// Check if two text string are equal - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Text formatting with variables (sprintf style) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Replace text string (WARNING: memory must be freed!) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextReplace(sbyte* text, sbyte* replace, sbyte* by); + /// Moves the camera in its forward direction + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// 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); + + + // Camera rotation + + /// + /// 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); + + /// + /// Rotates the camera around its right vector + /// + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void CameraPitch( + Camera3D* camera, + float angle, + CBool lockView, + CBool rotateAroundTarget, + CBool rotateUp + ); + + /// Rotates the camera around its forward vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void CameraRoll(Camera3D* camera, float angle); + + /// Returns the camera view matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 GetCameraViewMatrix(Camera3D* camera); + + /// Returns the camera projection matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 GetCameraProjectionMatrix(Camera3D* camera, float aspect); + + + //------------------------------------------------------------------------------------ + // Basic Shapes Drawing Functions (Module: shapes) + //------------------------------------------------------------------------------------ + + /// + /// Set texture and rectangle to be used on shapes drawing
+ /// 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); + + // Basic shapes drawing functions + + /// Draw a pixel + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawPixel(int posX, int posY, Color color); + + /// Draw a pixel (Vector version) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Draw a line (Vector version) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// Draw line using quadratic bezier curves with a control point + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawLineBezierQuad( + Vector2 startPos, + Vector2 endPos, + Vector2 controlPos, + float thick, + Color color + ); + + /// Draw line using cubic bezier curves with 2 control points + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawLineBezierCubic( + Vector2 startPos, + Vector2 endPos, + Vector2 startControlPos, + Vector2 endControlPos, + float thick, + Color color + ); + + /// Draw lines sequence + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Draw a piece of a circle + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawCircleSector( + Vector2 center, + float radius, + float startAngle, + float endAngle, + int segments, + Color color + ); + + /// Draw circle sector outline + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawCircleSectorLines( + Vector2 center, + float radius, + float startAngle, + float endAngle, + int segments, + Color color + ); + + /// Draw a gradient-filled circle + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawCircleGradient( + int centerX, + int centerY, + float radius, + Color color1, + Color color2 + ); + + /// Draw a color-filled circle (Vector version) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Draw ellipse + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Draw ring + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawRing( + Vector2 center, + float innerRadius, + float outerRadius, + float startAngle, + float endAngle, + int segments, + Color color + ); + + /// Draw ring outline + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawRingLines( + Vector2 center, + float innerRadius, + float outerRadius, + float startAngle, + float endAngle, + int segments, + Color color + ); + + /// 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); + + /// Draw a color-filled rectangle (Vector version) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// Draw a vertical-gradient-filled rectangle + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawRectangleGradientV( + int posX, + int posY, + int width, + int height, + Color color1, + Color color2 + ); + + /// Draw a horizontal-gradient-filled rectangle + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawRectangleGradientH( + int posX, + int posY, + int width, + int height, + Color color1, + Color color2 + ); + + /// Draw a gradient-filled rectangle with custom vertex colors + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawRectangleGradientEx( + Rectangle rec, + Color col1, + Color col2, + Color col3, + Color col4 + ); + + /// Draw rectangle outline + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Draw rectangle with rounded edges + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color); + + /// Draw rectangle with rounded edges outline + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawRectangleRoundedLines( + Rectangle rec, + float roundness, + int segments, + float lineThick, + Color color + ); + + /// 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); + + /// 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); + + /// 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); + + /// Draw a triangle strip defined by points + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// Draw a polygon outline of n sides with extended parameters + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawPolyLinesEx( + Vector2 center, + int sides, + float radius, + float rotation, + float lineThick, + Color color + ); + + // Basic shapes collision detection functions + + /// Check collision between two rectangles + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); + + /// Check collision between two circles + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool CheckCollisionCircles( + Vector2 center1, + float radius1, + Vector2 center2, + float radius2 + ); + + /// Check collision between circle and rectangle + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); + + /// Check if point is inside rectangle + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// 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); + + /// + /// 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( + Vector2 startPos1, + Vector2 endPos1, + Vector2 startPos2, + Vector2 endPos2, + Vector2* collisionPoint + ); + + /// + /// 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); + + /// Get collision rectangle for two rectangles collision + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); + + + //------------------------------------------------------------------------------------ + // Texture Loading and Drawing Functions (Module: textures) + //------------------------------------------------------------------------------------ + + // Image loading functions + // 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); + + /// Load image from RAW file data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image LoadImageRaw( + sbyte* fileName, + int width, + int height, + PixelFormat format, + int headerSize + ); + + /// Load image sequence from file (frames appended to image.data) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Load image from GPU texture data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image LoadImageFromTexture(Texture2D texture); + + /// Load image from screen buffer and (screenshot) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image LoadImageFromScreen(); + + /// Check if an image is ready + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsImageReady(Image image); + + /// Unload image from CPU memory (RAM) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadImage(Image image); + + /// Export image data to file + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool ExportImage(Image image, sbyte* fileName); + + /// Export image as code file defining an array of bytes + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Generate image: vertical gradient + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image GenImageGradientV(int width, int height, Color top, Color bottom); + + /// Generate image: horizontal gradient + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image GenImageGradientH(int width, int height, Color left, Color right); + + /// Generate image: radial gradient + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image GenImageGradientRadial( + int width, + int height, + float density, + Color inner, + Color outer + ); + + /// Generate image: checked + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image GenImageChecked( + int width, + int height, + int checksX, + int checksY, + Color col1, + Color col2 + ); + + /// Generate image: white noise + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// Generate image: grayscale image from text data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image GenImageText(int width, int height, int tileSize); + + + // Image manipulation functions + + /// Create an image duplicate (useful for transformations) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Create an image from text (default font) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Convert image data to desired format + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Crop an image to a defined rectangle + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Clear alpha channel to desired color + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Premultiply alpha channel + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Resize image (Bicubic scaling algorithm) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Resize canvas and fill with color + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageResizeCanvas( + Image* image, + int newWidth, + int newHeight, + int offsetX, + int offsetY, + Color color + ); + + /// Generate all mipmap levels for a provided image + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Flip image vertically + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageFlipVertical(Image* image); + + /// Flip image horizontally + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageFlipHorizontal(Image* image); + + /// Rotate image clockwise 90deg + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageRotateCW(Image* image); + + /// Rotate image counter-clockwise 90deg + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageRotateCCW(Image* image); + + /// Modify image color: tint + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageColorTint(Image* image, Color color); + + /// Modify image color: invert + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageColorInvert(Image* image); + + /// Modify image color: grayscale + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Modify image color: brightness (-255 to 255) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Load color data from image as a Color array (RGBA - 32bit) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Unload color data loaded with LoadImageColors() + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadImageColors(Color* colors); + + /// Unload colors palette loaded with LoadImagePalette() + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadImagePalette(Color* colors); + + /// Get image alpha border rectangle + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + + // 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); + + /// Draw pixel within an image + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Draw line within an image + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageDrawLine( + Image* dst, + int startPosX, + int startPosY, + int endPosX, + int endPosY, + Color color + ); + + /// 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); + + /// 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); + + /// 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); + + /// 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); + + /// 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); + + /// Draw rectangle within an image + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageDrawRectangle( + Image* dst, + int posX, + int posY, + int width, + int height, + Color color + ); + + /// 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); + + /// Draw rectangle within an image + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// 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); + + /// Draw text (custom sprite font) within an image (destination) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageDrawTextEx( + Image* dst, + Font font, + sbyte* text, + Vector2 position, + float fontSize, + float spacing, + Color tint + ); + + + // Texture loading functions + // 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); + + /// Load texture from image data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Load texture for rendering (framebuffer) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern RenderTexture2D LoadRenderTexture(int width, int height); + + /// Check if a texture is ready + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsTextureReady(Texture2D texture); + + /// Unload texture from GPU memory (VRAM) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadTexture(Texture2D texture); + + /// Check if a render texture is ready + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsRenderTextureReady(RenderTexture2D target); + + /// Unload render texture from GPU memory (VRAM) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadRenderTexture(RenderTexture2D target); + + /// Update GPU texture with new data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + + // Texture configuration functions + + /// Generate GPU mipmaps for a texture + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void GenTextureMipmaps(Texture2D* texture); + + /// Set texture scaling filter mode + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetTextureFilter(Texture2D texture, TextureFilter filter); + + /// Set texture wrapping mode + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Draw a Texture2D with position defined as Vector2 + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawTextureV(Texture2D texture, Vector2 position, Color tint); + + /// Draw a Texture2D with extended parameters + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawTextureEx( + Texture2D texture, + Vector2 position, + float rotation, + float scale, + Color tint + ); - /// 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); + /// 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); + + /// Draw a part of a texture defined by a rectangle with 'pro' parameters + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawTexturePro( + Texture2D texture, + Rectangle source, + Rectangle dest, + Vector2 origin, + float rotation, + Color tint + ); + + /// Draws a texture (or part of it) that stretches or shrinks nicely + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawTextureNPatch( + Texture2D texture, + NPatchInfo nPatchInfo, + Rectangle dest, + Vector2 origin, + float rotation, + Color tint + ); + + + // Color/pixel related functions + + /// Get hexadecimal value for a Color + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int ColorToInt(Color color); + + /// Get color normalized as float [0..1] + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector4 ColorNormalize(Color color); + + /// Get color from normalized values [0..1] + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// Get color multiplied with another color + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// 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); + + /// 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); + + /// Get Color structure from hexadecimal value + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Set color formatted into destination pixel pointer + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + + //------------------------------------------------------------------------------------ + // Font Loading and Text Drawing Functions (Module: text) + //------------------------------------------------------------------------------------ + + // Font loading/unloading functions + + /// Get the default Font + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Font GetFontDefault(); + + /// Load font from file into GPU memory (VRAM) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Font LoadFont(sbyte* fileName); + + /// + /// Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load + /// the default character set + /// + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Font LoadFontEx(sbyte* fileName, int fontSize, int* fontChars, int glyphCount); + + /// Load font from Image (XNA style) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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( + sbyte* fileType, + byte* fileData, + int dataSize, + int fontSize, + int* fontChars, + int glyphCount + ); + + /// Check if a font is ready + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsFontReady(Font font); + + /// Load font data for further use + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern GlyphInfo* LoadFontData( + byte* fileData, + int dataSize, + int fontSize, + int* fontChars, + int glyphCount, + FontType type + ); + + /// Generate image font atlas using chars info + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image GenImageFontAtlas( + GlyphInfo* chars, + Rectangle** recs, + int glyphCount, + int fontSize, + int padding, + int packMethod + ); + + /// Unload font chars info data (RAM) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadFontData(GlyphInfo* chars, int glyphCount); + + /// Unload Font from GPU memory (VRAM) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + + // Text drawing functions + + /// Shows current FPS + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Draw text using font and additional parameters + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawTextEx( + Font font, + sbyte* text, + Vector2 position, + float fontSize, + float spacing, + Color tint + ); + + /// Draw text using Font and pro parameters (rotation) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawTextPro( + Font font, + sbyte* text, + Vector2 position, + Vector2 origin, + float rotation, + float fontSize, + float spacing, + Color tint + ); + + /// Draw one character (codepoint) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawTextCodepoint( + Font font, + int codepoint, + Vector2 position, + float fontSize, + Color tint + ); + + /// Draw multiple characters (codepoint) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawTextCodepoints( + Font font, + int* codepoints, + int count, + Vector2 position, + float fontSize, + float spacing, + Color tint + ); + + // Text font info functions + + /// Measure string width for default font + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// + /// 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); + + /// + /// 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); + + /// + /// 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); + + + // 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); + + /// Unload UTF-8 text encoded from codepoints array + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Unload codepoints data from memory + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// 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); + + /// 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); + + /// 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); + + + // 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); + + /// Check if two text string are equal + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Text formatting with variables (sprintf style) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Replace text string (WARNING: memory must be freed!) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* TextReplace(sbyte* text, sbyte* replace, sbyte* by); - /// Join text strings with delimiter - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Append text at specific position and move cursor! - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Get upper case version of provided string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextToUpper(sbyte* text); - - /// Get lower case version of provided string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextToLower(sbyte* text); - - /// Get Pascal case notation version of provided string - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextToPascal(sbyte* text); - - /// Get integer value from text (negative values not supported) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int TextToInteger(sbyte* text); - - - //------------------------------------------------------------------------------------ - // Basic 3d Shapes Drawing Functions (Module: models) - //------------------------------------------------------------------------------------ - - // 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); - - /// Draw a point in 3D space, actually a small line - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawPoint3D(Vector3 position, Color color); - - /// Draw a circle in 3D world space - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCircle3D( - Vector3 center, - float radius, - Vector3 rotationAxis, - float rotationAngle, - Color color - ); - - /// 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); - - /// Draw a triangle strip defined by points - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Draw cube (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Draw cube wires (Vector version) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// Draw sphere wires - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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( - Vector3 position, - float radiusTop, - float radiusBottom, - float height, - int slices, - Color color - ); - - /// Draw a cylinder with base at startPos and top at endPos - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCylinderEx( - Vector3 startPos, - Vector3 endPos, - float startRadius, - float endRadius, - int sides, - Color color - ); - - /// Draw a cylinder/cone wires - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCylinderWires( - Vector3 position, - float radiusTop, - float radiusBottom, - float height, - int slices, - Color color - ); - - /// Draw a cylinder wires with base at startPos and top at endPos - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCylinderWiresEx( - Vector3 startPos, - Vector3 endPos, - float startRadius, - float endRadius, - int sides, - Color color - ); - - /// Draw a capsule with the center of its sphere caps at startPos and endPos - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCapsule( - Vector3 startPos, - Vector3 endPos, - float radius, - int slices, - int rings, - Color color - ); - - /// Draw capsule wireframe with the center of its sphere caps at startPos and endPos - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCapsuleWires( - Vector3 startPos, - Vector3 endPos, - float radius, - int slices, - int rings, - Color color - ); - - /// Draw a plane XZ - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Draw a grid (centered at (0, 0, 0)) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawGrid(int slices, float spacing); - - - //------------------------------------------------------------------------------------ - // Model 3d Loading and Drawing Functions (Module: models) - //------------------------------------------------------------------------------------ - - // Model management functions - - /// Load model from files (meshes and materials) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Model LoadModel(sbyte* fileName); - - /// Load model from generated mesh (default material) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Model LoadModelFromMesh(Mesh mesh); - - /// Check if a model is ready - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsModelReady(Model model); - - /// Unload model from memory (RAM and/or VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadModel(Model model); - - /// Compute model bounding box limits (considers all meshes) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Draw a model with extended parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawModelEx( - Model model, - Vector3 position, - Vector3 rotationAxis, - float rotationAngle, - Vector3 scale, - Color tint - ); - - /// 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); - - /// Draw a model wires (with texture if set) with extended parameters - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawModelWiresEx( - Model model, - Vector3 position, - Vector3 rotationAxis, - float rotationAngle, - Vector3 scale, - Color tint - ); - - /// Draw bounding box (wires) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawBoundingBox(BoundingBox box, Color color); - - /// Draw a billboard texture - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawBillboard( - Camera3D camera, - Texture2D texture, - Vector3 center, - float size, - Color tint - ); - - /// Draw a billboard texture defined by source - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawBillboardRec( - Camera3D camera, - Texture2D texture, - Rectangle source, - Vector3 position, - Vector2 size, - Color tint - ); - - /// Draw a billboard texture defined by source and rotation - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawBillboardPro( - Camera3D camera, - Texture2D texture, - Rectangle source, - Vector3 position, - Vector3 up, - Vector2 size, - Vector2 origin, - float rotation, - Color tint - ); - - - // 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); - - /// 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); - - /// Unload mesh from memory (RAM and/or VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// Export mesh data to file, returns true on success - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportMesh(Mesh mesh, sbyte* fileName); - - /// Compute mesh bounding box limits - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern BoundingBox GetMeshBoundingBox(Mesh mesh); - - /// Compute mesh tangents - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void GenMeshTangents(Mesh* mesh); - - - // Mesh generation functions - - /// Generate polygonal mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Generate cuboid mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Generate half-sphere mesh (no bottom cap) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Generate cone/pyramid mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Generate trefoil knot mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshKnot(float radius, float size, int radSeg, int sides); + /// 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); - /// Generate heightmap mesh from image data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshHeightmap(Image heightmap, Vector3 size); + /// Join text strings with delimiter + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Append text at specific position and move cursor! + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Get upper case version of provided string + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* TextToUpper(sbyte* text); + + /// Get lower case version of provided string + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* TextToLower(sbyte* text); + + /// Get Pascal case notation version of provided string + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* TextToPascal(sbyte* text); + + /// Get integer value from text (negative values not supported) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TextToInteger(sbyte* text); + + + //------------------------------------------------------------------------------------ + // Basic 3d Shapes Drawing Functions (Module: models) + //------------------------------------------------------------------------------------ + + // 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); + + /// Draw a point in 3D space, actually a small line + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawPoint3D(Vector3 position, Color color); + + /// Draw a circle in 3D world space + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawCircle3D( + Vector3 center, + float radius, + Vector3 rotationAxis, + float rotationAngle, + Color color + ); + + /// 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); + + /// Draw a triangle strip defined by points + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Draw cube (Vector version) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Draw cube wires (Vector version) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// Draw sphere wires + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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( + Vector3 position, + float radiusTop, + float radiusBottom, + float height, + int slices, + Color color + ); + + /// Draw a cylinder with base at startPos and top at endPos + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawCylinderEx( + Vector3 startPos, + Vector3 endPos, + float startRadius, + float endRadius, + int sides, + Color color + ); + + /// Draw a cylinder/cone wires + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawCylinderWires( + Vector3 position, + float radiusTop, + float radiusBottom, + float height, + int slices, + Color color + ); + + /// Draw a cylinder wires with base at startPos and top at endPos + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawCylinderWiresEx( + Vector3 startPos, + Vector3 endPos, + float startRadius, + float endRadius, + int sides, + Color color + ); + + /// Draw a capsule with the center of its sphere caps at startPos and endPos + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawCapsule( + Vector3 startPos, + Vector3 endPos, + float radius, + int slices, + int rings, + Color color + ); + + /// Draw capsule wireframe with the center of its sphere caps at startPos and endPos + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawCapsuleWires( + Vector3 startPos, + Vector3 endPos, + float radius, + int slices, + int rings, + Color color + ); + + /// Draw a plane XZ + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Draw a grid (centered at (0, 0, 0)) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawGrid(int slices, float spacing); + + + //------------------------------------------------------------------------------------ + // Model 3d Loading and Drawing Functions (Module: models) + //------------------------------------------------------------------------------------ + + // Model management functions + + /// Load model from files (meshes and materials) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Model LoadModel(sbyte* fileName); + + /// Load model from generated mesh (default material) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Model LoadModelFromMesh(Mesh mesh); + + /// Check if a model is ready + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsModelReady(Model model); + + /// Unload model from memory (RAM and/or VRAM) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadModel(Model model); + + /// Compute model bounding box limits (considers all meshes) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Draw a model with extended parameters + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawModelEx( + Model model, + Vector3 position, + Vector3 rotationAxis, + float rotationAngle, + Vector3 scale, + Color tint + ); + + /// 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); + + /// Draw a model wires (with texture if set) with extended parameters + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawModelWiresEx( + Model model, + Vector3 position, + Vector3 rotationAxis, + float rotationAngle, + Vector3 scale, + Color tint + ); + + /// Draw bounding box (wires) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawBoundingBox(BoundingBox box, Color color); + + /// Draw a billboard texture + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawBillboard( + Camera3D camera, + Texture2D texture, + Vector3 center, + float size, + Color tint + ); + + /// Draw a billboard texture defined by source + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawBillboardRec( + Camera3D camera, + Texture2D texture, + Rectangle source, + Vector3 position, + Vector2 size, + Color tint + ); + + /// Draw a billboard texture defined by source and rotation + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawBillboardPro( + Camera3D camera, + Texture2D texture, + Rectangle source, + Vector3 position, + Vector3 up, + Vector2 size, + Vector2 origin, + float rotation, + Color tint + ); + + + // 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); + + /// 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); + + /// Unload mesh from memory (RAM and/or VRAM) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// Export mesh data to file, returns true on success + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool ExportMesh(Mesh mesh, sbyte* fileName); + + /// Compute mesh bounding box limits + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern BoundingBox GetMeshBoundingBox(Mesh mesh); + + /// Compute mesh tangents + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void GenMeshTangents(Mesh* mesh); + + + // Mesh generation functions + + /// Generate polygonal mesh + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Generate cuboid mesh + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Generate half-sphere mesh (no bottom cap) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Generate cone/pyramid mesh + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Generate trefoil knot mesh + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Mesh GenMeshKnot(float radius, float size, int radSeg, int sides); - /// Generate cubes-based map mesh from image data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); + /// Generate heightmap mesh from image data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); - // 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); + // Material loading/unloading functions - /// Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Material LoadMaterialDefault(); + //TODO: safe Helper method + /// Load materials from model file + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Material* LoadMaterials(sbyte* fileName, int* materialCount); - /// Check if a material is ready - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMaterialReady(); + /// Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Material LoadMaterialDefault(); - /// Unload material from GPU memory (VRAM) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadMaterial(Material material); + /// Check if a material is ready + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsMaterialReady(); - /// 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); + /// Unload material from GPU memory (VRAM) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadMaterial(Material material); - /// Set material for a mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetModelMeshMaterial(Model* model, int meshId, int materialId); + /// 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); + /// Set material for a mesh + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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, uint* animCount); + // Model animations loading/unloading functions - /// Update model animation pose - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); + /// Load model animations from file + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern ModelAnimation* LoadModelAnimations(sbyte* fileName, uint* animCount); - /// Unload animation data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadModelAnimation(ModelAnimation anim); + /// Update model animation pose + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); - /// Unload animation array data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadModelAnimations(ModelAnimation* animations, uint count); + /// Unload animation data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadModelAnimation(ModelAnimation anim); - /// Check model animation skeleton match - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsModelAnimationValid(Model model, ModelAnimation anim); + /// Unload animation array data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadModelAnimations(ModelAnimation* animations, uint count); - // Collision detection functions + /// Check model animation skeleton match + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsModelAnimationValid(Model model, ModelAnimation anim); - /// Detect collision between two spheres - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionSpheres( - Vector3 center1, - float radius1, - Vector3 center2, - float radius2 - ); + // Collision detection functions - /// Detect collision between two bounding boxes - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); + /// Detect collision between two spheres + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool CheckCollisionSpheres( + Vector3 center1, + float radius1, + Vector3 center2, + float radius2 + ); - /// Detect collision between box and sphere - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); + /// Detect collision between two bounding boxes + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); - /// Detect collision between ray and sphere - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); + /// Detect collision between box and sphere + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); - /// Detect collision between ray and box - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); + /// Detect collision between ray and sphere + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); - /// Get collision info between ray and mesh - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix4x4 transform); + /// Detect collision between ray and box + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); - /// 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); + /// Get collision info between ray and mesh + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix4x4 transform); - /// 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); + /// 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); + /// 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); - //------------------------------------------------------------------------------------ - // Audio Loading and Playing Functions (Module: audio) - //------------------------------------------------------------------------------------ - // Audio device management functions + //------------------------------------------------------------------------------------ + // Audio Loading and Playing Functions (Module: audio) + //------------------------------------------------------------------------------------ - /// Initialize audio device and context - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void InitAudioDevice(); + // Audio device management functions - /// Close the audio device and context - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void CloseAudioDevice(); + /// Initialize audio device and context + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void InitAudioDevice(); - /// Check if audio device has been initialized successfully - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsAudioDeviceReady(); + /// Close the audio device and context + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void CloseAudioDevice(); - /// Set master volume (listener) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMasterVolume(float volume); + /// Check if audio device has been initialized successfully + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsAudioDeviceReady(); + /// Set master volume (listener) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetMasterVolume(float volume); - // Wave/Sound loading/unloading functions - /// Load wave data from file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Wave LoadWave(sbyte* fileName); + // Wave/Sound loading/unloading functions - /// 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); + /// Load wave data from file + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Wave LoadWave(sbyte* fileName); - /// Checks if wave data is ready - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsWaveReady(Wave wave); + /// 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); - /// Load sound from file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Sound LoadSound(sbyte* fileName); + /// Checks if wave data is ready + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsWaveReady(Wave wave); - /// Load sound from wave data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Sound LoadSoundFromWave(Wave wave); + /// Load sound from file + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Sound LoadSound(sbyte* fileName); - /// Checks if a sound is ready - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsSoundReady(Sound sound); + /// Load sound from wave data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Sound LoadSoundFromWave(Wave wave); - /// Update sound buffer with new data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateSound(Sound sound, void* data, int sampleCount); + /// Checks if a sound is ready + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsSoundReady(Sound sound); - /// Unload wave data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadWave(Wave wave); + /// Update sound buffer with new data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UpdateSound(Sound sound, void* data, int sampleCount); - /// Unload sound - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadSound(Sound sound); + /// Unload wave data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadWave(Wave wave); - /// Export wave data to file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportWave(Wave wave, sbyte* fileName); + /// Unload sound + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadSound(Sound sound); - /// Export wave sample data to code (.h) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportWaveAsCode(Wave wave, sbyte* fileName); + /// Export wave data to file + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); - // Wave/Sound management functions - /// Play a sound - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PlaySound(Sound sound); + // Wave/Sound management functions - /// Stop playing a sound - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void StopSound(Sound sound); + /// Play a sound + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void PlaySound(Sound sound); - /// Pause a sound - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PauseSound(Sound sound); + /// Stop playing a sound + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void StopSound(Sound sound); - /// Resume a paused sound - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ResumeSound(Sound sound); + /// Pause a sound + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void PauseSound(Sound sound); - /// Get number of sounds playing in the multichannel - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetSoundsPlaying(); + /// Resume a paused sound + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ResumeSound(Sound sound); - /// Check if a sound is currently playing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsSoundPlaying(Sound sound); + /// Get number of sounds playing in the multichannel + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int GetSoundsPlaying(); - /// Set volume for a sound (1.0 is max level) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetSoundVolume(Sound sound, float volume); + /// Check if a sound is currently playing + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsSoundPlaying(Sound sound); - /// Set pitch for a sound (1.0 is base level) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetSoundPitch(Sound sound, float pitch); + /// Set volume for a sound (1.0 is max level) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetSoundVolume(Sound sound, float volume); - /// Set pan for a sound (0.5 is center) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetSoundPan(Sound sound, float pan); + /// Set pitch for a sound (1.0 is base level) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetSoundPitch(Sound sound, float pitch); - /// Copy a wave to a new wave - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Wave WaveCopy(Wave wave); + /// Set pan for a sound (0.5 is center) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetSoundPan(Sound sound, float pan); - /// Crop a wave to defined samples range - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void WaveCrop(Wave* wave, int initSample, int finalSample); + /// Copy a wave to a new wave + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Wave WaveCopy(Wave wave); - /// Convert wave data to desired format - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void WaveFormat(Wave* wave, int sampleRate, int sampleSize, int channels); + /// Crop a wave to defined samples range + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void WaveCrop(Wave* wave, int initSample, int finalSample); - /// Get samples data from wave as a floats array - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float* LoadWaveSamples(Wave wave); + /// Convert wave data to desired format + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void WaveFormat(Wave* wave, int sampleRate, int sampleSize, int channels); - /// Unload samples data loaded with LoadWaveSamples() - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadWaveSamples(float* samples); + /// Get samples data from wave as a floats array + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float* LoadWaveSamples(Wave wave); - // Music management functions + /// Unload samples data loaded with LoadWaveSamples() + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadWaveSamples(float* samples); - /// Load music stream from file - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Music LoadMusicStream(sbyte* fileName); + // Music management functions - /// 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); + /// Load music stream from file + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Music LoadMusicStream(sbyte* fileName); - /// Checks if a music stream is ready - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMusicReady(Music music); + /// 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); - /// Unload music stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadMusicStream(Music music); + /// Checks if a music stream is ready + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsMusicReady(Music music); - /// Start music playing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PlayMusicStream(Music music); + /// Unload music stream + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadMusicStream(Music music); - /// Check if music is playing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsMusicStreamPlaying(Music music); + /// Start music playing + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void PlayMusicStream(Music music); - /// Updates buffers for music streaming - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateMusicStream(Music music); + /// Check if music is playing + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsMusicStreamPlaying(Music music); - /// Stop music playing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void StopMusicStream(Music music); + /// Updates buffers for music streaming + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UpdateMusicStream(Music music); - /// Pause music playing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PauseMusicStream(Music music); + /// Stop music playing + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void StopMusicStream(Music music); - /// Resume playing paused music - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ResumeMusicStream(Music music); + /// Pause music playing + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void PauseMusicStream(Music music); - /// Seek music to a position (in seconds) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SeekMusicStream(Music music, float position); + /// Resume playing paused music + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ResumeMusicStream(Music music); - /// Set volume for music (1.0 is max level) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Set pan for a music (0.5 is center) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMusicPan(Music music, float pan); - - /// Get music time length (in seconds) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float GetMusicTimeLength(Music music); - - /// Get current music time played (in seconds) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Checks if an audio stream is ready - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsAudioStreamReady(AudioStream stream); - - /// Unload audio stream and free memory - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Check if any audio stream buffers requires refill - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsAudioStreamProcessed(AudioStream stream); - - /// Play audio stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PlayAudioStream(AudioStream stream); - - /// Pause audio stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PauseAudioStream(AudioStream stream); - - /// Resume audio stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ResumeAudioStream(AudioStream stream); - - /// Check if audio stream is playing - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool IsAudioStreamPlaying(AudioStream stream); - - /// Stop audio stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Set pitch for audio stream (1.0 is base level) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Default size for new audio streams - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetAudioStreamBufferSizeDefault(int size); - - /// Audio thread callback to request new data - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetAudioStreamCallback( - AudioStream stream, - delegate* unmanaged[Cdecl] callback - ); - - /// Attach audio stream processor to stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void AttachAudioStreamProcessor( - AudioStream stream, - delegate* unmanaged[Cdecl] processor - ); - - /// Detach audio stream processor from stream - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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( - delegate* unmanaged[Cdecl] processor - ); - - /// Detach audio stream processor from the entire audio pipeline - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DetachAudioMixedProcessor( - delegate* unmanaged[Cdecl] processor - ); - } + /// Seek music to a position (in seconds) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Set pitch for a music (1.0 is base level) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Get music time length (in seconds) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float GetMusicTimeLength(Music music); + + /// Get current music time played (in seconds) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Checks if an audio stream is ready + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsAudioStreamReady(AudioStream stream); + + /// Unload audio stream and free memory + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Check if any audio stream buffers requires refill + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsAudioStreamProcessed(AudioStream stream); + + /// Play audio stream + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void PlayAudioStream(AudioStream stream); + + /// Pause audio stream + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void PauseAudioStream(AudioStream stream); + + /// Resume audio stream + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ResumeAudioStream(AudioStream stream); + + /// Check if audio stream is playing + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsAudioStreamPlaying(AudioStream stream); + + /// Stop audio stream + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Set pitch for audio stream (1.0 is base level) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Default size for new audio streams + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetAudioStreamBufferSizeDefault(int size); + + /// Audio thread callback to request new data + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetAudioStreamCallback( + AudioStream stream, + delegate* unmanaged[Cdecl] callback + ); + + /// Attach audio stream processor to stream + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void AttachAudioStreamProcessor( + AudioStream stream, + delegate* unmanaged[Cdecl] processor + ); + + /// Detach audio stream processor from stream + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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( + delegate* unmanaged[Cdecl] processor + ); + + /// Detach audio stream processor from the entire audio pipeline + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DetachAudioMixedProcessor( + delegate* unmanaged[Cdecl] processor + ); } diff --git a/Raylib-cs/interop/Raymath.cs b/Raylib-cs/interop/Raymath.cs index 74171bb..2e76098 100644 --- a/Raylib-cs/interop/Raymath.cs +++ b/Raylib-cs/interop/Raymath.cs @@ -2,543 +2,542 @@ using System.Numerics; using System.Runtime.InteropServices; using System.Security; -namespace Raylib_cs +namespace Raylib_cs; + +// NOTE: Helper types to be used instead of array return types for *ToFloat functions +public unsafe struct Float3 { - // NOTE: Helper types to be used instead of array return types for *ToFloat functions - public unsafe struct Float3 - { - public fixed float v[3]; - } - - public unsafe struct Float16 - { - public fixed float v[16]; - } - - [SuppressUnmanagedCodeSecurity] - public static unsafe partial class Raymath - { - /// - /// Used by DllImport to load the native library - /// - public const string NativeLibName = "raylib"; - - /// Clamp float value - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Normalize input value within input range - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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, - 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); - - /// Check whether two given floats are almost equal - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int FloatEquals(float x, float y); - - /// Vector with components value 0.0f - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Zero(); - - /// Vector with components value 1.0f - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2One(); - - /// Add two vectors (v1 + v2) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Subtract two vectors (v1 - v2) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Calculate vector length - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector2Length(Vector2 v); - - /// Calculate vector square length - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector2LengthSqr(Vector2 v); - - /// Calculate two vectors dot product - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Calculate square distance between two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// - /// 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); - - /// Scale vector (multiply by value) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Scale(Vector2 v, float scale); - - /// Multiply vector by vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Multiply(Vector2 v1, Vector2 v2); - - /// Negate vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Negate(Vector2 v); - - /// Divide vector by vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector2 Vector2Divide(Vector2 v1, Vector2 v2); - - /// Normalize provided vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Calculate linear interpolation between two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Rotate vector by angle - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Invert the given vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// Check whether two given vectors are almost equal - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int Vector2Equals(Vector2 p, Vector2 q); - - - /// Vector with components value 0.0f - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Zero(); - - /// Vector with components value 1.0f - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3One(); - - /// Add two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Subtract two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Multiply vector by scalar - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Scale(Vector3 v, float scalar); - - /// Multiply vector by vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Calculate one vector perpendicular vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Perpendicular(Vector3 v); - - /// Calculate vector length - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector3Length(Vector3 v); - - /// Calculate vector square length - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float Vector3LengthSqr(Vector3 v); - - /// Calculate two vectors dot product - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Calculate square distance between two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Negate provided vector (invert direction) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Negate(Vector3 v); - - /// Divide vector by vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Divide(Vector3 v1, Vector3 v2); - - /// Normalize provided vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Normalize(Vector3 v); - - /// - /// 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); - - /// Transforms a Vector3 by a given Matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Rotates a vector around an axis - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle); - - /// Calculate linear interpolation between two vectors - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount); - - /// Calculate reflected vector to normal - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Get max value for each pair of components - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// - /// 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); - - /// Get Vector3 as float array - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Float3 Vector3ToFloatV(Vector3 v); - - /// Invert the given vector - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// Check whether two given vectors are almost equal - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int Vector3Equals(Vector3 p, Vector3 q); - - /// - /// Compute the direction of a refracted ray where v specifies the - /// normalized direction of the incoming ray, n specifies the - /// normalized normal vector of the interface of two optical media, - /// and r specifies the 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 Vector3 Vector3Refract(Vector3 v, Vector3 n, float r); - - - /// Compute matrix determinant - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Transposes provided matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixTranspose(Matrix4x4 mat); - - /// Invert provided matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixInvert(Matrix4x4 mat); - - /// Get identity matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixIdentity(); - - /// Add two matrices - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// - /// 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); - - /// Get translation matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Get x-rotation matrix (angle in radians) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixRotateX(float angle); - - /// Get y-rotation matrix (angle in radians) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixRotateY(float angle); - - /// Get z-rotation matrix (angle in radians) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixRotateZ(float angle); - - /// Get xyz-rotation matrix (angles in radians) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixRotateXYZ(Vector3 ang); - - /// Get zyx-rotation matrix (angles in radians) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixRotateZYX(Vector3 ang); - - /// Get scaling matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixScale(float x, float y, float z); - - /// Get perspective projection matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixFrustum( - double left, - double right, - double bottom, - double top, - double near, - double far - ); - - /// - /// 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); - - /// Get orthographic projection matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 MatrixOrtho( - double left, - double right, - double bottom, - double top, - double near, - double far - ); - - /// Get camera look-at matrix (view matrix) - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - - /// Add 2 quaternions - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Subtract 2 quaternions - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Get identity quaternion - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionIdentity(); - - /// Computes the length of a quaternion - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float QuaternionLength(Quaternion q); - - /// Normalize provided quaternion - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionNormalize(Quaternion q); - - /// Invert provided quaternion - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionInvert(Quaternion q); - - /// Calculate two quaternion multiplication - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Divide two quaternions - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Calculate slerp-optimized interpolation between two quaternions - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// Get a quaternion for a given rotation matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Quaternion QuaternionFromMatrix(Matrix4x4 mat); - - /// Get a matrix for a given quaternion - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// - /// 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); - - /// - /// 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); - - /// Transform a quaternion given a transformation matrix - [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - } + public fixed float v[3]; +} + +public unsafe struct Float16 +{ + public fixed float v[16]; +} + +[SuppressUnmanagedCodeSecurity] +public static unsafe partial class Raymath +{ + /// + /// Used by DllImport to load the native library + /// + public const string NativeLibName = "raylib"; + + /// Clamp float value + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Normalize input value within input range + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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, + 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); + + /// Check whether two given floats are almost equal + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int FloatEquals(float x, float y); + + /// Vector with components value 0.0f + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 Vector2Zero(); + + /// Vector with components value 1.0f + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 Vector2One(); + + /// Add two vectors (v1 + v2) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Subtract two vectors (v1 - v2) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Calculate vector length + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float Vector2Length(Vector2 v); + + /// Calculate vector square length + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float Vector2LengthSqr(Vector2 v); + + /// Calculate two vectors dot product + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Calculate square distance between two vectors + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// + /// 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); + + /// Scale vector (multiply by value) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 Vector2Scale(Vector2 v, float scale); + + /// Multiply vector by vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 Vector2Multiply(Vector2 v1, Vector2 v2); + + /// Negate vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 Vector2Negate(Vector2 v); + + /// Divide vector by vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 Vector2Divide(Vector2 v1, Vector2 v2); + + /// Normalize provided vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Calculate linear interpolation between two vectors + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Rotate vector by angle + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Invert the given vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// Check whether two given vectors are almost equal + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Vector2Equals(Vector2 p, Vector2 q); + + + /// Vector with components value 0.0f + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3Zero(); + + /// Vector with components value 1.0f + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3One(); + + /// Add two vectors + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Subtract two vectors + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Multiply vector by scalar + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3Scale(Vector3 v, float scalar); + + /// Multiply vector by vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Calculate one vector perpendicular vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3Perpendicular(Vector3 v); + + /// Calculate vector length + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float Vector3Length(Vector3 v); + + /// Calculate vector square length + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float Vector3LengthSqr(Vector3 v); + + /// Calculate two vectors dot product + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Calculate square distance between two vectors + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Negate provided vector (invert direction) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3Negate(Vector3 v); + + /// Divide vector by vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3Divide(Vector3 v1, Vector3 v2); + + /// Normalize provided vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3Normalize(Vector3 v); + + /// + /// 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); + + /// Transforms a Vector3 by a given Matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Rotates a vector around an axis + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle); + + /// Calculate linear interpolation between two vectors + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount); + + /// Calculate reflected vector to normal + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Get max value for each pair of components + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// + /// 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); + + /// Get Vector3 as float array + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Float3 Vector3ToFloatV(Vector3 v); + + /// Invert the given vector + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// Check whether two given vectors are almost equal + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Vector3Equals(Vector3 p, Vector3 q); + + /// + /// Compute the direction of a refracted ray where v specifies the + /// normalized direction of the incoming ray, n specifies the + /// normalized normal vector of the interface of two optical media, + /// and r specifies the 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 Vector3 Vector3Refract(Vector3 v, Vector3 n, float r); + + + /// Compute matrix determinant + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Transposes provided matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 MatrixTranspose(Matrix4x4 mat); + + /// Invert provided matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 MatrixInvert(Matrix4x4 mat); + + /// Get identity matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 MatrixIdentity(); + + /// Add two matrices + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// + /// 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); + + /// Get translation matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Get x-rotation matrix (angle in radians) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 MatrixRotateX(float angle); + + /// Get y-rotation matrix (angle in radians) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 MatrixRotateY(float angle); + + /// Get z-rotation matrix (angle in radians) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 MatrixRotateZ(float angle); + + /// Get xyz-rotation matrix (angles in radians) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 MatrixRotateXYZ(Vector3 ang); + + /// Get zyx-rotation matrix (angles in radians) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 MatrixRotateZYX(Vector3 ang); + + /// Get scaling matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 MatrixScale(float x, float y, float z); + + /// Get perspective projection matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 MatrixFrustum( + double left, + double right, + double bottom, + double top, + double near, + double far + ); + + /// + /// 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); + + /// Get orthographic projection matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 MatrixOrtho( + double left, + double right, + double bottom, + double top, + double near, + double far + ); + + /// Get camera look-at matrix (view matrix) + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + + /// Add 2 quaternions + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Subtract 2 quaternions + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Get identity quaternion + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Quaternion QuaternionIdentity(); + + /// Computes the length of a quaternion + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float QuaternionLength(Quaternion q); + + /// Normalize provided quaternion + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Quaternion QuaternionNormalize(Quaternion q); + + /// Invert provided quaternion + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Quaternion QuaternionInvert(Quaternion q); + + /// Calculate two quaternion multiplication + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Divide two quaternions + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Calculate slerp-optimized interpolation between two quaternions + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// Get a quaternion for a given rotation matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Quaternion QuaternionFromMatrix(Matrix4x4 mat); + + /// Get a matrix for a given quaternion + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// + /// 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); + + /// + /// 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); + + /// Transform a quaternion given a transformation matrix + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern 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); } diff --git a/Raylib-cs/interop/Rlgl.cs b/Raylib-cs/interop/Rlgl.cs index b71ad16..5cb3fc8 100644 --- a/Raylib-cs/interop/Rlgl.cs +++ b/Raylib-cs/interop/Rlgl.cs @@ -2,806 +2,805 @@ using System.Numerics; using System.Runtime.InteropServices; using System.Security; -namespace Raylib_cs +namespace Raylib_cs; + +[SuppressUnmanagedCodeSecurity] +public static unsafe partial class Rlgl { - [SuppressUnmanagedCodeSecurity] - public static unsafe partial class Rlgl + /// + /// Used by DllImport to load the native library + /// + public const string NativeLibName = "raylib"; + + public const int DEFAULT_BATCH_BUFFER_ELEMENTS = 8192; + public const int DEFAULT_BATCH_BUFFERS = 1; + public const int DEFAULT_BATCH_DRAWCALLS = 256; + public const int MAX_BATCH_ACTIVE_TEXTURES = 4; + public const int MAX_MATRIX_STACK_SIZE = 32; + public const float CULL_DISTANCE_NEAR = 0.01f; + public const float CULL_DISTANCE_FAR = 1000.0f; + + // Texture parameters (equivalent to OpenGL defines) + public const int TEXTURE_WRAP_S = 0x2802; + public const int TEXTURE_WRAP_T = 0x2803; + public const int TEXTURE_MAG_FILTER = 0x2800; + public const int TEXTURE_MIN_FILTER = 0x2801; + + public const int TEXTURE_FILTER_NEAREST = 0x2600; + public const int TEXTURE_FILTER_LINEAR = 0x2601; + public const int TEXTURE_FILTER_MIP_NEAREST = 0x2700; + public const int TEXTURE_FILTER_NEAREST_MIP_LINEAR = 0x2702; + public const int TEXTURE_FILTER_LINEAR_MIP_NEAREST = 0x2701; + public const int TEXTURE_FILTER_MIP_LINEAR = 0x2703; + public const int TEXTURE_FILTER_ANISOTROPIC = 0x3000; + public const int TEXTURE_MIPMAP_BIAS_RATIO = 0x4000; + + public const int TEXTURE_WRAP_REPEAT = 0x2901; + public const int TEXTURE_WRAP_CLAMP = 0x812F; + public const int TEXTURE_WRAP_MIRROR_REPEAT = 0x8370; + public const int TEXTURE_WRAP_MIRROR_CLAMP = 0x8742; + + // GL equivalent data types + public const int UNSIGNED_BYTE = 0x1401; + public const int FLOAT = 0x1406; + + // Buffer usage hint + public const int STREAM_DRAW = 0x88E0; + public const int STREAM_READ = 0x88E1; + public const int STREAM_COPY = 0x88E2; + public const int STATIC_DRAW = 0x88E4; + public const int STATIC_READ = 0x88E5; + public const int STATIC_COPY = 0x88E6; + public const int DYNAMIC_DRAW = 0x88E8; + public const int DYNAMIC_READ = 0x88E9; + public const int DYNAMIC_COPY = 0x88EA; + + // GL blending factors + public const int ZERO = 0; + public const int ONE = 1; + public const int SRC_COLOR = 0x0300; + public const int ONE_MINUS_SRC_COLOR = 0x0301; + public const int SRC_ALPHA = 0x0302; + public const int ONE_MINUS_SRC_ALPHA = 0x0303; + public const int DST_ALPHA = 0x0304; + public const int ONE_MINUS_DST_ALPHA = 0x0305; + public const int DST_COLOR = 0x0306; + public const int ONE_MINUS_DST_COLOR = 0x0307; + public const int SRC_ALPHA_SATURATE = 0x0308; + public const int CONSTANT_COLOR = 0x8001; + public const int ONE_MINUS_CONSTANT_COLOR = 0x8002; + public const int CONSTANT_ALPHA = 0x8003; + public const int ONE_MINUS_CONSTANT_ALPHA = 0x8004; + + // GL blending functions/equations + public const int FUNC_ADD = 0x8006; + public const int MIN = 0x8007; + public const int MAX = 0x8008; + public const int FUNC_SUBTRACT = 0x800A; + public const int FUNC_REVERSE_SUBTRACT = 0x800B; + public const int BLEND_EQUATION = 0x8009; + public const int BLEND_EQUATION_RGB = 0x8009; + public const int BLEND_EQUATION_ALPHA = 0x883D; + public const int BLEND_DST_RGB = 0x80C8; + public const int BLEND_SRC_RGB = 0x80C9; + public const int BLEND_DST_ALPHA = 0x80CA; + public const int BLEND_SRC_ALPHA = 0x80CB; + public const int BLEND_COLOR = 0x8005; + + // ------------------------------------------------------------------------------------ + // Functions Declaration - Matrix operations + // ------------------------------------------------------------------------------------ + + /// Choose the current matrix to be transformed + [DllImport(NativeLibName, EntryPoint = "rlMatrixMode", CallingConvention = CallingConvention.Cdecl)] + public static extern void MatrixMode(int mode); + + /// + public static void MatrixMode(MatrixMode mode) { - /// - /// Used by DllImport to load the native library - /// - public const string NativeLibName = "raylib"; - - public const int DEFAULT_BATCH_BUFFER_ELEMENTS = 8192; - public const int DEFAULT_BATCH_BUFFERS = 1; - public const int DEFAULT_BATCH_DRAWCALLS = 256; - public const int MAX_BATCH_ACTIVE_TEXTURES = 4; - public const int MAX_MATRIX_STACK_SIZE = 32; - public const float CULL_DISTANCE_NEAR = 0.01f; - public const float CULL_DISTANCE_FAR = 1000.0f; - - // Texture parameters (equivalent to OpenGL defines) - public const int TEXTURE_WRAP_S = 0x2802; - public const int TEXTURE_WRAP_T = 0x2803; - public const int TEXTURE_MAG_FILTER = 0x2800; - public const int TEXTURE_MIN_FILTER = 0x2801; - - public const int TEXTURE_FILTER_NEAREST = 0x2600; - public const int TEXTURE_FILTER_LINEAR = 0x2601; - public const int TEXTURE_FILTER_MIP_NEAREST = 0x2700; - public const int TEXTURE_FILTER_NEAREST_MIP_LINEAR = 0x2702; - public const int TEXTURE_FILTER_LINEAR_MIP_NEAREST = 0x2701; - public const int TEXTURE_FILTER_MIP_LINEAR = 0x2703; - public const int TEXTURE_FILTER_ANISOTROPIC = 0x3000; - public const int TEXTURE_MIPMAP_BIAS_RATIO = 0x4000; - - public const int TEXTURE_WRAP_REPEAT = 0x2901; - public const int TEXTURE_WRAP_CLAMP = 0x812F; - public const int TEXTURE_WRAP_MIRROR_REPEAT = 0x8370; - public const int TEXTURE_WRAP_MIRROR_CLAMP = 0x8742; - - // GL equivalent data types - public const int UNSIGNED_BYTE = 0x1401; - public const int FLOAT = 0x1406; - - // Buffer usage hint - public const int STREAM_DRAW = 0x88E0; - public const int STREAM_READ = 0x88E1; - public const int STREAM_COPY = 0x88E2; - public const int STATIC_DRAW = 0x88E4; - public const int STATIC_READ = 0x88E5; - public const int STATIC_COPY = 0x88E6; - public const int DYNAMIC_DRAW = 0x88E8; - public const int DYNAMIC_READ = 0x88E9; - public const int DYNAMIC_COPY = 0x88EA; - - // GL blending factors - public const int ZERO = 0; - public const int ONE = 1; - public const int SRC_COLOR = 0x0300; - public const int ONE_MINUS_SRC_COLOR = 0x0301; - public const int SRC_ALPHA = 0x0302; - public const int ONE_MINUS_SRC_ALPHA = 0x0303; - public const int DST_ALPHA = 0x0304; - public const int ONE_MINUS_DST_ALPHA = 0x0305; - public const int DST_COLOR = 0x0306; - public const int ONE_MINUS_DST_COLOR = 0x0307; - public const int SRC_ALPHA_SATURATE = 0x0308; - public const int CONSTANT_COLOR = 0x8001; - public const int ONE_MINUS_CONSTANT_COLOR = 0x8002; - public const int CONSTANT_ALPHA = 0x8003; - public const int ONE_MINUS_CONSTANT_ALPHA = 0x8004; - - // GL blending functions/equations - public const int FUNC_ADD = 0x8006; - public const int MIN = 0x8007; - public const int MAX = 0x8008; - public const int FUNC_SUBTRACT = 0x800A; - public const int FUNC_REVERSE_SUBTRACT = 0x800B; - public const int BLEND_EQUATION = 0x8009; - public const int BLEND_EQUATION_RGB = 0x8009; - public const int BLEND_EQUATION_ALPHA = 0x883D; - public const int BLEND_DST_RGB = 0x80C8; - public const int BLEND_SRC_RGB = 0x80C9; - public const int BLEND_DST_ALPHA = 0x80CA; - public const int BLEND_SRC_ALPHA = 0x80CB; - public const int BLEND_COLOR = 0x8005; - - // ------------------------------------------------------------------------------------ - // Functions Declaration - Matrix operations - // ------------------------------------------------------------------------------------ - - /// Choose the current matrix to be transformed - [DllImport(NativeLibName, EntryPoint = "rlMatrixMode", CallingConvention = CallingConvention.Cdecl)] - public static extern void MatrixMode(int mode); - - /// - public static void MatrixMode(MatrixMode mode) - { - MatrixMode((int)mode); - } - - /// Push the current matrix to stack - [DllImport(NativeLibName, EntryPoint = "rlPushMatrix", CallingConvention = CallingConvention.Cdecl)] - public static extern void PushMatrix(); - - /// Pop lattest inserted matrix from stack - [DllImport(NativeLibName, EntryPoint = "rlPopMatrix", CallingConvention = CallingConvention.Cdecl)] - public static extern void PopMatrix(); - - /// Reset current matrix to identity matrix - [DllImport(NativeLibName, EntryPoint = "rlLoadIdentity", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// 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); - - /// - /// 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); - - /// - public static void MultMatrixf(Matrix4x4 matf) - { - Float16 f = Raymath.MatrixToFloatV(matf); - MultMatrixf(f.v); - } - - [DllImport(NativeLibName, EntryPoint = "rlFrustum", CallingConvention = CallingConvention.Cdecl)] - public static extern void Frustum( - double left, - double right, - double bottom, - double top, - double znear, - double zfar - ); - - [DllImport(NativeLibName, EntryPoint = "rlOrtho", CallingConvention = CallingConvention.Cdecl)] - public static extern void Ortho( - double left, - double right, - double bottom, - double top, - double znear, - double zfar - ); - - /// Set the viewport area - [DllImport(NativeLibName, EntryPoint = "rlViewport", CallingConvention = CallingConvention.Cdecl)] - public static extern void Viewport(int x, int y, int width, int height); - - - // ------------------------------------------------------------------------------------ - // Functions Declaration - Vertex level operations - // ------------------------------------------------------------------------------------ - - /// Initialize drawing mode (how to organize vertex) - [DllImport(NativeLibName, EntryPoint = "rlBegin", CallingConvention = CallingConvention.Cdecl)] - public static extern void Begin(int mode); - - public static void Begin(DrawMode mode) - { - Begin((int)mode); - } - - /// Finish vertex providing - [DllImport(NativeLibName, EntryPoint = "rlEnd", CallingConvention = CallingConvention.Cdecl)] - public static extern void End(); - - /// Define one vertex (position) - 2 int - [DllImport(NativeLibName, EntryPoint = "rlVertex2i", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Define one vertex (position) - 3 float - [DllImport(NativeLibName, EntryPoint = "rlVertex3f", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Define one vertex (normal) - 3 float - [DllImport(NativeLibName, EntryPoint = "rlNormal3f", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Define one vertex (color) - 3 float - [DllImport(NativeLibName, EntryPoint = "rlColor3f", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - - // ------------------------------------------------------------------------------------ - // Functions Declaration - OpenGL equivalent functions (common to 1.1, 3.3+, ES2) - // NOTE: This functions are used to completely abstract raylib code from OpenGL layer - // ------------------------------------------------------------------------------------ - - /// Vertex buffers state - - /// Enable vertex array (VAO, if supported) - [DllImport(NativeLibName, EntryPoint = "rlEnableVertexArray", CallingConvention = CallingConvention.Cdecl)] - public static extern CBool EnableVertexArray(uint vaoId); - - /// Disable vertex array (VAO, if supported) - [DllImport(NativeLibName, EntryPoint = "rlDisableVertexArray", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableVertexArray(); - - /// Enable vertex buffer (VBO) - [DllImport(NativeLibName, EntryPoint = "rlEnableVertexBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableVertexBuffer(uint id); - - /// Disable vertex buffer (VBO) - [DllImport(NativeLibName, EntryPoint = "rlDisableVertexBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableVertexBuffer(); - - /// Enable vertex buffer element (VBO element) - [DllImport(NativeLibName, EntryPoint = "rlEnableVertexBufferElement", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableVertexBufferElement(uint id); - - /// Disable vertex buffer element (VBO element) - [DllImport(NativeLibName, EntryPoint = "rlDisableVertexBufferElement", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableVertexBufferElement(); - - /// Enable vertex attribute index - [DllImport(NativeLibName, EntryPoint = "rlEnableVertexAttribute", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableVertexAttribute(uint index); - - /// Disable vertex attribute index - [DllImport(NativeLibName, EntryPoint = "rlDisableVertexAttribute", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - - // Textures state - - /// Select and active a texture slot - [DllImport(NativeLibName, EntryPoint = "rlActiveTextureSlot", CallingConvention = CallingConvention.Cdecl)] - public static extern void ActiveTextureSlot(int slot); - - /// Enable texture - [DllImport(NativeLibName, EntryPoint = "rlEnableTexture", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableTexture(uint id); - - /// Disable texture - [DllImport(NativeLibName, EntryPoint = "rlDisableTexture", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableTexture(); - - /// Enable texture cubemap - [DllImport(NativeLibName, EntryPoint = "rlEnableTextureCubemap", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableTextureCubemap(uint id); - - /// Disable texture cubemap - [DllImport(NativeLibName, EntryPoint = "rlDisableTextureCubemap", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Set cubemap parameters (filter, wrap) - [DllImport(NativeLibName, EntryPoint = "rlCubemapParameters", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Disable shader program - [DllImport(NativeLibName, EntryPoint = "rlDisableShader", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableShader(); - - - // Framebuffer state - - /// Enable render texture (fbo) - [DllImport(NativeLibName, EntryPoint = "rlEnableFramebuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableFramebuffer(uint id); - - /// Disable render texture (fbo), return to default framebuffer - [DllImport(NativeLibName, EntryPoint = "rlDisableFramebuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableFramebuffer(); - - /// Activate multiple draw color buffers - [DllImport(NativeLibName, EntryPoint = "rlActiveDrawBuffers", CallingConvention = CallingConvention.Cdecl)] - public static extern void ActiveDrawBuffers(int count); - - - // General render state - - /// Enable color blending - [DllImport(NativeLibName, EntryPoint = "rlEnableColorBlend", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableColorBlend(); - - /// Disable color blending - [DllImport(NativeLibName, EntryPoint = "rlDisableColorBlend", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableColorBlend(); - - /// Enable depth test - [DllImport(NativeLibName, EntryPoint = "rlEnableDepthTest", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableDepthTest(); - - /// Disable depth test - [DllImport(NativeLibName, EntryPoint = "rlDisableDepthTest", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableDepthTest(); - - /// Enable depth write - [DllImport(NativeLibName, EntryPoint = "rlEnableDepthMask", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableDepthMask(); - - /// Disable depth write - [DllImport(NativeLibName, EntryPoint = "rlDisableDepthMask", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableDepthMask(); - - /// Enable backface culling - [DllImport(NativeLibName, EntryPoint = "rlEnableBackfaceCulling", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableBackfaceCulling(); - - /// Disable backface culling - [DllImport(NativeLibName, EntryPoint = "rlDisableBackfaceCulling", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableBackfaceCulling(); - - /// Set face culling mode - [DllImport(NativeLibName, EntryPoint = "rlSetCullFace", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetCullFace(int mode); - - /// Enable scissor test - [DllImport(NativeLibName, EntryPoint = "rlEnableScissorTest", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableScissorTest(); - - /// Disable scissor test - [DllImport(NativeLibName, EntryPoint = "rlDisableScissorTest", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableScissorTest(); - - /// Scissor test - [DllImport(NativeLibName, EntryPoint = "rlScissor", CallingConvention = CallingConvention.Cdecl)] - public static extern 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(); - - /// Disable wire mode - [DllImport(NativeLibName, EntryPoint = "rlDisableWireMode", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableWireMode(); - - /// Set the line drawing width - [DllImport(NativeLibName, EntryPoint = "rlSetLineWidth", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetLineWidth(float width); - - /// Get the line drawing width - [DllImport(NativeLibName, EntryPoint = "rlGetLineWidth", CallingConvention = CallingConvention.Cdecl)] - public static extern float GetLineWidth(); - - /// Enable line aliasing - [DllImport(NativeLibName, EntryPoint = "rlEnableSmoothLines", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableSmoothLines(); - - /// Disable line aliasing - [DllImport(NativeLibName, EntryPoint = "rlDisableSmoothLines", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableSmoothLines(); - - /// Enable stereo rendering - [DllImport(NativeLibName, EntryPoint = "rlEnableStereoRender", CallingConvention = CallingConvention.Cdecl)] - public static extern void EnableStereoRender(); - - /// Disable stereo rendering - [DllImport(NativeLibName, EntryPoint = "rlDisableStereoRender", CallingConvention = CallingConvention.Cdecl)] - public static extern void DisableStereoRender(); - - /// Check if stereo render is enabled - [DllImport(NativeLibName, EntryPoint = "rlIsStereoRenderEnabled", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Clear used screen buffers (color and depth) - [DllImport(NativeLibName, EntryPoint = "rlClearScreenBuffers", CallingConvention = CallingConvention.Cdecl)] - public static extern void ClearScreenBuffers(); - - /// Check and log OpenGL error codes - [DllImport(NativeLibName, EntryPoint = "rlCheckErrors", CallingConvention = CallingConvention.Cdecl)] - public static extern void CheckErrors(); - - /// Set blending mode - [DllImport(NativeLibName, EntryPoint = "rlSetBlendMode", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Set blending mode factors and equations separately (using OpenGL factors) - [DllImport(NativeLibName, EntryPoint = "rlSetBlendFactorsSeparate", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetBlendFactorsSeparate( - int glSrcRGB, - int glDstRGB, - int glSrcAlpha, - int glDstAlpha, - int glEqRGB, - int glEqAlpha - ); - - - // ------------------------------------------------------------------------------------ - // Functions Declaration - rlgl functionality - // ------------------------------------------------------------------------------------ - - /// Initialize rlgl (buffers, shaders, textures, states) - [DllImport(NativeLibName, EntryPoint = "rlglInit", CallingConvention = CallingConvention.Cdecl)] - public static extern void GlInit(int width, int height); - - /// De-inititialize rlgl (buffers, shaders, textures) - [DllImport(NativeLibName, EntryPoint = "rlglClose", CallingConvention = CallingConvention.Cdecl)] - public static extern void GlClose(); - - /// Load OpenGL extensions - [DllImport(NativeLibName, EntryPoint = "rlLoadExtensions", CallingConvention = CallingConvention.Cdecl)] - public static extern void LoadExtensions(void* loader); - - /// Get current OpenGL version - [DllImport(NativeLibName, EntryPoint = "rlGetVersion", CallingConvention = CallingConvention.Cdecl)] - public static extern GlVersion GetVersion(); - - /// Get default framebuffer width - [DllImport(NativeLibName, EntryPoint = "rlGetFramebufferWidth", CallingConvention = CallingConvention.Cdecl)] - public static extern int GetFramebufferWidth(); - - /// Get default framebuffer height - [DllImport(NativeLibName, EntryPoint = "rlGetFramebufferHeight", CallingConvention = CallingConvention.Cdecl)] - public static extern int GetFramebufferHeight(); - - /// Get default texture - [DllImport(NativeLibName, EntryPoint = "rlGetTextureIdDefault", CallingConvention = CallingConvention.Cdecl)] - public static extern uint GetTextureIdDefault(); - - /// Get default shader - [DllImport(NativeLibName, EntryPoint = "rlGetShaderIdDefault", CallingConvention = CallingConvention.Cdecl)] - public static extern uint GetShaderIdDefault(); - - /// Get default shader locations - [DllImport(NativeLibName, EntryPoint = "rlGetShaderLocsDefault", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Unload render batch system - [DllImport(NativeLibName, EntryPoint = "rlUnloadRenderBatch", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// Update and draw internal render batch - [DllImport(NativeLibName, EntryPoint = "rlDrawRenderBatchActive", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Set current texture for render batch and check buffers limits - [DllImport(NativeLibName, EntryPoint = "rlSetTexture", CallingConvention = CallingConvention.Cdecl)] - public static extern 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(); - - /// Load a vertex buffer attribute - [DllImport(NativeLibName, EntryPoint = "rlLoadVertexBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// 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); - - [DllImport(NativeLibName, EntryPoint = "rlUnloadVertexArray", CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadVertexArray(uint vaoId); - - [DllImport(NativeLibName, EntryPoint = "rlUnloadVertexBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadVertexBuffer(uint vboId); - - [DllImport(NativeLibName, EntryPoint = "rlSetVertexAttribute", CallingConvention = CallingConvention.Cdecl)] - public static extern void SetVertexAttribute( - uint index, - int compSize, - int type, - CBool normalized, - int stride, - void* pointer - ); - - [DllImport(NativeLibName, EntryPoint = "rlSetVertexAttributeDivisor", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - [DllImport(NativeLibName, EntryPoint = "rlDrawVertexArray", CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawVertexArray(int offset, int count); - - [DllImport(NativeLibName, EntryPoint = "rlDrawVertexArrayElements", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - [DllImport(NativeLibName, EntryPoint = "rlDrawVertexArrayElementsInstanced", CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawVertexArrayElementsInstanced( - int offset, - int count, - void* buffer, - int instances - ); - - - // 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); - - /// 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); - - /// Load texture cubemap - [DllImport(NativeLibName, EntryPoint = "rlLoadTextureCubemap", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadTextureCubemap(void* data, int size, PixelFormat format); - - /// Update GPU texture with new data - [DllImport(NativeLibName, EntryPoint = "rlUpdateTexture", CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateTexture( - uint id, - int offsetX, - int offsetY, - int width, - int height, - PixelFormat format, - void* data - ); - - /// Get OpenGL internal formats - [DllImport(NativeLibName, EntryPoint = "rlGetGlTextureFormats", CallingConvention = CallingConvention.Cdecl)] - public static extern void GetGlTextureFormats( - PixelFormat format, - int* glInternalFormat, - int* glFormat, - int* glType - ); - - /// Get OpenGL internal formats - [DllImport(NativeLibName, EntryPoint = "rlGetPixelFormatName", CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* GetPixelFormatName(PixelFormat format); - - /// Unload texture from GPU memory - [DllImport(NativeLibName, EntryPoint = "rlUnloadTexture", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Read texture pixel data - [DllImport(NativeLibName, EntryPoint = "rlReadTexturePixels", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - - // Framebuffer management (fbo) - - /// Load an empty framebuffer - [DllImport(NativeLibName, EntryPoint = "rlLoadFramebuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadFramebuffer(int width, int height); - - /// Attach texture/renderbuffer to a framebuffer - [DllImport(NativeLibName, EntryPoint = "rlFramebufferAttach", CallingConvention = CallingConvention.Cdecl)] - public static extern void FramebufferAttach( - uint fboId, - uint texId, - FramebufferAttachType attachType, - FramebufferAttachTextureType texType, - int mipLevel - ); - - /// Verify framebuffer is complete - [DllImport(NativeLibName, EntryPoint = "rlFramebufferComplete", CallingConvention = CallingConvention.Cdecl)] - public static extern CBool FramebufferComplete(uint id); - - /// Delete framebuffer from GPU - [DllImport(NativeLibName, EntryPoint = "rlUnloadFramebuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// 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); - - /// Load custom shader program - [DllImport(NativeLibName, EntryPoint = "rlLoadShaderProgram", CallingConvention = CallingConvention.Cdecl)] - public static extern uint LoadShaderProgram(uint vShaderId, uint fShaderId); - - /// Unload shader program - [DllImport(NativeLibName, EntryPoint = "rlUnloadShaderProgram", CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadShaderProgram(uint id); - - /// Get shader location uniform - [DllImport(NativeLibName, EntryPoint = "rlGetLocationUniform", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Set shader value uniform - [DllImport(NativeLibName, EntryPoint = "rlSetUniform", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Set shader value sampler - [DllImport(NativeLibName, EntryPoint = "rlSetUniformSampler", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - - // Compute shader management - - /// Load compute shader program - [DllImport(NativeLibName, EntryPoint = "rlLoadComputeShaderProgram", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - - // 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); - - /// Unload shader storage buffer object (SSBO) - [DllImport(NativeLibName, EntryPoint = "rlUnloadShaderBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Bind SSBO buffer data - [DllImport(NativeLibName, EntryPoint = "rlBindShaderBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Copy SSBO data between buffers - [DllImport(NativeLibName, EntryPoint = "rlCopyShaderBuffer", CallingConvention = CallingConvention.Cdecl)] - public static extern void CopyShaderBuffer( - uint destId, - uint srcId, - uint destOffset, - uint srcOffset, - uint count - ); - - /// Get SSBO buffer size - [DllImport(NativeLibName, EntryPoint = "rlGetShaderBufferSize", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - - // Matrix state management - - /// Get internal modelview matrix - [DllImport(NativeLibName, EntryPoint = "rlGetMatrixModelview", CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetMatrixModelview(); - - /// Get internal projection matrix - [DllImport(NativeLibName, EntryPoint = "rlGetMatrixProjection", CallingConvention = CallingConvention.Cdecl)] - public static extern Matrix4x4 GetMatrixProjection(); - - /// Get internal accumulated transform matrix - [DllImport(NativeLibName, EntryPoint = "rlGetMatrixTransform", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Get internal view offset matrix for stereo render (selected eye) - [DllImport(NativeLibName, EntryPoint = "rlGetMatrixViewOffsetStereo", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Set a custom modelview matrix (replaces internal modelview matrix) - [DllImport(NativeLibName, EntryPoint = "rlSetMatrixModelview", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - /// Set eyes view offsets matrices for stereo rendering - [DllImport(NativeLibName, EntryPoint = "rlSetMatrixViewOffsetStereo", CallingConvention = CallingConvention.Cdecl)] - public static extern 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(); - - /// Load and draw a quad - [DllImport(NativeLibName, EntryPoint = "rlLoadDrawQuad", CallingConvention = CallingConvention.Cdecl)] - public static extern void LoadDrawQuad(); + MatrixMode((int)mode); } + + /// Push the current matrix to stack + [DllImport(NativeLibName, EntryPoint = "rlPushMatrix", CallingConvention = CallingConvention.Cdecl)] + public static extern void PushMatrix(); + + /// Pop lattest inserted matrix from stack + [DllImport(NativeLibName, EntryPoint = "rlPopMatrix", CallingConvention = CallingConvention.Cdecl)] + public static extern void PopMatrix(); + + /// Reset current matrix to identity matrix + [DllImport(NativeLibName, EntryPoint = "rlLoadIdentity", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// 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); + + /// + /// 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); + + /// + public static void MultMatrixf(Matrix4x4 matf) + { + Float16 f = Raymath.MatrixToFloatV(matf); + MultMatrixf(f.v); + } + + [DllImport(NativeLibName, EntryPoint = "rlFrustum", CallingConvention = CallingConvention.Cdecl)] + public static extern void Frustum( + double left, + double right, + double bottom, + double top, + double znear, + double zfar + ); + + [DllImport(NativeLibName, EntryPoint = "rlOrtho", CallingConvention = CallingConvention.Cdecl)] + public static extern void Ortho( + double left, + double right, + double bottom, + double top, + double znear, + double zfar + ); + + /// Set the viewport area + [DllImport(NativeLibName, EntryPoint = "rlViewport", CallingConvention = CallingConvention.Cdecl)] + public static extern void Viewport(int x, int y, int width, int height); + + + // ------------------------------------------------------------------------------------ + // Functions Declaration - Vertex level operations + // ------------------------------------------------------------------------------------ + + /// Initialize drawing mode (how to organize vertex) + [DllImport(NativeLibName, EntryPoint = "rlBegin", CallingConvention = CallingConvention.Cdecl)] + public static extern void Begin(int mode); + + public static void Begin(DrawMode mode) + { + Begin((int)mode); + } + + /// Finish vertex providing + [DllImport(NativeLibName, EntryPoint = "rlEnd", CallingConvention = CallingConvention.Cdecl)] + public static extern void End(); + + /// Define one vertex (position) - 2 int + [DllImport(NativeLibName, EntryPoint = "rlVertex2i", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Define one vertex (position) - 3 float + [DllImport(NativeLibName, EntryPoint = "rlVertex3f", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Define one vertex (normal) - 3 float + [DllImport(NativeLibName, EntryPoint = "rlNormal3f", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Define one vertex (color) - 3 float + [DllImport(NativeLibName, EntryPoint = "rlColor3f", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + + // ------------------------------------------------------------------------------------ + // Functions Declaration - OpenGL equivalent functions (common to 1.1, 3.3+, ES2) + // NOTE: This functions are used to completely abstract raylib code from OpenGL layer + // ------------------------------------------------------------------------------------ + + /// Vertex buffers state + + /// Enable vertex array (VAO, if supported) + [DllImport(NativeLibName, EntryPoint = "rlEnableVertexArray", CallingConvention = CallingConvention.Cdecl)] + public static extern CBool EnableVertexArray(uint vaoId); + + /// Disable vertex array (VAO, if supported) + [DllImport(NativeLibName, EntryPoint = "rlDisableVertexArray", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableVertexArray(); + + /// Enable vertex buffer (VBO) + [DllImport(NativeLibName, EntryPoint = "rlEnableVertexBuffer", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableVertexBuffer(uint id); + + /// Disable vertex buffer (VBO) + [DllImport(NativeLibName, EntryPoint = "rlDisableVertexBuffer", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableVertexBuffer(); + + /// Enable vertex buffer element (VBO element) + [DllImport(NativeLibName, EntryPoint = "rlEnableVertexBufferElement", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableVertexBufferElement(uint id); + + /// Disable vertex buffer element (VBO element) + [DllImport(NativeLibName, EntryPoint = "rlDisableVertexBufferElement", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableVertexBufferElement(); + + /// Enable vertex attribute index + [DllImport(NativeLibName, EntryPoint = "rlEnableVertexAttribute", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableVertexAttribute(uint index); + + /// Disable vertex attribute index + [DllImport(NativeLibName, EntryPoint = "rlDisableVertexAttribute", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + + // Textures state + + /// Select and active a texture slot + [DllImport(NativeLibName, EntryPoint = "rlActiveTextureSlot", CallingConvention = CallingConvention.Cdecl)] + public static extern void ActiveTextureSlot(int slot); + + /// Enable texture + [DllImport(NativeLibName, EntryPoint = "rlEnableTexture", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableTexture(uint id); + + /// Disable texture + [DllImport(NativeLibName, EntryPoint = "rlDisableTexture", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableTexture(); + + /// Enable texture cubemap + [DllImport(NativeLibName, EntryPoint = "rlEnableTextureCubemap", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableTextureCubemap(uint id); + + /// Disable texture cubemap + [DllImport(NativeLibName, EntryPoint = "rlDisableTextureCubemap", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Set cubemap parameters (filter, wrap) + [DllImport(NativeLibName, EntryPoint = "rlCubemapParameters", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Disable shader program + [DllImport(NativeLibName, EntryPoint = "rlDisableShader", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableShader(); + + + // Framebuffer state + + /// Enable render texture (fbo) + [DllImport(NativeLibName, EntryPoint = "rlEnableFramebuffer", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableFramebuffer(uint id); + + /// Disable render texture (fbo), return to default framebuffer + [DllImport(NativeLibName, EntryPoint = "rlDisableFramebuffer", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableFramebuffer(); + + /// Activate multiple draw color buffers + [DllImport(NativeLibName, EntryPoint = "rlActiveDrawBuffers", CallingConvention = CallingConvention.Cdecl)] + public static extern void ActiveDrawBuffers(int count); + + + // General render state + + /// Enable color blending + [DllImport(NativeLibName, EntryPoint = "rlEnableColorBlend", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableColorBlend(); + + /// Disable color blending + [DllImport(NativeLibName, EntryPoint = "rlDisableColorBlend", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableColorBlend(); + + /// Enable depth test + [DllImport(NativeLibName, EntryPoint = "rlEnableDepthTest", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableDepthTest(); + + /// Disable depth test + [DllImport(NativeLibName, EntryPoint = "rlDisableDepthTest", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableDepthTest(); + + /// Enable depth write + [DllImport(NativeLibName, EntryPoint = "rlEnableDepthMask", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableDepthMask(); + + /// Disable depth write + [DllImport(NativeLibName, EntryPoint = "rlDisableDepthMask", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableDepthMask(); + + /// Enable backface culling + [DllImport(NativeLibName, EntryPoint = "rlEnableBackfaceCulling", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableBackfaceCulling(); + + /// Disable backface culling + [DllImport(NativeLibName, EntryPoint = "rlDisableBackfaceCulling", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableBackfaceCulling(); + + /// Set face culling mode + [DllImport(NativeLibName, EntryPoint = "rlSetCullFace", CallingConvention = CallingConvention.Cdecl)] + public static extern void SetCullFace(int mode); + + /// Enable scissor test + [DllImport(NativeLibName, EntryPoint = "rlEnableScissorTest", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableScissorTest(); + + /// Disable scissor test + [DllImport(NativeLibName, EntryPoint = "rlDisableScissorTest", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableScissorTest(); + + /// Scissor test + [DllImport(NativeLibName, EntryPoint = "rlScissor", CallingConvention = CallingConvention.Cdecl)] + public static extern 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(); + + /// Disable wire mode + [DllImport(NativeLibName, EntryPoint = "rlDisableWireMode", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableWireMode(); + + /// Set the line drawing width + [DllImport(NativeLibName, EntryPoint = "rlSetLineWidth", CallingConvention = CallingConvention.Cdecl)] + public static extern void SetLineWidth(float width); + + /// Get the line drawing width + [DllImport(NativeLibName, EntryPoint = "rlGetLineWidth", CallingConvention = CallingConvention.Cdecl)] + public static extern float GetLineWidth(); + + /// Enable line aliasing + [DllImport(NativeLibName, EntryPoint = "rlEnableSmoothLines", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableSmoothLines(); + + /// Disable line aliasing + [DllImport(NativeLibName, EntryPoint = "rlDisableSmoothLines", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableSmoothLines(); + + /// Enable stereo rendering + [DllImport(NativeLibName, EntryPoint = "rlEnableStereoRender", CallingConvention = CallingConvention.Cdecl)] + public static extern void EnableStereoRender(); + + /// Disable stereo rendering + [DllImport(NativeLibName, EntryPoint = "rlDisableStereoRender", CallingConvention = CallingConvention.Cdecl)] + public static extern void DisableStereoRender(); + + /// Check if stereo render is enabled + [DllImport(NativeLibName, EntryPoint = "rlIsStereoRenderEnabled", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Clear used screen buffers (color and depth) + [DllImport(NativeLibName, EntryPoint = "rlClearScreenBuffers", CallingConvention = CallingConvention.Cdecl)] + public static extern void ClearScreenBuffers(); + + /// Check and log OpenGL error codes + [DllImport(NativeLibName, EntryPoint = "rlCheckErrors", CallingConvention = CallingConvention.Cdecl)] + public static extern void CheckErrors(); + + /// Set blending mode + [DllImport(NativeLibName, EntryPoint = "rlSetBlendMode", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Set blending mode factors and equations separately (using OpenGL factors) + [DllImport(NativeLibName, EntryPoint = "rlSetBlendFactorsSeparate", CallingConvention = CallingConvention.Cdecl)] + public static extern void SetBlendFactorsSeparate( + int glSrcRGB, + int glDstRGB, + int glSrcAlpha, + int glDstAlpha, + int glEqRGB, + int glEqAlpha + ); + + + // ------------------------------------------------------------------------------------ + // Functions Declaration - rlgl functionality + // ------------------------------------------------------------------------------------ + + /// Initialize rlgl (buffers, shaders, textures, states) + [DllImport(NativeLibName, EntryPoint = "rlglInit", CallingConvention = CallingConvention.Cdecl)] + public static extern void GlInit(int width, int height); + + /// De-inititialize rlgl (buffers, shaders, textures) + [DllImport(NativeLibName, EntryPoint = "rlglClose", CallingConvention = CallingConvention.Cdecl)] + public static extern void GlClose(); + + /// Load OpenGL extensions + [DllImport(NativeLibName, EntryPoint = "rlLoadExtensions", CallingConvention = CallingConvention.Cdecl)] + public static extern void LoadExtensions(void* loader); + + /// Get current OpenGL version + [DllImport(NativeLibName, EntryPoint = "rlGetVersion", CallingConvention = CallingConvention.Cdecl)] + public static extern GlVersion GetVersion(); + + /// Get default framebuffer width + [DllImport(NativeLibName, EntryPoint = "rlGetFramebufferWidth", CallingConvention = CallingConvention.Cdecl)] + public static extern int GetFramebufferWidth(); + + /// Get default framebuffer height + [DllImport(NativeLibName, EntryPoint = "rlGetFramebufferHeight", CallingConvention = CallingConvention.Cdecl)] + public static extern int GetFramebufferHeight(); + + /// Get default texture + [DllImport(NativeLibName, EntryPoint = "rlGetTextureIdDefault", CallingConvention = CallingConvention.Cdecl)] + public static extern uint GetTextureIdDefault(); + + /// Get default shader + [DllImport(NativeLibName, EntryPoint = "rlGetShaderIdDefault", CallingConvention = CallingConvention.Cdecl)] + public static extern uint GetShaderIdDefault(); + + /// Get default shader locations + [DllImport(NativeLibName, EntryPoint = "rlGetShaderLocsDefault", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Unload render batch system + [DllImport(NativeLibName, EntryPoint = "rlUnloadRenderBatch", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// Update and draw internal render batch + [DllImport(NativeLibName, EntryPoint = "rlDrawRenderBatchActive", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Set current texture for render batch and check buffers limits + [DllImport(NativeLibName, EntryPoint = "rlSetTexture", CallingConvention = CallingConvention.Cdecl)] + public static extern 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(); + + /// Load a vertex buffer attribute + [DllImport(NativeLibName, EntryPoint = "rlLoadVertexBuffer", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// 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); + + [DllImport(NativeLibName, EntryPoint = "rlUnloadVertexArray", CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadVertexArray(uint vaoId); + + [DllImport(NativeLibName, EntryPoint = "rlUnloadVertexBuffer", CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadVertexBuffer(uint vboId); + + [DllImport(NativeLibName, EntryPoint = "rlSetVertexAttribute", CallingConvention = CallingConvention.Cdecl)] + public static extern void SetVertexAttribute( + uint index, + int compSize, + int type, + CBool normalized, + int stride, + void* pointer + ); + + [DllImport(NativeLibName, EntryPoint = "rlSetVertexAttributeDivisor", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + [DllImport(NativeLibName, EntryPoint = "rlDrawVertexArray", CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawVertexArray(int offset, int count); + + [DllImport(NativeLibName, EntryPoint = "rlDrawVertexArrayElements", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + [DllImport(NativeLibName, EntryPoint = "rlDrawVertexArrayElementsInstanced", CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawVertexArrayElementsInstanced( + int offset, + int count, + void* buffer, + int instances + ); + + + // 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); + + /// 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); + + /// Load texture cubemap + [DllImport(NativeLibName, EntryPoint = "rlLoadTextureCubemap", CallingConvention = CallingConvention.Cdecl)] + public static extern uint LoadTextureCubemap(void* data, int size, PixelFormat format); + + /// Update GPU texture with new data + [DllImport(NativeLibName, EntryPoint = "rlUpdateTexture", CallingConvention = CallingConvention.Cdecl)] + public static extern void UpdateTexture( + uint id, + int offsetX, + int offsetY, + int width, + int height, + PixelFormat format, + void* data + ); + + /// Get OpenGL internal formats + [DllImport(NativeLibName, EntryPoint = "rlGetGlTextureFormats", CallingConvention = CallingConvention.Cdecl)] + public static extern void GetGlTextureFormats( + PixelFormat format, + int* glInternalFormat, + int* glFormat, + int* glType + ); + + /// Get OpenGL internal formats + [DllImport(NativeLibName, EntryPoint = "rlGetPixelFormatName", CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* GetPixelFormatName(PixelFormat format); + + /// Unload texture from GPU memory + [DllImport(NativeLibName, EntryPoint = "rlUnloadTexture", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Read texture pixel data + [DllImport(NativeLibName, EntryPoint = "rlReadTexturePixels", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + + // Framebuffer management (fbo) + + /// Load an empty framebuffer + [DllImport(NativeLibName, EntryPoint = "rlLoadFramebuffer", CallingConvention = CallingConvention.Cdecl)] + public static extern uint LoadFramebuffer(int width, int height); + + /// Attach texture/renderbuffer to a framebuffer + [DllImport(NativeLibName, EntryPoint = "rlFramebufferAttach", CallingConvention = CallingConvention.Cdecl)] + public static extern void FramebufferAttach( + uint fboId, + uint texId, + FramebufferAttachType attachType, + FramebufferAttachTextureType texType, + int mipLevel + ); + + /// Verify framebuffer is complete + [DllImport(NativeLibName, EntryPoint = "rlFramebufferComplete", CallingConvention = CallingConvention.Cdecl)] + public static extern CBool FramebufferComplete(uint id); + + /// Delete framebuffer from GPU + [DllImport(NativeLibName, EntryPoint = "rlUnloadFramebuffer", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// 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); + + /// Load custom shader program + [DllImport(NativeLibName, EntryPoint = "rlLoadShaderProgram", CallingConvention = CallingConvention.Cdecl)] + public static extern uint LoadShaderProgram(uint vShaderId, uint fShaderId); + + /// Unload shader program + [DllImport(NativeLibName, EntryPoint = "rlUnloadShaderProgram", CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadShaderProgram(uint id); + + /// Get shader location uniform + [DllImport(NativeLibName, EntryPoint = "rlGetLocationUniform", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Set shader value uniform + [DllImport(NativeLibName, EntryPoint = "rlSetUniform", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Set shader value sampler + [DllImport(NativeLibName, EntryPoint = "rlSetUniformSampler", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + + // Compute shader management + + /// Load compute shader program + [DllImport(NativeLibName, EntryPoint = "rlLoadComputeShaderProgram", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + + // 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); + + /// Unload shader storage buffer object (SSBO) + [DllImport(NativeLibName, EntryPoint = "rlUnloadShaderBuffer", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Bind SSBO buffer data + [DllImport(NativeLibName, EntryPoint = "rlBindShaderBuffer", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Copy SSBO data between buffers + [DllImport(NativeLibName, EntryPoint = "rlCopyShaderBuffer", CallingConvention = CallingConvention.Cdecl)] + public static extern void CopyShaderBuffer( + uint destId, + uint srcId, + uint destOffset, + uint srcOffset, + uint count + ); + + /// Get SSBO buffer size + [DllImport(NativeLibName, EntryPoint = "rlGetShaderBufferSize", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + + // Matrix state management + + /// Get internal modelview matrix + [DllImport(NativeLibName, EntryPoint = "rlGetMatrixModelview", CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 GetMatrixModelview(); + + /// Get internal projection matrix + [DllImport(NativeLibName, EntryPoint = "rlGetMatrixProjection", CallingConvention = CallingConvention.Cdecl)] + public static extern Matrix4x4 GetMatrixProjection(); + + /// Get internal accumulated transform matrix + [DllImport(NativeLibName, EntryPoint = "rlGetMatrixTransform", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Get internal view offset matrix for stereo render (selected eye) + [DllImport(NativeLibName, EntryPoint = "rlGetMatrixViewOffsetStereo", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Set a custom modelview matrix (replaces internal modelview matrix) + [DllImport(NativeLibName, EntryPoint = "rlSetMatrixModelview", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + /// Set eyes view offsets matrices for stereo rendering + [DllImport(NativeLibName, EntryPoint = "rlSetMatrixViewOffsetStereo", CallingConvention = CallingConvention.Cdecl)] + public static extern 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(); + + /// Load and draw a quad + [DllImport(NativeLibName, EntryPoint = "rlLoadDrawQuad", CallingConvention = CallingConvention.Cdecl)] + public static extern void LoadDrawQuad(); } diff --git a/Raylib-cs/types/Audio.cs b/Raylib-cs/types/Audio.cs index 8a58ccc..facf624 100644 --- a/Raylib-cs/types/Audio.cs +++ b/Raylib-cs/types/Audio.cs @@ -1,123 +1,122 @@ using System; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Wave type, defines audio wave data +/// +[StructLayout(LayoutKind.Sequential)] +public unsafe partial struct Wave { /// - /// Wave type, defines audio wave data + /// Number of samples /// - [StructLayout(LayoutKind.Sequential)] - public unsafe partial struct Wave - { - /// - /// Number of samples - /// - public uint SampleCount; - - /// - /// Frequency (samples per second) - /// - public uint SampleRate; - - /// - /// Bit depth (bits per sample): 8, 16, 32 (24 not supported) - /// - public uint SampleSize; - - /// - /// Number of channels (1-mono, 2-stereo) - /// - public uint Channels; - - //TODO: SPAN ? - /// - /// Buffer data pointer - /// - public void* Data; - } + public uint SampleCount; /// - /// Audio stream type
- /// NOTE: Useful to create custom audio streams not bound to a specific file + /// Frequency (samples per second) ///
- [StructLayout(LayoutKind.Sequential)] - public partial struct AudioStream - { - //TODO: convert - /// - /// Pointer to internal data(rAudioBuffer *) used by the audio system - /// - public IntPtr Buffer; - - /// - /// Pointer to internal data processor, useful for audio effects - /// - public IntPtr Processor; - - /// - /// Frequency (samples per second) - /// - public uint SampleRate; - - /// - /// Bit depth (bits per sample): 8, 16, 32 (24 not supported) - /// - public uint SampleSize; - - /// - /// Number of channels (1-mono, 2-stereo) - /// - public uint Channels; - } + public uint SampleRate; /// - /// Sound source type + /// Bit depth (bits per sample): 8, 16, 32 (24 not supported) /// - [StructLayout(LayoutKind.Sequential)] - public partial struct Sound - { - /// - /// Audio stream - /// - public AudioStream Stream; - - /// - /// Total number of frames (considering channels) - /// - public uint FrameCount; - } + public uint SampleSize; /// - /// Music stream type (audio file streaming from memory)
- /// NOTE: Anything longer than ~10 seconds should be streamed + /// Number of channels (1-mono, 2-stereo) ///
- [StructLayout(LayoutKind.Sequential)] - public unsafe partial struct Music - { - /// - /// Audio stream - /// - public AudioStream Stream; + public uint Channels; - /// - /// Total number of samples - /// - public uint FrameCount; - - /// - /// Music looping enable - /// - public CBool Looping; - - /// - /// Type of music context (audio filetype) - /// - public int CtxType; - - //TODO span - /// - /// Audio context data, depends on type - /// - public void* CtxData; - } + //TODO: SPAN ? + /// + /// Buffer data pointer + /// + public void* Data; +} + +/// +/// Audio stream type
+/// NOTE: Useful to create custom audio streams not bound to a specific file +///
+[StructLayout(LayoutKind.Sequential)] +public partial struct AudioStream +{ + //TODO: convert + /// + /// Pointer to internal data(rAudioBuffer *) used by the audio system + /// + public IntPtr Buffer; + + /// + /// Pointer to internal data processor, useful for audio effects + /// + public IntPtr Processor; + + /// + /// Frequency (samples per second) + /// + public uint SampleRate; + + /// + /// Bit depth (bits per sample): 8, 16, 32 (24 not supported) + /// + public uint SampleSize; + + /// + /// Number of channels (1-mono, 2-stereo) + /// + public uint Channels; +} + +/// +/// Sound source type +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct Sound +{ + /// + /// Audio stream + /// + public AudioStream Stream; + + /// + /// Total number of frames (considering channels) + /// + public uint FrameCount; +} + +/// +/// Music stream type (audio file streaming from memory)
+/// NOTE: Anything longer than ~10 seconds should be streamed +///
+[StructLayout(LayoutKind.Sequential)] +public unsafe partial struct Music +{ + /// + /// Audio stream + /// + public AudioStream Stream; + + /// + /// Total number of samples + /// + public uint FrameCount; + + /// + /// Music looping enable + /// + public CBool Looping; + + /// + /// Type of music context (audio filetype) + /// + public int CtxType; + + //TODO span + /// + /// Audio context data, depends on type + /// + public void* CtxData; } diff --git a/Raylib-cs/types/BoundingBox.cs b/Raylib-cs/types/BoundingBox.cs index 77d16ce..3e12bc3 100644 --- a/Raylib-cs/types/BoundingBox.cs +++ b/Raylib-cs/types/BoundingBox.cs @@ -1,26 +1,25 @@ using System.Numerics; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// Bounding box type +[StructLayout(LayoutKind.Sequential)] +public partial struct BoundingBox { - /// Bounding box type - [StructLayout(LayoutKind.Sequential)] - public partial struct BoundingBox + /// + /// Minimum vertex box-corner + /// + public Vector3 Min; + + /// + /// Maximum vertex box-corner + /// + public Vector3 Max; + + public BoundingBox(Vector3 min, Vector3 max) { - /// - /// Minimum vertex box-corner - /// - public Vector3 Min; - - /// - /// Maximum vertex box-corner - /// - public Vector3 Max; - - public BoundingBox(Vector3 min, Vector3 max) - { - this.Min = min; - this.Max = max; - } + this.Min = min; + this.Max = max; } } diff --git a/Raylib-cs/types/Camera2D.cs b/Raylib-cs/types/Camera2D.cs index 72fc72a..f26f6e4 100644 --- a/Raylib-cs/types/Camera2D.cs +++ b/Raylib-cs/types/Camera2D.cs @@ -1,40 +1,39 @@ using System.Numerics; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Camera2D, defines position/orientation in 2d space +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct Camera2D { /// - /// Camera2D, defines position/orientation in 2d space + /// Camera offset (displacement from target) /// - [StructLayout(LayoutKind.Sequential)] - public partial struct Camera2D + public Vector2 Offset; + + /// + /// Camera target (rotation and zoom origin) + /// + public Vector2 Target; + + /// + /// Camera rotation in degrees + /// + public float Rotation; + + /// + /// Camera zoom (scaling), should be 1.0f by default + /// + public float Zoom; + + public Camera2D(Vector2 offset, Vector2 target, float rotation, float zoom) { - /// - /// Camera offset (displacement from target) - /// - public Vector2 Offset; - - /// - /// Camera target (rotation and zoom origin) - /// - public Vector2 Target; - - /// - /// Camera rotation in degrees - /// - public float Rotation; - - /// - /// Camera zoom (scaling), should be 1.0f by default - /// - public float Zoom; - - public Camera2D(Vector2 offset, Vector2 target, float rotation, float zoom) - { - this.Offset = offset; - this.Target = target; - this.Rotation = rotation; - this.Zoom = zoom; - } + this.Offset = offset; + this.Target = target; + this.Rotation = rotation; + this.Zoom = zoom; } } diff --git a/Raylib-cs/types/Camera3D.cs b/Raylib-cs/types/Camera3D.cs index c66fea2..ecb3c05 100644 --- a/Raylib-cs/types/Camera3D.cs +++ b/Raylib-cs/types/Camera3D.cs @@ -1,67 +1,66 @@ using System.Numerics; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Camera system modes +/// +public enum CameraMode +{ + CAMERA_CUSTOM = 0, + CAMERA_FREE, + CAMERA_ORBITAL, + CAMERA_FIRST_PERSON, + CAMERA_THIRD_PERSON +} + +/// +/// Camera projection +/// +public enum CameraProjection +{ + CAMERA_PERSPECTIVE = 0, + CAMERA_ORTHOGRAPHIC +} + +/// +/// Camera3D, defines position/orientation in 3d space +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct Camera3D { /// - /// Camera system modes + /// Camera position /// - public enum CameraMode - { - CAMERA_CUSTOM = 0, - CAMERA_FREE, - CAMERA_ORBITAL, - CAMERA_FIRST_PERSON, - CAMERA_THIRD_PERSON - } + public Vector3 Position; /// - /// Camera projection + /// Camera target it looks-at /// - public enum CameraProjection - { - CAMERA_PERSPECTIVE = 0, - CAMERA_ORTHOGRAPHIC - } + public Vector3 Target; /// - /// Camera3D, defines position/orientation in 3d space + /// Camera up vector (rotation over its axis) /// - [StructLayout(LayoutKind.Sequential)] - public partial struct Camera3D + public Vector3 Up; + + /// + /// Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic + /// + public float FovY; + + /// + /// Camera type, defines projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC + /// + public CameraProjection Projection; + + public Camera3D(Vector3 position, Vector3 target, Vector3 up, float fovY, CameraProjection projection) { - /// - /// Camera position - /// - public Vector3 Position; - - /// - /// Camera target it looks-at - /// - public Vector3 Target; - - /// - /// Camera up vector (rotation over its axis) - /// - public Vector3 Up; - - /// - /// Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic - /// - public float FovY; - - /// - /// Camera type, defines projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC - /// - public CameraProjection Projection; - - public Camera3D(Vector3 position, Vector3 target, Vector3 up, float fovY, CameraProjection projection) - { - this.Position = position; - this.Target = target; - this.Up = up; - this.FovY = fovY; - this.Projection = projection; - } + this.Position = position; + this.Target = target; + this.Up = up; + this.FovY = fovY; + this.Projection = projection; } } diff --git a/Raylib-cs/types/Color.cs b/Raylib-cs/types/Color.cs index 4fb7478..f41d29b 100644 --- a/Raylib-cs/types/Color.cs +++ b/Raylib-cs/types/Color.cs @@ -1,67 +1,66 @@ using System; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Color type, RGBA (32bit) +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct Color { - /// - /// Color type, RGBA (32bit) - /// - [StructLayout(LayoutKind.Sequential)] - public partial struct Color + public byte R; + public byte G; + public byte B; + public byte A; + + // Example - Color.RED instead of RED + // Custom raylib color palette for amazing visuals + public static readonly Color LIGHTGRAY = new Color(200, 200, 200, 255); + public static readonly Color GRAY = new Color(130, 130, 130, 255); + public static readonly Color DARKGRAY = new Color(80, 80, 80, 255); + public static readonly Color YELLOW = new Color(253, 249, 0, 255); + public static readonly Color GOLD = new Color(255, 203, 0, 255); + public static readonly Color ORANGE = new Color(255, 161, 0, 255); + public static readonly Color PINK = new Color(255, 109, 194, 255); + public static readonly Color RED = new Color(230, 41, 55, 255); + public static readonly Color MAROON = new Color(190, 33, 55, 255); + public static readonly Color GREEN = new Color(0, 228, 48, 255); + public static readonly Color LIME = new Color(0, 158, 47, 255); + public static readonly Color DARKGREEN = new Color(0, 117, 44, 255); + public static readonly Color SKYBLUE = new Color(102, 191, 255, 255); + public static readonly Color BLUE = new Color(0, 121, 241, 255); + public static readonly Color DARKBLUE = new Color(0, 82, 172, 255); + public static readonly Color PURPLE = new Color(200, 122, 255, 255); + public static readonly Color VIOLET = new Color(135, 60, 190, 255); + public static readonly Color DARKPURPLE = new Color(112, 31, 126, 255); + public static readonly Color BEIGE = new Color(211, 176, 131, 255); + public static readonly Color BROWN = new Color(127, 106, 79, 255); + public static readonly Color DARKBROWN = new Color(76, 63, 47, 255); + public static readonly Color WHITE = new Color(255, 255, 255, 255); + public static readonly Color BLACK = new Color(0, 0, 0, 255); + public static readonly Color BLANK = new Color(0, 0, 0, 0); + public static readonly Color MAGENTA = new Color(255, 0, 255, 255); + public static readonly Color RAYWHITE = new Color(245, 245, 245, 255); + + public Color(byte r, byte g, byte b, byte a) { - public byte R; - public byte G; - public byte B; - public byte A; + this.R = r; + this.G = g; + this.B = b; + this.A = a; + } - // Example - Color.RED instead of RED - // Custom raylib color palette for amazing visuals - public static readonly Color LIGHTGRAY = new Color(200, 200, 200, 255); - public static readonly Color GRAY = new Color(130, 130, 130, 255); - public static readonly Color DARKGRAY = new Color(80, 80, 80, 255); - public static readonly Color YELLOW = new Color(253, 249, 0, 255); - public static readonly Color GOLD = new Color(255, 203, 0, 255); - public static readonly Color ORANGE = new Color(255, 161, 0, 255); - public static readonly Color PINK = new Color(255, 109, 194, 255); - public static readonly Color RED = new Color(230, 41, 55, 255); - public static readonly Color MAROON = new Color(190, 33, 55, 255); - public static readonly Color GREEN = new Color(0, 228, 48, 255); - public static readonly Color LIME = new Color(0, 158, 47, 255); - public static readonly Color DARKGREEN = new Color(0, 117, 44, 255); - public static readonly Color SKYBLUE = new Color(102, 191, 255, 255); - public static readonly Color BLUE = new Color(0, 121, 241, 255); - public static readonly Color DARKBLUE = new Color(0, 82, 172, 255); - public static readonly Color PURPLE = new Color(200, 122, 255, 255); - public static readonly Color VIOLET = new Color(135, 60, 190, 255); - public static readonly Color DARKPURPLE = new Color(112, 31, 126, 255); - public static readonly Color BEIGE = new Color(211, 176, 131, 255); - public static readonly Color BROWN = new Color(127, 106, 79, 255); - public static readonly Color DARKBROWN = new Color(76, 63, 47, 255); - public static readonly Color WHITE = new Color(255, 255, 255, 255); - public static readonly Color BLACK = new Color(0, 0, 0, 255); - public static readonly Color BLANK = new Color(0, 0, 0, 0); - public static readonly Color MAGENTA = new Color(255, 0, 255, 255); - public static readonly Color RAYWHITE = new Color(245, 245, 245, 255); + public Color(int r, int g, int b, int a) + { + this.R = Convert.ToByte(r); + this.G = Convert.ToByte(g); + this.B = Convert.ToByte(b); + this.A = Convert.ToByte(a); + } - public Color(byte r, byte g, byte b, byte a) - { - this.R = r; - this.G = g; - this.B = b; - this.A = a; - } - - public Color(int r, int g, int b, int a) - { - this.R = Convert.ToByte(r); - this.G = Convert.ToByte(g); - this.B = Convert.ToByte(b); - this.A = Convert.ToByte(a); - } - - public override string ToString() - { - return $"{{R:{R} G:{G} B:{B} A:{A}}}"; - } + public override string ToString() + { + return $"{{R:{R} G:{G} B:{B} A:{A}}}"; } } diff --git a/Raylib-cs/types/Core.cs b/Raylib-cs/types/Core.cs index d377c13..664a8c8 100644 --- a/Raylib-cs/types/Core.cs +++ b/Raylib-cs/types/Core.cs @@ -1,181 +1,180 @@ using System; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// System config flags
+/// NOTE: Every bit registers one state (use it with bit masks)
+/// By default all flags are set to 0 +///
+[Flags] +public enum ConfigFlags : uint { /// - /// System config flags
- /// NOTE: Every bit registers one state (use it with bit masks)
- /// By default all flags are set to 0 + /// Set to try enabling V-Sync on GPU ///
- [Flags] - public enum ConfigFlags : uint - { - /// - /// Set to try enabling V-Sync on GPU - /// - FLAG_VSYNC_HINT = 0x00000040, - - /// - /// Set to run program in fullscreen - /// - FLAG_FULLSCREEN_MODE = 0x00000002, - - /// - /// Set to allow resizable window - /// - FLAG_WINDOW_RESIZABLE = 0x00000004, - - /// - /// Set to disable window decoration (frame and buttons) - /// - FLAG_WINDOW_UNDECORATED = 0x00000008, - - /// - /// Set to hide window - /// - FLAG_WINDOW_HIDDEN = 0x00000080, - - /// - /// Set to minimize window (iconify) - /// - FLAG_WINDOW_MINIMIZED = 0x00000200, - - /// - /// Set to maximize window (expanded to monitor) - /// - FLAG_WINDOW_MAXIMIZED = 0x00000400, - - /// - /// Set to window non focused - /// - FLAG_WINDOW_UNFOCUSED = 0x00000800, - - /// - /// Set to window always on top - /// - FLAG_WINDOW_TOPMOST = 0x00001000, - - /// - /// Set to allow windows running while minimized - /// - FLAG_WINDOW_ALWAYS_RUN = 0x00000100, - - /// - /// Set to allow transparent framebuffer - /// - FLAG_WINDOW_TRANSPARENT = 0x00000010, - - /// - /// Set to support HighDPI - /// - FLAG_WINDOW_HIGHDPI = 0x00002000, - - /// - /// Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED - /// - FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, - - /// - /// Set to try enabling MSAA 4X - /// - FLAG_MSAA_4X_HINT = 0x00000020, - - /// - /// Set to try enabling interlaced video format (for V3D) - /// - FLAG_INTERLACED_HINT = 0x00010000, - } + FLAG_VSYNC_HINT = 0x00000040, /// - /// Trace log level
- /// NOTE: Organized by priority level + /// Set to run program in fullscreen ///
- public enum TraceLogLevel - { - /// - /// Display all logs - /// - LOG_ALL = 0, - - /// - /// Trace logging, intended for internal use only - /// - LOG_TRACE, - - /// - /// Debug logging, used for internal debugging, it should be disabled on release builds - /// - LOG_DEBUG, - - /// - /// Info logging, used for program execution info - /// - LOG_INFO, - - /// - /// Warning logging, used on recoverable failures - /// - LOG_WARNING, - - /// - /// Error logging, used on unrecoverable failures - /// - LOG_ERROR, - - /// - /// Fatal logging, used to abort program: exit(EXIT_FAILURE) - /// - LOG_FATAL, - - /// - /// Disable logging - /// - LOG_NONE - } + FLAG_FULLSCREEN_MODE = 0x00000002, /// - /// Color blending modes (pre-defined) + /// Set to allow resizable window /// - public enum BlendMode - { - /// - /// Blend textures considering alpha (default) - /// - BLEND_ALPHA = 0, + FLAG_WINDOW_RESIZABLE = 0x00000004, - /// - /// Blend textures adding colors - /// - BLEND_ADDITIVE, + /// + /// Set to disable window decoration (frame and buttons) + /// + FLAG_WINDOW_UNDECORATED = 0x00000008, - /// - /// Blend textures multiplying colors - /// - BLEND_MULTIPLIED, + /// + /// Set to hide window + /// + FLAG_WINDOW_HIDDEN = 0x00000080, - /// - /// Blend textures adding colors (alternative) - /// - BLEND_ADD_COLORS, + /// + /// Set to minimize window (iconify) + /// + FLAG_WINDOW_MINIMIZED = 0x00000200, - /// - /// Blend textures subtracting colors (alternative) - /// - BLEND_SUBTRACT_COLORS, + /// + /// Set to maximize window (expanded to monitor) + /// + FLAG_WINDOW_MAXIMIZED = 0x00000400, - /// - /// Blend premultiplied textures considering alpha - /// - BLEND_ALPHA_PREMULTIPLY, + /// + /// Set to window non focused + /// + FLAG_WINDOW_UNFOCUSED = 0x00000800, - /// - /// Blend textures using custom src/dst factors (use rlSetBlendFactors()) - /// - BLEND_CUSTOM, + /// + /// Set to window always on top + /// + FLAG_WINDOW_TOPMOST = 0x00001000, - /// - /// Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate()) - /// - BLEND_CUSTOM_SEPARATE - } + /// + /// Set to allow windows running while minimized + /// + FLAG_WINDOW_ALWAYS_RUN = 0x00000100, + + /// + /// Set to allow transparent framebuffer + /// + FLAG_WINDOW_TRANSPARENT = 0x00000010, + + /// + /// Set to support HighDPI + /// + FLAG_WINDOW_HIGHDPI = 0x00002000, + + /// + /// Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED + /// + FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, + + /// + /// Set to try enabling MSAA 4X + /// + FLAG_MSAA_4X_HINT = 0x00000020, + + /// + /// Set to try enabling interlaced video format (for V3D) + /// + FLAG_INTERLACED_HINT = 0x00010000, +} + +/// +/// Trace log level
+/// NOTE: Organized by priority level +///
+public enum TraceLogLevel +{ + /// + /// Display all logs + /// + LOG_ALL = 0, + + /// + /// Trace logging, intended for internal use only + /// + LOG_TRACE, + + /// + /// Debug logging, used for internal debugging, it should be disabled on release builds + /// + LOG_DEBUG, + + /// + /// Info logging, used for program execution info + /// + LOG_INFO, + + /// + /// Warning logging, used on recoverable failures + /// + LOG_WARNING, + + /// + /// Error logging, used on unrecoverable failures + /// + LOG_ERROR, + + /// + /// Fatal logging, used to abort program: exit(EXIT_FAILURE) + /// + LOG_FATAL, + + /// + /// Disable logging + /// + LOG_NONE +} + +/// +/// Color blending modes (pre-defined) +/// +public enum BlendMode +{ + /// + /// Blend textures considering alpha (default) + /// + BLEND_ALPHA = 0, + + /// + /// Blend textures adding colors + /// + BLEND_ADDITIVE, + + /// + /// Blend textures multiplying colors + /// + BLEND_MULTIPLIED, + + /// + /// Blend textures adding colors (alternative) + /// + BLEND_ADD_COLORS, + + /// + /// Blend textures subtracting colors (alternative) + /// + BLEND_SUBTRACT_COLORS, + + /// + /// Blend premultiplied textures considering alpha + /// + BLEND_ALPHA_PREMULTIPLY, + + /// + /// Blend textures using custom src/dst factors (use rlSetBlendFactors()) + /// + BLEND_CUSTOM, + + /// + /// Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate()) + /// + BLEND_CUSTOM_SEPARATE } diff --git a/Raylib-cs/types/Font.cs b/Raylib-cs/types/Font.cs index 1e508da..081de3b 100644 --- a/Raylib-cs/types/Font.cs +++ b/Raylib-cs/types/Font.cs @@ -1,94 +1,93 @@ using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Font type, defines generation method +/// +public enum FontType { /// - /// Font type, defines generation method + /// Default font generation, anti-aliased /// - public enum FontType - { - /// - /// Default font generation, anti-aliased - /// - FONT_DEFAULT = 0, - - /// - /// Bitmap font generation, no anti-aliasing - /// - FONT_BITMAP, - - /// - /// SDF font generation, requires external shader - /// - FONT_SDF - } + FONT_DEFAULT = 0, /// - /// GlyphInfo, font characters glyphs info + /// Bitmap font generation, no anti-aliasing /// - [StructLayout(LayoutKind.Sequential)] - public partial struct GlyphInfo - { - /// - /// Character value (Unicode) - /// - public int Value; - - /// - /// Character offset X when drawing - /// - public int OffsetX; - - /// - /// Character offset Y when drawing - /// - public int OffsetY; - - /// - /// Character advance position X - /// - public int AdvanceX; - - /// - /// Character image data - /// - public Image Image; - } + FONT_BITMAP, /// - /// Font, font texture and GlyphInfo array data + /// SDF font generation, requires external shader /// - [StructLayout(LayoutKind.Sequential)] - public unsafe partial struct Font - { - /// - /// Base size (default chars height) - /// - public int BaseSize; - - /// - /// Number of characters - /// - public int GlyphCount; - - /// - /// Padding around the glyph characters - /// - public int GlyphPadding; - - /// - /// Texture atlas containing the glyphs - /// - public Texture2D Texture; - - /// - /// Rectangles in texture for the glyphs - /// - public Rectangle* Recs; - - /// - /// Glyphs info data - /// - public GlyphInfo* Glyphs; - } + FONT_SDF +} + +/// +/// GlyphInfo, font characters glyphs info +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct GlyphInfo +{ + /// + /// Character value (Unicode) + /// + public int Value; + + /// + /// Character offset X when drawing + /// + public int OffsetX; + + /// + /// Character offset Y when drawing + /// + public int OffsetY; + + /// + /// Character advance position X + /// + public int AdvanceX; + + /// + /// Character image data + /// + public Image Image; +} + +/// +/// Font, font texture and GlyphInfo array data +/// +[StructLayout(LayoutKind.Sequential)] +public unsafe partial struct Font +{ + /// + /// Base size (default chars height) + /// + public int BaseSize; + + /// + /// Number of characters + /// + public int GlyphCount; + + /// + /// Padding around the glyph characters + /// + public int GlyphPadding; + + /// + /// Texture atlas containing the glyphs + /// + public Texture2D Texture; + + /// + /// Rectangles in texture for the glyphs + /// + public Rectangle* Recs; + + /// + /// Glyphs info data + /// + public GlyphInfo* Glyphs; } diff --git a/Raylib-cs/types/Image.cs b/Raylib-cs/types/Image.cs index 98a18fa..74f6362 100644 --- a/Raylib-cs/types/Image.cs +++ b/Raylib-cs/types/Image.cs @@ -1,148 +1,147 @@ using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Pixel formats
+/// NOTE: Support depends on OpenGL version and platform +///
+public enum PixelFormat { /// - /// Pixel formats
- /// NOTE: Support depends on OpenGL version and platform + /// 8 bit per pixel (no alpha) ///
- public enum PixelFormat - { - /// - /// 8 bit per pixel (no alpha) - /// - PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, - - /// - /// 8*2 bpp (2 channels) - /// - PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, - - /// - /// 16 bpp - /// - PIXELFORMAT_UNCOMPRESSED_R5G6B5, - - /// - /// 24 bpp - /// - PIXELFORMAT_UNCOMPRESSED_R8G8B8, - - /// - /// 16 bpp (1 bit alpha) - /// - PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, - - /// - /// 16 bpp (4 bit alpha) - /// - PIXELFORMAT_UNCOMPRESSED_R4G4B4A4, - - /// - /// 32 bpp - /// - PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, - - /// - /// 32 bpp (1 channel - float) - /// - PIXELFORMAT_UNCOMPRESSED_R32, - - /// - /// 32*3 bpp (3 channels - float) - /// - PIXELFORMAT_UNCOMPRESSED_R32G32B32, - - /// - /// 32*4 bpp (4 channels - float) - /// - PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, - - /// - /// 4 bpp (no alpha) - /// - PIXELFORMAT_COMPRESSED_DXT1_RGB, - - /// - /// 4 bpp (1 bit alpha) - /// - PIXELFORMAT_COMPRESSED_DXT1_RGBA, - - /// - /// 8 bpp - /// - PIXELFORMAT_COMPRESSED_DXT3_RGBA, - - /// - /// 8 bpp - /// - PIXELFORMAT_COMPRESSED_DXT5_RGBA, - - /// - /// 4 bpp - /// - PIXELFORMAT_COMPRESSED_ETC1_RGB, - - /// - /// 4 bpp - /// - PIXELFORMAT_COMPRESSED_ETC2_RGB, - - /// - /// 8 bpp - /// - PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA, - - /// - /// 4 bpp - /// - PIXELFORMAT_COMPRESSED_PVRT_RGB, - - /// - /// 4 bpp - /// - PIXELFORMAT_COMPRESSED_PVRT_RGBA, - - /// - /// 8 bpp - /// - PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, - - /// - /// 2 bpp - /// - PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA - } + PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, /// - /// Image, pixel data stored in CPU memory (RAM) + /// 8*2 bpp (2 channels) /// - [StructLayout(LayoutKind.Sequential)] - public unsafe partial struct Image - { - /// - /// Image raw data - /// - public void* Data; + PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, - /// - /// Image base width - /// - public int Width; + /// + /// 16 bpp + /// + PIXELFORMAT_UNCOMPRESSED_R5G6B5, - /// - /// Image base height - /// - public int Height; + /// + /// 24 bpp + /// + PIXELFORMAT_UNCOMPRESSED_R8G8B8, - /// - /// Mipmap levels, 1 by default - /// - public int Mipmaps; + /// + /// 16 bpp (1 bit alpha) + /// + PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, - /// - /// Data format (PixelFormat type) - /// - public PixelFormat Format; - } + /// + /// 16 bpp (4 bit alpha) + /// + PIXELFORMAT_UNCOMPRESSED_R4G4B4A4, + + /// + /// 32 bpp + /// + PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, + + /// + /// 32 bpp (1 channel - float) + /// + PIXELFORMAT_UNCOMPRESSED_R32, + + /// + /// 32*3 bpp (3 channels - float) + /// + PIXELFORMAT_UNCOMPRESSED_R32G32B32, + + /// + /// 32*4 bpp (4 channels - float) + /// + PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, + + /// + /// 4 bpp (no alpha) + /// + PIXELFORMAT_COMPRESSED_DXT1_RGB, + + /// + /// 4 bpp (1 bit alpha) + /// + PIXELFORMAT_COMPRESSED_DXT1_RGBA, + + /// + /// 8 bpp + /// + PIXELFORMAT_COMPRESSED_DXT3_RGBA, + + /// + /// 8 bpp + /// + PIXELFORMAT_COMPRESSED_DXT5_RGBA, + + /// + /// 4 bpp + /// + PIXELFORMAT_COMPRESSED_ETC1_RGB, + + /// + /// 4 bpp + /// + PIXELFORMAT_COMPRESSED_ETC2_RGB, + + /// + /// 8 bpp + /// + PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA, + + /// + /// 4 bpp + /// + PIXELFORMAT_COMPRESSED_PVRT_RGB, + + /// + /// 4 bpp + /// + PIXELFORMAT_COMPRESSED_PVRT_RGBA, + + /// + /// 8 bpp + /// + PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, + + /// + /// 2 bpp + /// + PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA +} + +/// +/// Image, pixel data stored in CPU memory (RAM) +/// +[StructLayout(LayoutKind.Sequential)] +public unsafe partial struct Image +{ + /// + /// Image raw data + /// + public void* Data; + + /// + /// Image base width + /// + public int Width; + + /// + /// Image base height + /// + public int Height; + + /// + /// Mipmap levels, 1 by default + /// + public int Mipmaps; + + /// + /// Data format (PixelFormat type) + /// + public PixelFormat Format; } diff --git a/Raylib-cs/types/Input.cs b/Raylib-cs/types/Input.cs index cf56730..460d6f3 100644 --- a/Raylib-cs/types/Input.cs +++ b/Raylib-cs/types/Input.cs @@ -2,504 +2,503 @@ using System; using System.Numerics; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Keyboard keys (US keyboard layout)
+/// NOTE: Use GetKeyPressed() to allow redefining required keys for alternative layouts +///
+public enum KeyboardKey { /// - /// Keyboard keys (US keyboard layout)
- /// NOTE: Use GetKeyPressed() to allow redefining required keys for alternative layouts + /// NULL, used for no key pressed ///
- public enum KeyboardKey - { - /// - /// NULL, used for no key pressed - /// - KEY_NULL = 0, - - // Alphanumeric keys - KEY_APOSTROPHE = 39, - KEY_COMMA = 44, - KEY_MINUS = 45, - KEY_PERIOD = 46, - KEY_SLASH = 47, - KEY_ZERO = 48, - KEY_ONE = 49, - KEY_TWO = 50, - KEY_THREE = 51, - KEY_FOUR = 52, - KEY_FIVE = 53, - KEY_SIX = 54, - KEY_SEVEN = 55, - KEY_EIGHT = 56, - KEY_NINE = 57, - KEY_SEMICOLON = 59, - KEY_EQUAL = 61, - KEY_A = 65, - KEY_B = 66, - KEY_C = 67, - KEY_D = 68, - KEY_E = 69, - KEY_F = 70, - KEY_G = 71, - KEY_H = 72, - KEY_I = 73, - KEY_J = 74, - KEY_K = 75, - KEY_L = 76, - KEY_M = 77, - KEY_N = 78, - KEY_O = 79, - KEY_P = 80, - KEY_Q = 81, - KEY_R = 82, - KEY_S = 83, - KEY_T = 84, - KEY_U = 85, - KEY_V = 86, - KEY_W = 87, - KEY_X = 88, - KEY_Y = 89, - KEY_Z = 90, - - // Function keys - KEY_SPACE = 32, - KEY_ESCAPE = 256, - KEY_ENTER = 257, - KEY_TAB = 258, - KEY_BACKSPACE = 259, - KEY_INSERT = 260, - KEY_DELETE = 261, - KEY_RIGHT = 262, - KEY_LEFT = 263, - KEY_DOWN = 264, - KEY_UP = 265, - KEY_PAGE_UP = 266, - KEY_PAGE_DOWN = 267, - KEY_HOME = 268, - KEY_END = 269, - KEY_CAPS_LOCK = 280, - KEY_SCROLL_LOCK = 281, - KEY_NUM_LOCK = 282, - KEY_PRINT_SCREEN = 283, - KEY_PAUSE = 284, - KEY_F1 = 290, - KEY_F2 = 291, - KEY_F3 = 292, - KEY_F4 = 293, - KEY_F5 = 294, - KEY_F6 = 295, - KEY_F7 = 296, - KEY_F8 = 297, - KEY_F9 = 298, - KEY_F10 = 299, - KEY_F11 = 300, - KEY_F12 = 301, - KEY_LEFT_SHIFT = 340, - KEY_LEFT_CONTROL = 341, - KEY_LEFT_ALT = 342, - KEY_LEFT_SUPER = 343, - KEY_RIGHT_SHIFT = 344, - KEY_RIGHT_CONTROL = 345, - KEY_RIGHT_ALT = 346, - KEY_RIGHT_SUPER = 347, - KEY_KB_MENU = 348, - KEY_LEFT_BRACKET = 91, - KEY_BACKSLASH = 92, - KEY_RIGHT_BRACKET = 93, - KEY_GRAVE = 96, - - // Keypad keys - KEY_KP_0 = 320, - KEY_KP_1 = 321, - KEY_KP_2 = 322, - KEY_KP_3 = 323, - KEY_KP_4 = 324, - KEY_KP_5 = 325, - KEY_KP_6 = 326, - KEY_KP_7 = 327, - KEY_KP_8 = 328, - KEY_KP_9 = 329, - KEY_KP_DECIMAL = 330, - KEY_KP_DIVIDE = 331, - KEY_KP_MULTIPLY = 332, - KEY_KP_SUBTRACT = 333, - KEY_KP_ADD = 334, - KEY_KP_ENTER = 335, - KEY_KP_EQUAL = 336, - - // Android key buttons - KEY_BACK = 4, - KEY_MENU = 82, - KEY_VOLUME_UP = 24, - KEY_VOLUME_DOWN = 25 - } - - /// - /// Mouse buttons - /// - public enum MouseButton - { - /// - /// Mouse button left - /// - MOUSE_BUTTON_LEFT = 0, - - /// - /// Mouse button right - /// - MOUSE_BUTTON_RIGHT = 1, - - /// - /// Mouse button middle (pressed wheel) - /// - MOUSE_BUTTON_MIDDLE = 2, - - /// - /// Mouse button side (advanced mouse device) - /// - MOUSE_BUTTON_SIDE = 3, - - /// - /// Mouse button extra (advanced mouse device) - /// - MOUSE_BUTTON_EXTRA = 4, - - /// - /// Mouse button forward (advanced mouse device) - /// - MOUSE_BUTTON_FORWARD = 5, - - /// - /// Mouse button back (advanced mouse device) - /// - MOUSE_BUTTON_BACK = 6, - - MOUSE_LEFT_BUTTON = MOUSE_BUTTON_LEFT, - MOUSE_RIGHT_BUTTON = MOUSE_BUTTON_RIGHT, - MOUSE_MIDDLE_BUTTON = MOUSE_BUTTON_MIDDLE, - } - - /// - /// Mouse cursor - /// - public enum MouseCursor - { - /// - /// Default pointer shape - /// - MOUSE_CURSOR_DEFAULT = 0, - - /// - /// Arrow shape - /// - MOUSE_CURSOR_ARROW = 1, - - /// - /// Text writing cursor shape - /// - MOUSE_CURSOR_IBEAM = 2, - - /// - /// Cross shape - /// - MOUSE_CURSOR_CROSSHAIR = 3, - - /// - /// Pointing hand cursor - /// - MOUSE_CURSOR_POINTING_HAND = 4, - - /// - /// Horizontal resize/move arrow shape - /// - MOUSE_CURSOR_RESIZE_EW = 5, - - /// - /// Vertical resize/move arrow shape - /// - MOUSE_CURSOR_RESIZE_NS = 6, - - /// - /// Top-left to bottom-right diagonal resize/move arrow shape - /// - MOUSE_CURSOR_RESIZE_NWSE = 7, - - /// - /// The top-right to bottom-left diagonal resize/move arrow shape - /// - MOUSE_CURSOR_RESIZE_NESW = 8, - - /// - /// The omnidirectional resize/move cursor shape - /// - MOUSE_CURSOR_RESIZE_ALL = 9, - - /// - /// The operation-not-allowed shape - /// - MOUSE_CURSOR_NOT_ALLOWED = 10 - } - - /// Gamepad axis - public enum GamepadAxis - { - /// - /// Gamepad left stick X axis - /// - GAMEPAD_AXIS_LEFT_X = 0, - - /// - /// Gamepad left stick Y axis - /// - GAMEPAD_AXIS_LEFT_Y = 1, - - /// - /// Gamepad right stick X axis - /// - GAMEPAD_AXIS_RIGHT_X = 2, - - /// - /// Gamepad right stick Y axis - /// - GAMEPAD_AXIS_RIGHT_Y = 3, - - /// - /// Gamepad back trigger left, pressure level: [1..-1] - /// - GAMEPAD_AXIS_LEFT_TRIGGER = 4, - - /// - /// Gamepad back trigger right, pressure level: [1..-1] - /// - GAMEPAD_AXIS_RIGHT_TRIGGER = 5 - } - - /// - /// Gamepad buttons - /// - public enum GamepadButton - { - /// - /// Unknown button, just for error checking - /// - GAMEPAD_BUTTON_UNKNOWN = 0, - - /// - /// Gamepad left DPAD up button - /// - GAMEPAD_BUTTON_LEFT_FACE_UP, - - /// - /// Gamepad left DPAD right button - /// - GAMEPAD_BUTTON_LEFT_FACE_RIGHT, - - /// - /// Gamepad left DPAD down button - /// - GAMEPAD_BUTTON_LEFT_FACE_DOWN, - - /// - /// Gamepad left DPAD left button - /// - GAMEPAD_BUTTON_LEFT_FACE_LEFT, - - /// - /// Gamepad right button up (i.e. PS3: Triangle, Xbox: Y) - /// - GAMEPAD_BUTTON_RIGHT_FACE_UP, - - /// - /// Gamepad right button right (i.e. PS3: Square, Xbox: X) - /// - GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, - - /// - /// Gamepad right button down (i.e. PS3: Cross, Xbox: A) - /// - GAMEPAD_BUTTON_RIGHT_FACE_DOWN, - - /// - /// Gamepad right button left (i.e. PS3: Circle, Xbox: B) - /// - GAMEPAD_BUTTON_RIGHT_FACE_LEFT, - - /// - /// Gamepad top/back trigger left (first), it could be a trailing button - /// - GAMEPAD_BUTTON_LEFT_TRIGGER_1, - - /// - /// Gamepad top/back trigger left (second), it could be a trailing button - /// - GAMEPAD_BUTTON_LEFT_TRIGGER_2, - - /// - /// Gamepad top/back trigger right (first), it could be a trailing button - /// - GAMEPAD_BUTTON_RIGHT_TRIGGER_1, - - /// - /// Gamepad top/back trigger right (second), it could be a trailing button - /// - GAMEPAD_BUTTON_RIGHT_TRIGGER_2, - - /// - /// Gamepad center buttons, left one (i.e. PS3: Select) - /// - GAMEPAD_BUTTON_MIDDLE_LEFT, - - /// - /// Gamepad center buttons, middle one (i.e. PS3: PS, Xbox: XBOX) - /// - GAMEPAD_BUTTON_MIDDLE, - - /// - /// Gamepad center buttons, right one (i.e. PS3: Start) - /// - GAMEPAD_BUTTON_MIDDLE_RIGHT, - - /// - /// Gamepad joystick pressed button left - /// - GAMEPAD_BUTTON_LEFT_THUMB, - - /// - /// Gamepad joystick pressed button right - /// - GAMEPAD_BUTTON_RIGHT_THUMB - } - - /// - /// Gesture - /// NOTE: It could be used as flags to enable only some gestures - /// - [Flags] - public enum Gesture : uint - { - GESTURE_NONE = 0, - GESTURE_TAP = 1, - GESTURE_DOUBLETAP = 2, - GESTURE_HOLD = 4, - GESTURE_DRAG = 8, - GESTURE_SWIPE_RIGHT = 16, - GESTURE_SWIPE_LEFT = 32, - GESTURE_SWIPE_UP = 64, - GESTURE_SWIPE_DOWN = 128, - GESTURE_PINCH_IN = 256, - GESTURE_PINCH_OUT = 512 - } - - /// - /// Head-Mounted-Display device parameters - /// - [StructLayout(LayoutKind.Sequential)] - public unsafe partial struct VrDeviceInfo - { - /// - /// HMD horizontal resolution in pixels - /// - public int HResolution; - - /// - /// HMD vertical resolution in pixels - /// - public int VResolution; - - /// - /// HMD horizontal size in meters - /// - public float HScreenSize; - - /// - /// HMD vertical size in meters - /// - public float VScreenSize; - - /// - /// HMD screen center in meters - /// - public float VScreenCenter; - - /// - /// HMD distance between eye and display in meters - /// - public float EyeToScreenDistance; - - /// - /// HMD lens separation distance in meters - /// - public float LensSeparationDistance; - - /// - /// HMD IPD (distance between pupils) in meters - /// - public float InterpupillaryDistance; - - /// - /// HMD lens distortion constant parameters - /// - public fixed float LensDistortionValues[4]; - - /// - /// HMD chromatic aberration correction parameters - /// - public fixed float ChromaAbCorrection[4]; - } - - /// - /// VR Stereo rendering configuration for simulator - /// - [StructLayout(LayoutKind.Sequential)] - public partial struct VrStereoConfig - { - /// - /// VR projection matrices (per eye) - /// - public Matrix4x4 Projection1; - - /// - /// VR projection matrices (per eye) - /// - public Matrix4x4 Projection2; - - /// - /// VR view offset matrices (per eye) - /// - public Matrix4x4 ViewOffset1; - - /// - /// VR view offset matrices (per eye) - /// - public Matrix4x4 ViewOffset2; - - /// - /// VR left lens center - /// - public Vector2 LeftLensCenter; - - /// - /// VR right lens center - /// - public Vector2 RightLensCenter; - - /// - /// VR left screen center - /// - public Vector2 LeftScreenCenter; - - /// - /// VR right screen center - /// - public Vector2 RightScreenCenter; - - /// - /// VR distortion scale - /// - public Vector2 Scale; - - /// - /// VR distortion scale in - /// - public Vector2 ScaleIn; - } + KEY_NULL = 0, + + // Alphanumeric keys + KEY_APOSTROPHE = 39, + KEY_COMMA = 44, + KEY_MINUS = 45, + KEY_PERIOD = 46, + KEY_SLASH = 47, + KEY_ZERO = 48, + KEY_ONE = 49, + KEY_TWO = 50, + KEY_THREE = 51, + KEY_FOUR = 52, + KEY_FIVE = 53, + KEY_SIX = 54, + KEY_SEVEN = 55, + KEY_EIGHT = 56, + KEY_NINE = 57, + KEY_SEMICOLON = 59, + KEY_EQUAL = 61, + KEY_A = 65, + KEY_B = 66, + KEY_C = 67, + KEY_D = 68, + KEY_E = 69, + KEY_F = 70, + KEY_G = 71, + KEY_H = 72, + KEY_I = 73, + KEY_J = 74, + KEY_K = 75, + KEY_L = 76, + KEY_M = 77, + KEY_N = 78, + KEY_O = 79, + KEY_P = 80, + KEY_Q = 81, + KEY_R = 82, + KEY_S = 83, + KEY_T = 84, + KEY_U = 85, + KEY_V = 86, + KEY_W = 87, + KEY_X = 88, + KEY_Y = 89, + KEY_Z = 90, + + // Function keys + KEY_SPACE = 32, + KEY_ESCAPE = 256, + KEY_ENTER = 257, + KEY_TAB = 258, + KEY_BACKSPACE = 259, + KEY_INSERT = 260, + KEY_DELETE = 261, + KEY_RIGHT = 262, + KEY_LEFT = 263, + KEY_DOWN = 264, + KEY_UP = 265, + KEY_PAGE_UP = 266, + KEY_PAGE_DOWN = 267, + KEY_HOME = 268, + KEY_END = 269, + KEY_CAPS_LOCK = 280, + KEY_SCROLL_LOCK = 281, + KEY_NUM_LOCK = 282, + KEY_PRINT_SCREEN = 283, + KEY_PAUSE = 284, + KEY_F1 = 290, + KEY_F2 = 291, + KEY_F3 = 292, + KEY_F4 = 293, + KEY_F5 = 294, + KEY_F6 = 295, + KEY_F7 = 296, + KEY_F8 = 297, + KEY_F9 = 298, + KEY_F10 = 299, + KEY_F11 = 300, + KEY_F12 = 301, + KEY_LEFT_SHIFT = 340, + KEY_LEFT_CONTROL = 341, + KEY_LEFT_ALT = 342, + KEY_LEFT_SUPER = 343, + KEY_RIGHT_SHIFT = 344, + KEY_RIGHT_CONTROL = 345, + KEY_RIGHT_ALT = 346, + KEY_RIGHT_SUPER = 347, + KEY_KB_MENU = 348, + KEY_LEFT_BRACKET = 91, + KEY_BACKSLASH = 92, + KEY_RIGHT_BRACKET = 93, + KEY_GRAVE = 96, + + // Keypad keys + KEY_KP_0 = 320, + KEY_KP_1 = 321, + KEY_KP_2 = 322, + KEY_KP_3 = 323, + KEY_KP_4 = 324, + KEY_KP_5 = 325, + KEY_KP_6 = 326, + KEY_KP_7 = 327, + KEY_KP_8 = 328, + KEY_KP_9 = 329, + KEY_KP_DECIMAL = 330, + KEY_KP_DIVIDE = 331, + KEY_KP_MULTIPLY = 332, + KEY_KP_SUBTRACT = 333, + KEY_KP_ADD = 334, + KEY_KP_ENTER = 335, + KEY_KP_EQUAL = 336, + + // Android key buttons + KEY_BACK = 4, + KEY_MENU = 82, + KEY_VOLUME_UP = 24, + KEY_VOLUME_DOWN = 25 +} + +/// +/// Mouse buttons +/// +public enum MouseButton +{ + /// + /// Mouse button left + /// + MOUSE_BUTTON_LEFT = 0, + + /// + /// Mouse button right + /// + MOUSE_BUTTON_RIGHT = 1, + + /// + /// Mouse button middle (pressed wheel) + /// + MOUSE_BUTTON_MIDDLE = 2, + + /// + /// Mouse button side (advanced mouse device) + /// + MOUSE_BUTTON_SIDE = 3, + + /// + /// Mouse button extra (advanced mouse device) + /// + MOUSE_BUTTON_EXTRA = 4, + + /// + /// Mouse button forward (advanced mouse device) + /// + MOUSE_BUTTON_FORWARD = 5, + + /// + /// Mouse button back (advanced mouse device) + /// + MOUSE_BUTTON_BACK = 6, + + MOUSE_LEFT_BUTTON = MOUSE_BUTTON_LEFT, + MOUSE_RIGHT_BUTTON = MOUSE_BUTTON_RIGHT, + MOUSE_MIDDLE_BUTTON = MOUSE_BUTTON_MIDDLE, +} + +/// +/// Mouse cursor +/// +public enum MouseCursor +{ + /// + /// Default pointer shape + /// + MOUSE_CURSOR_DEFAULT = 0, + + /// + /// Arrow shape + /// + MOUSE_CURSOR_ARROW = 1, + + /// + /// Text writing cursor shape + /// + MOUSE_CURSOR_IBEAM = 2, + + /// + /// Cross shape + /// + MOUSE_CURSOR_CROSSHAIR = 3, + + /// + /// Pointing hand cursor + /// + MOUSE_CURSOR_POINTING_HAND = 4, + + /// + /// Horizontal resize/move arrow shape + /// + MOUSE_CURSOR_RESIZE_EW = 5, + + /// + /// Vertical resize/move arrow shape + /// + MOUSE_CURSOR_RESIZE_NS = 6, + + /// + /// Top-left to bottom-right diagonal resize/move arrow shape + /// + MOUSE_CURSOR_RESIZE_NWSE = 7, + + /// + /// The top-right to bottom-left diagonal resize/move arrow shape + /// + MOUSE_CURSOR_RESIZE_NESW = 8, + + /// + /// The omnidirectional resize/move cursor shape + /// + MOUSE_CURSOR_RESIZE_ALL = 9, + + /// + /// The operation-not-allowed shape + /// + MOUSE_CURSOR_NOT_ALLOWED = 10 +} + +/// Gamepad axis +public enum GamepadAxis +{ + /// + /// Gamepad left stick X axis + /// + GAMEPAD_AXIS_LEFT_X = 0, + + /// + /// Gamepad left stick Y axis + /// + GAMEPAD_AXIS_LEFT_Y = 1, + + /// + /// Gamepad right stick X axis + /// + GAMEPAD_AXIS_RIGHT_X = 2, + + /// + /// Gamepad right stick Y axis + /// + GAMEPAD_AXIS_RIGHT_Y = 3, + + /// + /// Gamepad back trigger left, pressure level: [1..-1] + /// + GAMEPAD_AXIS_LEFT_TRIGGER = 4, + + /// + /// Gamepad back trigger right, pressure level: [1..-1] + /// + GAMEPAD_AXIS_RIGHT_TRIGGER = 5 +} + +/// +/// Gamepad buttons +/// +public enum GamepadButton +{ + /// + /// Unknown button, just for error checking + /// + GAMEPAD_BUTTON_UNKNOWN = 0, + + /// + /// Gamepad left DPAD up button + /// + GAMEPAD_BUTTON_LEFT_FACE_UP, + + /// + /// Gamepad left DPAD right button + /// + GAMEPAD_BUTTON_LEFT_FACE_RIGHT, + + /// + /// Gamepad left DPAD down button + /// + GAMEPAD_BUTTON_LEFT_FACE_DOWN, + + /// + /// Gamepad left DPAD left button + /// + GAMEPAD_BUTTON_LEFT_FACE_LEFT, + + /// + /// Gamepad right button up (i.e. PS3: Triangle, Xbox: Y) + /// + GAMEPAD_BUTTON_RIGHT_FACE_UP, + + /// + /// Gamepad right button right (i.e. PS3: Square, Xbox: X) + /// + GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, + + /// + /// Gamepad right button down (i.e. PS3: Cross, Xbox: A) + /// + GAMEPAD_BUTTON_RIGHT_FACE_DOWN, + + /// + /// Gamepad right button left (i.e. PS3: Circle, Xbox: B) + /// + GAMEPAD_BUTTON_RIGHT_FACE_LEFT, + + /// + /// Gamepad top/back trigger left (first), it could be a trailing button + /// + GAMEPAD_BUTTON_LEFT_TRIGGER_1, + + /// + /// Gamepad top/back trigger left (second), it could be a trailing button + /// + GAMEPAD_BUTTON_LEFT_TRIGGER_2, + + /// + /// Gamepad top/back trigger right (first), it could be a trailing button + /// + GAMEPAD_BUTTON_RIGHT_TRIGGER_1, + + /// + /// Gamepad top/back trigger right (second), it could be a trailing button + /// + GAMEPAD_BUTTON_RIGHT_TRIGGER_2, + + /// + /// Gamepad center buttons, left one (i.e. PS3: Select) + /// + GAMEPAD_BUTTON_MIDDLE_LEFT, + + /// + /// Gamepad center buttons, middle one (i.e. PS3: PS, Xbox: XBOX) + /// + GAMEPAD_BUTTON_MIDDLE, + + /// + /// Gamepad center buttons, right one (i.e. PS3: Start) + /// + GAMEPAD_BUTTON_MIDDLE_RIGHT, + + /// + /// Gamepad joystick pressed button left + /// + GAMEPAD_BUTTON_LEFT_THUMB, + + /// + /// Gamepad joystick pressed button right + /// + GAMEPAD_BUTTON_RIGHT_THUMB +} + +/// +/// Gesture +/// NOTE: It could be used as flags to enable only some gestures +/// +[Flags] +public enum Gesture : uint +{ + GESTURE_NONE = 0, + GESTURE_TAP = 1, + GESTURE_DOUBLETAP = 2, + GESTURE_HOLD = 4, + GESTURE_DRAG = 8, + GESTURE_SWIPE_RIGHT = 16, + GESTURE_SWIPE_LEFT = 32, + GESTURE_SWIPE_UP = 64, + GESTURE_SWIPE_DOWN = 128, + GESTURE_PINCH_IN = 256, + GESTURE_PINCH_OUT = 512 +} + +/// +/// Head-Mounted-Display device parameters +/// +[StructLayout(LayoutKind.Sequential)] +public unsafe partial struct VrDeviceInfo +{ + /// + /// HMD horizontal resolution in pixels + /// + public int HResolution; + + /// + /// HMD vertical resolution in pixels + /// + public int VResolution; + + /// + /// HMD horizontal size in meters + /// + public float HScreenSize; + + /// + /// HMD vertical size in meters + /// + public float VScreenSize; + + /// + /// HMD screen center in meters + /// + public float VScreenCenter; + + /// + /// HMD distance between eye and display in meters + /// + public float EyeToScreenDistance; + + /// + /// HMD lens separation distance in meters + /// + public float LensSeparationDistance; + + /// + /// HMD IPD (distance between pupils) in meters + /// + public float InterpupillaryDistance; + + /// + /// HMD lens distortion constant parameters + /// + public fixed float LensDistortionValues[4]; + + /// + /// HMD chromatic aberration correction parameters + /// + public fixed float ChromaAbCorrection[4]; +} + +/// +/// VR Stereo rendering configuration for simulator +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct VrStereoConfig +{ + /// + /// VR projection matrices (per eye) + /// + public Matrix4x4 Projection1; + + /// + /// VR projection matrices (per eye) + /// + public Matrix4x4 Projection2; + + /// + /// VR view offset matrices (per eye) + /// + public Matrix4x4 ViewOffset1; + + /// + /// VR view offset matrices (per eye) + /// + public Matrix4x4 ViewOffset2; + + /// + /// VR left lens center + /// + public Vector2 LeftLensCenter; + + /// + /// VR right lens center + /// + public Vector2 RightLensCenter; + + /// + /// VR left screen center + /// + public Vector2 LeftScreenCenter; + + /// + /// VR right screen center + /// + public Vector2 RightScreenCenter; + + /// + /// VR distortion scale + /// + public Vector2 Scale; + + /// + /// VR distortion scale in + /// + public Vector2 ScaleIn; } diff --git a/Raylib-cs/types/Logging.cs b/Raylib-cs/types/Logging.cs index a301252..2e1789f 100644 --- a/Raylib-cs/types/Logging.cs +++ b/Raylib-cs/types/Logging.cs @@ -4,161 +4,160 @@ using System; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +internal readonly struct Native { - internal readonly 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); + + [DllImport(Libc, EntryPoint = "vsprintf", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); + + [DllImport(Libc, EntryPoint = "vsnprintf", CallingConvention = CallingConvention.Cdecl)] + public static extern 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); +} + +[StructLayout(LayoutKind.Sequential, Pack = 4)] +struct VaListLinuxX64 +{ + uint _gpOffset; + uint _fpOffset; + IntPtr _overflowArgArea; + IntPtr _regSaveArea; +} + +/// +/// Logging workaround for formatting strings from native code +/// +public static unsafe class Logging +{ + [UnmanagedCallersOnly(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + public static unsafe void LogConsole(int msgType, sbyte* text, sbyte* args) { - 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); - - [DllImport(Libc, EntryPoint = "vsprintf", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); - - [DllImport(Libc, EntryPoint = "vsnprintf", CallingConvention = CallingConvention.Cdecl)] - public static extern 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); + var message = GetLogMessage(new IntPtr(text), new IntPtr(args)); + Console.WriteLine(message); } - [StructLayout(LayoutKind.Sequential, Pack = 4)] - struct VaListLinuxX64 + public static string GetLogMessage(IntPtr format, IntPtr args) { - uint _gpOffset; - uint _fpOffset; - IntPtr _overflowArgArea; - IntPtr _regSaveArea; - } - - /// - /// Logging workaround for formatting strings from native code - /// - public static unsafe class Logging - { - [UnmanagedCallersOnly(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] - public static unsafe void LogConsole(int msgType, sbyte* text, sbyte* args) + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - var message = GetLogMessage(new IntPtr(text), new IntPtr(args)); - Console.WriteLine(message); + return AppleLogCallback(format, args); } - public static string GetLogMessage(IntPtr format, IntPtr args) + // Special marshalling is needed on Linux desktop 64 bits. + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && IntPtr.Size == 8) { - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - return AppleLogCallback(format, args); - } + return LinuxX64LogCallback(format, args); + } - // Special marshalling is needed on Linux desktop 64 bits. - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && IntPtr.Size == 8) - { - return LinuxX64LogCallback(format, args); - } + var byteLength = VsnPrintf(IntPtr.Zero, UIntPtr.Zero, format, args) + 1; + if (byteLength <= 1) + { + return string.Empty; + } - var byteLength = VsnPrintf(IntPtr.Zero, UIntPtr.Zero, format, args) + 1; - if (byteLength <= 1) + var buffer = Marshal.AllocHGlobal(byteLength); + VsPrintf(buffer, format, args); + + string result = Marshal.PtrToStringUTF8(buffer); + Marshal.FreeHGlobal(buffer); + + return result; + } + + static string AppleLogCallback(IntPtr format, IntPtr args) + { + IntPtr buffer = IntPtr.Zero; + try + { + var count = Native.VasPrintfApple(ref buffer, format, args); + if (count == -1) { return string.Empty; } - - var buffer = Marshal.AllocHGlobal(byteLength); - VsPrintf(buffer, format, args); - - string result = Marshal.PtrToStringUTF8(buffer); + return Marshal.PtrToStringUTF8(buffer) ?? string.Empty; + } + finally + { Marshal.FreeHGlobal(buffer); - - return result; - } - - static string AppleLogCallback(IntPtr format, IntPtr args) - { - IntPtr buffer = IntPtr.Zero; - try - { - var count = Native.VasPrintfApple(ref buffer, format, args); - if (count == -1) - { - return string.Empty; - } - return Marshal.PtrToStringUTF8(buffer) ?? string.Empty; - } - finally - { - Marshal.FreeHGlobal(buffer); - } - } - - static string LinuxX64LogCallback(IntPtr format, IntPtr args) - { - // The args pointer cannot be reused between two calls. We need to make a copy of the underlying structure. - var listStructure = Marshal.PtrToStructure(args); - IntPtr listPointer = IntPtr.Zero; - int byteLength = 0; - string result = ""; - - // Get length of args - listPointer = Marshal.AllocHGlobal(Marshal.SizeOf(listStructure)); - Marshal.StructureToPtr(listStructure, listPointer, false); - byteLength = Native.VsnPrintfLinux(IntPtr.Zero, UIntPtr.Zero, format, listPointer) + 1; - - // Allocate buffer for result - Marshal.StructureToPtr(listStructure, listPointer, false); - - IntPtr utf8Buffer = IntPtr.Zero; - utf8Buffer = Marshal.AllocHGlobal(byteLength); - - // Print result into buffer - Native.VsPrintfLinux(utf8Buffer, format, listPointer); - result = Marshal.PtrToStringUTF8(utf8Buffer); - - Marshal.FreeHGlobal(listPointer); - Marshal.FreeHGlobal(utf8Buffer); - - return result; - } - - // https://github.com/dotnet/runtime/issues/51052 - static int VsnPrintf(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args) - { - var os = Environment.OSVersion; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return Native.VsnPrintfWindows(buffer, size, format, args); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - return Native.VsnPrintfLinux(buffer, size, format, args); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID"))) - { - return Native.VsPrintfLinux(buffer, format, args); - } - return -1; - } - - // https://github.com/dotnet/runtime/issues/51052 - static int VsPrintf(IntPtr buffer, IntPtr format, IntPtr args) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return Native.VsPrintfWindows(buffer, format, args); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - return Native.VsPrintfLinux(buffer, format, args); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID"))) - { - return Native.VsPrintfLinux(buffer, format, args); - } - return -1; } } + + static string LinuxX64LogCallback(IntPtr format, IntPtr args) + { + // The args pointer cannot be reused between two calls. We need to make a copy of the underlying structure. + var listStructure = Marshal.PtrToStructure(args); + IntPtr listPointer = IntPtr.Zero; + int byteLength = 0; + string result = ""; + + // Get length of args + listPointer = Marshal.AllocHGlobal(Marshal.SizeOf(listStructure)); + Marshal.StructureToPtr(listStructure, listPointer, false); + byteLength = Native.VsnPrintfLinux(IntPtr.Zero, UIntPtr.Zero, format, listPointer) + 1; + + // Allocate buffer for result + Marshal.StructureToPtr(listStructure, listPointer, false); + + IntPtr utf8Buffer = IntPtr.Zero; + utf8Buffer = Marshal.AllocHGlobal(byteLength); + + // Print result into buffer + Native.VsPrintfLinux(utf8Buffer, format, listPointer); + result = Marshal.PtrToStringUTF8(utf8Buffer); + + Marshal.FreeHGlobal(listPointer); + Marshal.FreeHGlobal(utf8Buffer); + + return result; + } + + // https://github.com/dotnet/runtime/issues/51052 + static int VsnPrintf(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args) + { + var os = Environment.OSVersion; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return Native.VsnPrintfWindows(buffer, size, format, args); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + return Native.VsnPrintfLinux(buffer, size, format, args); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID"))) + { + return Native.VsPrintfLinux(buffer, format, args); + } + return -1; + } + + // https://github.com/dotnet/runtime/issues/51052 + static int VsPrintf(IntPtr buffer, IntPtr format, IntPtr args) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return Native.VsPrintfWindows(buffer, format, args); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + return Native.VsPrintfLinux(buffer, format, args); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID"))) + { + return Native.VsPrintfLinux(buffer, format, args); + } + return -1; + } } diff --git a/Raylib-cs/types/Material.cs b/Raylib-cs/types/Material.cs index d5b3d22..3ee4c5e 100644 --- a/Raylib-cs/types/Material.cs +++ b/Raylib-cs/types/Material.cs @@ -1,91 +1,90 @@ using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Material map index +/// +public enum MaterialMapIndex { /// - /// Material map index + /// NOTE: Same as MATERIAL_MAP_DIFFUSE /// - public enum MaterialMapIndex - { - /// - /// NOTE: Same as MATERIAL_MAP_DIFFUSE - /// - MATERIAL_MAP_ALBEDO = 0, - - /// - /// NOTE: Same as MATERIAL_MAP_SPECULAR - /// - MATERIAL_MAP_METALNESS, - - MATERIAL_MAP_NORMAL, - MATERIAL_MAP_ROUGHNESS, - MATERIAL_MAP_OCCLUSION, - MATERIAL_MAP_EMISSION, - MATERIAL_MAP_HEIGHT, - - /// - /// NOTE: Uses GL_TEXTURE_CUBE_MAP - /// - MATERIAL_MAP_CUBEMAP, - - /// - /// NOTE: Uses GL_TEXTURE_CUBE_MAP - /// - MATERIAL_MAP_IRRADIANCE, - - /// - /// NOTE: Uses GL_TEXTURE_CUBE_MAP - /// - MATERIAL_MAP_PREFILTER, - - MATERIAL_MAP_BRDF, - - MATERIAL_MAP_DIFFUSE = MATERIAL_MAP_ALBEDO, - MATERIAL_MAP_SPECULAR = MATERIAL_MAP_METALNESS, - } + MATERIAL_MAP_ALBEDO = 0, /// - /// Material texture map + /// NOTE: Same as MATERIAL_MAP_SPECULAR /// - [StructLayout(LayoutKind.Sequential)] - public partial struct MaterialMap - { - /// - /// Material map texture - /// - public Texture2D Texture; + MATERIAL_MAP_METALNESS, - /// - /// Material map color - /// - public Color Color; - - /// - /// Material map value - /// - public float Value; - } + MATERIAL_MAP_NORMAL, + MATERIAL_MAP_ROUGHNESS, + MATERIAL_MAP_OCCLUSION, + MATERIAL_MAP_EMISSION, + MATERIAL_MAP_HEIGHT, /// - /// Material type (generic) + /// NOTE: Uses GL_TEXTURE_CUBE_MAP /// - [StructLayout(LayoutKind.Sequential)] - public unsafe partial struct Material - { - /// - /// Material shader - /// - public Shader Shader; + MATERIAL_MAP_CUBEMAP, - //TODO: convert - /// - /// Material maps - /// - public MaterialMap* Maps; + /// + /// NOTE: Uses GL_TEXTURE_CUBE_MAP + /// + MATERIAL_MAP_IRRADIANCE, - /// - /// Material generic parameters (if required) - /// - public fixed float Param[4]; - } + /// + /// NOTE: Uses GL_TEXTURE_CUBE_MAP + /// + MATERIAL_MAP_PREFILTER, + + MATERIAL_MAP_BRDF, + + MATERIAL_MAP_DIFFUSE = MATERIAL_MAP_ALBEDO, + MATERIAL_MAP_SPECULAR = MATERIAL_MAP_METALNESS, +} + +/// +/// Material texture map +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct MaterialMap +{ + /// + /// Material map texture + /// + public Texture2D Texture; + + /// + /// Material map color + /// + public Color Color; + + /// + /// Material map value + /// + public float Value; +} + +/// +/// Material type (generic) +/// +[StructLayout(LayoutKind.Sequential)] +public unsafe partial struct Material +{ + /// + /// Material shader + /// + public Shader Shader; + + //TODO: convert + /// + /// Material maps + /// + public MaterialMap* Maps; + + /// + /// Material generic parameters (if required) + /// + public fixed float Param[4]; } diff --git a/Raylib-cs/types/Mesh.cs b/Raylib-cs/types/Mesh.cs index 61926f2..116542e 100644 --- a/Raylib-cs/types/Mesh.cs +++ b/Raylib-cs/types/Mesh.cs @@ -1,99 +1,98 @@ using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Vertex data definning a mesh
+/// NOTE: Data stored in CPU memory (and GPU) +///
+[StructLayout(LayoutKind.Sequential)] +public unsafe partial struct Mesh { /// - /// Vertex data definning a mesh
- /// NOTE: Data stored in CPU memory (and GPU) + /// Number of vertices stored in arrays ///
- [StructLayout(LayoutKind.Sequential)] - public unsafe partial struct Mesh - { - /// - /// Number of vertices stored in arrays - /// - public int VertexCount; + public int VertexCount; - /// - /// Number of triangles stored (indexed or not) - /// - public int TriangleCount; + /// + /// Number of triangles stored (indexed or not) + /// + public int TriangleCount; - #region Default vertex data + #region Default vertex data - /// - /// Vertex position (XYZ - 3 components per vertex) (shader-location = 0) - /// - public float* Vertices; + /// + /// Vertex position (XYZ - 3 components per vertex) (shader-location = 0) + /// + public float* Vertices; - /// - /// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) - /// - public float* TexCoords; + /// + /// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) + /// + public float* TexCoords; - /// - /// Vertex second texture coordinates (useful for lightmaps) (shader-location = 5) - /// - public float* TexCoords2; + /// + /// Vertex second texture coordinates (useful for lightmaps) (shader-location = 5) + /// + public float* TexCoords2; - /// - /// Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) - /// - public float* Normals; + /// + /// Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) + /// + public float* Normals; - /// - /// Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4) - /// - public float* Tangents; + /// + /// Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4) + /// + public float* Tangents; - /// - /// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) - /// - public byte* Colors; + /// + /// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) + /// + public byte* Colors; - /// - /// Vertex indices (in case vertex data comes indexed) - /// - public ushort* Indices; + /// + /// Vertex indices (in case vertex data comes indexed) + /// + public ushort* Indices; - #endregion + #endregion - #region Animation vertex data + #region Animation vertex data - /// - /// Animated vertex positions (after bones transformations) - /// - public float* AnimVertices; + /// + /// Animated vertex positions (after bones transformations) + /// + public float* AnimVertices; - /// - /// Animated normals (after bones transformations) - /// - public float* AnimNormals; + /// + /// Animated normals (after bones transformations) + /// + public float* AnimNormals; - /// - /// Vertex bone ids, up to 4 bones influence by vertex (skinning) - /// - public byte* BoneIds; + /// + /// Vertex bone ids, up to 4 bones influence by vertex (skinning) + /// + public byte* BoneIds; - /// - /// Vertex bone weight, up to 4 bones influence by vertex (skinning) - /// - public float* BoneWeights; + /// + /// Vertex bone weight, up to 4 bones influence by vertex (skinning) + /// + public float* BoneWeights; - #endregion + #endregion - #region OpenGL identifiers + #region OpenGL identifiers - /// - /// OpenGL Vertex Array Object id - /// - public uint VaoId; + /// + /// OpenGL Vertex Array Object id + /// + public uint VaoId; - /// - /// OpenGL Vertex Buffer Objects id (default vertex data, uint[]) - /// - public uint* VboId; + /// + /// OpenGL Vertex Buffer Objects id (default vertex data, uint[]) + /// + public uint* VboId; - #endregion - } + #endregion } diff --git a/Raylib-cs/types/Model.cs b/Raylib-cs/types/Model.cs index 5405d6c..d4d041b 100644 --- a/Raylib-cs/types/Model.cs +++ b/Raylib-cs/types/Model.cs @@ -2,144 +2,143 @@ using System; using System.Numerics; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Bone information +/// +[StructLayout(LayoutKind.Sequential)] +public unsafe partial struct BoneInfo { /// - /// Bone information + /// Bone name (char[32]) /// - [StructLayout(LayoutKind.Sequential)] - public unsafe partial struct BoneInfo - { - /// - /// Bone name (char[32]) - /// - public fixed sbyte Name[32]; - - /// - /// Bone parent - /// - public int Parent; - } + public fixed sbyte Name[32]; /// - /// Model type + /// Bone parent /// - [StructLayout(LayoutKind.Sequential)] - public unsafe partial struct Model - { - /// - /// Local transform matrix - /// - public Matrix4x4 Transform; + public int Parent; +} - /// - /// Number of meshes - /// - public int MeshCount; - - /// - /// Number of materials - /// - public int MaterialCount; - - /// - /// Meshes array (Mesh *) - /// - public Mesh* Meshes; - - /// - /// Materials array (Material *) - /// - public Material* Materials; - - /// - /// Mesh material number (int *) - /// - public int* MeshMaterial; - - /// - /// Number of bones - /// - public int BoneCount; - - //TODO: Span - /// - /// Bones information (skeleton, BoneInfo *) - /// - public BoneInfo* Bones; - - //TODO: Span - /// - /// Bones base transformation (pose, Transform *) - /// - public Transform* BindPose; - } +/// +/// Model type +/// +[StructLayout(LayoutKind.Sequential)] +public unsafe partial struct Model +{ + /// + /// Local transform matrix + /// + public Matrix4x4 Transform; /// - /// Model animation + /// Number of meshes /// - [StructLayout(LayoutKind.Sequential)] - public readonly unsafe partial struct ModelAnimation + public int MeshCount; + + /// + /// Number of materials + /// + public int MaterialCount; + + /// + /// Meshes array (Mesh *) + /// + public Mesh* Meshes; + + /// + /// Materials array (Material *) + /// + public Material* Materials; + + /// + /// Mesh material number (int *) + /// + public int* MeshMaterial; + + /// + /// Number of bones + /// + public int BoneCount; + + //TODO: Span + /// + /// Bones information (skeleton, BoneInfo *) + /// + public BoneInfo* Bones; + + //TODO: Span + /// + /// Bones base transformation (pose, Transform *) + /// + public Transform* BindPose; +} + +/// +/// Model animation +/// +[StructLayout(LayoutKind.Sequential)] +public readonly unsafe partial struct ModelAnimation +{ + /// + /// Number of bones + /// + public readonly int BoneCount; + + /// + /// Number of animation frames + /// + public readonly int FrameCount; + + /// + /// Bones information (skeleton, BoneInfo *) + /// + public readonly BoneInfo* Bones; + + /// + public ReadOnlySpan BoneInfo => new(Bones, BoneCount); + + /// + /// Poses array by frame (Transform **) + /// + public readonly Transform** FramePoses; + + /// + public FramePosesCollection FramePosesColl => new(FramePoses, FrameCount, BoneCount); + + public struct FramePosesCollection { - /// - /// Number of bones - /// - public readonly int BoneCount; + readonly Transform** _framePoses; - /// - /// Number of animation frames - /// - public readonly int FrameCount; + readonly int _frameCount; - /// - /// Bones information (skeleton, BoneInfo *) - /// - public readonly BoneInfo* Bones; + readonly int _boneCount; - /// - public ReadOnlySpan BoneInfo => new(Bones, BoneCount); + public FramePoses this[int index] => new(_framePoses[index], _boneCount); - /// - /// Poses array by frame (Transform **) - /// - public readonly Transform** FramePoses; + public Transform this[int index1, int index2] => new FramePoses(_framePoses[index1], _boneCount)[index2]; - /// - public FramePosesCollection FramePosesColl => new(FramePoses, FrameCount, BoneCount); - - public struct FramePosesCollection + internal FramePosesCollection(Transform** framePoses, int frameCount, int boneCount) { - readonly Transform** _framePoses; - - readonly int _frameCount; - - readonly int _boneCount; - - public FramePoses this[int index] => new(_framePoses[index], _boneCount); - - public Transform this[int index1, int index2] => new FramePoses(_framePoses[index1], _boneCount)[index2]; - - internal FramePosesCollection(Transform** framePoses, int frameCount, int boneCount) - { - this._framePoses = framePoses; - this._frameCount = frameCount; - this._boneCount = boneCount; - } - } - } - - public unsafe struct FramePoses - { - readonly Transform* _poses; - - readonly int _count; - - public ref Transform this[int index] => ref _poses[index]; - - internal FramePoses(Transform* poses, int count) - { - this._poses = poses; - this._count = count; + this._framePoses = framePoses; + this._frameCount = frameCount; + this._boneCount = boneCount; } } } + +public unsafe struct FramePoses +{ + readonly Transform* _poses; + + readonly int _count; + + public ref Transform this[int index] => ref _poses[index]; + + internal FramePoses(Transform* poses, int count) + { + this._poses = poses; + this._count = count; + } +} diff --git a/Raylib-cs/types/NPatchInfo.cs b/Raylib-cs/types/NPatchInfo.cs index 7782622..7a94ca2 100644 --- a/Raylib-cs/types/NPatchInfo.cs +++ b/Raylib-cs/types/NPatchInfo.cs @@ -1,62 +1,61 @@ using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// N-patch layout +/// +public enum NPatchLayout { /// - /// N-patch layout + /// Npatch defined by 3x3 tiles /// - public enum NPatchLayout - { - /// - /// Npatch defined by 3x3 tiles - /// - NPATCH_NINE_PATCH = 0, - - /// - /// Npatch defined by 1x3 tiles - /// - NPATCH_THREE_PATCH_VERTICAL, - - /// - /// Npatch defined by 3x1 tiles - /// - NPATCH_THREE_PATCH_HORIZONTAL - } + NPATCH_NINE_PATCH = 0, /// - /// N-Patch layout info + /// Npatch defined by 1x3 tiles /// - [StructLayout(LayoutKind.Sequential)] - public partial struct NPatchInfo - { - /// - /// Texture source rectangle - /// - public Rectangle Source; + NPATCH_THREE_PATCH_VERTICAL, - /// - /// Left border offset - /// - public int Left; - - /// - /// Top border offset - /// - public int Top; - - /// - /// Right border offset - /// - public int Right; - - /// - /// Bottom border offset - /// - public int Bottom; - - /// - /// Layout of the n-patch: 3x3, 1x3 or 3x1 - /// - public NPatchLayout Layout; - } + /// + /// Npatch defined by 3x1 tiles + /// + NPATCH_THREE_PATCH_HORIZONTAL +} + +/// +/// N-Patch layout info +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct NPatchInfo +{ + /// + /// Texture source rectangle + /// + public Rectangle Source; + + /// + /// Left border offset + /// + public int Left; + + /// + /// Top border offset + /// + public int Top; + + /// + /// Right border offset + /// + public int Right; + + /// + /// Bottom border offset + /// + public int Bottom; + + /// + /// Layout of the n-patch: 3x3, 1x3 or 3x1 + /// + public NPatchLayout Layout; } diff --git a/Raylib-cs/types/Ray.cs b/Raylib-cs/types/Ray.cs index 60a2e02..ff829f2 100644 --- a/Raylib-cs/types/Ray.cs +++ b/Raylib-cs/types/Ray.cs @@ -1,55 +1,54 @@ using System.Numerics; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Ray, ray for raycasting +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct Ray { /// - /// Ray, ray for raycasting + /// Ray position (origin) /// - [StructLayout(LayoutKind.Sequential)] - public partial struct Ray - { - /// - /// Ray position (origin) - /// - public Vector3 Position; - - /// - /// Ray direction - /// - public Vector3 Direction; - - public Ray(Vector3 position, Vector3 direction) - { - this.Position = position; - this.Direction = direction; - } - } + public Vector3 Position; /// - /// Raycast hit information + /// Ray direction /// - [StructLayout(LayoutKind.Sequential)] - public partial struct RayCollision + public Vector3 Direction; + + public Ray(Vector3 position, Vector3 direction) { - /// - /// Did the ray hit something? - /// - public CBool Hit; - - /// - /// Distance to the nearest hit - /// - public float Distance; - - /// - /// Point of the nearest hit - /// - public Vector3 Point; - - /// - /// Surface normal of hit - /// - public Vector3 Normal; + this.Position = position; + this.Direction = direction; } } + +/// +/// Raycast hit information +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct RayCollision +{ + /// + /// Did the ray hit something? + /// + public CBool Hit; + + /// + /// Distance to the nearest hit + /// + public float Distance; + + /// + /// Point of the nearest hit + /// + public Vector3 Point; + + /// + /// Surface normal of hit + /// + public Vector3 Normal; +} diff --git a/Raylib-cs/types/Raylib.Utils.cs b/Raylib-cs/types/Raylib.Utils.cs index 762015d..96b4cdc 100644 --- a/Raylib-cs/types/Raylib.Utils.cs +++ b/Raylib-cs/types/Raylib.Utils.cs @@ -2,1105 +2,1104 @@ using System; using System.Numerics; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +public static unsafe partial class Raylib { - public static unsafe partial class Raylib + /// Initialize window and OpenGL context + public static void InitWindow(int width, int height, string title) { - /// Initialize window and OpenGL context - public static void InitWindow(int width, int height, string title) - { - using var str1 = title.ToUtf8Buffer(); - InitWindow(width, height, str1.AsPointer()); - } - - /// Set title for window (only PLATFORM_DESKTOP) - public static void SetWindowTitle(string title) - { - using var str1 = title.ToUtf8Buffer(); - SetWindowTitle(str1.AsPointer()); - } - - /// Get the human-readable, UTF-8 encoded name of the specified monitor - public static string GetMonitorName_(int monitor) - { - return Utf8StringUtils.GetUTF8String(GetMonitorName(monitor)); - } - - /// Get clipboard text content - public static string GetClipboardText_() - { - return Utf8StringUtils.GetUTF8String(GetClipboardText()); - } - - /// Set clipboard text content - public static void SetClipboardText(string text) - { - using var str1 = text.ToUtf8Buffer(); - SetClipboardText(str1.AsPointer()); - } - - /// Open URL with default system browser (if available) - public static void OpenURL(string url) - { - using var str1 = url.ToUtf8Buffer(); - OpenURL(str1.AsPointer()); - } - - /// Set internal gamepad mappings (SDL_GameControllerDB) - public static int SetGamepadMappings(string mappings) - { - using var str1 = mappings.ToUtf8Buffer(); - return SetGamepadMappings(str1.AsPointer()); - } - - /// Load shader from files and bind default locations - public static Shader LoadShader(string vsFileName, string fsFileName) - { - using var str1 = vsFileName.ToAnsiBuffer(); - using var str2 = fsFileName.ToAnsiBuffer(); - return LoadShader(str1.AsPointer(), str2.AsPointer()); - } - - /// Load shader from code string and bind default locations - public static Shader LoadShaderFromMemory(string vsCode, string fsCode) - { - using var str1 = vsCode.ToUtf8Buffer(); - using var str2 = fsCode.ToUtf8Buffer(); - return LoadShaderFromMemory(str1.AsPointer(), str2.AsPointer()); - } - - /// Get shader uniform location - public static int GetShaderLocation(Shader shader, string uniformName) - { - using var str1 = uniformName.ToUtf8Buffer(); - return GetShaderLocation(shader, str1.AsPointer()); - } - - /// Get shader attribute location - public static int GetShaderLocationAttrib(Shader shader, string attribName) - { - using var str1 = attribName.ToUtf8Buffer(); - return GetShaderLocationAttrib(shader, str1.AsPointer()); - } - - /// Takes a screenshot of current screen (saved a .png) - public static void TakeScreenshot(string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - TakeScreenshot(str1.AsPointer()); - } - - /// Check file extension - public static CBool IsFileExtension(string fileName, string ext) - { - using var str1 = fileName.ToAnsiBuffer(); - using var str2 = ext.ToAnsiBuffer(); - return IsFileExtension(str1.AsPointer(), str2.AsPointer()); - } - - /// Get file modification time (last write time) - public static long GetFileModTime(string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return GetFileModTime(str1.AsPointer()); - } - - /// Load image from file into CPU memory (RAM) - public static Image LoadImage(string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return LoadImage(str1.AsPointer()); - } - - /// Load image from RAW file data - public static Image LoadImageRaw(string fileName, int width, int height, PixelFormat format, int headerSize) - { - using var str1 = fileName.ToAnsiBuffer(); - return LoadImageRaw(str1.AsPointer(), width, height, format, headerSize); - } - - /// Load image sequence from file (frames appended to image.data) - public static Image LoadImageAnim(string fileName, out int frames) - { - using var str1 = fileName.ToAnsiBuffer(); - fixed (int* p = &frames) - { - return LoadImageAnim(str1.AsPointer(), p); - } - } - - /// - /// Load image from managed memory, fileType refers to extension: i.e. "png" - /// - public static Image LoadImageFromMemory(string fileType, byte[] fileData) - { - using var fileTypeNative = fileType.ToAnsiBuffer(); - fixed (byte* fileDataNative = fileData) - { - Image image = LoadImageFromMemory(fileTypeNative.AsPointer(), fileDataNative, fileData.Length); - return image; - } - } - - /// Export image data to file - public static CBool ExportImage(Image image, string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return ExportImage(image, str1.AsPointer()); - } - - /// Export image as code file defining an array of bytes - public static CBool ExportImageAsCode(Image image, string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return ExportImageAsCode(image, str1.AsPointer()); - } - - /// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) - public static void TraceLog(TraceLogLevel logLevel, string text) - { - using var str1 = text.ToUtf8Buffer(); - TraceLog(logLevel, str1.AsPointer()); - } - - /// Set shader uniform value vector - public static void SetShaderValueV( - Shader shader, - int locIndex, - T[] values, - ShaderUniformDataType uniformType, - int count - ) where T : unmanaged - { - SetShaderValueV(shader, locIndex, (Span)values, uniformType, count); - } - - /// Set shader uniform value vector - public static void SetShaderValueV( - Shader shader, - int locIndex, - Span values, - ShaderUniformDataType uniformType, - int count - ) where T : unmanaged - { - fixed (T* valuePtr = values) - { - SetShaderValueV(shader, locIndex, valuePtr, uniformType, count); - } - } - - /// Set shader uniform value - public static void SetShaderValue(Shader shader, int locIndex, T value, ShaderUniformDataType uniformType) - where T : unmanaged - { - SetShaderValue(shader, locIndex, &value, uniformType); - } - - /// Set shader uniform value - public static void SetShaderValue( - Shader shader, - int locIndex, - T[] values, - ShaderUniformDataType uniformType - ) where T : unmanaged - { - SetShaderValue(shader, locIndex, (Span)values, uniformType); - } - - /// Set shader uniform value - public static void SetShaderValue( - Shader shader, - int locIndex, - Span values, - ShaderUniformDataType uniformType - ) where T : unmanaged - { - fixed (T* valuePtr = values) - { - SetShaderValue(shader, locIndex, valuePtr, uniformType); - } - } - - /// Load file data as byte array (read) - public static byte* LoadFileData(string fileName, ref uint bytesRead) - { - using var str1 = fileName.ToAnsiBuffer(); - fixed (uint* p = &bytesRead) - { - return LoadFileData(str1.AsPointer(), p); - } - } - - /// Get dropped files names (memory should be freed) - public static string[] GetDroppedFiles() - { - var filePathList = LoadDroppedFiles(); - var files = new string[filePathList.Count]; - - for (var i = 0; i < filePathList.Count; i++) - { - files[i] = Marshal.PtrToStringUTF8((IntPtr)filePathList.Paths[i]); - } - UnloadDroppedFiles(filePathList); - - return files; - } - - /// Get gamepad internal name id - public static string GetGamepadName_(int gamepad) - { - return Utf8StringUtils.GetUTF8String(GetGamepadName(gamepad)); - } - - /// Update camera position for selected mode - public static void UpdateCamera(ref Camera3D camera, CameraMode mode) - { - fixed (Camera3D* c = &camera) - { - UpdateCamera(c, mode); - } - } - - /// Update camera movement/rotation - public static void UpdateCameraPro(ref Camera3D camera, Vector3 movement, Vector3 rotation, float zoom) - { - fixed (Camera3D* c = &camera) - { - UpdateCameraPro(c, movement, rotation, zoom); - } - } - - /// - /// Check the collision between two lines defined by two points each, returns collision point by reference - /// - public static CBool CheckCollisionLines( - Vector2 startPos1, - Vector2 endPos1, - Vector2 startPos2, - Vector2 endPos2, - ref Vector2 collisionPoint - ) - { - fixed (Vector2* p = &collisionPoint) - { - return CheckCollisionLines(startPos1, endPos1, startPos2, endPos2, p); - } - } - - /// Create an image from text (default font) - public static Image ImageText(string text, int fontSize, Color color) - { - using var str1 = text.ToUtf8Buffer(); - return ImageText(str1.AsPointer(), fontSize, color); - } - - /// Create an image from text (custom sprite font) - public static Image ImageTextEx(Font font, string text, float fontSize, float spacing, Color tint) - { - using var str1 = text.ToUtf8Buffer(); - return ImageTextEx(font, str1.AsPointer(), fontSize, spacing, tint); - } - - /// Convert image to POT (power-of-two) - public static void ImageToPOT(ref Image image, Color fill) - { - fixed (Image* p = &image) - { - ImageToPOT(p, fill); - } - } - - /// Convert image data to desired format - public static void ImageFormat(ref Image image, PixelFormat newFormat) - { - fixed (Image* p = &image) - { - ImageFormat(p, newFormat); - } - } - - /// Apply alpha mask to image - public static void ImageAlphaMask(ref Image image, Image alphaMask) - { - fixed (Image* p = &image) - { - ImageAlphaMask(p, alphaMask); - } - } - - /// Clear alpha channel to desired color - public static void ImageAlphaClear(ref Image image, Color color, float threshold) - { - fixed (Image* p = &image) - { - ImageAlphaClear(p, color, threshold); - } - } - - /// Crop image depending on alpha value - public static void ImageAlphaCrop(ref Image image, float threshold) - { - fixed (Image* p = &image) - { - ImageAlphaCrop(p, threshold); - } - } - - /// Premultiply alpha channel - public static void ImageAlphaPremultiply(ref Image image) - { - fixed (Image* p = &image) - { - ImageAlphaPremultiply(p); - } - } - - /// Apply Gaussian blur using a box blur approximation - public static void ImageBlurGaussian(ref Image image, int blurSize) - { - fixed (Image* p = &image) - { - ImageBlurGaussian(p, blurSize); - } - } - - /// Crop an image to a defined rectangle - public static void ImageCrop(ref Image image, Rectangle crop) - { - fixed (Image* p = &image) - { - ImageCrop(p, crop); - } - } - - /// Resize image (Bicubic scaling algorithm) - public static void ImageResize(ref Image image, int newWidth, int newHeight) - { - fixed (Image* p = &image) - { - ImageResize(p, newWidth, newHeight); - } - } - - /// Resize image (Nearest-Neighbor scaling algorithm) - public static void ImageResizeNN(ref Image image, int newWidth, int newHeight) - { - fixed (Image* p = &image) - { - ImageResizeNN(p, newWidth, newHeight); - } - } - - /// Resize canvas and fill with color - public static void ImageResizeCanvas( - ref Image image, - int newWidth, - int newHeight, - int offsetX, - int offsetY, - Color color - ) - { - fixed (Image* p = &image) - { - ImageResizeCanvas(p, newWidth, newHeight, offsetX, offsetY, color); - } - } - - /// Generate all mipmap levels for a provided image - public static void ImageMipmaps(ref Image image) - { - fixed (Image* p = &image) - { - ImageMipmaps(p); - } - } - - /// Dither image data to 16bpp or lower (Floyd-Steinberg dithering) - public static void ImageDither(ref Image image, int rBpp, int gBpp, int bBpp, int aBpp) - { - fixed (Image* p = &image) - { - ImageDither(p, rBpp, gBpp, bBpp, aBpp); - } - } - - /// Flip image vertically - public static void ImageFlipVertical(ref Image image) - { - fixed (Image* p = &image) - { - ImageFlipVertical(p); - } - } - - /// Flip image horizontally - public static void ImageFlipHorizontal(ref Image image) - { - fixed (Image* p = &image) - { - ImageFlipHorizontal(p); - } - } - - /// Rotate image clockwise 90deg - public static void ImageRotateCW(ref Image image) - { - fixed (Image* p = &image) - { - ImageRotateCW(p); - } - } - - /// Rotate image counter-clockwise 90deg - public static void ImageRotateCCW(ref Image image) - { - fixed (Image* p = &image) - { - ImageRotateCCW(p); - } - } - - /// Modify image color: tint - public static void ImageColorTint(ref Image image, Color color) - { - fixed (Image* p = &image) - { - ImageColorTint(p, color); - } - } - - /// Modify image color: invert - public static void ImageColorInvert(ref Image image) - { - fixed (Image* p = &image) - { - ImageColorInvert(p); - } - } - - /// Modify image color: grayscale - public static void ImageColorGrayscale(ref Image image) - { - fixed (Image* p = &image) - { - ImageColorGrayscale(p); - } - } - - /// Modify image color: contrast (-100 to 100) - public static void ImageColorContrast(ref Image image, float contrast) - { - fixed (Image* p = &image) - { - ImageColorContrast(p, contrast); - } - } - - /// Modify image color: brightness (-255 to 255) - public static void ImageColorBrightness(ref Image image, int brightness) - { - fixed (Image* p = &image) - { - ImageColorBrightness(p, brightness); - } - } - - /// Modify image color: replace color - public static void ImageColorReplace(ref Image image, Color color, Color replace) - { - fixed (Image* p = &image) - { - ImageColorReplace(p, color, replace); - } - } - - /// Clear image background with given color - public static void ImageClearBackground(ref Image dst, Color color) - { - fixed (Image* p = &dst) - { - ImageClearBackground(p, color); - } - } - - /// Draw pixel within an image - public static void ImageDrawPixel(ref Image dst, int posX, int posY, Color color) - { - fixed (Image* p = &dst) - { - ImageDrawPixel(p, posX, posY, color); - } - } - - /// Draw pixel within an image (Vector version) - public static void ImageDrawPixelV(ref Image dst, Vector2 position, Color color) - { - fixed (Image* p = &dst) - { - ImageDrawPixelV(p, position, color); - } - } - - /// Draw line within an image - public static void ImageDrawLine( - ref Image dst, - int startPosX, - int startPosY, - int endPosX, - int endPosY, - Color color - ) - { - fixed (Image* p = &dst) - { - ImageDrawLine(p, startPosX, startPosY, endPosX, endPosY, color); - } - } - - /// Draw line within an image (Vector version) - public static void ImageDrawLineV(ref Image dst, Vector2 start, Vector2 end, Color color) - { - fixed (Image* p = &dst) - { - ImageDrawLineV(p, start, end, color); - } - } - - /// Draw circle within an image - public static void ImageDrawCircle(ref Image dst, int centerX, int centerY, int radius, Color color) - { - fixed (Image* p = &dst) - { - ImageDrawCircle(p, centerX, centerY, radius, color); - } - } - - /// Draw circle within an image (Vector version) - public static void ImageDrawCircleV(ref Image dst, Vector2 center, int radius, Color color) - { - fixed (Image* p = &dst) - { - ImageDrawCircleV(p, center, radius, color); - } - } - - /// Draw rectangle within an image - public static void ImageDrawRectangle(ref Image dst, int posX, int posY, int width, int height, Color color) - { - fixed (Image* p = &dst) - { - ImageDrawRectangle(p, posX, posY, width, height, color); - } - } - - /// Draw rectangle within an image (Vector version) - public static void ImageDrawRectangleV(ref Image dst, Vector2 position, Vector2 size, Color color) - { - fixed (Image* p = &dst) - { - ImageDrawRectangleV(p, position, size, color); - } - } - - /// Draw rectangle within an image - public static void ImageDrawRectangleRec(ref Image dst, Rectangle rec, Color color) - { - fixed (Image* p = &dst) - { - ImageDrawRectangleRec(p, rec, color); - } - } - - /// Draw rectangle lines within an image - public static void ImageDrawRectangleLines(ref Image dst, Rectangle rec, int thick, Color color) - { - fixed (Image* p = &dst) - { - ImageDrawRectangleLines(p, rec, thick, color); - } - } - - /// Draw a source image within a destination image (tint applied to source) - public static void ImageDraw(ref Image dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint) - { - fixed (Image* p = &dst) - { - ImageDraw(p, src, srcRec, dstRec, tint); - } - } - - /// Draw text (using default font) within an image (destination) - public static void ImageDrawText(ref Image dst, string text, int x, int y, int fontSize, Color color) - { - using var str1 = text.ToUtf8Buffer(); - fixed (Image* p = &dst) - { - ImageDrawText(p, str1.AsPointer(), x, y, fontSize, color); - } - } - - /// Draw text (custom sprite font) within an image (destination) - public static void ImageDrawTextEx( - ref Image dst, - Font font, - string text, - Vector2 position, - int fontSize, - float spacing, - Color color - ) - { - using var str1 = text.ToUtf8Buffer(); - fixed (Image* p = &dst) - { - ImageDrawTextEx(p, font, str1.AsPointer(), position, fontSize, spacing, color); - } - } - - /// Load texture from file into GPU memory (VRAM) - public static Texture2D LoadTexture(string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return LoadTexture(str1.AsPointer()); - } - - /// Update GPU texture with new data - public static void UpdateTexture(Texture2D texture, T[] pixels) where T : unmanaged - { - UpdateTexture(texture, (ReadOnlySpan)pixels); - } - - /// Update GPU texture with new data - public static void UpdateTexture(Texture2D texture, ReadOnlySpan pixels) where T : unmanaged - { - fixed (void* pixelPtr = pixels) - { - UpdateTexture(texture, pixelPtr); - } - } - - /// Update GPU texture rectangle with new data - public static void UpdateTextureRec(Texture2D texture, Rectangle rec, T[] pixels) where T : unmanaged - { - UpdateTextureRec(texture, rec, (ReadOnlySpan)pixels); - } - - /// Update GPU texture rectangle with new data - public static void UpdateTextureRec(Texture2D texture, Rectangle rec, ReadOnlySpan pixels) where T : unmanaged - { - fixed (void* pixelPtr = pixels) - { - UpdateTextureRec(texture, rec, pixelPtr); - } - } - - /// Generate GPU mipmaps for a texture - public static void GenTextureMipmaps(ref Texture2D texture) - { - fixed (Texture2D* p = &texture) - { - GenTextureMipmaps(p); - } - } - - /// Load font from file into GPU memory (VRAM) - public static Font LoadFont(string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return LoadFont(str1.AsPointer()); - } - - /// Load font from file with extended parameters - public static Font LoadFontEx(string fileName, int fontSize, int[] fontChars, int glyphCount) - { - using var str1 = fileName.ToAnsiBuffer(); - fixed (int* p = fontChars) - { - return LoadFontEx(str1.AsPointer(), fontSize, p, glyphCount); - } - } - - /// - /// Load font from managed memory, fileType refers to extension: i.e. "ttf" - /// - public static Font LoadFontFromMemory( - string fileType, - byte[] fileData, - int fontSize, - int[] fontChars, - int glyphCount - ) - { - using var fileTypeNative = fileType.ToAnsiBuffer(); - fixed (byte* fileDataNative = fileData) - { - fixed (int* fontCharsNative = fontChars) - { - Font font = LoadFontFromMemory( - fileTypeNative.AsPointer(), - fileDataNative, - fileData.Length, - fontSize, - fontCharsNative, - glyphCount - ); - - return font; - } - } - } - - /// Upload vertex data into GPU and provided VAO/VBO ids - public static void UploadMesh(ref Mesh mesh, CBool dynamic) - { - fixed (Mesh* p = &mesh) - { - UploadMesh(p, dynamic); - } - } - - /// Unload mesh from memory (RAM and/or VRAM) - public static void UnloadMesh(ref Mesh mesh) - { - fixed (Mesh* p = &mesh) - { - UnloadMesh(p); - } - } - - /// Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...) - public static void SetMaterialTexture(ref Material material, MaterialMapIndex mapType, Texture2D texture) - { - fixed (Material* p = &material) - { - SetMaterialTexture(p, mapType, texture); - } - } - - /// Set material for a mesh - public static void SetModelMeshMaterial(ref Model model, int meshId, int materialId) - { - fixed (Model* p = &model) - { - SetModelMeshMaterial(p, meshId, materialId); - } - } - - /// Load model animations from file - public static ReadOnlySpan LoadModelAnimations(string fileName, ref uint animCount) - { - using var str1 = fileName.ToAnsiBuffer(); - fixed (uint* p = &animCount) - { - ModelAnimation* modelAnimations = LoadModelAnimations(str1.AsPointer(), p); - - if ((IntPtr)modelAnimations == IntPtr.Zero) - { - throw new ApplicationException("Failed to load animation"); - } - - return new ReadOnlySpan(modelAnimations, (int)animCount); - } - } - - /// Compute mesh tangents - public static void GenMeshTangents(ref Mesh mesh) - { - fixed (Mesh* p = &mesh) - { - GenMeshTangents(p); - } - } - - /// Convert wave data to desired format - public static void WaveFormat(ref Wave wave, int sampleRate, int sampleSize, int channels) - { - fixed (Wave* p = &wave) - { - WaveFormat(p, sampleRate, sampleSize, channels); - } - } - - /// Crop a wave to defined samples range - public static void WaveCrop(ref Wave wave, int initSample, int finalSample) - { - fixed (Wave* p = &wave) - { - WaveCrop(p, initSample, finalSample); - } - } - - /// Draw lines sequence - public static void DrawLineStrip(Vector2[] points, int pointCount, Color color) - { - fixed (Vector2* p = points) - { - DrawLineStrip(p, pointCount, color); - } - } - - /// Draw a triangle fan defined by points (first vertex is the center) - public static void DrawTriangleFan(Vector2[] points, int pointCount, Color color) - { - fixed (Vector2* p = points) - { - DrawTriangleFan(p, pointCount, color); - } - } - - /// Draw a triangle strip defined by points - public static void DrawTriangleStrip(Vector2[] points, int pointCount, Color color) - { - fixed (Vector2* p = points) - { - DrawTriangleStrip(p, pointCount, color); - } - } - - /// Draw text (using default font) - public static void DrawText(string text, int posX, int posY, int fontSize, Color color) - { - using var str1 = text.ToUtf8Buffer(); - DrawText(str1.AsPointer(), posX, posY, fontSize, color); - } - - /// Draw text using font and additional parameters - public static void DrawTextEx( - Font font, - string text, - Vector2 position, - float fontSize, - float spacing, - Color tint - ) - { - using var str1 = text.ToUtf8Buffer(); - DrawTextEx(font, str1.AsPointer(), position, fontSize, spacing, tint); - } - - /// Draw text using Font and pro parameters (rotation) - public static void DrawTextPro( - Font font, - string text, - Vector2 position, - Vector2 origin, - float rotation, - float fontSize, - float spacing, - Color tint - ) - { - using var str1 = text.ToUtf8Buffer(); - DrawTextPro(font, str1.AsPointer(), position, origin, rotation, fontSize, spacing, tint); - } - - /// Measure string width for default font - public static int MeasureText(string text, int fontSize) - { - using var str1 = text.ToUtf8Buffer(); - return MeasureText(str1.AsPointer(), fontSize); - } - - /// Measure string size for Font - public static Vector2 MeasureTextEx(Font font, string text, float fontSize, float spacing) - { - using var str1 = text.ToUtf8Buffer(); - return MeasureTextEx(font, str1.AsPointer(), fontSize, spacing); - } - - /// Get all codepoints in a string, codepoints count returned by parameters - public static int[] LoadCodepoints(string text, ref int count) - { - using var str1 = text.ToUtf8Buffer(); - fixed (int* c = &count) - { - var pointsPtr = LoadCodepoints(str1.AsPointer(), c); - var codepoints = new ReadOnlySpan(pointsPtr, count).ToArray(); - UnloadCodepoints(pointsPtr); - return codepoints; - } - } - - /// Get total number of codepoints in a UTF8 encoded string - public static int GetCodepointCount(string text) - { - using var str1 = text.ToUtf8Buffer(); - return GetCodepointCount(str1.AsPointer()); - } - - /// Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure - public static int GetCodepoint(string text, ref int codepointSize) - { - using var str1 = text.ToUtf8Buffer(); - fixed (int* p = &codepointSize) - { - return GetCodepoint(str1.AsPointer(), p); - } - } - - /// Encode one codepoint into UTF-8 byte array (array length returned as parameter) - public static string CodepointToUTF8(int codepoint, ref int utf8Size) - { - fixed (int* l1 = &utf8Size) - { - var ptr = CodepointToUTF8(codepoint, l1); - return Utf8StringUtils.GetUTF8String(ptr); - } - } - - /// Load UTF-8 text encoded from codepoints array - public static string LoadUTF8(int[] codepoints, int length) - { - fixed (int* c1 = codepoints) - { - var ptr = LoadUTF8(c1, length); - var text = Utf8StringUtils.GetUTF8String(ptr); - MemFree(ptr); - return text; - } - } - - /// Draw a model (with texture if set) - public static Model LoadModel(string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return LoadModel(str1.AsPointer()); - } - - /// Export mesh data to file, returns true on success - public static CBool ExportMesh(Mesh mesh, string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return ExportMesh(mesh, str1.AsPointer()); - } - - /// Draw a triangle strip defined by points - public static void DrawTriangleStrip3D(Vector3[] points, int pointCount, Color color) - { - fixed (Vector3* p = points) - { - DrawTriangleStrip3D(p, pointCount, color); - } - } - - /// Draw multiple mesh instances with material and different transforms - public static void DrawMeshInstanced(Mesh mesh, Material material, Matrix4x4[] transforms, int instances) - { - fixed (Matrix4x4* p = transforms) - { - DrawMeshInstanced(mesh, material, p, instances); - } - } - - /// Load wave data from file - public static Wave LoadWave(string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return LoadWave(str1.AsPointer()); - } - - /// - /// Load wave from managed memory, fileType refers to extension: i.e. "wav" - /// - public static Wave LoadWaveFromMemory( - string fileType, - byte[] fileData - ) - { - using var fileTypeNative = fileType.ToAnsiBuffer(); - - fixed (byte* fileDataNative = fileData) - { - Wave wave = LoadWaveFromMemory( - fileTypeNative.AsPointer(), - fileDataNative, - fileData.Length - ); - - return wave; - } - } - - /// Load sound from file - public static Sound LoadSound(string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return LoadSound(str1.AsPointer()); - } - - /// Export wave data to file - public static CBool ExportWave(Wave wave, string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return ExportWave(wave, str1.AsPointer()); - } - - /// Export wave sample data to code (.h) - public static CBool ExportWaveAsCode(Wave wave, string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return ExportWaveAsCode(wave, str1.AsPointer()); - } - - /// Load music stream from file - public static Music LoadMusicStream(string fileName) - { - using var str1 = fileName.ToAnsiBuffer(); - return LoadMusicStream(str1.AsPointer()); - } - - /// - /// Load music stream from managed memory, fileType refers to extension: i.e. ".wav" - /// - public static Music LoadMusicStreamFromMemory( - string fileType, - byte[] fileData - ) - { - using var fileTypeNative = fileType.ToAnsiBuffer(); - - fixed (byte* fileDataNative = fileData) - { - Music music = LoadMusicStreamFromMemory( - fileTypeNative.AsPointer(), - fileDataNative, - fileData.Length - ); - - return music; - } - } - - public static string SubText(this string input, int position, int length) - { - return input.Substring(position, Math.Min(length, input.Length)); - } - - public static Material GetMaterial(ref Model model, int materialIndex) - { - return model.Materials[materialIndex]; - } - - public static Texture2D GetMaterialTexture(ref Model model, int materialIndex, MaterialMapIndex mapIndex) - { - return model.Materials[materialIndex].Maps[(int)mapIndex].Texture; - } - - public static void SetMaterialTexture( - ref Model model, - int materialIndex, - MaterialMapIndex mapIndex, - ref Texture2D texture - ) - { - SetMaterialTexture(&model.Materials[materialIndex], mapIndex, texture); - } - - public static void SetMaterialShader(ref Model model, int materialIndex, ref Shader shader) - { - model.Materials[materialIndex].Shader = shader; + using var str1 = title.ToUtf8Buffer(); + InitWindow(width, height, str1.AsPointer()); + } + + /// Set title for window (only PLATFORM_DESKTOP) + public static void SetWindowTitle(string title) + { + using var str1 = title.ToUtf8Buffer(); + SetWindowTitle(str1.AsPointer()); + } + + /// Get the human-readable, UTF-8 encoded name of the specified monitor + public static string GetMonitorName_(int monitor) + { + return Utf8StringUtils.GetUTF8String(GetMonitorName(monitor)); + } + + /// Get clipboard text content + public static string GetClipboardText_() + { + return Utf8StringUtils.GetUTF8String(GetClipboardText()); + } + + /// Set clipboard text content + public static void SetClipboardText(string text) + { + using var str1 = text.ToUtf8Buffer(); + SetClipboardText(str1.AsPointer()); + } + + /// Open URL with default system browser (if available) + public static void OpenURL(string url) + { + using var str1 = url.ToUtf8Buffer(); + OpenURL(str1.AsPointer()); + } + + /// Set internal gamepad mappings (SDL_GameControllerDB) + public static int SetGamepadMappings(string mappings) + { + using var str1 = mappings.ToUtf8Buffer(); + return SetGamepadMappings(str1.AsPointer()); + } + + /// Load shader from files and bind default locations + public static Shader LoadShader(string vsFileName, string fsFileName) + { + using var str1 = vsFileName.ToAnsiBuffer(); + using var str2 = fsFileName.ToAnsiBuffer(); + return LoadShader(str1.AsPointer(), str2.AsPointer()); + } + + /// Load shader from code string and bind default locations + public static Shader LoadShaderFromMemory(string vsCode, string fsCode) + { + using var str1 = vsCode.ToUtf8Buffer(); + using var str2 = fsCode.ToUtf8Buffer(); + return LoadShaderFromMemory(str1.AsPointer(), str2.AsPointer()); + } + + /// Get shader uniform location + public static int GetShaderLocation(Shader shader, string uniformName) + { + using var str1 = uniformName.ToUtf8Buffer(); + return GetShaderLocation(shader, str1.AsPointer()); + } + + /// Get shader attribute location + public static int GetShaderLocationAttrib(Shader shader, string attribName) + { + using var str1 = attribName.ToUtf8Buffer(); + return GetShaderLocationAttrib(shader, str1.AsPointer()); + } + + /// Takes a screenshot of current screen (saved a .png) + public static void TakeScreenshot(string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + TakeScreenshot(str1.AsPointer()); + } + + /// Check file extension + public static CBool IsFileExtension(string fileName, string ext) + { + using var str1 = fileName.ToAnsiBuffer(); + using var str2 = ext.ToAnsiBuffer(); + return IsFileExtension(str1.AsPointer(), str2.AsPointer()); + } + + /// Get file modification time (last write time) + public static long GetFileModTime(string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return GetFileModTime(str1.AsPointer()); + } + + /// Load image from file into CPU memory (RAM) + public static Image LoadImage(string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return LoadImage(str1.AsPointer()); + } + + /// Load image from RAW file data + public static Image LoadImageRaw(string fileName, int width, int height, PixelFormat format, int headerSize) + { + using var str1 = fileName.ToAnsiBuffer(); + return LoadImageRaw(str1.AsPointer(), width, height, format, headerSize); + } + + /// Load image sequence from file (frames appended to image.data) + public static Image LoadImageAnim(string fileName, out int frames) + { + using var str1 = fileName.ToAnsiBuffer(); + fixed (int* p = &frames) + { + return LoadImageAnim(str1.AsPointer(), p); } } + + /// + /// Load image from managed memory, fileType refers to extension: i.e. "png" + /// + public static Image LoadImageFromMemory(string fileType, byte[] fileData) + { + using var fileTypeNative = fileType.ToAnsiBuffer(); + fixed (byte* fileDataNative = fileData) + { + Image image = LoadImageFromMemory(fileTypeNative.AsPointer(), fileDataNative, fileData.Length); + return image; + } + } + + /// Export image data to file + public static CBool ExportImage(Image image, string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return ExportImage(image, str1.AsPointer()); + } + + /// Export image as code file defining an array of bytes + public static CBool ExportImageAsCode(Image image, string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return ExportImageAsCode(image, str1.AsPointer()); + } + + /// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) + public static void TraceLog(TraceLogLevel logLevel, string text) + { + using var str1 = text.ToUtf8Buffer(); + TraceLog(logLevel, str1.AsPointer()); + } + + /// Set shader uniform value vector + public static void SetShaderValueV( + Shader shader, + int locIndex, + T[] values, + ShaderUniformDataType uniformType, + int count + ) where T : unmanaged + { + SetShaderValueV(shader, locIndex, (Span)values, uniformType, count); + } + + /// Set shader uniform value vector + public static void SetShaderValueV( + Shader shader, + int locIndex, + Span values, + ShaderUniformDataType uniformType, + int count + ) where T : unmanaged + { + fixed (T* valuePtr = values) + { + SetShaderValueV(shader, locIndex, valuePtr, uniformType, count); + } + } + + /// Set shader uniform value + public static void SetShaderValue(Shader shader, int locIndex, T value, ShaderUniformDataType uniformType) + where T : unmanaged + { + SetShaderValue(shader, locIndex, &value, uniformType); + } + + /// Set shader uniform value + public static void SetShaderValue( + Shader shader, + int locIndex, + T[] values, + ShaderUniformDataType uniformType + ) where T : unmanaged + { + SetShaderValue(shader, locIndex, (Span)values, uniformType); + } + + /// Set shader uniform value + public static void SetShaderValue( + Shader shader, + int locIndex, + Span values, + ShaderUniformDataType uniformType + ) where T : unmanaged + { + fixed (T* valuePtr = values) + { + SetShaderValue(shader, locIndex, valuePtr, uniformType); + } + } + + /// Load file data as byte array (read) + public static byte* LoadFileData(string fileName, ref uint bytesRead) + { + using var str1 = fileName.ToAnsiBuffer(); + fixed (uint* p = &bytesRead) + { + return LoadFileData(str1.AsPointer(), p); + } + } + + /// Get dropped files names (memory should be freed) + public static string[] GetDroppedFiles() + { + var filePathList = LoadDroppedFiles(); + var files = new string[filePathList.Count]; + + for (var i = 0; i < filePathList.Count; i++) + { + files[i] = Marshal.PtrToStringUTF8((IntPtr)filePathList.Paths[i]); + } + UnloadDroppedFiles(filePathList); + + return files; + } + + /// Get gamepad internal name id + public static string GetGamepadName_(int gamepad) + { + return Utf8StringUtils.GetUTF8String(GetGamepadName(gamepad)); + } + + /// Update camera position for selected mode + public static void UpdateCamera(ref Camera3D camera, CameraMode mode) + { + fixed (Camera3D* c = &camera) + { + UpdateCamera(c, mode); + } + } + + /// Update camera movement/rotation + public static void UpdateCameraPro(ref Camera3D camera, Vector3 movement, Vector3 rotation, float zoom) + { + fixed (Camera3D* c = &camera) + { + UpdateCameraPro(c, movement, rotation, zoom); + } + } + + /// + /// Check the collision between two lines defined by two points each, returns collision point by reference + /// + public static CBool CheckCollisionLines( + Vector2 startPos1, + Vector2 endPos1, + Vector2 startPos2, + Vector2 endPos2, + ref Vector2 collisionPoint + ) + { + fixed (Vector2* p = &collisionPoint) + { + return CheckCollisionLines(startPos1, endPos1, startPos2, endPos2, p); + } + } + + /// Create an image from text (default font) + public static Image ImageText(string text, int fontSize, Color color) + { + using var str1 = text.ToUtf8Buffer(); + return ImageText(str1.AsPointer(), fontSize, color); + } + + /// Create an image from text (custom sprite font) + public static Image ImageTextEx(Font font, string text, float fontSize, float spacing, Color tint) + { + using var str1 = text.ToUtf8Buffer(); + return ImageTextEx(font, str1.AsPointer(), fontSize, spacing, tint); + } + + /// Convert image to POT (power-of-two) + public static void ImageToPOT(ref Image image, Color fill) + { + fixed (Image* p = &image) + { + ImageToPOT(p, fill); + } + } + + /// Convert image data to desired format + public static void ImageFormat(ref Image image, PixelFormat newFormat) + { + fixed (Image* p = &image) + { + ImageFormat(p, newFormat); + } + } + + /// Apply alpha mask to image + public static void ImageAlphaMask(ref Image image, Image alphaMask) + { + fixed (Image* p = &image) + { + ImageAlphaMask(p, alphaMask); + } + } + + /// Clear alpha channel to desired color + public static void ImageAlphaClear(ref Image image, Color color, float threshold) + { + fixed (Image* p = &image) + { + ImageAlphaClear(p, color, threshold); + } + } + + /// Crop image depending on alpha value + public static void ImageAlphaCrop(ref Image image, float threshold) + { + fixed (Image* p = &image) + { + ImageAlphaCrop(p, threshold); + } + } + + /// Premultiply alpha channel + public static void ImageAlphaPremultiply(ref Image image) + { + fixed (Image* p = &image) + { + ImageAlphaPremultiply(p); + } + } + + /// Apply Gaussian blur using a box blur approximation + public static void ImageBlurGaussian(ref Image image, int blurSize) + { + fixed (Image* p = &image) + { + ImageBlurGaussian(p, blurSize); + } + } + + /// Crop an image to a defined rectangle + public static void ImageCrop(ref Image image, Rectangle crop) + { + fixed (Image* p = &image) + { + ImageCrop(p, crop); + } + } + + /// Resize image (Bicubic scaling algorithm) + public static void ImageResize(ref Image image, int newWidth, int newHeight) + { + fixed (Image* p = &image) + { + ImageResize(p, newWidth, newHeight); + } + } + + /// Resize image (Nearest-Neighbor scaling algorithm) + public static void ImageResizeNN(ref Image image, int newWidth, int newHeight) + { + fixed (Image* p = &image) + { + ImageResizeNN(p, newWidth, newHeight); + } + } + + /// Resize canvas and fill with color + public static void ImageResizeCanvas( + ref Image image, + int newWidth, + int newHeight, + int offsetX, + int offsetY, + Color color + ) + { + fixed (Image* p = &image) + { + ImageResizeCanvas(p, newWidth, newHeight, offsetX, offsetY, color); + } + } + + /// Generate all mipmap levels for a provided image + public static void ImageMipmaps(ref Image image) + { + fixed (Image* p = &image) + { + ImageMipmaps(p); + } + } + + /// Dither image data to 16bpp or lower (Floyd-Steinberg dithering) + public static void ImageDither(ref Image image, int rBpp, int gBpp, int bBpp, int aBpp) + { + fixed (Image* p = &image) + { + ImageDither(p, rBpp, gBpp, bBpp, aBpp); + } + } + + /// Flip image vertically + public static void ImageFlipVertical(ref Image image) + { + fixed (Image* p = &image) + { + ImageFlipVertical(p); + } + } + + /// Flip image horizontally + public static void ImageFlipHorizontal(ref Image image) + { + fixed (Image* p = &image) + { + ImageFlipHorizontal(p); + } + } + + /// Rotate image clockwise 90deg + public static void ImageRotateCW(ref Image image) + { + fixed (Image* p = &image) + { + ImageRotateCW(p); + } + } + + /// Rotate image counter-clockwise 90deg + public static void ImageRotateCCW(ref Image image) + { + fixed (Image* p = &image) + { + ImageRotateCCW(p); + } + } + + /// Modify image color: tint + public static void ImageColorTint(ref Image image, Color color) + { + fixed (Image* p = &image) + { + ImageColorTint(p, color); + } + } + + /// Modify image color: invert + public static void ImageColorInvert(ref Image image) + { + fixed (Image* p = &image) + { + ImageColorInvert(p); + } + } + + /// Modify image color: grayscale + public static void ImageColorGrayscale(ref Image image) + { + fixed (Image* p = &image) + { + ImageColorGrayscale(p); + } + } + + /// Modify image color: contrast (-100 to 100) + public static void ImageColorContrast(ref Image image, float contrast) + { + fixed (Image* p = &image) + { + ImageColorContrast(p, contrast); + } + } + + /// Modify image color: brightness (-255 to 255) + public static void ImageColorBrightness(ref Image image, int brightness) + { + fixed (Image* p = &image) + { + ImageColorBrightness(p, brightness); + } + } + + /// Modify image color: replace color + public static void ImageColorReplace(ref Image image, Color color, Color replace) + { + fixed (Image* p = &image) + { + ImageColorReplace(p, color, replace); + } + } + + /// Clear image background with given color + public static void ImageClearBackground(ref Image dst, Color color) + { + fixed (Image* p = &dst) + { + ImageClearBackground(p, color); + } + } + + /// Draw pixel within an image + public static void ImageDrawPixel(ref Image dst, int posX, int posY, Color color) + { + fixed (Image* p = &dst) + { + ImageDrawPixel(p, posX, posY, color); + } + } + + /// Draw pixel within an image (Vector version) + public static void ImageDrawPixelV(ref Image dst, Vector2 position, Color color) + { + fixed (Image* p = &dst) + { + ImageDrawPixelV(p, position, color); + } + } + + /// Draw line within an image + public static void ImageDrawLine( + ref Image dst, + int startPosX, + int startPosY, + int endPosX, + int endPosY, + Color color + ) + { + fixed (Image* p = &dst) + { + ImageDrawLine(p, startPosX, startPosY, endPosX, endPosY, color); + } + } + + /// Draw line within an image (Vector version) + public static void ImageDrawLineV(ref Image dst, Vector2 start, Vector2 end, Color color) + { + fixed (Image* p = &dst) + { + ImageDrawLineV(p, start, end, color); + } + } + + /// Draw circle within an image + public static void ImageDrawCircle(ref Image dst, int centerX, int centerY, int radius, Color color) + { + fixed (Image* p = &dst) + { + ImageDrawCircle(p, centerX, centerY, radius, color); + } + } + + /// Draw circle within an image (Vector version) + public static void ImageDrawCircleV(ref Image dst, Vector2 center, int radius, Color color) + { + fixed (Image* p = &dst) + { + ImageDrawCircleV(p, center, radius, color); + } + } + + /// Draw rectangle within an image + public static void ImageDrawRectangle(ref Image dst, int posX, int posY, int width, int height, Color color) + { + fixed (Image* p = &dst) + { + ImageDrawRectangle(p, posX, posY, width, height, color); + } + } + + /// Draw rectangle within an image (Vector version) + public static void ImageDrawRectangleV(ref Image dst, Vector2 position, Vector2 size, Color color) + { + fixed (Image* p = &dst) + { + ImageDrawRectangleV(p, position, size, color); + } + } + + /// Draw rectangle within an image + public static void ImageDrawRectangleRec(ref Image dst, Rectangle rec, Color color) + { + fixed (Image* p = &dst) + { + ImageDrawRectangleRec(p, rec, color); + } + } + + /// Draw rectangle lines within an image + public static void ImageDrawRectangleLines(ref Image dst, Rectangle rec, int thick, Color color) + { + fixed (Image* p = &dst) + { + ImageDrawRectangleLines(p, rec, thick, color); + } + } + + /// Draw a source image within a destination image (tint applied to source) + public static void ImageDraw(ref Image dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint) + { + fixed (Image* p = &dst) + { + ImageDraw(p, src, srcRec, dstRec, tint); + } + } + + /// Draw text (using default font) within an image (destination) + public static void ImageDrawText(ref Image dst, string text, int x, int y, int fontSize, Color color) + { + using var str1 = text.ToUtf8Buffer(); + fixed (Image* p = &dst) + { + ImageDrawText(p, str1.AsPointer(), x, y, fontSize, color); + } + } + + /// Draw text (custom sprite font) within an image (destination) + public static void ImageDrawTextEx( + ref Image dst, + Font font, + string text, + Vector2 position, + int fontSize, + float spacing, + Color color + ) + { + using var str1 = text.ToUtf8Buffer(); + fixed (Image* p = &dst) + { + ImageDrawTextEx(p, font, str1.AsPointer(), position, fontSize, spacing, color); + } + } + + /// Load texture from file into GPU memory (VRAM) + public static Texture2D LoadTexture(string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return LoadTexture(str1.AsPointer()); + } + + /// Update GPU texture with new data + public static void UpdateTexture(Texture2D texture, T[] pixels) where T : unmanaged + { + UpdateTexture(texture, (ReadOnlySpan)pixels); + } + + /// Update GPU texture with new data + public static void UpdateTexture(Texture2D texture, ReadOnlySpan pixels) where T : unmanaged + { + fixed (void* pixelPtr = pixels) + { + UpdateTexture(texture, pixelPtr); + } + } + + /// Update GPU texture rectangle with new data + public static void UpdateTextureRec(Texture2D texture, Rectangle rec, T[] pixels) where T : unmanaged + { + UpdateTextureRec(texture, rec, (ReadOnlySpan)pixels); + } + + /// Update GPU texture rectangle with new data + public static void UpdateTextureRec(Texture2D texture, Rectangle rec, ReadOnlySpan pixels) where T : unmanaged + { + fixed (void* pixelPtr = pixels) + { + UpdateTextureRec(texture, rec, pixelPtr); + } + } + + /// Generate GPU mipmaps for a texture + public static void GenTextureMipmaps(ref Texture2D texture) + { + fixed (Texture2D* p = &texture) + { + GenTextureMipmaps(p); + } + } + + /// Load font from file into GPU memory (VRAM) + public static Font LoadFont(string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return LoadFont(str1.AsPointer()); + } + + /// Load font from file with extended parameters + public static Font LoadFontEx(string fileName, int fontSize, int[] fontChars, int glyphCount) + { + using var str1 = fileName.ToAnsiBuffer(); + fixed (int* p = fontChars) + { + return LoadFontEx(str1.AsPointer(), fontSize, p, glyphCount); + } + } + + /// + /// Load font from managed memory, fileType refers to extension: i.e. "ttf" + /// + public static Font LoadFontFromMemory( + string fileType, + byte[] fileData, + int fontSize, + int[] fontChars, + int glyphCount + ) + { + using var fileTypeNative = fileType.ToAnsiBuffer(); + fixed (byte* fileDataNative = fileData) + { + fixed (int* fontCharsNative = fontChars) + { + Font font = LoadFontFromMemory( + fileTypeNative.AsPointer(), + fileDataNative, + fileData.Length, + fontSize, + fontCharsNative, + glyphCount + ); + + return font; + } + } + } + + /// Upload vertex data into GPU and provided VAO/VBO ids + public static void UploadMesh(ref Mesh mesh, CBool dynamic) + { + fixed (Mesh* p = &mesh) + { + UploadMesh(p, dynamic); + } + } + + /// Unload mesh from memory (RAM and/or VRAM) + public static void UnloadMesh(ref Mesh mesh) + { + fixed (Mesh* p = &mesh) + { + UnloadMesh(p); + } + } + + /// Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...) + public static void SetMaterialTexture(ref Material material, MaterialMapIndex mapType, Texture2D texture) + { + fixed (Material* p = &material) + { + SetMaterialTexture(p, mapType, texture); + } + } + + /// Set material for a mesh + public static void SetModelMeshMaterial(ref Model model, int meshId, int materialId) + { + fixed (Model* p = &model) + { + SetModelMeshMaterial(p, meshId, materialId); + } + } + + /// Load model animations from file + public static ReadOnlySpan LoadModelAnimations(string fileName, ref uint animCount) + { + using var str1 = fileName.ToAnsiBuffer(); + fixed (uint* p = &animCount) + { + ModelAnimation* modelAnimations = LoadModelAnimations(str1.AsPointer(), p); + + if ((IntPtr)modelAnimations == IntPtr.Zero) + { + throw new ApplicationException("Failed to load animation"); + } + + return new ReadOnlySpan(modelAnimations, (int)animCount); + } + } + + /// Compute mesh tangents + public static void GenMeshTangents(ref Mesh mesh) + { + fixed (Mesh* p = &mesh) + { + GenMeshTangents(p); + } + } + + /// Convert wave data to desired format + public static void WaveFormat(ref Wave wave, int sampleRate, int sampleSize, int channels) + { + fixed (Wave* p = &wave) + { + WaveFormat(p, sampleRate, sampleSize, channels); + } + } + + /// Crop a wave to defined samples range + public static void WaveCrop(ref Wave wave, int initSample, int finalSample) + { + fixed (Wave* p = &wave) + { + WaveCrop(p, initSample, finalSample); + } + } + + /// Draw lines sequence + public static void DrawLineStrip(Vector2[] points, int pointCount, Color color) + { + fixed (Vector2* p = points) + { + DrawLineStrip(p, pointCount, color); + } + } + + /// Draw a triangle fan defined by points (first vertex is the center) + public static void DrawTriangleFan(Vector2[] points, int pointCount, Color color) + { + fixed (Vector2* p = points) + { + DrawTriangleFan(p, pointCount, color); + } + } + + /// Draw a triangle strip defined by points + public static void DrawTriangleStrip(Vector2[] points, int pointCount, Color color) + { + fixed (Vector2* p = points) + { + DrawTriangleStrip(p, pointCount, color); + } + } + + /// Draw text (using default font) + public static void DrawText(string text, int posX, int posY, int fontSize, Color color) + { + using var str1 = text.ToUtf8Buffer(); + DrawText(str1.AsPointer(), posX, posY, fontSize, color); + } + + /// Draw text using font and additional parameters + public static void DrawTextEx( + Font font, + string text, + Vector2 position, + float fontSize, + float spacing, + Color tint + ) + { + using var str1 = text.ToUtf8Buffer(); + DrawTextEx(font, str1.AsPointer(), position, fontSize, spacing, tint); + } + + /// Draw text using Font and pro parameters (rotation) + public static void DrawTextPro( + Font font, + string text, + Vector2 position, + Vector2 origin, + float rotation, + float fontSize, + float spacing, + Color tint + ) + { + using var str1 = text.ToUtf8Buffer(); + DrawTextPro(font, str1.AsPointer(), position, origin, rotation, fontSize, spacing, tint); + } + + /// Measure string width for default font + public static int MeasureText(string text, int fontSize) + { + using var str1 = text.ToUtf8Buffer(); + return MeasureText(str1.AsPointer(), fontSize); + } + + /// Measure string size for Font + public static Vector2 MeasureTextEx(Font font, string text, float fontSize, float spacing) + { + using var str1 = text.ToUtf8Buffer(); + return MeasureTextEx(font, str1.AsPointer(), fontSize, spacing); + } + + /// Get all codepoints in a string, codepoints count returned by parameters + public static int[] LoadCodepoints(string text, ref int count) + { + using var str1 = text.ToUtf8Buffer(); + fixed (int* c = &count) + { + var pointsPtr = LoadCodepoints(str1.AsPointer(), c); + var codepoints = new ReadOnlySpan(pointsPtr, count).ToArray(); + UnloadCodepoints(pointsPtr); + return codepoints; + } + } + + /// Get total number of codepoints in a UTF8 encoded string + public static int GetCodepointCount(string text) + { + using var str1 = text.ToUtf8Buffer(); + return GetCodepointCount(str1.AsPointer()); + } + + /// Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure + public static int GetCodepoint(string text, ref int codepointSize) + { + using var str1 = text.ToUtf8Buffer(); + fixed (int* p = &codepointSize) + { + return GetCodepoint(str1.AsPointer(), p); + } + } + + /// Encode one codepoint into UTF-8 byte array (array length returned as parameter) + public static string CodepointToUTF8(int codepoint, ref int utf8Size) + { + fixed (int* l1 = &utf8Size) + { + var ptr = CodepointToUTF8(codepoint, l1); + return Utf8StringUtils.GetUTF8String(ptr); + } + } + + /// Load UTF-8 text encoded from codepoints array + public static string LoadUTF8(int[] codepoints, int length) + { + fixed (int* c1 = codepoints) + { + var ptr = LoadUTF8(c1, length); + var text = Utf8StringUtils.GetUTF8String(ptr); + MemFree(ptr); + return text; + } + } + + /// Draw a model (with texture if set) + public static Model LoadModel(string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return LoadModel(str1.AsPointer()); + } + + /// Export mesh data to file, returns true on success + public static CBool ExportMesh(Mesh mesh, string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return ExportMesh(mesh, str1.AsPointer()); + } + + /// Draw a triangle strip defined by points + public static void DrawTriangleStrip3D(Vector3[] points, int pointCount, Color color) + { + fixed (Vector3* p = points) + { + DrawTriangleStrip3D(p, pointCount, color); + } + } + + /// Draw multiple mesh instances with material and different transforms + public static void DrawMeshInstanced(Mesh mesh, Material material, Matrix4x4[] transforms, int instances) + { + fixed (Matrix4x4* p = transforms) + { + DrawMeshInstanced(mesh, material, p, instances); + } + } + + /// Load wave data from file + public static Wave LoadWave(string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return LoadWave(str1.AsPointer()); + } + + /// + /// Load wave from managed memory, fileType refers to extension: i.e. "wav" + /// + public static Wave LoadWaveFromMemory( + string fileType, + byte[] fileData + ) + { + using var fileTypeNative = fileType.ToAnsiBuffer(); + + fixed (byte* fileDataNative = fileData) + { + Wave wave = LoadWaveFromMemory( + fileTypeNative.AsPointer(), + fileDataNative, + fileData.Length + ); + + return wave; + } + } + + /// Load sound from file + public static Sound LoadSound(string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return LoadSound(str1.AsPointer()); + } + + /// Export wave data to file + public static CBool ExportWave(Wave wave, string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return ExportWave(wave, str1.AsPointer()); + } + + /// Export wave sample data to code (.h) + public static CBool ExportWaveAsCode(Wave wave, string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return ExportWaveAsCode(wave, str1.AsPointer()); + } + + /// Load music stream from file + public static Music LoadMusicStream(string fileName) + { + using var str1 = fileName.ToAnsiBuffer(); + return LoadMusicStream(str1.AsPointer()); + } + + /// + /// Load music stream from managed memory, fileType refers to extension: i.e. ".wav" + /// + public static Music LoadMusicStreamFromMemory( + string fileType, + byte[] fileData + ) + { + using var fileTypeNative = fileType.ToAnsiBuffer(); + + fixed (byte* fileDataNative = fileData) + { + Music music = LoadMusicStreamFromMemory( + fileTypeNative.AsPointer(), + fileDataNative, + fileData.Length + ); + + return music; + } + } + + public static string SubText(this string input, int position, int length) + { + return input.Substring(position, Math.Min(length, input.Length)); + } + + public static Material GetMaterial(ref Model model, int materialIndex) + { + return model.Materials[materialIndex]; + } + + public static Texture2D GetMaterialTexture(ref Model model, int materialIndex, MaterialMapIndex mapIndex) + { + return model.Materials[materialIndex].Maps[(int)mapIndex].Texture; + } + + public static void SetMaterialTexture( + ref Model model, + int materialIndex, + MaterialMapIndex mapIndex, + ref Texture2D texture + ) + { + SetMaterialTexture(&model.Materials[materialIndex], mapIndex, texture); + } + + public static void SetMaterialShader(ref Model model, int materialIndex, ref Shader shader) + { + model.Materials[materialIndex].Shader = shader; + } } diff --git a/Raylib-cs/types/Rectangle.cs b/Raylib-cs/types/Rectangle.cs index cd21ae9..3f1c7ab 100644 --- a/Raylib-cs/types/Rectangle.cs +++ b/Raylib-cs/types/Rectangle.cs @@ -1,29 +1,28 @@ using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Rectangle type +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct Rectangle { - /// - /// Rectangle type - /// - [StructLayout(LayoutKind.Sequential)] - public partial struct Rectangle + public float X; + public float Y; + public float Width; + public float Height; + + public Rectangle(float x, float y, float width, float height) { - public float X; - public float Y; - public float Width; - public float Height; + this.X = x; + this.Y = y; + this.Width = width; + this.Height = height; + } - public Rectangle(float x, float y, float width, float height) - { - this.X = x; - this.Y = y; - this.Width = width; - this.Height = height; - } - - public override string ToString() - { - return $"{{X:{X} Y:{Y} Width:{Width} Height:{Height}}}"; - } + public override string ToString() + { + return $"{{X:{X} Y:{Y} Width:{Width} Height:{Height}}}"; } } diff --git a/Raylib-cs/types/RenderBatch.cs b/Raylib-cs/types/RenderBatch.cs index 783bbe6..d1da54f 100644 --- a/Raylib-cs/types/RenderBatch.cs +++ b/Raylib-cs/types/RenderBatch.cs @@ -1,271 +1,270 @@ using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// RenderBatch type +/// +[StructLayout(LayoutKind.Sequential)] +public unsafe partial struct RenderBatch { /// - /// RenderBatch type + /// Number of vertex buffers (multi-buffering support) /// - [StructLayout(LayoutKind.Sequential)] - public unsafe partial struct RenderBatch - { - /// - /// Number of vertex buffers (multi-buffering support) - /// - int _buffersCount; - - /// - /// Current buffer tracking in case of multi-buffering - /// - int _currentBuffer; - - /// - /// Dynamic buffer(s) for vertex data - /// - VertexBuffer* _vertexBuffer; - - /// - /// Draw calls array, depends on textureId - /// - DrawCall* _draws; - - /// - /// Draw calls counter - /// - int _drawsCounter; - - /// - /// Current depth value for next draw - /// - float _currentDepth; - } + int _buffersCount; /// - /// Dynamic vertex buffers (position + texcoords + colors + indices arrays) + /// Current buffer tracking in case of multi-buffering /// - [StructLayout(LayoutKind.Sequential)] - public unsafe partial struct VertexBuffer - { - /// - /// Number of elements in the buffer (QUADS) - /// - public int ElementCount; - - /// - /// Vertex position (XYZ - 3 components per vertex) (shader-location = 0) - /// - public float* Vertices; - - /// - /// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) - /// - public float* TexCoords; - - /// - /// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) - /// - public byte* Colors; - - /// - /// Vertex indices (in case vertex data comes indexed) (6 indices per quad)
- /// unsigned int* for GRAPHICS_API_OPENGL_11 or GRAPHICS_API_OPENGL_33
- /// unsigned short* for GRAPHICS_API_OPENGL_ES2 - ///
- public void* Indices; - - /// - /// OpenGL Vertex Array Object id - /// - public uint VaoId; - - /// - /// OpenGL Vertex Buffer Objects id (4 types of vertex data) - /// - public fixed uint VboId[4]; - } + int _currentBuffer; /// - /// Dynamic vertex buffers (position + texcoords + colors + indices arrays) + /// Dynamic buffer(s) for vertex data /// - [StructLayout(LayoutKind.Sequential)] - public partial struct DrawCall - { - /// - /// Drawing mode: LINES, TRIANGLES, QUADS - /// - int _mode; - - /// - /// Number of vertices for the draw call - /// - int _vertexCount; - - /// - /// Number of vertices required for index alignment (LINES, TRIANGLES) - /// - int _vertexAlignment; - - /// - /// Texture id to be used on the draw -> Use to create new draw call if changes - /// - uint _textureId; - } - - public enum GlVersion - { - OPENGL_11 = 1, - OPENGL_21, - OPENGL_33, - OPENGL_43, - OPENGL_ES_20 - } - - public enum FramebufferAttachType - { - RL_ATTACHMENT_COLOR_CHANNEL0 = 0, - RL_ATTACHMENT_COLOR_CHANNEL1, - RL_ATTACHMENT_COLOR_CHANNEL2, - RL_ATTACHMENT_COLOR_CHANNEL3, - RL_ATTACHMENT_COLOR_CHANNEL4, - RL_ATTACHMENT_COLOR_CHANNEL5, - RL_ATTACHMENT_COLOR_CHANNEL6, - RL_ATTACHMENT_COLOR_CHANNEL7, - RL_ATTACHMENT_DEPTH = 100, - RL_ATTACHMENT_STENCIL = 200, - } - - public enum FramebufferAttachTextureType - { - RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0, - RL_ATTACHMENT_CUBEMAP_NEGATIVE_X, - RL_ATTACHMENT_CUBEMAP_POSITIVE_Y, - RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y, - RL_ATTACHMENT_CUBEMAP_POSITIVE_Z, - RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z, - RL_ATTACHMENT_TEXTURE2D = 100, - RL_ATTACHMENT_RENDERBUFFER = 200, - } + VertexBuffer* _vertexBuffer; /// - /// Matrix Modes (equivalent to OpenGL) + /// Draw calls array, depends on textureId /// - public enum MatrixMode - { - /// - /// GL_MODELVIEW - /// - MODELVIEW = 0x1700, - - /// - /// GL_PROJECTION - /// - PROJECTION = 0x1701, - - /// - /// GL_TEXTURE - /// - TEXTURE = 0x1702 - } + DrawCall* _draws; /// - /// Primitive assembly draw modes + /// Draw calls counter /// - public enum DrawMode - { - /// - /// GL_LINES - /// - LINES = 0x0001, - - /// - /// GL_TRIANGLES - /// - TRIANGLES = 0x0004, - - /// - /// GL_QUADS - /// - QUADS = 0x0007 - } + int _drawsCounter; /// - /// Texture parameters (equivalent to OpenGL defines) + /// Current depth value for next draw /// - public enum TextureFilters - { - /// - /// RL_TEXTURE_FILTER_NEAREST - ///
- /// GL_NEAREST - ///
- NEAREST = 0x2600, - - /// - /// RL_TEXTURE_FILTER_LINEAR - ///
- /// GL_LINEAR - ///
- LINEAR = 0x2601, - - /// - /// RL_TEXTURE_FILTER_MIP_NEAREST - ///
- /// GL_NEAREST_MIPMAP_NEAREST - ///
- MIP_NEAREST = 0x2700, - - /// - /// RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR - ///
- /// GL_NEAREST_MIPMAP_LINEAR - ///
- NEAREST_MIP_LINEAR = 0x2702, - - /// - /// RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST - ///
- /// GL_LINEAR_MIPMAP_NEAREST - ///
- LINEAR_MIP_NEAREST = 0x2701, - - /// - /// RL_TEXTURE_FILTER_MIP_LINEAR - ///
- /// GL_LINEAR_MIPMAP_LINEAR - ///
- MIP_LINEAR = 0x2703, - - /// - /// RL_TEXTURE_FILTER_ANISOTROPIC - ///
- /// Anisotropic filter (custom identifier) - ///
- ANISOTROPIC = 0x3000 - } - - /// - /// GL Shader type - /// - public enum ShaderType - { - /// - /// RL_FRAGMENT_SHADER - ///
- /// GL_FRAGMENT_SHADER - ///
- FRAGMENT = 0x8B30, - - /// - /// RL_VERTEX_SHADER - ///
- /// GL_VERTEX_SHADER - ///
- VERTEX = 0x8B31, - - /// - /// RL_COMPUTE_SHADER - ///
- /// GL_COMPUTE_SHADER - ///
- COMPUTE = 0x91b9 - } + float _currentDepth; +} + +/// +/// Dynamic vertex buffers (position + texcoords + colors + indices arrays) +/// +[StructLayout(LayoutKind.Sequential)] +public unsafe partial struct VertexBuffer +{ + /// + /// Number of elements in the buffer (QUADS) + /// + public int ElementCount; + + /// + /// Vertex position (XYZ - 3 components per vertex) (shader-location = 0) + /// + public float* Vertices; + + /// + /// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) + /// + public float* TexCoords; + + /// + /// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) + /// + public byte* Colors; + + /// + /// Vertex indices (in case vertex data comes indexed) (6 indices per quad)
+ /// unsigned int* for GRAPHICS_API_OPENGL_11 or GRAPHICS_API_OPENGL_33
+ /// unsigned short* for GRAPHICS_API_OPENGL_ES2 + ///
+ public void* Indices; + + /// + /// OpenGL Vertex Array Object id + /// + public uint VaoId; + + /// + /// OpenGL Vertex Buffer Objects id (4 types of vertex data) + /// + public fixed uint VboId[4]; +} + +/// +/// Dynamic vertex buffers (position + texcoords + colors + indices arrays) +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct DrawCall +{ + /// + /// Drawing mode: LINES, TRIANGLES, QUADS + /// + int _mode; + + /// + /// Number of vertices for the draw call + /// + int _vertexCount; + + /// + /// Number of vertices required for index alignment (LINES, TRIANGLES) + /// + int _vertexAlignment; + + /// + /// Texture id to be used on the draw -> Use to create new draw call if changes + /// + uint _textureId; +} + +public enum GlVersion +{ + OPENGL_11 = 1, + OPENGL_21, + OPENGL_33, + OPENGL_43, + OPENGL_ES_20 +} + +public enum FramebufferAttachType +{ + RL_ATTACHMENT_COLOR_CHANNEL0 = 0, + RL_ATTACHMENT_COLOR_CHANNEL1, + RL_ATTACHMENT_COLOR_CHANNEL2, + RL_ATTACHMENT_COLOR_CHANNEL3, + RL_ATTACHMENT_COLOR_CHANNEL4, + RL_ATTACHMENT_COLOR_CHANNEL5, + RL_ATTACHMENT_COLOR_CHANNEL6, + RL_ATTACHMENT_COLOR_CHANNEL7, + RL_ATTACHMENT_DEPTH = 100, + RL_ATTACHMENT_STENCIL = 200, +} + +public enum FramebufferAttachTextureType +{ + RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0, + RL_ATTACHMENT_CUBEMAP_NEGATIVE_X, + RL_ATTACHMENT_CUBEMAP_POSITIVE_Y, + RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y, + RL_ATTACHMENT_CUBEMAP_POSITIVE_Z, + RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z, + RL_ATTACHMENT_TEXTURE2D = 100, + RL_ATTACHMENT_RENDERBUFFER = 200, +} + +/// +/// Matrix Modes (equivalent to OpenGL) +/// +public enum MatrixMode +{ + /// + /// GL_MODELVIEW + /// + MODELVIEW = 0x1700, + + /// + /// GL_PROJECTION + /// + PROJECTION = 0x1701, + + /// + /// GL_TEXTURE + /// + TEXTURE = 0x1702 +} + +/// +/// Primitive assembly draw modes +/// +public enum DrawMode +{ + /// + /// GL_LINES + /// + LINES = 0x0001, + + /// + /// GL_TRIANGLES + /// + TRIANGLES = 0x0004, + + /// + /// GL_QUADS + /// + QUADS = 0x0007 +} + +/// +/// Texture parameters (equivalent to OpenGL defines) +/// +public enum TextureFilters +{ + /// + /// RL_TEXTURE_FILTER_NEAREST + ///
+ /// GL_NEAREST + ///
+ NEAREST = 0x2600, + + /// + /// RL_TEXTURE_FILTER_LINEAR + ///
+ /// GL_LINEAR + ///
+ LINEAR = 0x2601, + + /// + /// RL_TEXTURE_FILTER_MIP_NEAREST + ///
+ /// GL_NEAREST_MIPMAP_NEAREST + ///
+ MIP_NEAREST = 0x2700, + + /// + /// RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR + ///
+ /// GL_NEAREST_MIPMAP_LINEAR + ///
+ NEAREST_MIP_LINEAR = 0x2702, + + /// + /// RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST + ///
+ /// GL_LINEAR_MIPMAP_NEAREST + ///
+ LINEAR_MIP_NEAREST = 0x2701, + + /// + /// RL_TEXTURE_FILTER_MIP_LINEAR + ///
+ /// GL_LINEAR_MIPMAP_LINEAR + ///
+ MIP_LINEAR = 0x2703, + + /// + /// RL_TEXTURE_FILTER_ANISOTROPIC + ///
+ /// Anisotropic filter (custom identifier) + ///
+ ANISOTROPIC = 0x3000 +} + +/// +/// GL Shader type +/// +public enum ShaderType +{ + /// + /// RL_FRAGMENT_SHADER + ///
+ /// GL_FRAGMENT_SHADER + ///
+ FRAGMENT = 0x8B30, + + /// + /// RL_VERTEX_SHADER + ///
+ /// GL_VERTEX_SHADER + ///
+ VERTEX = 0x8B31, + + /// + /// RL_COMPUTE_SHADER + ///
+ /// GL_COMPUTE_SHADER + ///
+ COMPUTE = 0x91b9 } diff --git a/Raylib-cs/types/RenderTexture2D.cs b/Raylib-cs/types/RenderTexture2D.cs index 50b063c..65d7849 100644 --- a/Raylib-cs/types/RenderTexture2D.cs +++ b/Raylib-cs/types/RenderTexture2D.cs @@ -1,26 +1,25 @@ using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// RenderTexture2D type, for texture rendering +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct RenderTexture2D { /// - /// RenderTexture2D type, for texture rendering + /// OpenGL Framebuffer Object (FBO) id /// - [StructLayout(LayoutKind.Sequential)] - public partial struct RenderTexture2D - { - /// - /// OpenGL Framebuffer Object (FBO) id - /// - public uint Id; + public uint Id; - /// - /// Color buffer attachment texture - /// - public Texture2D Texture; + /// + /// Color buffer attachment texture + /// + public Texture2D Texture; - /// - /// Depth buffer attachment texture - /// - public Texture2D Depth; - } + /// + /// Depth buffer attachment texture + /// + public Texture2D Depth; } diff --git a/Raylib-cs/types/Shader.cs b/Raylib-cs/types/Shader.cs index ef753df..e242da6 100644 --- a/Raylib-cs/types/Shader.cs +++ b/Raylib-cs/types/Shader.cs @@ -1,84 +1,83 @@ using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Shader location index +/// +public enum ShaderLocationIndex +{ + SHADER_LOC_VERTEX_POSITION = 0, + SHADER_LOC_VERTEX_TEXCOORD01, + SHADER_LOC_VERTEX_TEXCOORD02, + SHADER_LOC_VERTEX_NORMAL, + SHADER_LOC_VERTEX_TANGENT, + SHADER_LOC_VERTEX_COLOR, + SHADER_LOC_MATRIX_MVP, + SHADER_LOC_MATRIX_VIEW, + SHADER_LOC_MATRIX_PROJECTION, + SHADER_LOC_MATRIX_MODEL, + SHADER_LOC_MATRIX_NORMAL, + SHADER_LOC_VECTOR_VIEW, + SHADER_LOC_COLOR_DIFFUSE, + SHADER_LOC_COLOR_SPECULAR, + SHADER_LOC_COLOR_AMBIENT, + SHADER_LOC_MAP_ALBEDO, + SHADER_LOC_MAP_METALNESS, + SHADER_LOC_MAP_NORMAL, + SHADER_LOC_MAP_ROUGHNESS, + SHADER_LOC_MAP_OCCLUSION, + SHADER_LOC_MAP_EMISSION, + SHADER_LOC_MAP_HEIGHT, + SHADER_LOC_MAP_CUBEMAP, + SHADER_LOC_MAP_IRRADIANCE, + SHADER_LOC_MAP_PREFILTER, + SHADER_LOC_MAP_BRDF, + + SHADER_LOC_MAP_DIFFUSE = SHADER_LOC_MAP_ALBEDO, + SHADER_LOC_MAP_SPECULAR = SHADER_LOC_MAP_METALNESS, +} + +/// +/// Shader attribute data types +/// +public enum ShaderAttributeDataType +{ + SHADER_ATTRIB_FLOAT = 0, + SHADER_ATTRIB_VEC2, + SHADER_ATTRIB_VEC3, + SHADER_ATTRIB_VEC4 +} + +/// +/// Shader uniform data type +/// +public enum ShaderUniformDataType +{ + SHADER_UNIFORM_FLOAT = 0, + SHADER_UNIFORM_VEC2, + SHADER_UNIFORM_VEC3, + SHADER_UNIFORM_VEC4, + SHADER_UNIFORM_INT, + SHADER_UNIFORM_IVEC2, + SHADER_UNIFORM_IVEC3, + SHADER_UNIFORM_IVEC4, + SHADER_UNIFORM_SAMPLER2D +} + +/// +/// Shader type (generic) +/// +[StructLayout(LayoutKind.Sequential)] +public unsafe partial struct Shader { /// - /// Shader location index + /// Shader program id /// - public enum ShaderLocationIndex - { - SHADER_LOC_VERTEX_POSITION = 0, - SHADER_LOC_VERTEX_TEXCOORD01, - SHADER_LOC_VERTEX_TEXCOORD02, - SHADER_LOC_VERTEX_NORMAL, - SHADER_LOC_VERTEX_TANGENT, - SHADER_LOC_VERTEX_COLOR, - SHADER_LOC_MATRIX_MVP, - SHADER_LOC_MATRIX_VIEW, - SHADER_LOC_MATRIX_PROJECTION, - SHADER_LOC_MATRIX_MODEL, - SHADER_LOC_MATRIX_NORMAL, - SHADER_LOC_VECTOR_VIEW, - SHADER_LOC_COLOR_DIFFUSE, - SHADER_LOC_COLOR_SPECULAR, - SHADER_LOC_COLOR_AMBIENT, - SHADER_LOC_MAP_ALBEDO, - SHADER_LOC_MAP_METALNESS, - SHADER_LOC_MAP_NORMAL, - SHADER_LOC_MAP_ROUGHNESS, - SHADER_LOC_MAP_OCCLUSION, - SHADER_LOC_MAP_EMISSION, - SHADER_LOC_MAP_HEIGHT, - SHADER_LOC_MAP_CUBEMAP, - SHADER_LOC_MAP_IRRADIANCE, - SHADER_LOC_MAP_PREFILTER, - SHADER_LOC_MAP_BRDF, - - SHADER_LOC_MAP_DIFFUSE = SHADER_LOC_MAP_ALBEDO, - SHADER_LOC_MAP_SPECULAR = SHADER_LOC_MAP_METALNESS, - } + public uint Id; /// - /// Shader attribute data types + /// Shader locations array (MAX_SHADER_LOCATIONS, int *) /// - public enum ShaderAttributeDataType - { - SHADER_ATTRIB_FLOAT = 0, - SHADER_ATTRIB_VEC2, - SHADER_ATTRIB_VEC3, - SHADER_ATTRIB_VEC4 - } - - /// - /// Shader uniform data type - /// - public enum ShaderUniformDataType - { - SHADER_UNIFORM_FLOAT = 0, - SHADER_UNIFORM_VEC2, - SHADER_UNIFORM_VEC3, - SHADER_UNIFORM_VEC4, - SHADER_UNIFORM_INT, - SHADER_UNIFORM_IVEC2, - SHADER_UNIFORM_IVEC3, - SHADER_UNIFORM_IVEC4, - SHADER_UNIFORM_SAMPLER2D - } - - /// - /// Shader type (generic) - /// - [StructLayout(LayoutKind.Sequential)] - public unsafe partial struct Shader - { - /// - /// Shader program id - /// - public uint Id; - - /// - /// Shader locations array (MAX_SHADER_LOCATIONS, int *) - /// - public int* Locs; - } + public int* Locs; } diff --git a/Raylib-cs/types/Texture2D.cs b/Raylib-cs/types/Texture2D.cs index bbbcd1e..911c86a 100644 --- a/Raylib-cs/types/Texture2D.cs +++ b/Raylib-cs/types/Texture2D.cs @@ -1,137 +1,136 @@ using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Texture parameters: filter mode
+/// NOTE 1: Filtering considers mipmaps if available in the texture
+/// NOTE 2: Filter is accordingly set for minification and magnification +///
+public enum TextureFilter { /// - /// Texture parameters: filter mode
- /// NOTE 1: Filtering considers mipmaps if available in the texture
- /// NOTE 2: Filter is accordingly set for minification and magnification + /// No filter, just pixel aproximation ///
- public enum TextureFilter - { - /// - /// No filter, just pixel aproximation - /// - TEXTURE_FILTER_POINT = 0, - - /// - /// Linear filtering - /// - TEXTURE_FILTER_BILINEAR, - - /// - /// Trilinear filtering (linear with mipmaps) - /// - TEXTURE_FILTER_TRILINEAR, - - /// - /// Anisotropic filtering 4x - /// - TEXTURE_FILTER_ANISOTROPIC_4X, - - /// - /// Anisotropic filtering 8x - /// - TEXTURE_FILTER_ANISOTROPIC_8X, - - /// - /// Anisotropic filtering 16x - /// - TEXTURE_FILTER_ANISOTROPIC_16X, - } + TEXTURE_FILTER_POINT = 0, /// - /// Texture parameters: wrap mode + /// Linear filtering /// - public enum TextureWrap - { - /// - /// Repeats texture in tiled mode - /// - TEXTURE_WRAP_REPEAT = 0, - - /// - /// Clamps texture to edge pixel in tiled mode - /// - TEXTURE_WRAP_CLAMP, - - /// - /// Mirrors and repeats the texture in tiled mode - /// - TEXTURE_WRAP_MIRROR_REPEAT, - - /// - /// Mirrors and clamps to border the texture in tiled mode - /// - TEXTURE_WRAP_MIRROR_CLAMP - } + TEXTURE_FILTER_BILINEAR, /// - /// Cubemap layouts + /// Trilinear filtering (linear with mipmaps) /// - public enum CubemapLayout - { - /// - /// Automatically detect layout type - /// - CUBEMAP_LAYOUT_AUTO_DETECT = 0, - - /// - /// Layout is defined by a vertical line with faces - /// - CUBEMAP_LAYOUT_LINE_VERTICAL, - - /// - /// Layout is defined by a horizontal line with faces - /// - CUBEMAP_LAYOUT_LINE_HORIZONTAL, - - /// - /// Layout is defined by a 3x4 cross with cubemap faces - /// - CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, - - /// - /// Layout is defined by a 4x3 cross with cubemap faces - /// - CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, - - /// - /// Layout is defined by a panorama image (equirectangular map) - /// - CUBEMAP_LAYOUT_PANORAMA - } + TEXTURE_FILTER_TRILINEAR, /// - /// Texture2D type
- /// NOTE: Data stored in GPU memory + /// Anisotropic filtering 4x ///
- [StructLayout(LayoutKind.Sequential)] - public partial struct Texture2D - { - /// - /// OpenGL texture id - /// - public uint Id; + TEXTURE_FILTER_ANISOTROPIC_4X, - /// - /// Texture base width - /// - public int Width; + /// + /// Anisotropic filtering 8x + /// + TEXTURE_FILTER_ANISOTROPIC_8X, - /// - /// Texture base height - /// - public int Height; - - /// - /// Mipmap levels, 1 by default - /// - public int Mipmaps; - - /// - /// Data format (PixelFormat type) - /// - public PixelFormat Format; - } + /// + /// Anisotropic filtering 16x + /// + TEXTURE_FILTER_ANISOTROPIC_16X, +} + +/// +/// Texture parameters: wrap mode +/// +public enum TextureWrap +{ + /// + /// Repeats texture in tiled mode + /// + TEXTURE_WRAP_REPEAT = 0, + + /// + /// Clamps texture to edge pixel in tiled mode + /// + TEXTURE_WRAP_CLAMP, + + /// + /// Mirrors and repeats the texture in tiled mode + /// + TEXTURE_WRAP_MIRROR_REPEAT, + + /// + /// Mirrors and clamps to border the texture in tiled mode + /// + TEXTURE_WRAP_MIRROR_CLAMP +} + +/// +/// Cubemap layouts +/// +public enum CubemapLayout +{ + /// + /// Automatically detect layout type + /// + CUBEMAP_LAYOUT_AUTO_DETECT = 0, + + /// + /// Layout is defined by a vertical line with faces + /// + CUBEMAP_LAYOUT_LINE_VERTICAL, + + /// + /// Layout is defined by a horizontal line with faces + /// + CUBEMAP_LAYOUT_LINE_HORIZONTAL, + + /// + /// Layout is defined by a 3x4 cross with cubemap faces + /// + CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, + + /// + /// Layout is defined by a 4x3 cross with cubemap faces + /// + CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, + + /// + /// Layout is defined by a panorama image (equirectangular map) + /// + CUBEMAP_LAYOUT_PANORAMA +} + +/// +/// Texture2D type
+/// NOTE: Data stored in GPU memory +///
+[StructLayout(LayoutKind.Sequential)] +public partial struct Texture2D +{ + /// + /// OpenGL texture id + /// + public uint Id; + + /// + /// Texture base width + /// + public int Width; + + /// + /// Texture base height + /// + public int Height; + + /// + /// Mipmap levels, 1 by default + /// + public int Mipmaps; + + /// + /// Data format (PixelFormat type) + /// + public PixelFormat Format; } diff --git a/Raylib-cs/types/Transform.cs b/Raylib-cs/types/Transform.cs index b7692ce..b43a1f3 100644 --- a/Raylib-cs/types/Transform.cs +++ b/Raylib-cs/types/Transform.cs @@ -1,27 +1,26 @@ using System.Numerics; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Transform, vectex transformation data +/// +[StructLayout(LayoutKind.Sequential)] +public partial struct Transform { /// - /// Transform, vectex transformation data + /// Translation /// - [StructLayout(LayoutKind.Sequential)] - public partial struct Transform - { - /// - /// Translation - /// - public Vector3 Translation; + public Vector3 Translation; - /// - /// Rotation - /// - public Quaternion Rotation; + /// + /// Rotation + /// + public Quaternion Rotation; - /// - /// Scale - /// - public Vector3 Scale; - } + /// + /// Scale + /// + public Vector3 Scale; } diff --git a/Raylib-cs/types/native/AnsiBuffer.cs b/Raylib-cs/types/native/AnsiBuffer.cs index 529359f..e730bc2 100644 --- a/Raylib-cs/types/native/AnsiBuffer.cs +++ b/Raylib-cs/types/native/AnsiBuffer.cs @@ -1,36 +1,35 @@ using System; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Converts text to a Ansi buffer for passing to native code +/// +public readonly ref struct AnsiBuffer { - /// - /// Converts text to a Ansi buffer for passing to native code - /// - public readonly ref struct AnsiBuffer + private readonly IntPtr _data; + + public AnsiBuffer(string text) { - private readonly IntPtr _data; - - public AnsiBuffer(string text) - { - _data = Marshal.StringToHGlobalAnsi(text); - } - - public unsafe sbyte* AsPointer() - { - return (sbyte*)_data.ToPointer(); - } - - public void Dispose() - { - Marshal.FreeHGlobal(_data); - } + _data = Marshal.StringToHGlobalAnsi(text); } - public static class AnsiStringUtils + public unsafe sbyte* AsPointer() { - public static AnsiBuffer ToAnsiBuffer(this string text) - { - return new AnsiBuffer(text); - } + return (sbyte*)_data.ToPointer(); + } + + public void Dispose() + { + Marshal.FreeHGlobal(_data); + } +} + +public static class AnsiStringUtils +{ + public static AnsiBuffer ToAnsiBuffer(this string text) + { + return new AnsiBuffer(text); } } diff --git a/Raylib-cs/types/native/CBool.cs b/Raylib-cs/types/native/CBool.cs index 36964ca..93e9408 100644 --- a/Raylib-cs/types/native/CBool.cs +++ b/Raylib-cs/types/native/CBool.cs @@ -1,87 +1,89 @@ using System; using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +[StructLayout(LayoutKind.Sequential)] +public readonly struct CBool { - [StructLayout(LayoutKind.Sequential)] - public readonly struct CBool + /* The values of booleans in C++ are stored in a single byte, which means it + * only supports values from -128 to 127. It is possible to argument that + * they only support a single bit, yes, but the minimum storage unit of a + * computer is a sbyte, so that's what we'll be using when doing operations, + * which can be later implicitely cast onto any type during usage. + * + * It is wise to note that C booleans are any numeric value, but allocating an + * Int64 for every CBool instance is.. well, wildly memory-inefficient. Yes, the + * process is basically treated as a 0-cost instantiation, but it's better to rely + * on explicit motivation than to blindly trust the runtime judgement on its memory + * management. + * + * 'value' is visible and constructable (if necessary), but impossible to modify or access. + */ + public sbyte Value { - /* The values of booleans in C++ are stored in a single byte, which means it - * only supports values from -128 to 127. It is possible to argument that - * they only support a single bit, yes, but the minimum storage unit of a - * computer is a sbyte, so that's what we'll be using when doing operations, - * which can be later implicitely cast onto any type during usage. - * - * It is wise to note that C booleans are any numeric value, but allocating an - * Int64 for every CBool instance is.. well, wildly memory-inefficient. Yes, the - * process is basically treated as a 0-cost instantiation, but it's better to rely - * on explicit motivation than to blindly trust the runtime judgement on its memory - * management. - * - * 'value' is visible and constructable (if necessary), but impossible to modify or access. - */ - public sbyte Value { init; private get; } + init; private get; + } - // Constructors for easier usage. - public CBool(bool value) - { - this.Value = (sbyte)(value ? 1 : 0); - } - public CBool(Int64 value) - { - this.Value = (sbyte)(value != 0 ? 1 : 0); - } + // Constructors for easier usage. + public CBool(bool value) + { + this.Value = (sbyte)(value ? 1 : 0); + } + public CBool(Int64 value) + { + this.Value = (sbyte)(value != 0 ? 1 : 0); + } - // CBool -> Native - // Allows for arithmetic between CBools and for assignment to greater integer variables. - public static implicit operator sbyte(CBool x) - { - return x.Value; - } + // CBool -> Native + // Allows for arithmetic between CBools and for assignment to greater integer variables. + public static implicit operator sbyte(CBool x) + { + return x.Value; + } - // Allows for CBools to be implicitely assigned to a native boolean variable. - public static implicit operator bool(CBool x) - { - return x.Value != 0 ? true : false; - } + // Allows for CBools to be implicitely assigned to a native boolean variable. + public static implicit operator bool(CBool x) + { + return x.Value != 0 ? true : false; + } - // Native -> CBool - // Allows native booleans to be implicitely constructed into CBools while passing parameters. - public static implicit operator CBool(bool x) - { - return new CBool { Value = (sbyte)(x ? 1 : 0) }; - } + // Native -> CBool + // Allows native booleans to be implicitely constructed into CBools while passing parameters. + public static implicit operator CBool(bool x) + { + return new CBool { Value = (sbyte)(x ? 1 : 0) }; + } - // Same goes for integer numeric values (any value, so an Int64 is used). - public static implicit operator CBool(Int64 x) - { - return new CBool { Value = (sbyte)(x != 0 ? 1 : 0) }; - } + // Same goes for integer numeric values (any value, so an Int64 is used). + public static implicit operator CBool(Int64 x) + { + return new CBool { Value = (sbyte)(x != 0 ? 1 : 0) }; + } - /* Arithmetic overloads - * Operations between CBools and integers are already covered by the implicit - * sbyte cast. So no need to worry about those. - * - * All casts return CBool, since there is no way to know if the assignment is - * to a native boolean or integer, or a CBool. - */ + /* Arithmetic overloads + * Operations between CBools and integers are already covered by the implicit + * sbyte cast. So no need to worry about those. + * + * All casts return CBool, since there is no way to know if the assignment is + * to a native boolean or integer, or a CBool. + */ - // Addition - public static CBool operator +(CBool left, CBool right) - { - return new CBool { Value = (sbyte)(left.Value + right.Value) }; - } + // Addition + public static CBool operator +(CBool left, CBool right) + { + return new CBool { Value = (sbyte)(left.Value + right.Value) }; + } - // Subtraction - public static CBool operator -(CBool left, CBool right) - { - return new CBool { Value = (sbyte)(left.Value - right.Value) }; - } + // Subtraction + public static CBool operator -(CBool left, CBool right) + { + return new CBool { Value = (sbyte)(left.Value - right.Value) }; + } - // ToString override - public override string ToString() - { - return ((bool)this).ToString(); - } + // ToString override + public override string ToString() + { + return ((bool)this).ToString(); } } diff --git a/Raylib-cs/types/native/FilePathList.cs b/Raylib-cs/types/native/FilePathList.cs index f2497e3..b75dc1c 100644 --- a/Raylib-cs/types/native/FilePathList.cs +++ b/Raylib-cs/types/native/FilePathList.cs @@ -1,26 +1,25 @@ using System.Runtime.InteropServices; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// File path list +/// +[StructLayout(LayoutKind.Sequential)] +public unsafe struct FilePathList { /// - /// File path list + /// Filepaths max entries /// - [StructLayout(LayoutKind.Sequential)] - public unsafe struct FilePathList - { - /// - /// Filepaths max entries - /// - public uint Capacity; + public uint Capacity; - /// - /// Filepaths entries count - /// - public uint Count; + /// + /// Filepaths entries count + /// + public uint Count; - /// - /// Filepaths entries - /// - public byte** Paths; - } + /// + /// Filepaths entries + /// + public byte** Paths; } diff --git a/Raylib-cs/types/native/Utf8Buffer.cs b/Raylib-cs/types/native/Utf8Buffer.cs index 200ab75..f77bff7 100644 --- a/Raylib-cs/types/native/Utf8Buffer.cs +++ b/Raylib-cs/types/native/Utf8Buffer.cs @@ -1,63 +1,62 @@ -using System; +using System; using System.Runtime.InteropServices; using System.Text; -namespace Raylib_cs +namespace Raylib_cs; + +/// +/// Converts text to a UTF8 buffer for passing to native code +/// +public readonly ref struct Utf8Buffer { - /// - /// Converts text to a UTF8 buffer for passing to native code - /// - public readonly ref struct Utf8Buffer + private readonly IntPtr _data; + + public Utf8Buffer(string text) { - private readonly IntPtr _data; - - public Utf8Buffer(string text) - { - _data = Marshal.StringToCoTaskMemUTF8(text); - } - - public unsafe sbyte* AsPointer() - { - return (sbyte*)_data.ToPointer(); - } - - public void Dispose() - { - Marshal.ZeroFreeCoTaskMemUTF8(_data); - } + _data = Marshal.StringToCoTaskMemUTF8(text); } - public static class Utf8StringUtils + public unsafe sbyte* AsPointer() { - public static Utf8Buffer ToUtf8Buffer(this string text) - { - return new Utf8Buffer(text); - } + return (sbyte*)_data.ToPointer(); + } - public static byte[] ToUtf8String(this string text) - { - if (text == null) - { - return null; - } - - var length = Encoding.UTF8.GetByteCount(text); - - var byteArray = new byte[length + 1]; - var wrote = Encoding.UTF8.GetBytes(text, 0, text.Length, byteArray, 0); - byteArray[wrote] = 0; - - return byteArray; - } - - public static unsafe string GetUTF8String(sbyte* bytes) - { - return Marshal.PtrToStringUTF8((IntPtr)bytes); - } - - public static byte[] GetUTF8Bytes(this string text) - { - return Encoding.UTF8.GetBytes(text); - } + public void Dispose() + { + Marshal.ZeroFreeCoTaskMemUTF8(_data); + } +} + +public static class Utf8StringUtils +{ + public static Utf8Buffer ToUtf8Buffer(this string text) + { + return new Utf8Buffer(text); + } + + public static byte[] ToUtf8String(this string text) + { + if (text == null) + { + return null; + } + + var length = Encoding.UTF8.GetByteCount(text); + + var byteArray = new byte[length + 1]; + var wrote = Encoding.UTF8.GetBytes(text, 0, text.Length, byteArray, 0); + byteArray[wrote] = 0; + + return byteArray; + } + + public static unsafe string GetUTF8String(sbyte* bytes) + { + return Marshal.PtrToStringUTF8((IntPtr)bytes); + } + + public static byte[] GetUTF8Bytes(this string text) + { + return Encoding.UTF8.GetBytes(text); } }