2
0

raylib_core.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 Terminate Context
  4. bool WindowShouldClose(void); // Detect if KEY_ESCAPE pressed or Close icon pressed
  5. bool IsWindowMinimized(void); // Detect if window has been minimized (or lost focus)
  6. void ToggleFullscreen(void); // Fullscreen toggle (by default F11)
  7. int GetScreenWidth(void); // Get current screen width
  8. int GetScreenHeight(void); // Get current screen height
  9. // Cursor-related functions
  10. void ShowCursor(void); // Shows cursor
  11. void HideCursor(void); // Hides cursor
  12. bool IsCursorHidden(void); // Returns true if cursor is not visible
  13. void EnableCursor(void); // Enables cursor
  14. void DisableCursor(void); // Disables cursor
  15. // Drawing-related functions
  16. void ClearBackground(Color color); // Sets Background Color
  17. void BeginDrawing(void); // Setup drawing canvas to start drawing
  18. void EndDrawing(void); // End canvas drawing and Swap Buffers (Double Buffering)
  19. void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera
  20. void End2dMode(void); // Ends 2D mode custom camera usage
  21. void Begin3dMode(Camera camera); // Initializes 3D mode for drawing (Camera setup)
  22. void End3dMode(void); // Ends 3D mode and returns to default 2D orthographic mode
  23. void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing
  24. void EndTextureMode(void); // Ends drawing to render texture
  25. Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
  26. Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position from a 3d world space position
  27. Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
  28. // Timming-related functions
  29. void SetTargetFPS(int fps); // Set target FPS (maximum)
  30. float GetFPS(void); // Returns current FPS
  31. float GetFrameTime(void); // Returns time in seconds for one frame
  32. // Color-related functions
  33. Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
  34. int GetHexValue(Color color); // Returns hexadecimal value for a Color
  35. float *ColorToFloat(Color color); // Converts Color to float array and normalizes
  36. float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array
  37. float *MatrixToFloat(Matrix mat); // Converts Matrix to float array
  38. // Misc. functions
  39. int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
  40. Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0 to 1.0
  41. void SetConfigFlags(char flags); // Setup some window configuration flags
  42. void ShowLogo(void); // Activates raylib logo at startup (can be done with flags)
  43. // Drag-and-drop files functions
  44. bool IsFileDropped(void); // Check if a file have been dropped into window
  45. char **GetDroppedFiles(int *count); // Retrieve dropped files into window
  46. void ClearDroppedFiles(void); // Clear dropped files paths buffer
  47. // Persistent storage management
  48. void StorageSaveValue(int position, int value); // Storage save integer value (to defined position)
  49. int StorageLoadValue(int position); // Storage load integer value (from defined position)
  50. // Input-related functions: keyboard
  51. bool IsKeyPressed(int key); // Detect if a key has been pressed once
  52. bool IsKeyDown(int key); // Detect if a key is being pressed
  53. bool IsKeyReleased(int key); // Detect if a key has been released once
  54. bool IsKeyUp(int key); // Detect if a key is NOT being pressed
  55. int GetKeyPressed(void); // Get latest key pressed
  56. void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
  57. // Input-related functions: gamepads
  58. bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
  59. bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available)
  60. const char *GetGamepadName(int gamepad); // Return gamepad internal name id
  61. bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once
  62. bool IsGamepadButtonDown(int gamepad, int button); // Detect if a gamepad button is being pressed
  63. bool IsGamepadButtonReleased(int gamepad, int button); // Detect if a gamepad button has been released once
  64. bool IsGamepadButtonUp(int gamepad, int button); // Detect if a gamepad button is NOT being pressed
  65. int GetGamepadButtonPressed(void); // Get the last gamepad button pressed
  66. int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad
  67. float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
  68. // Input-related functions: mouse
  69. bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
  70. bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
  71. bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once
  72. bool IsMouseButtonUp(int button); // Detect if a mouse button is NOT being pressed
  73. int GetMouseX(void); // Returns mouse position X
  74. int GetMouseY(void); // Returns mouse position Y
  75. Vector2 GetMousePosition(void); // Returns mouse position XY
  76. void SetMousePosition(Vector2 position); // Set mouse position XY
  77. int GetMouseWheelMove(void); // Returns mouse wheel movement Y
  78. // Input-related functions: touch
  79. int GetTouchX(void); // Get touch position X for touch point 0 (relative to screen size)
  80. int GetTouchY(void); // Get touch position Y for touch point 0 (relative to screen size)
  81. Vector2 GetTouchPosition(int index); // Get touch position XY for a touch point index (relative to screen size)
  82. // Gestures-related functions
  83. void SetGesturesEnabled(unsigned int gestureFlags); // Enable a set of gestures using flags
  84. bool IsGestureDetected(int gesture); // Check if a gesture have been detected
  85. int GetGestureDetected(void); // Get latest detected gesture
  86. int GetTouchPointsCount(void); // Get touch points count
  87. float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds
  88. Vector2 GetGestureDragVector(void); // Get gesture drag vector
  89. float GetGestureDragAngle(void); // Get gesture drag angle
  90. Vector2 GetGesturePinchVector(void); // Get gesture pinch delta
  91. float GetGesturePinchAngle(void); // Get gesture pinch angle
  92. // Camera-related functions
  93. SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available)
  94. void UpdateCamera(Camera *camera); // Update camera position for selected mode
  95. void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera)
  96. void SetCameraAltControl(int altKey); // Set camera alt key to combine with mouse movement (free camera)
  97. void SetCameraSmoothZoomControl(int szKey); // Set camera smooth zoom key to combine with mouse (free camera)
  98. void SetCameraMoveControls(int frontKey, int backKey,
  99. int rightKey, int leftKey,
  100. int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras)