diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2024-01-03 18:32:45 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-03 18:32:45 +0000 |
| commit | 5961d4b31680aa4fc628b85fb49b6f936b3b925f (patch) | |
| tree | 7c30bbb18e730ee4727218eee158eafb5d44d845 /vendor/raylib/raylib.odin | |
| parent | b59c80d6fd892b0408440e2858782a27c6b28cd1 (diff) | |
| parent | a9166f52f8dfaa6e644eaa334aa4d3e81ede968f (diff) | |
Merge pull request #2983 from perogycook/raylib5dev-2024-01
Raylib5 bindings with fixes
Diffstat (limited to 'vendor/raylib/raylib.odin')
| -rw-r--r-- | vendor/raylib/raylib.odin | 224 |
1 files changed, 152 insertions, 72 deletions
diff --git a/vendor/raylib/raylib.odin b/vendor/raylib/raylib.odin index 21d044145..6d0ac4544 100644 --- a/vendor/raylib/raylib.odin +++ b/vendor/raylib/raylib.odin @@ -1,9 +1,9 @@ /* -Package vendor:raylib implements bindings for version 4.5 of the raylib library (https://www.raylib.com/) +Package vendor:raylib implements bindings for version 5.0 of the raylib library (https://www.raylib.com/) ********************************************************************************************* * - * raylib v4.5 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) + * raylib v5.0 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) * * FEATURES: * - NO external dependencies, all required libraries included with raylib @@ -124,7 +124,7 @@ when ODIN_OS == .Windows { // multiple copies of raylib.so, but since these bindings are for // particular version of the library, I better specify it. Ideally, // though, it's best specified in terms of major (.so.4) - "linux/libraylib.so.450", + "linux/libraylib.so.500", "system:dl", "system:pthread", } @@ -139,7 +139,7 @@ when ODIN_OS == .Windows { when ODIN_ARCH == .arm64 { when RAYLIB_SHARED { foreign import lib { - "macos-arm64/libraylib.450.dylib", + "macos-arm64/libraylib.500.dylib", "system:Cocoa.framework", "system:OpenGL.framework", "system:IOKit.framework", @@ -155,7 +155,7 @@ when ODIN_OS == .Windows { } else { when RAYLIB_SHARED { foreign import lib { - "macos/libraylib.450.dylib", + "macos/libraylib.500.dylib", "system:Cocoa.framework", "system:OpenGL.framework", "system:IOKit.framework", @@ -173,7 +173,10 @@ when ODIN_OS == .Windows { foreign import lib "system:raylib" } -VERSION :: "4.5" +VERSION_MAJOR :: 5 +VERSION_MINOR :: 0 +VERSION_PATCH :: 0 +VERSION :: "5.0" PI :: 3.14159265358979323846 DEG2RAD :: PI/180.0 @@ -514,6 +517,19 @@ FilePathList :: struct { paths: [^]cstring, // Filepaths entries } +// Automation event +AutomationEvent :: struct { + frame: c.uint, // Event frame + type: c.uint, // Event type (AutomationEventType) + params: [4]c.int, // Event parameters (if required) --- +} + +// Automation event list +AutomationEventList :: struct { + capacity: c.uint, // Events max entries (MAX_AUTOMATION_EVENTS) + count: c.uint, // Events entries count + events: [^]AutomationEvent, // Events entries +} //---------------------------------------------------------------------------------- // Enumerators Definition @@ -535,6 +551,7 @@ ConfigFlag :: enum c.int { WINDOW_TRANSPARENT = 4, // Set to allow transparent framebuffer WINDOW_HIGHDPI = 13, // Set to support HighDPI WINDOW_MOUSE_PASSTHROUGH = 14, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED + BORDERLESS_WINDOWED_MODE = 15, // Set to run program in borderless windowed mode MSAA_4X_HINT = 5, // Set to try enabling MSAA 4X INTERLACED_HINT = 16, // Set to try enabling interlaced video format (for V3D) } @@ -805,6 +822,9 @@ PixelFormat :: enum c.int { UNCOMPRESSED_R32, // 32 bpp (1 channel - float) UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float) UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float) + UNCOMPRESSED_R16, // 16 bpp (1 channel - float) + UNCOMPRESSED_R16G16B16, // 16*3 bpp (3 channels - float) + UNCOMPRESSED_R16G16B16A16, // 16*4 bpp (4 channels - float) COMPRESSED_DXT1_RGB, // 4 bpp (no alpha) COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha) COMPRESSED_DXT3_RGBA, // 8 bpp @@ -869,7 +889,7 @@ BlendMode :: enum c.int { // Gestures // NOTE: It could be used as flags to enable only some gestures -Gesture :: enum c.int { +Gesture :: enum c.uint { TAP = 0, // Tap gesture DOUBLETAP = 1, // Double tap gesture HOLD = 2, // Hold gesture @@ -881,7 +901,7 @@ Gesture :: enum c.int { PINCH_IN = 8, // Pinch in gesture PINCH_OUT = 9, // Pinch out gesture } -Gestures :: distinct bit_set[Gesture; c.int] +Gestures :: distinct bit_set[Gesture; c.uint] // Camera system modes CameraMode :: enum c.int { @@ -910,8 +930,8 @@ NPatchLayout :: enum c.int { // Callbacks to hook some internal functions // WARNING: This callbacks are intended for advance users TraceLogCallback :: #type proc "c" (logLevel: TraceLogLevel, text: cstring, args: c.va_list) // Logging: Redirect trace log messages -LoadFileDataCallback :: #type proc "c"(fileName: cstring, bytesRead: ^c.uint) -> [^]u8 // FileIO: Load binary data -SaveFileDataCallback :: #type proc "c" (fileName: cstring, data: rawptr, bytesToWrite: c.uint) -> bool // FileIO: Save binary data +LoadFileDataCallback :: #type proc "c"(fileName: cstring, dataSize: ^c.int) -> [^]u8 // FileIO: Load binary data +SaveFileDataCallback :: #type proc "c" (fileName: cstring, data: rawptr, dataSize: c.int) -> bool // FileIO: Save binary data LoadFileTextCallback :: #type proc "c" (fileName: cstring) -> [^]u8 // FileIO: Load text data SaveFileTextCallback :: #type proc "c" (fileName: cstring, text: cstring) -> bool // FileIO: Save text data @@ -932,7 +952,7 @@ foreign lib { // Window-related functions InitWindow :: proc(width, height: c.int, title: cstring) --- // Initialize window and OpenGL context - WindowShouldClose :: proc() -> bool --- // Check if KEY_ESCAPE pressed or Close icon pressed + WindowShouldClose :: proc() -> bool --- // Check if application should close (KEY_ESCAPE pressed or windows close icon clicked) CloseWindow :: proc() --- // Close window and unload OpenGL context IsWindowReady :: proc() -> bool --- // Check if window has been initialized successfully IsWindowFullscreen :: proc() -> bool --- // Check if window is currently fullscreen @@ -945,17 +965,20 @@ foreign lib { SetWindowState :: proc(flags: ConfigFlags) --- // Set window configuration state using flags (only PLATFORM_DESKTOP) ClearWindowState :: proc(flags: ConfigFlags) --- // Clear window configuration state flags ToggleFullscreen :: proc() --- // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP) + ToggleBorderlessWindowed :: proc() --- // Toggle window state: borderless windowed (only PLATFORM_DESKTOP) MaximizeWindow :: proc() --- // Set window state: maximized, if resizable (only PLATFORM_DESKTOP) MinimizeWindow :: proc() --- // Set window state: minimized, if resizable (only PLATFORM_DESKTOP) RestoreWindow :: proc() --- // Set window state: not minimized/maximized (only PLATFORM_DESKTOP) SetWindowIcon :: proc(image: Image) --- // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP) SetWindowIcons :: proc(images: [^]Image, count: c.int) --- // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP) - SetWindowTitle :: proc(title: cstring) --- // Set title for window (only PLATFORM_DESKTOP) + SetWindowTitle :: proc(title: cstring) --- // Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB) SetWindowPosition :: proc(x, y: c.int) --- // Set window position on screen (only PLATFORM_DESKTOP) - SetWindowMonitor :: proc(monitor: c.int) --- // Set monitor for the current window (fullscreen mode) + SetWindowMonitor :: proc(monitor: c.int) --- // Set monitor for the current window SetWindowMinSize :: proc(width, height: c.int) --- // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) + SetWindowMaxSize :: proc(width, height: c.int) --- // Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE) SetWindowSize :: proc(width, height: c.int) --- // Set window dimensions SetWindowOpacity :: proc(opacity: f32) --- // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP) + SetWindowFocused :: proc() --- // Set window focused (only PLATFORM_DESKTOP) GetWindowHandle :: proc() -> rawptr --- // Get native window handle GetScreenWidth :: proc() -> c.int --- // Get current screen width GetScreenHeight :: proc() -> c.int --- // Get current screen height @@ -971,7 +994,7 @@ foreign lib { GetMonitorRefreshRate :: proc(monitor: c.int) -> c.int --- // Get specified monitor refresh rate GetWindowPosition :: proc() -> Vector2 --- // Get window position XY on monitor GetWindowScaleDPI :: proc() -> Vector2 --- // Get window scale DPI factor - GetMonitorName :: proc(monitor: c.int) -> cstring --- // Get the human-readable, UTF-8 encoded name of the primary monitor + GetMonitorName :: proc(monitor: c.int) -> cstring --- // Get the human-readable, UTF-8 encoded name of the specified monitor SetClipboardText :: proc(text: cstring) --- // Set clipboard text content GetClipboardText :: proc() -> cstring --- // Get clipboard text content EnableEventWaiting :: proc() --- // Enable waiting for events on EndDrawing(), no automatic event polling @@ -980,7 +1003,7 @@ foreign lib { // 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() + // By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents() // To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL SwapScreenBuffer :: proc() --- // Swap back buffer with front buffer (screen drawing) @@ -1053,21 +1076,26 @@ foreign lib { GetFrameTime :: proc() -> f32 --- // Returns time in seconds for last frame drawn (delta time) GetTime :: proc() -> f64 --- // Returns elapsed time in seconds since InitWindow() - // Misc. functions + // Random value generation functions + + SetRandomSeed :: proc(seed: c.uint) --- // Set the seed for the random number generator + GetRandomValue :: proc(min, max: c.int) -> c.int --- // Get a random value between min and max (both included) + LoadRandomSequence :: proc(count : c.uint, min, max: c.int) --- // Load random values sequence, no values repeated + UnloadRandomSequence :: proc(sequence : ^c.int) --- // Unload random values sequence - GetRandomValue :: proc(min, max: c.int) -> c.int --- // Returns a random value between min and max (both included) - SetRandomSeed :: proc(seed: c.uint) --- // Set the seed for the random number generator + // Misc. functions TakeScreenshot :: proc(fileName: cstring) --- // Takes a screenshot of current screen (filename extension defines format) SetConfigFlags :: proc(flags: ConfigFlags) --- // Setup init configuration flags (view FLAGS) + OpenURL :: proc(url: cstring) --- // Open URL with default system browser (if available) + // NOTE: Following functions implemented in module [utils] + //------------------------------------------------------------------ TraceLog :: proc(logLevel: TraceLogLevel, text: cstring, #c_vararg args: ..any) --- // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) SetTraceLogLevel :: proc(logLevel: TraceLogLevel) --- // Set the current threshold (minimum) log level MemAlloc :: proc(size: c.uint) -> rawptr --- // Internal memory allocator MemRealloc :: proc(ptr: rawptr, size: c.uint) -> rawptr --- // Internal memory reallocator MemFree :: proc(ptr: rawptr) --- // Internal memory free - OpenURL :: proc(url: cstring) --- // Open URL with default system browser (if available) - // Set custom callbacks // WARNING: Callbacks setup is intended for advance users @@ -1079,13 +1107,16 @@ foreign lib { // Files management functions - LoadFileData :: proc(fileName: cstring, bytesRead: ^c.uint) -> [^]byte --- // Load file data as byte array (read) - UnloadFileData :: proc(data: [^]byte) --- // Unload file data allocated by LoadFileData() - SaveFileData :: proc(fileName: cstring, data: rawptr, bytesToWrite: c.uint) -> bool --- // Save data to file from byte array (write), returns true on success - ExportDataAsCode :: proc(data: rawptr, size: c.uint, fileName: cstring) -> bool --- // Export data to code (.h), returns true on success - LoadFileText :: proc(fileName: cstring) -> [^]byte --- // Load text data from file (read), returns a '\0' terminated string - UnloadFileText :: proc(text: [^]byte) --- // Unload file text data allocated by LoadFileText() - SaveFileText :: proc(fileName: cstring, text: [^]byte) -> bool --- // Save text data to file (write), string must be '\0' terminated, returns true on success + LoadFileData :: proc(fileName: cstring, dataSize: ^c.int) -> [^]byte --- // Load file data as byte array (read) + UnloadFileData :: proc(data: [^]byte) --- // Unload file data allocated by LoadFileData() + SaveFileData :: proc(fileName: cstring, data: rawptr, dataSize: c.int) -> bool --- // Save data to file from byte array (write), returns true on success + ExportDataAsCode :: proc(data: rawptr, dataSize: c.int, fileName: cstring) -> bool --- // Export data to code (.h), returns true on success + LoadFileText :: proc(fileName: cstring) -> [^]byte --- // Load text data from file (read), returns a '\0' terminated string + UnloadFileText :: proc(text: [^]byte) --- // Unload file text data allocated by LoadFileText() + SaveFileText :: proc(fileName: cstring, text: [^]byte) -> bool --- // Save text data to file (write), string must be '\0' terminated, returns true on success + + // File system functions + FileExists :: proc(fileName: cstring) -> bool --- // Check if file exists DirectoryExists :: proc(dirPath: cstring) -> bool --- // Check if a directory path exists IsFileExtension :: proc(fileName, ext: cstring) -> bool --- // Check file extension (including point: .png, .wav) @@ -1096,7 +1127,7 @@ foreign lib { GetDirectoryPath :: proc(filePath: cstring) -> cstring --- // Get full path for a given fileName with path (uses static string) GetPrevDirectoryPath :: proc(dirPath: cstring) -> cstring --- // Get previous directory path for a given path (uses static string) GetWorkingDirectory :: proc() -> cstring --- // Get current working directory (uses static string) - GetApplicationDirectory :: proc() -> cstring --- // Get the directory if the running application (uses static string) + GetApplicationDirectory :: proc() -> cstring --- // Get the directory of the running application (uses static string) ChangeDirectory :: proc(dir: cstring) -> bool --- // Change working directory, return true on success IsPathFile :: proc(path: cstring) -> bool --- // Check if a given path is a file or a directory LoadDirectoryFiles :: proc(dirPath: cstring) -> FilePathList --- // Load directory filepaths @@ -1114,19 +1145,31 @@ foreign lib { EncodeDataBase64 :: proc(data: rawptr, dataSize: c.int, outputSize: ^c.int) -> [^]byte --- // Encode data to Base64 string, memory must be MemFree() DecodeDataBase64 :: proc(data: rawptr, outputSize: ^c.int) -> [^]byte --- // Decode Base64 string data, memory must be MemFree() + // Automation events functionality + + LoadAutomationEventList :: proc(fileName: cstring) -> AutomationEventList --- // Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS + UnloadAutomationEventList :: proc(list: ^AutomationEventList) --- // Unload automation events list from file + ExportAutomationEventList :: proc(list: AutomationEventList, fileName: cstring) -> bool --- // Export automation events list as text file + SetAutomationEventList :: proc(list: ^AutomationEventList) --- // Set automation event list to record to + SetAutomationEventBaseFrame :: proc(frame: c.int) --- // Set automation event internal base frame to start recording + StartAutomationEventRecording :: proc() --- // Start recording automation events (AutomationEventList must be set) + StopAutomationEventRecording :: proc() --- // Stop recording automation events + PlayAutomationEvent :: proc(event: AutomationEvent) --- // Play a recorded automation event + //------------------------------------------------------------------------------------ // Input Handling Functions (Module: core) //------------------------------------------------------------------------------------ // Input-related functions: keyboard - IsKeyPressed :: proc(key: KeyboardKey) -> bool --- // Detect if a key has been pressed once - IsKeyDown :: proc(key: KeyboardKey) -> bool --- // Detect if a key is being pressed - IsKeyReleased :: proc(key: KeyboardKey) -> bool --- // Detect if a key has been released once - IsKeyUp :: proc(key: KeyboardKey) -> bool --- // Detect if a key is NOT being pressed - SetExitKey :: proc(key: KeyboardKey) --- // Set a custom key to exit program (default is ESC) - GetKeyPressed :: proc() -> KeyboardKey --- // Get key pressed (keycode), call it multiple times for keys queued - GetCharPressed :: proc() -> rune --- // Get char pressed (unicode), call it multiple times for chars queued + IsKeyPressed :: proc(key: KeyboardKey) -> bool --- // Detect if a key has been pressed once + IsKeyPressedRepeat :: proc(key: KeyboardKey) -> bool --- // Check if a key has been pressed again (Only PLATFORM_DESKTOP) + IsKeyDown :: proc(key: KeyboardKey) -> bool --- // Detect if a key is being pressed + IsKeyReleased :: proc(key: KeyboardKey) -> bool --- // Detect if a key has been released once + IsKeyUp :: proc(key: KeyboardKey) -> bool --- // Detect if a key is NOT being pressed + GetKeyPressed :: proc() -> KeyboardKey --- // Get key pressed (keycode), call it multiple times for keys queued + GetCharPressed :: proc() -> rune --- // Get char pressed (unicode), call it multiple times for chars queued + SetExitKey :: proc(key: KeyboardKey) --- // Set a custom key to exit program (default is ESC) // Input-related functions: gamepads @@ -1146,7 +1189,12 @@ foreign lib { IsMouseButtonPressed :: proc(button: MouseButton) -> bool --- // Detect if a mouse button has been pressed once IsMouseButtonDown :: proc(button: MouseButton) -> bool --- // Detect if a mouse button is being pressed IsMouseButtonReleased :: proc(button: MouseButton) -> bool --- // Detect if a mouse button has been released once - IsMouseButtonUp :: proc(button: MouseButton) -> bool --- // Detect if a mouse button is NOT being pressed + + when VERSION != "5.0" { + #panic("IsMouseButtonUp was broken in Raylib 5.0 but should be fixed in Raylib > 5.0. Remove this panic and the when block around it and also remove the workaround version of IsMouseButtonUp just after the end of the 'foreign lib {' block.") + IsMouseButtonUp :: proc(button: MouseButton) -> bool --- + } + GetMouseX :: proc() -> c.int --- // Returns mouse position X GetMouseY :: proc() -> c.int --- // Returns mouse position Y GetMousePosition :: proc() -> Vector2 --- // Returns mouse position XY @@ -1200,18 +1248,17 @@ foreign lib { DrawPixel :: proc(posX, posY: c.int, color: Color) --- // Draw a pixel DrawPixelV :: proc(position: Vector2, color: Color) --- // Draw a pixel (Vector version) DrawLine :: proc(startPosX, startPosY, endPosX, endPosY: c.int, color: Color) --- // Draw a line - DrawLineV :: proc(startPos, endPos: Vector2, color: Color) --- // Draw a line (Vector version) - DrawLineEx :: proc(startPos, endPos: Vector2, thick: f32, color: Color) --- // Draw a line defining thickness - DrawLineBezier :: proc(startPos, endPos: Vector2, thick: f32, color: Color) --- // Draw a line using cubic-bezier curves in-out - DrawLineBezierQuad :: proc(startPos, endPos: Vector2, controlPos: Vector2, thick: f32, color: Color) --- // Draw line using quadratic bezier curves with a control point - DrawLineBezierCubic :: proc(startPos, endPos: Vector2, startControlPos, endControlPos: Vector2, thick: f32, color: Color) --- // Draw line using cubic bezier curves with 2 control points - DrawLineStrip :: proc(points: [^]Vector2, pointCount: c.int, color: Color) --- // Draw lines sequence + DrawLineV :: proc(startPos, endPos: Vector2, color: Color) --- // Draw a line (using gl lines) + DrawLineEx :: proc(startPos, endPos: Vector2, thick: f32, color: Color) --- // Draw a line (using triangles/quads) + DrawLineStrip :: proc(points: [^]Vector2, pointCount: c.int, color: Color) --- // Draw lines sequence (using gl lines) + DrawLineBezier :: proc(startPos, endPos: Vector2, thick: f32, color: Color) --- // Draw line segment cubic-bezier in-out interpolation DrawCircle :: proc(centerX, centerY: c.int, radius: f32, color: Color) --- // Draw a color-filled circle DrawCircleSector :: proc(center: Vector2, radius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw a piece of a circle DrawCircleSectorLines :: proc(center: Vector2, radius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw circle sector outline DrawCircleGradient :: proc(centerX, centerY: c.int, radius: f32, color1, color2: Color) --- // Draw a gradient-filled circle DrawCircleV :: proc(center: Vector2, radius: f32, color: Color) --- // Draw a color-filled circle (Vector version) DrawCircleLines :: proc(centerX, centerY: c.int, radius: f32, color: Color) --- // Draw circle outline + DrawCircleLinesV :: proc(center: Vector2, radius: f32, color: Color) --- // Draw circle outline (Vector version) DrawEllipse :: proc(centerX, centerY: c.int, radiusH, radiusV: f32, color: Color) --- // Draw ellipse DrawEllipseLines :: proc(centerX, centerY: c.int, radiusH, radiusV: f32, color: Color) --- // Draw ellipse outline DrawRing :: proc(center: Vector2, innerRadius, outerRadius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw ring @@ -1235,6 +1282,24 @@ foreign lib { DrawPolyLines :: proc(center: Vector2, sides: c.int, radius: f32, rotation: f32, color: Color) --- // Draw a polygon outline of n sides DrawPolyLinesEx :: proc(center: Vector2, sides: c.int, radius: f32, rotation: f32, lineThick: f32, color: Color) --- // Draw a polygon outline of n sides with extended parameters + // Splines drawing functions + DrawSplineLinear :: proc(points: [^]Vector2, pointCount: c.int, thick: f32, color: Color) --- // Draw spline: Linear, minimum 2 points + DrawSplineBasis :: proc(points: [^]Vector2, pointCount: c.int, thick: f32, color: Color) --- // Draw spline: B-Spline, minimum 4 points + DrawSplineCatmullRom :: proc(points: [^]Vector2, pointCount: c.int, thick: f32, color: Color) --- // Draw spline: Catmull-Rom, minimum 4 points + DrawSplineBezierQuadratic :: proc(points: [^]Vector2, pointCount: c.int, thick: f32, color: Color) --- // Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...] + DrawSplineBezierCubic :: proc(points: [^]Vector2, pointCount: c.int, thick: f32, color: Color) --- // Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...] + DrawSplineSegmentLinear :: proc(p1, p2: Vector2, thick: f32, color: Color) --- // Draw spline segment: Linear, 2 points + DrawSplineSegmentBasis :: proc(p1, p2, p3, p4: Vector2, thick: f32, color: Color) --- // Draw spline segment: B-Spline, 4 points + DrawSplineSegmentCatmullRom :: proc(p1, p2, p3, p4: Vector2, thick: f32, color: Color) --- // Draw spline segment: Catmull-Rom, 4 points + DrawSplineSegmentBezierQuadratic :: proc(p1, c2, p3: Vector2, thick: f32, color: Color) --- // Draw spline segment: Quadratic Bezier, 2 points, 1 control point + DrawSplineSegmentBezierCubic :: proc(p1, c2, c3, p4: Vector2, thick: f32, color: Color) --- // Draw spline segment: Cubic Bezier, 2 points, 2 control points + + // Spline segment point evaluation functions, for a given t [0.0f .. 1.0f] + GetSplinePointLinear :: proc(startPos, endPos: Vector2, t: f32) -> Vector2 --- // Get (evaluate) spline point: Linear + GetSplinePointBasis :: proc(p1, p2, p3, p4: Vector2, t: f32) -> Vector2 --- // Get (evaluate) spline point: B-Spline + GetSplinePointCatmullRom :: proc(p1, p2, p3, p4: Vector2, t: f32) -> Vector2 --- // Get (evaluate) spline point: Catmull-Rom + GetSplinePointBezierQuad :: proc(p1, c2, p3: Vector2, t: f32) -> Vector2 --- // Get (evaluate) spline point: Quadratic Bezier + GetSplinePointBezierCubic :: proc(p1, c2, c3, p4: Vector2, t: f32) -> Vector2 --- // Get (evaluate) spline point: Cubic Bezier // Basic shapes collision detection functions CheckCollisionRecs :: proc(rec1, rec2: Rectangle) -> bool --- // Check collision between two rectangles CheckCollisionCircles :: proc(center1: Vector2, radius1: f32, center2: Vector2, radius2: f32) -> bool --- // Check collision between two circles @@ -1254,6 +1319,7 @@ foreign lib { LoadImage :: proc(fileName: cstring) -> Image --- // Load image from file into CPU memory (RAM) LoadImageRaw :: proc(fileName: cstring, width, height: c.int, format: PixelFormat, headerSize: c.int) -> Image --- // Load image from RAW file data + LoadImageSvg :: proc(fileNameOrString: cstring, width, height: c.int) -> Image --- // Load image from SVG file data or string with specified size LoadImageAnim :: proc(fileName: cstring, frames: [^]c.int) -> Image --- // Load image sequence from file (frames appended to image.data) LoadImageFromMemory :: proc(fileType: cstring, fileData: rawptr, dataSize: c.int) -> Image --- // Load image from memory buffer, fileType refers to extension: i.e. '.png' LoadImageFromTexture :: proc(texture: Texture2D) -> Image --- // Load image from GPU texture data @@ -1261,14 +1327,15 @@ foreign lib { IsImageReady :: proc(image: Image) -> bool --- // Check if an image is ready UnloadImage :: proc(image: Image) --- // Unload image from CPU memory (RAM) ExportImage :: proc(image: Image, fileName: cstring) -> bool --- // Export image data to file, returns true on success + ExportImageToMemory :: proc(image: Image, fileType: cstring, fileSize: ^c.int) -> rawptr --- // Export image to memory buffer ExportImageAsCode :: proc(image: Image, fileName: cstring) -> bool --- // Export image as code file defining an array of bytes, returns true on success // Image generation functions GenImageColor :: proc(width, height: c.int, color: Color) -> Image --- // Generate image: plain color - GenImageGradientV :: proc(width, height: c.int, top, bottom: Color) -> Image --- // Generate image: vertical gradient - GenImageGradientH :: proc(width, height: c.int, left, right: Color) -> Image --- // Generate image: horizontal gradient + GenImageGradientLinear :: proc(width, height, direction: c.int, start, end: Color) -> Image --- // Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient GenImageGradientRadial :: proc(width, height: c.int, density: f32, inner, outer: Color) -> Image --- // Generate image: radial gradient + GenImageGradientSquare :: proc(width, height: c.int, density: f32, inner, outer: Color) -> Image --- // Generate image: square gradient GenImageChecked :: proc(width, height: c.int, checksX, checksY: c.int, col1, col2: Color) -> Image --- // Generate image: checked GenImageWhiteNoise :: proc(width, height: c.int, factor: f32) -> Image --- // Generate image: white noise GenImagePerlinNoise :: proc(width, height: c.int, offsetX, offsetY: c.int, scale: f32) -> Image --- // Generate image: perlin noise @@ -1296,6 +1363,7 @@ foreign lib { ImageDither :: proc(image: ^Image, rBpp, gBpp, bBpp, aBpp: c.int) --- // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) ImageFlipVertical :: proc(image: ^Image) --- // Flip image vertically ImageFlipHorizontal :: proc(image: ^Image) --- // Flip image horizontally + ImageRotate :: proc(image: ^Image, degrees: c.int) --- // Rotate image by input angle in degrees( -359 to 359) ImageRotateCW :: proc(image: ^Image) --- // Rotate image clockwise 90deg ImageRotateCCW :: proc(image: ^Image) --- // Rotate image counter-clockwise 90deg ImageColorTint :: proc(image: ^Image, color: Color) --- // Modify image color: tint @@ -1386,34 +1454,35 @@ foreign lib { // Font loading/unloading functions - GetFontDefault :: proc() -> Font --- // Get the default Font - LoadFont :: proc(fileName: cstring) -> Font --- // Load font from file into GPU memory (VRAM) - LoadFontEx :: proc(fileName: cstring, fontSize: c.int, fontChars: [^]rune, glyphCount: c.int) -> Font --- // Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load the default character set - LoadFontFromImage :: proc(image: Image, key: Color, firstChar: rune) -> Font --- // Load font from Image (XNA style) - LoadFontFromMemory :: proc(fileType: cstring, fileData: rawptr, dataSize: c.int, fontSize: c.int, fontChars: [^]rune, glyphCount: c.int) -> Font --- // Load font from memory buffer, fileType refers to extension: i.e. '.ttf' - IsFontReady :: proc(font: Font) -> bool --- // Check if a font is ready - LoadFontData :: proc(fileData: rawptr, dataSize: c.int, fontSize: c.int, fontChars: [^]rune, glyphCount: c.int, type: FontType) -> [^]GlyphInfo --- // Load font data for further use - GenImageFontAtlas :: proc(chars: [^]GlyphInfo, recs: ^[^]Rectangle, glyphCount: c.int, fontSize: c.int, padding: c.int, packMethod: c.int) -> Image --- // Generate image font atlas using chars info - UnloadFontData :: proc(chars: [^]GlyphInfo, glyphCount: c.int) --- // Unload font chars info data (RAM) - UnloadFont :: proc(font: Font) --- // Unload font from GPU memory (VRAM) - ExportFontAsCode :: proc(font: Font, fileName: cstring) -> bool --- // Export font as code file, returns true on success + GetFontDefault :: proc() -> Font --- // Get the default Font + LoadFont :: proc(fileName: cstring) -> Font --- // Load font from file into GPU memory (VRAM) + LoadFontEx :: proc(fileName: cstring, fontSize: c.int, codepoints: [^]rune, codepointCount: c.int) -> Font --- // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set + LoadFontFromImage :: proc(image: Image, key: Color, firstChar: rune) -> Font --- // Load font from Image (XNA style) + LoadFontFromMemory :: proc(fileType: cstring, fileData: rawptr, dataSize: c.int, fontSize: c.int, codepoints: [^]rune, codepointCount: c.int) -> Font --- // Load font from memory buffer, fileType refers to extension: i.e. '.ttf' + IsFontReady :: proc(font: Font) -> bool --- // Check if a font is ready + LoadFontData :: proc(fileData: rawptr, dataSize: c.int, fontSize: c.int, codepoints: [^]rune, codepointCount: c.int, type: FontType) -> [^]GlyphInfo --- // Load font data for further use + GenImageFontAtlas :: proc(glyphs: [^]GlyphInfo, glyphRecs: ^[^]Rectangle, codepointCount: c.int, fontSize: c.int, padding: c.int, packMethod: c.int) -> Image --- // Generate image font atlas using chars info + UnloadFontData :: proc(glyphs: [^]GlyphInfo, glyphCount: c.int) --- // Unload font chars info data (RAM) + UnloadFont :: proc(font: Font) --- // Unload font from GPU memory (VRAM) + ExportFontAsCode :: proc(font: Font, fileName: cstring) -> bool --- // Export font as code file, returns true on success // Text drawing functions - DrawFPS :: proc(posX, posY: c.int) --- // Draw current FPS - DrawText :: proc(text: cstring, posX, posY: c.int, fontSize: c.int, color: Color) --- // Draw text (using default font) - DrawTextEx :: proc(font: Font, text: cstring, position: Vector2, fontSize: f32, spacing: f32, tint: Color) --- // Draw text using font and additional parameters - DrawTextPro :: proc(font: Font, text: cstring, position, origin: Vector2, rotation: f32, fontSize: f32, spacing: f32, tint: Color) --- // Draw text using Font and pro parameters (rotation) - DrawTextCodepoint :: proc(font: Font, codepoint: rune, position: Vector2, fontSize: f32, tint: Color) --- // Draw one character (codepoint) - DrawTextCodepoints :: proc(font: Font, codepoints: [^]rune, count: c.int, position: Vector2, fontSize: f32, spacing: f32, tint: Color) --- // Draw multiple character (codepoint) + DrawFPS :: proc(posX, posY: c.int) --- // Draw current FPS + DrawText :: proc(text: cstring, posX, posY: c.int, fontSize: c.int, color: Color) --- // Draw text (using default font) + DrawTextEx :: proc(font: Font, text: cstring, position: Vector2, fontSize: f32, spacing: f32, tint: Color) --- // Draw text using font and additional parameters + DrawTextPro :: proc(font: Font, text: cstring, position, origin: Vector2, rotation: f32, fontSize: f32, spacing: f32, tint: Color) --- // Draw text using Font and pro parameters (rotation) + DrawTextCodepoint :: proc(font: Font, codepoint: rune, position: Vector2, fontSize: f32, tint: Color) --- // Draw one character (codepoint) + DrawTextCodepoints :: proc(font: Font, codepoints: [^]rune, codepointCount: c.int, position: Vector2, fontSize: f32, spacing: f32, tint: Color) --- // Draw multiple character (codepoint) // Text font info functions - MeasureText :: proc(text: cstring, fontSize: c.int) -> c.int --- // Measure string width for default font - MeasureTextEx :: proc(font: Font, text: cstring, fontSize: f32, spacing: f32) -> Vector2 --- // Measure string size for Font - GetGlyphIndex :: proc(font: Font, codepoint: rune) -> c.int --- // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found - GetGlyphInfo :: proc(font: Font, codepoint: rune) -> GlyphInfo --- // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found - GetGlyphAtlasRec :: proc(font: Font, codepoint: rune) -> Rectangle --- // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found + SetTextLineSpacing :: proc(spacing: c.int) --- // Set vertical line spacing when drawing with line-breaks + MeasureText :: proc(text: cstring, fontSize: c.int) -> c.int --- // Measure string width for default font + MeasureTextEx :: proc(font: Font, text: cstring, fontSize: f32, spacing: f32) -> Vector2 --- // Measure string size for Font + GetGlyphIndex :: proc(font: Font, codepoint: rune) -> c.int --- // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found + GetGlyphInfo :: proc(font: Font, codepoint: rune) -> GlyphInfo --- // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found + GetGlyphAtlasRec :: proc(font: Font, codepoint: rune) -> Rectangle --- // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found // Text codepoints management functions (unicode characters) @@ -1536,10 +1605,10 @@ foreign lib { // Model animations loading/unloading functions - LoadModelAnimations :: proc(fileName: cstring, animCount: ^c.uint) -> [^]ModelAnimation --- // Load model animations from file + LoadModelAnimations :: proc(fileName: cstring, animCount: ^c.int) -> [^]ModelAnimation --- // Load model animations from file UpdateModelAnimation :: proc(model: Model, anim: ModelAnimation, frame: c.int) --- // Update model animation pose UnloadModelAnimation :: proc(anim: ModelAnimation) --- // Unload animation data - UnloadModelAnimations :: proc(animations: [^]ModelAnimation, count: c.uint) --- // Unload animation array data + UnloadModelAnimations :: proc(animations: [^]ModelAnimation, animCount: c.int) --- // Unload animation array data IsModelAnimationValid :: proc(model: Model, anim: ModelAnimation) -> bool --- // Check model animation skeleton match // Collision detection functions @@ -1563,6 +1632,7 @@ foreign lib { CloseAudioDevice :: proc() --- // Close the audio device and context IsAudioDeviceReady :: proc() -> bool --- // Check if audio device has been initialized successfully SetMasterVolume :: proc(volume: f32) --- // Set master volume (listener) + GetMasterVolume :: proc() -> f32 --- // Get master volume (listener) // Wave/Sound loading/unloading functions @@ -1571,10 +1641,12 @@ foreign lib { IsWaveReady :: proc(wave: Wave) -> bool --- // Checks if wave data is ready LoadSound :: proc(fileName: cstring) -> Sound --- // Load sound from file LoadSoundFromWave :: proc(wave: Wave) -> Sound --- // Load sound from wave data + LoadSoundAlias :: proc(source: Sound) -> Sound --- // Create a new sound that shares the same sample data as the source sound, does not own the sound data IsSoundReady :: proc(sound: Sound) -> bool --- // Checks if a sound is ready - UpdateSound :: proc(sound: Sound, data: rawptr, sampleCount: c.int) --- // Update sound buffer with new data + UpdateSound :: proc(sound: Sound, data: rawptr, frameCount: c.int) --- // Update sound buffer with new data UnloadWave :: proc(wave: Wave) --- // Unload wave data UnloadSound :: proc(sound: Sound) --- // Unload sound + UnloadSoundAlias :: proc(alias: Sound) --- // Unload a sound alias (does not deallocate sample data) ExportWave :: proc(wave: Wave, fileName: cstring) -> bool --- // Export wave data to file, returns true on success ExportWaveAsCode :: proc(wave: Wave, fileName: cstring) -> bool --- // Export wave sample data to code (.h), returns true on success @@ -1594,6 +1666,7 @@ foreign lib { LoadWaveSamples :: proc(wave: Wave) -> [^]f32 --- // Load samples data from wave as a 32bit float data array UnloadWaveSamples :: proc(samples: [^]f32) --- // Unload samples data loaded with LoadWaveSamples() + // Music management functions LoadMusicStream :: proc(fileName: cstring) -> Music --- // Load music stream from file @@ -1631,14 +1704,21 @@ foreign lib { SetAudioStreamBufferSizeDefault :: proc(size: c.int) --- // Default size for new audio streams SetAudioStreamCallback :: proc(stream: AudioStream, callback: AudioCallback) --- // Audio thread callback to request new data - AttachAudioStreamProcessor :: proc(stream: AudioStream, processor: AudioCallback) --- // Attach audio stream processor to stream + AttachAudioStreamProcessor :: proc(stream: AudioStream, processor: AudioCallback) --- // Attach audio stream processor to stream, receives the samples as <float>s DetachAudioStreamProcessor :: proc(stream: AudioStream, processor: AudioCallback) --- // Detach audio stream processor from stream - AttachAudioMixedProcessor :: proc(processor: AudioCallback) --- // Attach audio stream processor to the entire audio pipeline + AttachAudioMixedProcessor :: proc(processor: AudioCallback) --- // Attach audio stream processor to the entire audio pipeline, receives the samples as <float>s DetachAudioMixedProcessor :: proc(processor: AudioCallback) --- // Detach audio stream processor from the entire audio pipeline } - +// Workaround for broken IsMouseButtonUp in Raylib 5.0. +when VERSION == "5.0" { + IsMouseButtonUp :: proc(button: MouseButton) -> bool { + return !IsMouseButtonDown(button) + } +} else { + #panic("Remove this this when block and everything inside it for Raylib > 5.0. It's just here to fix a bug in Raylib 5.0. See IsMouseButtonUp inside 'foreign lib {' block.") +} // Text formatting with variables (sprintf style) TextFormat :: proc(text: cstring, args: ..any) -> cstring { |