1 module bindbc.raylib.bind.core; 2 3 import bindbc.raylib.config; 4 import bindbc.raylib.types; 5 6 version (BindRaylib_Static) { 7 extern (C) @nogc nothrow { 8 } 9 } else { 10 extern (C) @nogc nothrow { 11 /** 12 * Initialize window and OpenGL context 13 */ 14 alias pInitWindow = void function(int width, int height, const(char)* title); 15 /** 16 * Check if KEY_ESCAPE pressed or Close icon pressed 17 */ 18 alias pWindowShouldClose = bool function(); 19 /** 20 * Close window and unload OpenGL context 21 */ 22 alias pCloseWindow = void function(); 23 24 /** 25 * Check if window has been initialized successfully 26 */ 27 alias pIsWindowReady = bool function(); 28 /** 29 * Check if window has been minimized (or lost focus) 30 */ 31 alias pIsWindowMinimized = bool function(); 32 /** 33 * Check if window has been resized 34 */ 35 alias pIsWindowResized = bool function(); 36 /** 37 * Check if window is currently hidden 38 */ 39 alias pIsWindowHidden = bool function(); 40 /** 41 * Check if window is currently fullscreen 42 */ 43 alias pIsWindowFullScreen = bool function(); 44 45 46 47 48 /** 49 * Toggle fullscreen mode (only PLATFORM_DESKTOP) 50 */ 51 alias pToggleFullscreen = void function(); 52 /** 53 * Show the window 54 */ 55 alias pUnhideWindow = void function(); 56 /** 57 * Hide the window 58 */ 59 alias pHideWindow = void function(); 60 /** 61 * Set icon for window (only PLATFORM_DESKTOP) 62 */ 63 alias pSetWindowIcon = void function(Image image); 64 /** 65 * Set title for window (only PLATFORM_DESKTOP) 66 */ 67 alias pSetWindowTitle = void function(const(char)* title); 68 /** 69 * Set window position on screen (only PLATFORM_DESKTOP) 70 */ 71 alias pSetWindowPosition = void function(int x, int y); 72 /** 73 * Set monitor for the current window (fullscreen mode) 74 */ 75 alias pSetWindowMonitor = void function(int monitor); 76 /** 77 * Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) 78 */ 79 alias pSetWindowMinSize = void function(int width, int height); 80 /** 81 * Set window dimensions 82 */ 83 alias pSetWindowSize = void function(int width, int height); 84 /** 85 * Get native window handle 86 */ 87 alias pGetWindowHandle = void* function(); 88 /** 89 * Get current screen width 90 */ 91 alias pGetScreenWidth = int function(); 92 /** 93 * Get current screen height 94 */ 95 alias pGetScreenHeight = int function(); 96 /** 97 * Get number of connected monitors 98 */ 99 alias pGetMonitorCount = int function(); 100 /** 101 * Get primary monitor width 102 */ 103 alias pGetMonitorWidth = int function(int monitor); 104 /** 105 * Get primary monitor height 106 */ 107 alias pGetMonitorHeight = int function(int monitor); 108 /** 109 * Get primary monitor physical width in millimetres 110 */ 111 alias pGetMonitorPhysicalWidth = int function(int monitor); 112 /** 113 * Get primary monitor physical height in millimetres 114 */ 115 alias pGetMonitorPhysicalHeight = int function(int monitor); 116 /** 117 * Get window position XY on monitor 118 */ 119 alias pGetWindowPosition = Vector2 function(); 120 /** 121 * Get the human-readable, UTF-8 encoded name of the primary monitor 122 */ 123 alias pGetMonitorName = const(char)* function(int monitor); 124 /** 125 * Get clipboard text content 126 */ 127 alias pGetClipboardText = const(char)* function(); 128 /** 129 * Set clipboard text content 130 */ 131 alias pSetClipboardText = void function(const(char)* text); 132 133 /** 134 * Shows cursor 135 */ 136 alias pShowCursor = void function(); 137 /** 138 * Hides cursor 139 */ 140 alias pHideCursor = void function(); 141 /** 142 * Check if cursor is not visible 143 */ 144 alias pIsCursorHidden = bool function(); 145 /** 146 * Enables cursor (unlock cursor) 147 */ 148 alias pEnableCursor = void function(); 149 /** 150 * Disables cursor (lock cursor) 151 */ 152 alias pDisableCursor = void function(); 153 154 /** 155 * Set background color (framebuffer clear color) 156 */ 157 alias pClearBackground = void function(Color color); 158 /** 159 * Setup canvas (framebuffer) to start drawing 160 */ 161 alias pBeginDrawing = void function(); 162 /** 163 * End canvas drawing and swap buffers (double buffering) 164 */ 165 alias pEndDrawing = void function(); 166 /** 167 * Initialize 2D mode with custom camera (2D) 168 */ 169 alias pBeginMode2D = void function(Camera2D camera); 170 /** 171 * Ends 2D mode with custom camera 172 */ 173 alias pEndMode2D = void function(); 174 /** 175 * Initializes 3D mode with custom camera (3D) 176 */ 177 alias pBeginMode3D = void function(Camera3D camera); 178 /** 179 * Ends 3D mode and returns to default 2D orthographic mode 180 */ 181 alias pEndMode3D = void function(); 182 /** 183 * Initializes render texture for drawing 184 */ 185 alias pBeginTextureMode = void function(RenderTexture2D target); 186 /** 187 * Ends drawing to render texture 188 */ 189 alias pEndTextureMode = void function(); 190 /** 191 * Begin scissor mode (define screen area for following drawing) 192 */ 193 alias pBeginScissorMode = void function(int x, int y, int width, int height); 194 /** 195 * End scissor mode 196 */ 197 alias pEndScissorMode = void function(); 198 /** 199 * Returns a ray trace from mouse position 200 */ 201 alias pGetMouseRay = Ray function(Vector2 mousePosition, Camera camera); 202 /** 203 * Returns camera transform matrix (view matrix) 204 */ 205 alias pGetCameraMatrix = Matrix function(Camera camera); 206 /** 207 * Returns camera 2d transform matrix 208 */ 209 alias pGetCameraMatrix2D = Matrix function(Camera2D camera); 210 /** 211 * Returns the screen space position for a 3d world space position 212 */ 213 alias pGetWorldToScreen = Vector2 function(Vector3 position, Camera camera); 214 /** 215 * Returns size position for a 3d world space position 216 */ 217 alias pGetWorldToScreenEx = Vector2 function(Vector3 position, Camera camera, int width, int height); 218 /** 219 * Returns the screen space position for a 2d camera world space position 220 */ 221 alias pGetWorldToScreen2D = Vector2 function(Vector2 position, Camera2D camera); 222 /** 223 * Returns the world space position for a 2d camera screen space position 224 */ 225 alias pGetScreenToWorld2D = Vector2 function(Vector2 position, Camera2D camera); 226 227 /** 228 * Set target FPS (maximum) 229 */ 230 alias pSetTargetFPS = void function(int fps); 231 /** 232 * Returns current FPS 233 */ 234 alias pGetFPS = int function(); 235 /** 236 * Returns time in seconds for last frame drawn 237 */ 238 alias pGetFrameTime = float function(); 239 /** 240 * Returns elapsed time in seconds since InitWindow() 241 */ 242 alias pGetTime = double function(); 243 244 /** 245 * Returns hexadecimal value for a Color 246 */ 247 alias pColorToInt = int function(Color color); 248 /** 249 * Returns color normalized as float [0..1] 250 */ 251 alias pColorNormalize = Vector4 function(Color color); 252 /** 253 * Returns color from normalized values [0..1] 254 */ 255 alias pColorFromNormalized = Color function(Vector4 normalized); 256 /** 257 * Returns HSV values for a Color 258 */ 259 alias pColorToHSV = Vector3 function(Color color); 260 /** 261 * Returns a Color from HSV values 262 */ 263 alias pColorFromHSV = Color function(Vector3 hsv); 264 /** 265 * Returns a Color struct from hexadecimal value 266 */ 267 alias pGetColor = Color function(int hexValue); 268 /** 269 * Color fade-in or fade-out, alpha goes from 0.0f to 1.0f 270 */ 271 alias pFade = Color function(Color color, float alpha); 272 273 /** 274 * Setup window configuration flags (view FLAGS) 275 */ 276 alias pSetConfigFlags = void function(uint flags); 277 /** 278 * Takes a screenshot of current screen (saved a .png) 279 */ 280 alias pTakeScreenshot = void function(const(char)* fileName); 281 282 // Files management functions 283 // Use D func! 284 285 /** 286 * Check if file exists 287 */ 288 alias pFileExists = bool function(const(char)* fileName); 289 /** 290 * Check file extension 291 */ 292 alias pIsFileExtension = bool function(const(char)* fileName, const(char)* ext); 293 /** 294 * Check if a directory path exists 295 */ 296 alias pDirectoryExists = bool function(const(char)* dirPath); 297 /** 298 * Get pointer to extension for a filename string 299 */ 300 alias pGetExtension = const(char)* function(const(char)* fileName); 301 /** 302 * Get pointer to filename for a path string 303 */ 304 alias pGetFileName = const(char)* function(const(char)* filePath); 305 /** 306 * Get filename string without extension (uses static string) 307 */ 308 alias pGetFileNameWithoutExt = const(char)* function(const(char)* filePath); 309 /** 310 * Get full path for a given fileName with path (uses static string) 311 */ 312 alias pGetDirectoryPath = const(char)* function(const(char)* filePath); 313 /** 314 * Get previous directory path for a given path (uses static string) 315 */ 316 alias pGetPrevDirectoryPath = const(char)* function(const(char)* dirPath); 317 /** 318 * Get current working directory (uses static string) 319 */ 320 alias pGetWorkingDirectory = const(char)* function(); 321 /** 322 * Get filenames in a directory path (memory should be freed) 323 */ 324 alias pGetDirectoryFiles = char* function(const(char)* dirPath, int* count); 325 /** 326 * Clear directory files paths buffers (free memory) 327 */ 328 alias pClearDirectoryFiles = void function(); 329 /** 330 * Change working directory, returns true if success 331 */ 332 alias pChangeDirectory = bool function(const(char)* dir); 333 /** 334 * Check if a file has been dropped into window 335 */ 336 alias pIsFileDropped = bool function(); 337 /** 338 * Get dropped files names (memory should be freed) 339 */ 340 alias pGetDroppedFiles = char** function(int* count); 341 /** 342 * Clear dropped files paths buffer (free memory) 343 */ 344 alias pClearDroppedFiles = void function(); 345 /** 346 * Get file modification time (last write time)/ 347 */ 348 alias pGetFileModTime = long function(const(char)* fileName); 349 350 //------------------------------------------------------------------------------------ 351 // Input Handling Functions 352 //------------------------------------------------------------------------------------ 353 354 /** 355 * Detect if a key has been pressed once 356 */ 357 alias pIsKeyPressed = bool function(int key); 358 /** 359 * Detect if a key is being pressed 360 */ 361 alias pIsKeyDown = bool function(int key); 362 /** 363 * Detect if a key has been released once 364 */ 365 alias pIsKeyReleased = bool function(int key); 366 /** 367 * Detect if a key is NOT being pressed 368 */ 369 alias pIsKeyUp = bool function(int key); 370 /** 371 * Get latest key pressed 372 */ 373 alias pGetKeyPressed = int function(); 374 /** 375 * Set a custom key to exit program (default is ESC) 376 */ 377 alias pSetExitKey = void function(int key); 378 379 // Input-related functions: gamepads 380 /** 381 * Detect if a gamepad is available 382 */ 383 alias pIsGamepadAvailable = bool function(int gamepad); 384 /** 385 * Check gamepad name (if available) 386 */ 387 alias pIsGamepadName = bool function(int gamepad, const(char)* name); 388 /** 389 * Return gamepad internal name id 390 */ 391 alias pGetNamepadName = const(char)* function(int gamepad); 392 /** 393 * Detect if a gamepad button has been pressed once 394 */ 395 alias pIsGamepadButtonPressed = bool function(int gamepad, int button); 396 /** 397 * Detect if a gamepad button is being pressed 398 */ 399 alias pIsGamepadButtonDown = bool function(int gamepad, int button); 400 /** 401 * Detect if a gamepad button has been released once 402 */ 403 alias pIsGamepadButtonReleased = bool function(int gamepad, int button); 404 /** 405 * Detect if a gamepad button is NOT being pressed 406 */ 407 alias pIsGamepadButtonUp = bool function(int gamepad, int button); 408 /** 409 * Get the last gamepad button pressed 410 */ 411 alias pGetGamepadButtonPressed = int function(); 412 /** 413 * Return gamepad axis count for a gamepad 414 */ 415 alias pGetGamepadAxisCount = int function(int gamepad); 416 /** 417 * Return axis movement value for a gamepad axis 418 */ 419 alias pGetGamepadAxisMovement = float function(int gamepad, int axis); 420 421 // Input-related functions: mouse 422 /** 423 * Detect if a mouse button has been pressed once 424 */ 425 alias pIsMouseButtonPressed = bool function(int button); 426 /** 427 * Detect if a mouse button is being pressed 428 */ 429 alias pIsMouseButtonDown = bool function(int button); 430 /** 431 * Detect if a mouse button has been released once 432 */ 433 alias pIsMouseButtonReleased = bool function(int button); 434 /** 435 * Detect if a mouse button is NOT being pressed 436 */ 437 alias pIsMouseButtonUp = bool function(int button); 438 /** 439 * Returns mouse position X 440 */ 441 alias pGetMouseX = int function(); 442 /** 443 * Returns mouse position Y 444 */ 445 alias pGetMouseY = int function(); 446 /** 447 * Returns mouse position XY 448 */ 449 alias pGetMousePosition = Vector2 function(); 450 /** 451 * Set mouse position XY 452 */ 453 alias pSetMousePosition = void function(int x, int y); 454 /** 455 * Set mouse offset 456 */ 457 alias pSetMouseOffset = void function(int offsetX, int offsetY); 458 /** 459 * Set mouse scaling 460 */ 461 alias pSetMouseScale = void function(float scaleX, float scaleY); 462 /** 463 * Returns mouse wheel movement Y 464 */ 465 alias pGetMouseWheelMove = int function(); 466 467 // Input-related functions: touch 468 /** 469 * Returns touch position X for touch point 0 (relative to screen size) 470 */ 471 alias pGetTouchX = int function(); 472 /** 473 * Returns touch position Y for touch point 0 (relative to screen size) 474 */ 475 alias pGetTouchY = int function(); 476 /** 477 * Returns touch position XY for a touch point index (relative to screen size) 478 */ 479 alias pGetTouchPosition = Vector2 function(int index); 480 481 //------------------------------------------------------------------------------------ 482 // Gestures and Touch Handling Functions (Module: gestures) 483 //------------------------------------------------------------------------------------ 484 /** 485 * Enable a set of gestures using flags 486 */ 487 alias pSetGesturesEnabled = void function(uint gestureFlags); 488 /** 489 * Check if a gesture have been detected 490 */ 491 alias pIsGestureDetected = bool function(int gesture); 492 /** 493 * Get latest detected gesture 494 */ 495 alias pGetGestureDetected = int function(); 496 /** 497 * Get touch points count 498 */ 499 alias pGetTouchPointsCount = int function(); 500 /** 501 * Get gesture hold time in milliseconds 502 */ 503 alias pGetGestureHoldDuration = float function(); 504 /** 505 * Get gesture drag vector 506 */ 507 alias pGetGestureDragVector = Vector2 function(); 508 /** 509 * Get gesture drag angle 510 */ 511 alias pGetGestureDragAngle = float function(); 512 /** 513 * Get gesture pinch delta 514 */ 515 alias pGetGesturePinchVector = Vector2 function(); 516 /** 517 * Get gesture pinch angle 518 */ 519 alias pGetGesturePinchAngle = float function(); 520 521 //------------------------------------------------------------------------------------ 522 // Camera System Functions (Module: camera) 523 //------------------------------------------------------------------------------------ 524 /** 525 * Set camera mode (multiple camera modes available) 526 */ 527 alias pSetCameraMode = void function(Camera camera, int mode); 528 /** 529 * Update camera position for selected mode 530 */ 531 alias pUpdateCamera = void function(Camera* camera); 532 /** 533 * Set camera pan key to combine with mouse movement (free camera) 534 */ 535 alias pSetCameraPanControl = void function(int panKey); 536 /** 537 * Set camera alt key to combine with mouse movement (free camera) 538 */ 539 alias pSetCameraAltControl = void function(int altKey); 540 /** 541 * Set camera smooth zoom key to combine with mouse (free camera) 542 */ 543 alias pSetCameraSmoothZoomControl = void function(int szKey); 544 /** 545 * Set camera move controls (1st person and 3rd person cameras) 546 */ 547 alias pSetCameraMoveControls = void function(int frontKey, int backKey, int rightKey, int leftKey, int upKey, int downKey); 548 } 549 550 __gshared { 551 pInitWindow InitWindow; 552 pWindowShouldClose WindowShouldClose; 553 pCloseWindow CloseWindow; 554 pIsWindowReady IsWindowReady; 555 pIsWindowMinimized IsWindowMinimized; 556 pIsWindowResized IsWindowResized; 557 pIsWindowHidden IsWindowHidden; 558 pIsWindowFullScreen IsWindowFullscreen; 559 pToggleFullscreen ToggleFullscreen; 560 pUnhideWindow UnhideWindow; 561 pHideWindow HideWindow; 562 pSetWindowIcon SetWindowIcon; 563 pSetWindowTitle SetWindowTitle; 564 pSetWindowPosition SetWindowPosition; 565 pSetWindowMonitor SetWindowMonitor; 566 pSetWindowMinSize SetWindowMinSize; 567 pSetWindowSize SetWindowSize; 568 pGetWindowHandle GetWindowHandle; 569 pGetScreenWidth GetScreenWidth; 570 pGetScreenHeight GetScreenHeight; 571 pGetMonitorCount GetMonitorCount; 572 pGetMonitorWidth GetMonitorWidth; 573 pGetMonitorHeight GetMonitorHeight; 574 pGetMonitorPhysicalWidth GetMonitorPhysicalWidth; 575 pGetMonitorPhysicalHeight GetMonitorPhysicalHeight; 576 pGetWindowPosition GetWindowPosition; 577 pGetMonitorName GetMonitorName; 578 pGetClipboardText GetClipboardText; 579 pSetClipboardText SetClipboardText; 580 pShowCursor ShowCursor; 581 pHideCursor HideCursor; 582 pIsCursorHidden IsCursorHidden; 583 pEnableCursor EnableCursor; 584 pDisableCursor DisableCursor; 585 586 pClearBackground ClearBackground; 587 pBeginDrawing BeginDrawing; 588 pEndDrawing EndDrawing; 589 pBeginMode2D BeginMode2D; 590 pEndMode2D EndMode2D; 591 pBeginMode3D BeginMode3D; 592 pEndMode3D EndMode3D; 593 pBeginTextureMode BeginTextureMode; 594 pEndTextureMode EndTextureMode; 595 pBeginScissorMode BeginScissorMode; 596 pEndScissorMode EndScissorMode; 597 598 pGetMouseRay GetMouseRay; 599 pGetCameraMatrix GetCameraMatrix; 600 pGetCameraMatrix2D GetCameraMatrix2D; 601 pGetWorldToScreen GetWorldToScreen; 602 pGetWorldToScreenEx GetWorldToScreenEx; 603 pGetWorldToScreen2D GetWorldToScreen2D; 604 pGetScreenToWorld2D GetScreenToWorld2D; 605 606 pSetTargetFPS SetTargetFPS; 607 pGetFPS GetFPS; 608 pGetFrameTime GetFrameTime; 609 pGetTime GetTime; 610 611 pColorToInt ColorToInt; 612 pColorNormalize ColorNormalize; 613 pColorFromNormalized ColorFromNormalized; 614 pColorToHSV ColorToHSV; 615 pColorFromHSV ColorFromHSV; 616 pGetColor GetColor; 617 pFade Fade; 618 619 // Misc. functions 620 pSetConfigFlags SetConfigFlags; 621 pTakeScreenshot TakeScreenshot; 622 623 pFileExists FileExists; 624 pIsFileExtension IsFileExtension; 625 pDirectoryExists DirectoryExists; 626 pGetExtension GetExtension; 627 pGetFileName GetFileName; 628 pGetFileNameWithoutExt GetFileNameWithoutExt; 629 pGetDirectoryPath GetDirectoryPath; 630 pGetPrevDirectoryPath GetPrevDirectoryPath; 631 pGetWorkingDirectory GetWorkingDirectory; 632 pGetDirectoryFiles GetDirectoryFiles; 633 pClearDirectoryFiles ClearDirectoryFiles; 634 pChangeDirectory ChangeDirectory; 635 pIsFileDropped IsFileDropped; 636 pGetDroppedFiles GetDroppedFiles; 637 pClearDroppedFiles ClearDroppedFiles; 638 pGetFileModTime GetFileModTime; 639 640 pIsKeyPressed IsKeyPressed; 641 pIsKeyDown IsKeyDown; 642 pIsKeyReleased IsKeyReleased; 643 pIsKeyUp IsKeyUp; 644 pGetKeyPressed GetKeyPressed; 645 pSetExitKey SetExitKey; 646 647 // Input-related functions: gamepads 648 pIsGamepadAvailable IsGamepadAvailable; 649 pIsGamepadName IsGamepadName; 650 pIsGamepadButtonPressed IsGamepadButtonPressed; 651 pIsGamepadButtonDown IsGamepadButtonDown; 652 pIsGamepadButtonReleased IsGamepadButtonReleased; 653 pIsGamepadButtonUp IsGamepadButtonUp; 654 pGetGamepadButtonPressed GetGamepadButtonPressed; 655 pGetGamepadAxisCount GetGamepadAxisCount; 656 pGetGamepadAxisMovement GetGamepadAxisMovement; 657 658 // Input-related functions: mouse 659 pIsMouseButtonPressed IsMouseButtonPressed; 660 pIsMouseButtonDown IsMouseButtonDown; 661 pIsMouseButtonReleased IsMouseButtonReleased; 662 pIsMouseButtonUp IsMouseButtonUp; 663 pGetMouseX GetMouseX; 664 pGetMouseY GetMouseY; 665 pGetMousePosition GetMousePosition; 666 pSetMousePosition SetMousePosition; 667 pSetMouseOffset SetMouseOffset; 668 pSetMouseScale SetMouseScale; 669 pGetMouseWheelMove GetMouseWheelMove; 670 671 pGetTouchX GetTouchX; 672 pGetTouchY GetTouchY; 673 pGetTouchPosition GetTouchPosition; 674 675 pSetGesturesEnabled SetGesturesEnabled; 676 pIsGestureDetected IsGestureDetected; 677 pGetGestureDetected GetGestureDetected; 678 pGetTouchPointsCount GetTouchPointsCount; 679 pGetGestureHoldDuration GetGestureHoldDuration; 680 pGetGestureDragVector GetGestureDragVector; 681 pGetGestureDragAngle GetGestureDragAngle; 682 pGetGesturePinchVector GetGesturePinchVector; 683 pGetGesturePinchAngle GetGesturePinchAngle; 684 685 pSetCameraMode SetCameraMode; 686 pUpdateCamera UpdateCamera; 687 pSetCameraPanControl SetCameraPanControl; 688 pSetCameraAltControl SetCameraAltControl; 689 pSetCameraSmoothZoomControl SetCameraSmoothZoomControl; 690 pSetCameraMoveControls SetCameraMoveControls; 691 } 692 693 static if (raylibSupport >= RaylibSupport.raylib300_70) { 694 extern (C) @nogc nothrow { 695 /** 696 * Get window scale DPI factor 697 */ 698 alias pGetWindowScaleDPI = Vector2 function(); 699 /** 700 * Check if window has been focused 701 */ 702 alias pIsWindowFocused = bool function(); 703 } 704 __gshared { 705 pGetWindowScaleDPI GetWindowScaleDPI; 706 pIsWindowFocused IsWindowFocused; 707 } 708 } 709 }