2
0

raylib_core.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // Window-related functions
  2. void InitWindow(int width, int height, char* title); // Initialize Window and Graphics Context (OpenGL)
  3. void CloseWindow(void); // Close window and unload OpenGL context
  4. bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
  5. bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
  6. void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP)
  7. void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP)
  8. void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
  9. void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode)
  10. void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
  11. int GetScreenWidth(void); // Get current screen width
  12. int GetScreenHeight(void); // Get current screen height
  13. // Cursor-related functions
  14. void ShowCursor(void); // Shows cursor
  15. void HideCursor(void); // Hides cursor
  16. bool IsCursorHidden(void); // Check if cursor is not visible
  17. void EnableCursor(void); // Enables cursor (unlock cursor)
  18. void DisableCursor(void); // Disables cursor (lock cursor)
  19. // Drawing-related functions
  20. void ClearBackground(Color color); // Set background color (framebuffer clear color)
  21. void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing
  22. void EndDrawing(void); // End canvas drawing and swap buffers (double buffering)
  23. void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D)
  24. void End2dMode(void); // Ends 2D mode with custom camera
  25. void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D)
  26. void End3dMode(void); // Ends 3D mode and returns to default 2D orthographic mode
  27. void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing
  28. void EndTextureMode(void); // Ends drawing to render texture
  29. // Screen-space-related functions
  30. Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
  31. Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position
  32. Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
  33. // Timming-related functions
  34. void SetTargetFPS(int fps); // Set target FPS (maximum)
  35. int GetFPS(void); // Returns current FPS
  36. float GetFrameTime(void); // Returns time in seconds for last frame drawn
  37. // Color-related functions
  38. int GetHexValue(Color color); // Returns hexadecimal value for a Color
  39. Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
  40. Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
  41. float *ColorToFloat(Color color); // Converts Color to float array and normalizes
  42. float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array
  43. float *MatrixToFloat(Matrix mat); // Converts Matrix to float array
  44. // Misc. functions
  45. void ShowLogo(void); // Activate raylib logo at startup (can be done with flags)
  46. void SetConfigFlags(char flags); // Setup window configuration flags (view FLAGS)
  47. void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG)
  48. void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
  49. int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
  50. // Files management functions
  51. bool IsFileExtension(const char *fileName, const char *ext); // Check file extension
  52. const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path)
  53. const char *GetWorkingDirectory(void); // Get current working directory
  54. bool ChangeDirectory(const char *dir); // Change working directory, returns true if success
  55. bool IsFileDropped(void); // Check if a file has been dropped into window
  56. char **GetDroppedFiles(int *count); // Get dropped files names
  57. void ClearDroppedFiles(void); // Clear dropped files paths buffer
  58. // Persistent storage management
  59. void StorageSaveValue(int position, int value); // Save integer value to storage file (to defined position)
  60. int StorageLoadValue(int position); // Load integer value from storage file (from defined position)
  61. // Input-related functions: keyboard
  62. bool IsKeyPressed(int key); // Detect if a key has been pressed once
  63. bool IsKeyDown(int key); // Detect if a key is being pressed
  64. bool IsKeyReleased(int key); // Detect if a key has been released once
  65. bool IsKeyUp(int key); // Detect if a key is NOT being pressed
  66. int GetKeyPressed(void); // Get latest key pressed
  67. void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
  68. // Input-related functions: gamepads
  69. bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
  70. bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available)
  71. const char *GetGamepadName(int gamepad); // Return gamepad internal name id
  72. bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once
  73. bool IsGamepadButtonDown(int gamepad, int button); // Detect if a gamepad button is being pressed
  74. bool IsGamepadButtonReleased(int gamepad, int button); // Detect if a gamepad button has been released once
  75. bool IsGamepadButtonUp(int gamepad, int button); // Detect if a gamepad button is NOT being pressed
  76. int GetGamepadButtonPressed(void); // Get the last gamepad button pressed
  77. int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad
  78. float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
  79. // Input-related functions: mouse
  80. bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
  81. bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
  82. bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once
  83. bool IsMouseButtonUp(int button); // Detect if a mouse button is NOT being pressed
  84. int GetMouseX(void); // Returns mouse position X
  85. int GetMouseY(void); // Returns mouse position Y
  86. Vector2 GetMousePosition(void); // Returns mouse position XY
  87. void SetMousePosition(Vector2 position); // Set mouse position XY
  88. int GetMouseWheelMove(void); // Returns mouse wheel movement Y
  89. // Input-related functions: touch
  90. int GetTouchX(void); // Get touch position X for touch point 0 (relative to screen size)
  91. int GetTouchY(void); // Get touch position Y for touch point 0 (relative to screen size)
  92. Vector2 GetTouchPosition(int index); // Get touch position XY for a touch point index (relative to screen size)
  93. // Gestures-related functions
  94. void SetGesturesEnabled(unsigned int gestureFlags); // Enable a set of gestures using flags
  95. bool IsGestureDetected(int gesture); // Check if a gesture have been detected
  96. int GetGestureDetected(void); // Get latest detected gesture
  97. int GetTouchPointsCount(void); // Get touch points count
  98. float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds
  99. Vector2 GetGestureDragVector(void); // Get gesture drag vector
  100. float GetGestureDragAngle(void); // Get gesture drag angle
  101. Vector2 GetGesturePinchVector(void); // Get gesture pinch delta
  102. float GetGesturePinchAngle(void); // Get gesture pinch angle
  103. // Camera-related functions
  104. SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available)
  105. void UpdateCamera(Camera *camera); // Update camera position for selected mode
  106. void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera)
  107. void SetCameraAltControl(int altKey); // Set camera alt key to combine with mouse movement (free camera)
  108. void SetCameraSmoothZoomControl(int szKey); // Set camera smooth zoom key to combine with mouse (free camera)
  109. void SetCameraMoveControls(int frontKey, int backKey,
  110. int rightKey, int leftKey,
  111. int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras)