Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 60 additions & 19 deletions src/platforms/rcore_desktop_rgfw.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -1677,27 +1677,79 @@ 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))
{
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)
{
Expand All @@ -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
Expand Down
Loading