mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-02 20:29:18 -05:00
[rcore] Use FLAG_* macros where possible (#5169)
* use FLAG_* macros where possible * rename `FLAG_CHECK()` to `FLAG_IS_SET()` * remove unnecessary equality checks * fix issues --------- Co-authored-by: Ray <raysan5@gmail.com>
This commit is contained in:
@ -303,7 +303,7 @@ void ToggleFullscreen(void)
|
||||
|
||||
platform.mon = RGFW_window_getMonitor(platform.window);
|
||||
CORE.Window.fullscreen = true;
|
||||
CORE.Window.flags |= FLAG_FULLSCREEN_MODE;
|
||||
FLAG_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
|
||||
|
||||
RGFW_monitor_scaleToWindow(platform.mon, platform.window);
|
||||
RGFW_window_setFullscreen(platform.window, 1);
|
||||
@ -311,7 +311,7 @@ void ToggleFullscreen(void)
|
||||
else
|
||||
{
|
||||
CORE.Window.fullscreen = false;
|
||||
CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE;
|
||||
FLAG_CLEAR(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
|
||||
|
||||
if (platform.mon.mode.area.w)
|
||||
{
|
||||
@ -330,7 +330,7 @@ void ToggleFullscreen(void)
|
||||
|
||||
// Try to enable GPU V-Sync, so frames are limited to screen refresh rate (60Hz -> 60 FPS)
|
||||
// NOTE: V-Sync can be enabled by graphic driver configuration
|
||||
if (CORE.Window.flags & FLAG_VSYNC_HINT) RGFW_window_swapInterval(platform.window, 1);
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_VSYNC_HINT)) RGFW_window_swapInterval(platform.window, 1);
|
||||
}
|
||||
|
||||
// Toggle borderless windowed mode
|
||||
@ -372,7 +372,7 @@ void MinimizeWindow(void)
|
||||
// Restore window from being minimized/maximized
|
||||
void RestoreWindow(void)
|
||||
{
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);
|
||||
if (!FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);
|
||||
|
||||
RGFW_window_restore(platform.window);
|
||||
}
|
||||
@ -382,72 +382,68 @@ void SetWindowState(unsigned int flags)
|
||||
{
|
||||
if (!CORE.Window.ready) TRACELOG(LOG_WARNING, "WINDOW: SetWindowState does nothing before window initialization, Use \"SetConfigFlags\" instead");
|
||||
|
||||
CORE.Window.flags |= flags;
|
||||
FLAG_SET(CORE.Window.flags, flags);
|
||||
|
||||
if (flags & FLAG_VSYNC_HINT)
|
||||
if (FLAG_IS_SET(flags, FLAG_VSYNC_HINT))
|
||||
{
|
||||
RGFW_window_swapInterval(platform.window, 1);
|
||||
}
|
||||
if (flags & FLAG_FULLSCREEN_MODE)
|
||||
if (FLAG_IS_SET(flags, FLAG_FULLSCREEN_MODE))
|
||||
{
|
||||
if (!CORE.Window.fullscreen) ToggleFullscreen();
|
||||
}
|
||||
if (flags & FLAG_WINDOW_RESIZABLE)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_RESIZABLE))
|
||||
{
|
||||
RGFW_window_setMaxSize(platform.window, RGFW_AREA(0, 0));
|
||||
RGFW_window_setMinSize(platform.window, RGFW_AREA(0, 0));
|
||||
}
|
||||
if (flags & FLAG_WINDOW_UNDECORATED)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_UNDECORATED))
|
||||
{
|
||||
RGFW_window_setBorder(platform.window, 0);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_HIDDEN)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_HIDDEN))
|
||||
{
|
||||
RGFW_window_hide(platform.window);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_MINIMIZED)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_MINIMIZED))
|
||||
{
|
||||
RGFW_window_minimize(platform.window);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_MAXIMIZED)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_MAXIMIZED))
|
||||
{
|
||||
RGFW_window_maximize(platform.window);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_UNFOCUSED)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_UNFOCUSED))
|
||||
{
|
||||
CORE.Window.flags |= FLAG_WINDOW_UNFOCUSED;
|
||||
platform.window->_flags &= ~RGFW_windowFocusOnShow;
|
||||
FLAG_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED);
|
||||
FLAG_CLEAR(platform.window->_flags, RGFW_windowFocusOnShow);
|
||||
RGFW_window_setFlags(platform.window, platform.window->_flags);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_TOPMOST)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_TOPMOST))
|
||||
{
|
||||
RGFW_window_setFloating(platform.window, RGFW_TRUE);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_ALWAYS_RUN)
|
||||
{
|
||||
CORE.Window.flags |= FLAG_WINDOW_ALWAYS_RUN;
|
||||
}
|
||||
if (flags & FLAG_WINDOW_TRANSPARENT)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_TRANSPARENT))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only be configured before window initialization");
|
||||
}
|
||||
if (flags & FLAG_WINDOW_HIGHDPI)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_HIGHDPI))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: High DPI can only be configured before window initialization");
|
||||
}
|
||||
if (flags & FLAG_WINDOW_MOUSE_PASSTHROUGH)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_MOUSE_PASSTHROUGH))
|
||||
{
|
||||
RGFW_window_setMousePassthrough(platform.window, 1);
|
||||
}
|
||||
if (flags & FLAG_BORDERLESS_WINDOWED_MODE)
|
||||
if (FLAG_IS_SET(flags, FLAG_BORDERLESS_WINDOWED_MODE))
|
||||
{
|
||||
ToggleBorderlessWindowed();
|
||||
}
|
||||
if (flags & FLAG_MSAA_4X_HINT)
|
||||
if (FLAG_IS_SET(flags, FLAG_MSAA_4X_HINT))
|
||||
{
|
||||
RGFW_setGLHint(RGFW_glSamples, 4);
|
||||
}
|
||||
if (flags & FLAG_INTERLACED_HINT)
|
||||
if (FLAG_IS_SET(flags, FLAG_INTERLACED_HINT))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only be configured before window initialization");
|
||||
}
|
||||
@ -456,77 +452,72 @@ void SetWindowState(unsigned int flags)
|
||||
// Clear window configuration state flags
|
||||
void ClearWindowState(unsigned int flags)
|
||||
{
|
||||
CORE.Window.flags &= ~flags;
|
||||
FLAG_CLEAR(CORE.Window.flags, flags);
|
||||
|
||||
if (flags & FLAG_VSYNC_HINT)
|
||||
if (FLAG_IS_SET(flags, FLAG_VSYNC_HINT))
|
||||
{
|
||||
RGFW_window_swapInterval(platform.window, 0);
|
||||
}
|
||||
if (flags & FLAG_FULLSCREEN_MODE)
|
||||
if (FLAG_IS_SET(flags, FLAG_FULLSCREEN_MODE))
|
||||
{
|
||||
if (CORE.Window.fullscreen) ToggleFullscreen();
|
||||
}
|
||||
if (flags & FLAG_WINDOW_RESIZABLE)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_RESIZABLE))
|
||||
{
|
||||
RGFW_window_setMaxSize(platform.window, RGFW_AREA(platform.window->r.w, platform.window->r.h));
|
||||
RGFW_window_setMinSize(platform.window, RGFW_AREA(platform.window->r.w, platform.window->r.h));
|
||||
}
|
||||
if (flags & FLAG_WINDOW_UNDECORATED)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_UNDECORATED))
|
||||
{
|
||||
RGFW_window_setBorder(platform.window, 1);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_HIDDEN)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_HIDDEN))
|
||||
{
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);
|
||||
if (!FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);
|
||||
|
||||
RGFW_window_show(platform.window);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_MINIMIZED)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_MINIMIZED))
|
||||
{
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);
|
||||
if (!FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);
|
||||
|
||||
RGFW_window_restore(platform.window);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_MAXIMIZED)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_MAXIMIZED))
|
||||
{
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);
|
||||
if (!FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);
|
||||
|
||||
RGFW_window_restore(platform.window);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_UNFOCUSED)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_UNFOCUSED))
|
||||
{
|
||||
RGFW_window_setFlags(platform.window, platform.window->_flags | RGFW_windowFocusOnShow);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED;
|
||||
}
|
||||
if (flags & FLAG_WINDOW_TOPMOST)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_TOPMOST))
|
||||
{
|
||||
RGFW_window_setFloating(platform.window, RGFW_FALSE);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_ALWAYS_RUN)
|
||||
{
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_ALWAYS_RUN;
|
||||
}
|
||||
if (flags & FLAG_WINDOW_TRANSPARENT)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_TRANSPARENT))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only be configured before window initialization");
|
||||
}
|
||||
if (flags & FLAG_WINDOW_HIGHDPI)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_HIGHDPI))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: High DPI can only be configured before window initialization");
|
||||
}
|
||||
if (flags & FLAG_WINDOW_MOUSE_PASSTHROUGH)
|
||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_MOUSE_PASSTHROUGH))
|
||||
{
|
||||
RGFW_window_setMousePassthrough(platform.window, 0);
|
||||
}
|
||||
if (flags & FLAG_BORDERLESS_WINDOWED_MODE)
|
||||
if (FLAG_IS_SET(flags, FLAG_BORDERLESS_WINDOWED_MODE))
|
||||
{
|
||||
if (CORE.Window.fullscreen) ToggleBorderlessWindowed();
|
||||
}
|
||||
if (flags & FLAG_MSAA_4X_HINT)
|
||||
if (FLAG_IS_SET(flags, FLAG_MSAA_4X_HINT))
|
||||
{
|
||||
RGFW_setGLHint(RGFW_glSamples, 0);
|
||||
}
|
||||
if (flags & FLAG_INTERLACED_HINT)
|
||||
if (FLAG_IS_SET(flags, FLAG_INTERLACED_HINT))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only be configured before window initialization");
|
||||
}
|
||||
@ -983,7 +974,7 @@ void PollInputEvents(void)
|
||||
CORE.Window.resizedLastFrame = false;
|
||||
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
if (platform.window->_flags & RGFW_HOLD_MOUSE)
|
||||
if (FLAG_IS_SET(platform.window->_flags, RGFW_HOLD_MOUSE))
|
||||
{
|
||||
CORE.Input.Mouse.previousPosition = (Vector2){ 0.0f, 0.0f };
|
||||
CORE.Input.Mouse.currentPosition = (Vector2){ 0.0f, 0.0f };
|
||||
@ -1062,18 +1053,18 @@ void PollInputEvents(void)
|
||||
} break;
|
||||
case RGFW_windowMaximized:
|
||||
{
|
||||
CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED; // The window was maximized
|
||||
FLAG_SET(CORE.Window.flags, FLAG_WINDOW_MAXIMIZED); // The window was maximized
|
||||
} break;
|
||||
case RGFW_windowMinimized:
|
||||
{
|
||||
CORE.Window.flags |= FLAG_WINDOW_MINIMIZED; // The window was iconified
|
||||
FLAG_SET(CORE.Window.flags, FLAG_WINDOW_MINIMIZED); // The window was iconified
|
||||
} break;
|
||||
case RGFW_windowRestored:
|
||||
{
|
||||
if (RGFW_window_isMaximized(platform.window))
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_MAXIMIZED; // The window was restored
|
||||
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_MAXIMIZED); // The window was restored
|
||||
if (RGFW_window_isMinimized(platform.window))
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; // The window was restored
|
||||
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_MINIMIZED); // The window was restored
|
||||
} break;
|
||||
case RGFW_windowMoved:
|
||||
{
|
||||
@ -1159,7 +1150,7 @@ void PollInputEvents(void)
|
||||
} break;
|
||||
case RGFW_mousePosChanged:
|
||||
{
|
||||
if (platform.window->_flags & RGFW_HOLD_MOUSE)
|
||||
if (FLAG_IS_SET(platform.window->_flags, RGFW_HOLD_MOUSE))
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition.x += (float)event->vector.x;
|
||||
CORE.Input.Mouse.currentPosition.y += (float)event->vector.y;
|
||||
@ -1283,24 +1274,24 @@ int InitPlatform(void)
|
||||
unsigned int flags = RGFW_windowCenter | RGFW_windowAllowDND;
|
||||
|
||||
// Check window creation flags
|
||||
if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0)
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
|
||||
{
|
||||
CORE.Window.fullscreen = true;
|
||||
flags |= RGFW_windowFullscreen;
|
||||
FLAG_SET(flags, RGFW_windowFullscreen);
|
||||
}
|
||||
|
||||
if ((CORE.Window.flags & FLAG_BORDERLESS_WINDOWED_MODE) > 0)
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_BORDERLESS_WINDOWED_MODE))
|
||||
{
|
||||
CORE.Window.fullscreen = true;
|
||||
flags |= RGFW_windowedFullscreen;
|
||||
FLAG_SET(flags, RGFW_windowedFullscreen);
|
||||
}
|
||||
|
||||
if ((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) > 0) flags |= RGFW_windowNoBorder;
|
||||
if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) == 0) flags |= RGFW_windowNoResize;
|
||||
if ((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) > 0) flags |= RGFW_windowTransparent;
|
||||
if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0) flags |= RGFW_windowFullscreen;
|
||||
if ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0) flags |= RGFW_windowHide;
|
||||
if ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0) flags |= RGFW_windowMaximize;
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_UNDECORATED)) FLAG_SET(flags, RGFW_windowNoBorder);
|
||||
if (!FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_RESIZABLE)) FLAG_SET(flags, RGFW_windowNoResize);
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_TRANSPARENT)) FLAG_SET(flags, RGFW_windowTransparent);
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE)) FLAG_SET(flags, RGFW_windowFullscreen);
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIDDEN)) FLAG_SET(flags, RGFW_windowHide);
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_MAXIMIZED)) FLAG_SET(flags, RGFW_windowMaximize);
|
||||
|
||||
// NOTE: Some OpenGL context attributes must be set before window creation
|
||||
// Check selection OpenGL version
|
||||
@ -1320,9 +1311,9 @@ int InitPlatform(void)
|
||||
RGFW_setGLHint(RGFW_glMinor, 3);
|
||||
}
|
||||
|
||||
if (CORE.Window.flags & FLAG_MSAA_4X_HINT) RGFW_setGLHint(RGFW_glSamples, 4);
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT)) RGFW_setGLHint(RGFW_glSamples, 4);
|
||||
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED)) flags |= RGFW_windowFocusOnShow | RGFW_windowFocus;
|
||||
if (!FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED)) FLAG_SET(flags, RGFW_windowFocusOnShow | RGFW_windowFocus);
|
||||
|
||||
platform.window = RGFW_createWindow(CORE.Window.title, RGFW_RECT(0, 0, CORE.Window.screen.width, CORE.Window.screen.height), flags);
|
||||
platform.mon.mode.area.w = 0;
|
||||
@ -1345,8 +1336,8 @@ int InitPlatform(void)
|
||||
// TODO: Is this needed by raylib now?
|
||||
// If so, rcore_desktop_sdl should be updated too
|
||||
//SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height);
|
||||
|
||||
if (CORE.Window.flags & FLAG_VSYNC_HINT) RGFW_window_swapInterval(platform.window, 1);
|
||||
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_VSYNC_HINT)) RGFW_window_swapInterval(platform.window, 1);
|
||||
RGFW_window_makeCurrent(platform.window);
|
||||
|
||||
// Check surface and context activation
|
||||
|
||||
Reference in New Issue
Block a user