mirror of
https://github.com/raysan5/raylib.git
synced 2026-05-13 17:04:31 +00:00
[rcore][RGFW] Add fullscreen behaviour on size 0 window creation (#5859)
* port glfw's behaviour on size 0 window creation to rgfw * updates with change suggestions * don't do the FLAG_FULLSCREEN_MODE check twice for no reason --------- Co-authored-by: CrackedPixel <5776225+CrackedPixel@users.noreply.github.com>
This commit is contained in:
79
src/platforms/rcore_desktop_rgfw.c
Executable file → Normal file
79
src/platforms/rcore_desktop_rgfw.c
Executable file → Normal file
@@ -1677,10 +1677,62 @@ int InitPlatform(void)
|
||||
// Initialize RGFW internal global state, only required systems
|
||||
unsigned int flags = RGFW_windowCenter | RGFW_windowAllowDND;
|
||||
|
||||
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_WINDOW_HIDDEN)) FLAG_SET(flags, RGFW_windowHide);
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_MAXIMIZED)) FLAG_SET(flags, RGFW_windowMaximize);
|
||||
if (!FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED)) FLAG_SET(flags, RGFW_windowFocusOnShow | RGFW_windowFocus);
|
||||
|
||||
if ((CORE.Window.screen.width == 0) || (CORE.Window.screen.height == 0))
|
||||
{
|
||||
FLAG_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
|
||||
}
|
||||
|
||||
// Check window creation flags
|
||||
|
||||
// Init window in fullscreen mode if requested
|
||||
// NOTE: Keeping original screen size for toggle
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
|
||||
{
|
||||
FLAG_SET(flags, RGFW_windowFullscreen);
|
||||
int result = RGFW_init();
|
||||
if (result != 0)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RGFW: Failed to initialize RGFW");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// NOTE: Fullscreen applications default to the primary monitor
|
||||
RGFW_monitor *monitor = RGFW_getPrimaryMonitor();
|
||||
if (!monitor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RGFW: Failed to get primary monitor");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Default display resolution to that of the current mode
|
||||
CORE.Window.display.width = monitor->mode.w;
|
||||
CORE.Window.display.height = monitor->mode.h;
|
||||
|
||||
// Check if user requested some screen size
|
||||
if ((CORE.Window.screen.width == 0) || (CORE.Window.screen.height == 0))
|
||||
{
|
||||
// Set some default screen size in case user decides to exit fullscreen mode
|
||||
CORE.Window.previousScreen.width = 800;
|
||||
CORE.Window.previousScreen.height = 450;
|
||||
CORE.Window.previousPosition.x = (CORE.Window.display.width - CORE.Window.previousScreen.width)/2;
|
||||
CORE.Window.previousPosition.y = (CORE.Window.display.height - CORE.Window.previousScreen.height)/2;
|
||||
|
||||
// Set screen width/height to the display width/height
|
||||
if (CORE.Window.screen.width == 0) CORE.Window.screen.width = CORE.Window.display.width;
|
||||
if (CORE.Window.screen.height == 0) CORE.Window.screen.height = CORE.Window.display.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
CORE.Window.previousScreen = CORE.Window.screen;
|
||||
CORE.Window.screen = CORE.Window.display;
|
||||
}
|
||||
}
|
||||
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_BORDERLESS_WINDOWED_MODE))
|
||||
@@ -1688,16 +1740,16 @@ int InitPlatform(void)
|
||||
FLAG_SET(flags, RGFW_windowedFullscreen);
|
||||
}
|
||||
|
||||
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);
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||
{
|
||||
#if !defined(__APPLE__)
|
||||
CORE.Window.screen.width = CORE.Window.screen.width * GetWindowScaleDPI().x;
|
||||
CORE.Window.screen.height = CORE.Window.screen.height * GetWindowScaleDPI().y;
|
||||
#endif
|
||||
}
|
||||
|
||||
// NOTE: Some OpenGL context attributes must be set before window creation
|
||||
// Check selection OpenGL version
|
||||
|
||||
RGFW_glHints* hints = RGFW_getGlobalHints_OpenGL();
|
||||
if (rlGetVersion() == RL_OPENGL_21)
|
||||
{
|
||||
@@ -1720,20 +1772,9 @@ int InitPlatform(void)
|
||||
hints->minor = 1;
|
||||
hints->renderer = RGFW_glSoftware;
|
||||
}
|
||||
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT)) hints->samples = 4;
|
||||
|
||||
if (!FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED)) FLAG_SET(flags, RGFW_windowFocusOnShow | RGFW_windowFocus);
|
||||
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||
{
|
||||
#if !defined(__APPLE__)
|
||||
CORE.Window.screen.width = CORE.Window.screen.width * GetWindowScaleDPI().x;
|
||||
CORE.Window.screen.height = CORE.Window.screen.height * GetWindowScaleDPI().y;
|
||||
#endif
|
||||
}
|
||||
|
||||
RGFW_setGlobalHints_OpenGL(hints);
|
||||
|
||||
platform.window = RGFW_createWindow((CORE.Window.title != 0)? CORE.Window.title : " ", 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, flags | RGFW_windowOpenGL);
|
||||
|
||||
#ifndef PLATFORM_WEB_RGFW
|
||||
|
||||
Reference in New Issue
Block a user