diff --git a/src/core.c b/src/core.c index 1051355d3..27148f995 100644 --- a/src/core.c +++ b/src/core.c @@ -387,6 +387,7 @@ typedef struct CoreData { char **dropFilesPath; // Store dropped files paths as strings int dropFilesCount; // Count dropped files strings + windowReSizeDrawCallB resizeDrawCallB; } Window; #if defined(PLATFORM_ANDROID) struct { @@ -591,7 +592,7 @@ extern void UnloadFontDefault(void); // [Module: text] Unloads default fo static void InitTimer(void); // Initialize timer (hi-resolution if available) static bool InitGraphicsDevice(int width, int height); // Initialize graphics device static void SetupFramebuffer(int width, int height); // Setup main framebuffer -static void SetupViewport(int width, int height); // Set viewport for a provided width and height +void SetupViewport(int width, int height); // Set viewport for a provided width and height #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error @@ -697,6 +698,8 @@ void InitWindow(int width, int height, const char *title) CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW; CORE.Input.Gamepad.lastButtonPressed = -1; + CORE.Window.resizeDrawCallB = NULL; + #if defined(PLATFORM_ANDROID) CORE.Window.screen.width = width; CORE.Window.screen.height = height; @@ -4835,6 +4838,13 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height) CORE.Window.screen.height = height; // NOTE: Postprocessing texture is not scaled to new size + if (CORE.Window.resizeDrawCallB != NULL) { + CORE.Window.resizeDrawCallB(); + } +} + +void SetWindowResizeDrawCallback(windowReSizeDrawCallB func) { + CORE.Window.resizeDrawCallB = func; } // GLFW3 WindowIconify Callback, runs when window is minimized/restored diff --git a/src/raylib.h b/src/raylib.h index 38af9f0eb..5d492fdb3 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -493,6 +493,8 @@ typedef enum { FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D) } ConfigFlags; +typedef void(*windowReSizeDrawCallB)(void); + // Trace log level // NOTE: Organized by priority level typedef enum { @@ -934,6 +936,8 @@ RLAPI Vector2 GetWindowScaleDPI(void); // Get window RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor RLAPI void SetClipboardText(const char *text); // Set clipboard text content RLAPI const char *GetClipboardText(void); // Get clipboard text content +RLAPI void SetupViewport(int width, int height); +RLAPI void SetWindowResizeDrawCallback(windowReSizeDrawCallB func) // Custom frame control functions // NOTE: Those functions are intended for advance users that want full control over the frame processing