diff options
| author | raysan5 <[email protected]> | 2020-12-23 14:45:26 +0100 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2020-12-23 14:45:26 +0100 |
| commit | 53a8ac406298e836470c66117de9b1838920901c (patch) | |
| tree | 61ea07abbb9a1558d8b0241eca1ba662779e6242 /cheatsheet/raylib_core.c | |
| parent | 1e275f7857bc8834837d03fdec491d7be8a2c9b4 (diff) | |
| download | raylib.com-53a8ac406298e836470c66117de9b1838920901c.tar.gz raylib.com-53a8ac406298e836470c66117de9b1838920901c.zip | |
Update cheatsheet for raylib 3.5
Diffstat (limited to 'cheatsheet/raylib_core.c')
| -rw-r--r-- | cheatsheet/raylib_core.c | 106 |
1 files changed, 58 insertions, 48 deletions
diff --git a/cheatsheet/raylib_core.c b/cheatsheet/raylib_core.c index 4d08523..cd54384 100644 --- a/cheatsheet/raylib_core.c +++ b/cheatsheet/raylib_core.c @@ -4,13 +4,19 @@ bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed void CloseWindow(void); // Close window and unload OpenGL context bool IsWindowReady(void); // Check if window has been initialized successfully - bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus) - bool IsWindowResized(void); // Check if window has been resized - bool IsWindowHidden(void); // Check if window is currently hidden bool IsWindowFullscreen(void); // Check if window is currently fullscreen - void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP) - void UnhideWindow(void); // Show the window - void HideWindow(void); // Hide the window + bool IsWindowHidden(void); // Check if window is currently hidden (only PLATFORM_DESKTOP) + bool IsWindowMinimized(void); // Check if window is currently minimized (only PLATFORM_DESKTOP) + bool IsWindowMaximized(void); // Check if window is currently maximized (only PLATFORM_DESKTOP) + bool IsWindowFocused(void); // Check if window is currently focused (only PLATFORM_DESKTOP) + bool IsWindowResized(void); // Check if window has been resized last frame + bool IsWindowState(unsigned int flag); // Check if one specific window flag is enabled + void SetWindowState(unsigned int flags); // Set window configuration state using flags + void ClearWindowState(unsigned int flags); // Clear window configuration state flags + void ToggleFullscreen(void); // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP) + void MaximizeWindow(void); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP) + void MinimizeWindow(void); // Set window state: minimized, if resizable (only PLATFORM_DESKTOP) + void RestoreWindow(void); // Set window state: not minimized/maximized (only PLATFORM_DESKTOP) void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP) void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP) void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP) @@ -21,22 +27,26 @@ int GetScreenWidth(void); // Get current screen width int GetScreenHeight(void); // Get current screen height int GetMonitorCount(void); // Get number of connected monitors - int GetMonitorWidth(int monitor); // Get primary monitor width - int GetMonitorHeight(int monitor); // Get primary monitor height - int GetMonitorPhysicalWidth(int monitor); // Get primary monitor physical width in millimetres - int GetMonitorPhysicalHeight(int monitor); // Get primary monitor physical height in millimetres + Vector2 GetMonitorPosition(int monitor); // Get specified monitor position + int GetMonitorWidth(int monitor); // Get specified monitor width + int GetMonitorHeight(int monitor); // Get specified monitor height + int GetMonitorPhysicalWidth(int monitor); // Get specified monitor physical width in millimetres + int GetMonitorPhysicalHeight(int monitor); // Get specified monitor physical height in millimetres + int GetMonitorRefreshRate(int monitor); // Get specified monitor refresh rate Vector2 GetWindowPosition(void); // Get window position XY on monitor + Vector2 GetWindowScaleDPI(void); // Get window scale DPI factor const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor - const char *GetClipboardText(void); // Get clipboard text content void SetClipboardText(const char *text); // Set clipboard text content - + const char *GetClipboardText(void); // Get clipboard text content + // Cursor-related functions void ShowCursor(void); // Shows cursor void HideCursor(void); // Hides cursor bool IsCursorHidden(void); // Check if cursor is not visible void EnableCursor(void); // Enables cursor (unlock cursor) void DisableCursor(void); // Disables cursor (lock cursor) - + bool IsCursorOnScreen(void); // Check if cursor is on the current screen. + // Drawing-related functions void ClearBackground(Color color); // Set background color (framebuffer clear color) void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing @@ -49,8 +59,8 @@ void EndTextureMode(void); // Ends drawing to render texture void BeginScissorMode(int x, int y, int width, int height); // Begin scissor mode (define screen area for following drawing) void EndScissorMode(void); // End scissor mode - - // Screen-space-related functions + + // Screen-space-related functions Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix) Matrix GetCameraMatrix2D(Camera2D camera); // Returns camera 2d transform matrix @@ -58,40 +68,37 @@ Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Returns size position for a 3d world space position Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Returns the screen space position for a 2d camera world space position Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Returns the world space position for a 2d camera screen space position - - // Timing-related functions + + // Timing-related functions void SetTargetFPS(int fps); // Set target FPS (maximum) int GetFPS(void); // Returns current FPS float GetFrameTime(void); // Returns time in seconds for last frame drawn double GetTime(void); // Returns elapsed time in seconds since InitWindow() - - // Color-related functions - int ColorToInt(Color color); // Returns hexadecimal value for a Color - Vector4 ColorNormalize(Color color); // Returns color normalized as float [0..1] - Color ColorFromNormalized(Vector4 normalized); // Returns color from normalized values [0..1] - Vector3 ColorToHSV(Color color); // Returns HSV values for a Color - Color ColorFromHSV(Vector3 hsv); // Returns a Color from HSV values - Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value - Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f - + // Misc. functions - void SetConfigFlags(unsigned int flags); // Setup window configuration flags (view FLAGS) + void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS) + void SetTraceLogLevel(int logType); // Set the current threshold (minimum) log level void SetTraceLogExit(int logType); // Set the exit threshold (minimum) log level void SetTraceLogCallback(TraceLogCallback callback); // Set a trace log callback to enable custom logging void TraceLog(int logType, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) + + void *MemAlloc(int size); // Internal memory allocator + void MemFree(void *ptr); // Internal memory free void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png) int GetRandomValue(int min, int max); // Returns a random value between min and max (both included) - + // Files management functions unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read) - void SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write) + void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData() + bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write), returns true on success char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string - void SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated + void UnloadFileText(unsigned char *text); // Unload file text data allocated by LoadFileText() + bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success bool FileExists(const char *fileName); // Check if file exists - bool IsFileExtension(const char *fileName, const char *ext); // Check file extension bool DirectoryExists(const char *dirPath); // Check if a directory path exists - const char *GetExtension(const char *fileName); // Get pointer to extension for a filename string + bool IsFileExtension(const char *fileName, const char *ext); // Check file extension (including point: .png, .wav) + const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (including point: ".png") const char *GetFileName(const char *filePath); // Get pointer to filename for a path string const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (uses static string) const char *GetDirectoryPath(const char *filePath); // Get full path for a given fileName with path (uses static string) @@ -99,32 +106,33 @@ const char *GetWorkingDirectory(void); // Get current working directory (uses static string) char **GetDirectoryFiles(const char *dirPath, int *count); // Get filenames in a directory path (memory should be freed) void ClearDirectoryFiles(void); // Clear directory files paths buffers (free memory) - bool ChangeDirectory(const char *dir); // Change working directory, returns true if success + bool ChangeDirectory(const char *dir); // Change working directory, return true on success bool IsFileDropped(void); // Check if a file has been dropped into window char **GetDroppedFiles(int *count); // Get dropped files names (memory should be freed) void ClearDroppedFiles(void); // Clear dropped files paths buffer (free memory) long GetFileModTime(const char *fileName); // Get file modification time (last write time) - - unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorythm) - unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorythm) - + + unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorithm) + unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorithm) + // Persistent storage management - void SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position) + bool SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position), returns true on success int LoadStorageValue(unsigned int position); // Load integer value from storage file (from defined position) - + void OpenURL(const char *url); // Open URL with default system browser (if available) //------------------------------------------------------------------------------------ - // Input Handling Functions + // Input Handling Functions (Module: core) //------------------------------------------------------------------------------------ - // Input-related functions: keyb + // Input-related functions: keyboard bool IsKeyPressed(int key); // Detect if a key has been pressed once bool IsKeyDown(int key); // Detect if a key is being pressed bool IsKeyReleased(int key); // Detect if a key has been released once bool IsKeyUp(int key); // Detect if a key is NOT being pressed - int GetKeyPressed(void); // Get latest key pressed void SetExitKey(int key); // Set a custom key to exit program (default is ESC) + int GetKeyPressed(void); // Get key pressed (keycode), call it multiple times for keys queued + int GetCharPressed(void); // Get char pressed (unicode), call it multiple times for chars queued // Input-related functions: gamepads bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available @@ -149,8 +157,10 @@ void SetMousePosition(int x, int y); // Set mouse position XY void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling - int GetMouseWheelMove(void); // Returns mouse wheel movement Y - + float GetMouseWheelMove(void); // Returns mouse wheel movement Y + int GetMouseCursor(void); // Returns mouse cursor if (MouseCursor enum) + void SetMouseCursor(int cursor); // Set mouse cursor + // Input-related functions: touch int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size) int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size) @@ -175,9 +185,9 @@ void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available) void UpdateCamera(Camera *camera); // Update camera position for selected mode - void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera) - void SetCameraAltControl(int altKey); // Set camera alt key to combine with mouse movement (free camera) - void SetCameraSmoothZoomControl(int szKey); // Set camera smooth zoom key to combine with mouse (free camera) + void SetCameraPanControl(int keyPan); // Set camera pan key to combine with mouse movement (free camera) + void SetCameraAltControl(int keyAlt); // Set camera alt key to combine with mouse movement (free camera) + void SetCameraSmoothZoomControl(int keySmoothZoom); // Set camera smooth zoom key to combine with mouse (free camera) void SetCameraMoveControls(int frontKey, int backKey, int rightKey, int leftKey, int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras) |
