diff --git a/Raylib-cs/Raylib.cs b/Raylib-cs/Raylib.cs index 872feb7..158e0d8 100644 --- a/Raylib-cs/Raylib.cs +++ b/Raylib-cs/Raylib.cs @@ -398,20 +398,20 @@ namespace Raylib_cs [Flags] public enum ConfigFlag { - FLAG_VSYNC_HINT = 0x00000040, // Set to try enabling V-Sync on GPU - FLAG_FULLSCREEN_MODE = 0x00000002, // Set to run program in fullscreen - FLAG_WINDOW_RESIZABLE = 0x00000004, // Set to allow resizable window + FLAG_VSYNC_HINT = 0x00000040, // Set to try enabling V-Sync on GPU + FLAG_FULLSCREEN_MODE = 0x00000002, // Set to run program in fullscreen + FLAG_WINDOW_RESIZABLE = 0x00000004, // Set to allow resizable window FLAG_WINDOW_UNDECORATED = 0x00000008, // Set to disable window decoration (frame and buttons) - FLAG_WINDOW_HIDDEN = 0x00000080, // Set to hide window - FLAG_WINDOW_MINIMIZED = 0x00000200, // Set to minimize window (iconify) - FLAG_WINDOW_MAXIMIZED = 0x00000400, // Set to maximize window (expanded to monitor) - FLAG_WINDOW_UNFOCUSED = 0x00000800, // Set to window non focused - FLAG_WINDOW_TOPMOST = 0x00001000, // Set to window always on top - FLAG_WINDOW_ALWAYS_RUN = 0x00000100, // Set to allow windows running while minimized + FLAG_WINDOW_HIDDEN = 0x00000080, // Set to hide window + FLAG_WINDOW_MINIMIZED = 0x00000200, // Set to minimize window (iconify) + FLAG_WINDOW_MAXIMIZED = 0x00000400, // Set to maximize window (expanded to monitor) + FLAG_WINDOW_UNFOCUSED = 0x00000800, // Set to window non focused + FLAG_WINDOW_TOPMOST = 0x00001000, // Set to window always on top + FLAG_WINDOW_ALWAYS_RUN = 0x00000100, // Set to allow windows running while minimized FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer - FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI - FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X - FLAG_INTERLACED_HINT = 0x00010000, // Set to try enabling interlaced video format (for V3D) + FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI + FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X + FLAG_INTERLACED_HINT = 0x00010000, // Set to try enabling interlaced video format (for V3D) } // Trace log type @@ -433,157 +433,157 @@ namespace Raylib_cs public enum KeyboardKey { // 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, + 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, + 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 + 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 buttons public enum AndroidButton { - KEY_BACK = 4, - KEY_MENU = 82, - KEY_VOLUME_UP = 24, - KEY_VOLUME_DOWN = 25 + KEY_BACK = 4, + KEY_MENU = 82, + KEY_VOLUME_UP = 24, + KEY_VOLUME_DOWN = 25 } // Mouse buttons public enum MouseButton { - MOUSE_LEFT_BUTTON = 0, - MOUSE_RIGHT_BUTTON = 1, + MOUSE_LEFT_BUTTON = 0, + MOUSE_RIGHT_BUTTON = 1, MOUSE_MIDDLE_BUTTON = 2 } // Mouse cursor types public enum MouseCursor { - MOUSE_CURSOR_DEFAULT = 0, - MOUSE_CURSOR_ARROW = 1, - MOUSE_CURSOR_IBEAM = 2, - MOUSE_CURSOR_CROSSHAIR = 3, + MOUSE_CURSOR_DEFAULT = 0, + MOUSE_CURSOR_ARROW = 1, + MOUSE_CURSOR_IBEAM = 2, + MOUSE_CURSOR_CROSSHAIR = 3, MOUSE_CURSOR_POINTING_HAND = 4, - MOUSE_CURSOR_RESIZE_EW = 5, // The horizontal resize/move arrow shape - MOUSE_CURSOR_RESIZE_NS = 6, // The vertical resize/move arrow shape - MOUSE_CURSOR_RESIZE_NWSE = 7, // The top-left to bottom-right diagonal resize/move arrow shape - MOUSE_CURSOR_RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape - MOUSE_CURSOR_RESIZE_ALL = 9, // The omni-directional resize/move cursor shape - MOUSE_CURSOR_NOT_ALLOWED = 10 // The operation-not-allowed shape + MOUSE_CURSOR_RESIZE_EW = 5, // The horizontal resize/move arrow shape + MOUSE_CURSOR_RESIZE_NS = 6, // The vertical resize/move arrow shape + MOUSE_CURSOR_RESIZE_NWSE = 7, // The top-left to bottom-right diagonal resize/move arrow shape + MOUSE_CURSOR_RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape + MOUSE_CURSOR_RESIZE_ALL = 9, // The omni-directional resize/move cursor shape + MOUSE_CURSOR_NOT_ALLOWED = 10 // The operation-not-allowed shape } // Gamepad number public enum GamepadNumber { - GAMEPAD_PLAYER1 = 0, - GAMEPAD_PLAYER2 = 1, - GAMEPAD_PLAYER3 = 2, - GAMEPAD_PLAYER4 = 3 + GAMEPAD_PLAYER1 = 0, + GAMEPAD_PLAYER2 = 1, + GAMEPAD_PLAYER3 = 2, + GAMEPAD_PLAYER4 = 3 } // Gamepad buttons @@ -689,9 +689,9 @@ namespace Raylib_cs // Material maps public enum MaterialMapType { - MAP_ALBEDO = 0, // MAP_DIFFUSE + MAP_ALBEDO = 0, // MAP_DIFFUSE MAP_METALNESS = 1, // MAP_SPECULAR - MAP_NORMAL = 2, + MAP_NORMAL = 2, MAP_ROUGHNESS = 3, MAP_OCCLUSION, MAP_EMISSION, @@ -786,17 +786,17 @@ namespace Raylib_cs [Flags] public enum GestureType { - GESTURE_NONE = 0, - GESTURE_TAP = 1, - GESTURE_DOUBLETAP = 2, - GESTURE_HOLD = 4, - GESTURE_DRAG = 8, + 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 + GESTURE_SWIPE_LEFT = 32, + GESTURE_SWIPE_UP = 64, + GESTURE_SWIPE_DOWN = 128, + GESTURE_PINCH_IN = 256, + GESTURE_PINCH_OUT = 512 } // Camera system modes @@ -1681,6 +1681,11 @@ namespace Raylib_cs [return: MarshalAs(UnmanagedType.I1)] public static extern bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); + // Check the collision between two lines defined by two points each, returns collision point by reference + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool CheckCollisionLines(Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, ref Vector2 collisionPoint); + //------------------------------------------------------------------------------------ // Texture Loading and Drawing Functions (Module: textures) //------------------------------------------------------------------------------------ diff --git a/Raylib-cs/Rlgl.cs b/Raylib-cs/Rlgl.cs index 5645e3c..ef6ee46 100644 --- a/Raylib-cs/Rlgl.cs +++ b/Raylib-cs/Rlgl.cs @@ -16,18 +16,45 @@ namespace Raylib_cs 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 FramebufferTexType + { + 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, + } + [SuppressUnmanagedCodeSecurity] public static class Rlgl { // Used by DllImport to load the native library. public const string nativeLibName = "raylib"; - public const float MAX_BATCH_ELEMENTS = 8192; - public const float MAX_BATCH_BUFFERING = 1; - public const float MAX_MATRIX_STACK_SIZE = 32; - public const float MAX_DRAWCALL_REGISTERED = 256; - public const float DEFAULT_NEAR_CULL_DISTANCE = 0.01f; - public const float DEFAULT_FAR_CULL_DISTANCE = 1000.0f; + 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 RL_CULL_DISTANCE_NEAR = 0.01f; + public const float RL_CULL_DISTANCE_FAR = 1000.0f; public const int RL_TEXTURE_WRAP_S = 0x2802; public const int RL_TEXTURE_WRAP_T = 0x2803; public const int RL_TEXTURE_MAG_FILTER = 0x2800; @@ -159,11 +186,11 @@ namespace Raylib_cs // Enable render texture (fbo) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void rlEnableRenderTexture(uint id); + public static extern void rlEnableFramebuffer(uint id); // Disable render texture (fbo), return to default framebuffer [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void rlDisableRenderTexture(); + public static extern void rlDisableFramebuffer(); // Enable depth test [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -173,6 +200,14 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void rlDisableDepthTest(); + // Enable depth write + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void rlEnableDepthMask(); + + // Disable depth write + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void rlDisableDepthMask(); + // Enable backface culling [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void rlEnableBackfaceCulling(); @@ -283,7 +318,7 @@ namespace Raylib_cs // Load texture in GPU // data refers to a void * [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern uint rlLoadTexture(IntPtr data, int width, int height, int format, int mipmapCount); + public static extern uint rlLoadTexture(IntPtr data, int width, int height, PixelFormat format, int mipmapCount); // Load depth texture/renderbuffer (to be attached to fbo) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -292,16 +327,16 @@ namespace Raylib_cs // Load texture cubemap // data refers to a void * [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern uint rlLoadTextureCubemap(IntPtr data, int size, int format); + public static extern uint rlLoadTextureCubemap(IntPtr data, int size, PixelFormat format); // Update GPU texture with new data // data refers to a const void * [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void rlUpdateTexture(uint id, int width, int height, int format, IntPtr data); + public static extern void rlUpdateTexture(uint id, int width, int height, PixelFormat format, IntPtr data); // Get OpenGL internal formats [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void rlGetGlTextureFormats(int format, ref uint glInternalFormat, ref uint glFormat, ref uint glType); + public static extern void rlGetGlTextureFormats(PixelFormat format, ref uint glInternalFormat, ref uint glFormat, ref uint glType); // Unload texture from GPU memory [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -329,7 +364,7 @@ namespace Raylib_cs // Attach texture/renderbuffer to a framebuffer [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void rlFrameBufferAttach(uint fboId, uint texId, int attachType, int texType); + public static extern void rlFrameBufferAttach(uint fboId, uint texId, FramebufferAttachType attachType, FramebufferTexType texType); // Verify framebuffer is complete [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]