call the render callback on window size and move.

This commit is contained in:
Jeff Myers 2026-06-30 21:11:26 -07:00
commit 159136a6eb
3 changed files with 29 additions and 7 deletions

View file

@ -144,6 +144,7 @@ static void WindowIconifyCallback(GLFWwindow *window, int iconified);
static void WindowMaximizeCallback(GLFWwindow *window, int maximized); // GLFW3 Window Maximize Callback, runs when window is maximized
static void WindowFocusCallback(GLFWwindow *window, int focused); // GLFW3 WindowFocus Callback, runs when window get/lose focus
static void WindowDropCallback(GLFWwindow *window, int count, const char **paths); // GLFW3 Window Drop Callback, runs when drop files into window
static void WindowRefreshCallback(GLFWwindow* window); // GLFW3 Window Refresh Callback, runs when window content needs to be refreshed
// Input callbacks events
static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods); // GLFW3 Keyboard Callback, runs on key pressed
@ -1438,17 +1439,23 @@ void WindowRefreshCallback(GLFWwindow* window)
{
return;
}
CORE.Time.current = GetTime(); // Number of elapsed seconds since InitTimer()
CORE.Time.update = CORE.Time.current - CORE.Time.previous;
CORE.Time.previous = CORE.Time.current;
rlLoadIdentity(); // Reset current matrix (modelview)
rlMultMatrixf(MatrixToFloat(CORE.Window.screenScale)); // Apply screen scaling
CORE.Window.updateCallback();
rlDrawRenderBatchActive();
SwapScreenBuffer();
CORE.Time.current = GetTime();
CORE.Time.draw = CORE.Time.current - CORE.Time.previous;
CORE.Time.previous = CORE.Time.current;
SwapScreenBuffer(); // Copy back buffer to front buffer (screen)
// Frame time control system
CORE.Time.current = GetTime();
CORE.Time.draw = CORE.Time.current - CORE.Time.previous;
@ -1457,6 +1464,8 @@ void WindowRefreshCallback(GLFWwindow* window)
CORE.Time.frame = CORE.Time.update + CORE.Time.draw;
CORE.Time.frameCounter++;
CORE.Window.wasDirtyThisFrame = true;
}
// Initialize platform: graphics, inputs and more
@ -2026,6 +2035,7 @@ static void WindowPosCallback(GLFWwindow *window, int x, int y)
// Set current window position
CORE.Window.position.x = x;
CORE.Window.position.y = y;
WindowRefreshCallback(window); // Force window refresh on position change
}
// GLFW3: Window iconify callback, runs when window is minimized/restored

View file

@ -319,7 +319,7 @@ typedef struct CoreData {
unsigned int dropFileCount; // Count dropped files strings
bool(*updateCallback)(void); // Optional user defined callback to draw a frame
bool wasDirtyThisFrame;
} Window;
struct {
const char *basePath; // Base path for data storage
@ -743,12 +743,19 @@ static bool RunLoop = false;
void ProcessSingleFrame(void)
{
// if the dirty callback rendered this frame, don't double render, skip it until the next frame
if (CORE.Window.wasDirtyThisFrame)
{
CORE.Window.wasDirtyThisFrame = false;
return;
}
BeginDrawing();
RunLoop = CORE.Window.updateCallback();
EndDrawing();
#if defined(SUPPORT_CUSTOM_FRAME_CONTROL)
SwapBuffers();
#if SUPPORT_CUSTOM_FRAME_CONTROL
SwapScreenBuffer();
PollInputEvents();
#endif
}