Sfoglia il codice sorgente

[rcore] [GLFW] [SDL2] Updates `CORE.Window.eventWaiting` and `FLAG_WINDOW_ALWAYS_RUN` handling (#4642)

* Add implementation for CORE.Window.eventWaiting on PLATFORM_DESKTOP_SDL

* Optimize GetFrameTime() reset

* Optimize FLAG_WINDOW_ALWAYS_RUN and GetFrameTime() reset for PLATFORM_DESKTOP_GLFW
pull/4646/head
Asdqwe 2 settimane fa
committed by GitHub
parent
commit
5b822585e5
Non sono state trovate chiavi note per questa firma nel database ID Chiave GPG: B5690EEEBB952194
2 ha cambiato i file con 11 aggiunte e 13 eliminazioni
  1. +6
    -10
      src/platforms/rcore_desktop_glfw.c
  2. +5
    -3
      src/platforms/rcore_desktop_sdl.c

+ 6
- 10
src/platforms/rcore_desktop_glfw.c Vedi File

@ -1248,12 +1248,13 @@ void PollInputEvents(void)
CORE.Window.resizedLastFrame = false;
if (CORE.Window.eventWaiting) glfwWaitEvents(); // Wait for in input events before continue (drawing is paused)
if ((CORE.Window.eventWaiting) || (IsWindowState(FLAG_WINDOW_MINIMIZED) && !IsWindowState(FLAG_WINDOW_ALWAYS_RUN)))
{
glfwWaitEvents(); // Wait for in input events before continue (drawing is paused)
CORE.Time.previous = GetTime();
}
else glfwPollEvents(); // Poll input events: keyboard/mouse/window events (callbacks) -> Update keys state
// While window minimized, stop loop execution
while (IsWindowState(FLAG_WINDOW_MINIMIZED) && !IsWindowState(FLAG_WINDOW_ALWAYS_RUN)) glfwWaitEvents();
CORE.Window.shouldClose = glfwWindowShouldClose(platform.handle);
// Reset close status for next frame
@ -1739,12 +1740,7 @@ static void WindowContentScaleCallback(GLFWwindow *window, float scalex, float s
static void WindowIconifyCallback(GLFWwindow *window, int iconified)
{
if (iconified) CORE.Window.flags |= FLAG_WINDOW_MINIMIZED; // The window was iconified
else
{
CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; // The window was restored
if ((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) == 0) CORE.Time.previous = GetTime();
}
else CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; // The window was restored
}
// GLFW3 WindowMaximize Callback, runs when window is maximized/restored

+ 5
- 3
src/platforms/rcore_desktop_sdl.c Vedi File

@ -1378,7 +1378,11 @@ void PollInputEvents(void)
CORE.Window.resizedLastFrame = false;
if (((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) && ((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) == 0)) SDL_WaitEvent(NULL);
if ((CORE.Window.eventWaiting) || (((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) && ((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) == 0)))
{
SDL_WaitEvent(NULL);
CORE.Time.previous = GetTime();
}
SDL_Event event = { 0 };
while (SDL_PollEvent(&event) != 0)
@ -1499,8 +1503,6 @@ void PollInputEvents(void)
if ((CORE.Window.flags & SDL_WINDOW_MAXIMIZED) > 0) CORE.Window.flags &= ~SDL_WINDOW_MAXIMIZED;
}
#endif
if ((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) == 0) CORE.Time.previous = GetTime();
} break;
case SDL_WINDOWEVENT_HIDDEN:

Caricamento…
Annulla
Salva