REVIEWED: Window state flags -WIP-

WARNING: Several functions removed, replaced by SetWindowState() / ClearWindowState() equivalents, only for advance users.
ADDED: ClearWindowState() to reset window state
REMOVED: HideWindow() / UnhideWindow()
REMOVED: DecorateWindow() / UndecorateWindow()
This commit is contained in:
Ray 2020-11-23 23:46:05 +01:00
parent 468a0bedd8
commit 3d1ae3500c
3 changed files with 266 additions and 118 deletions

View File

@ -20,24 +20,23 @@ int main(void)
// Possible window flags
/*
FLAG_FULLSCREEN_MODE -> not working
FLAG_VSYNC_HINT
FLAG_FULLSCREEN_MODE -> not working properly -> wrong scaling!
FLAG_WINDOW_RESIZABLE
FLAG_WINDOW_UNDECORATED
FLAG_WINDOW_TRANSPARENT
FLAG_WINDOW_HIDDEN
FLAG_WINDOW_MINIMIZED -> not working
FLAG_WINDOW_MAXIMIZED -> not working
FLAG_WINDOW_MINIMIZED -> not working properly -> Support it on window creation?
FLAG_WINDOW_MAXIMIZED -> not working properly -> Support it on window creation?
FLAG_WINDOW_UNFOCUSED
FLAG_WINDOW_TOPMOST
FLAG_WINDOW_HIGHDPI -> errors after minimize-resize, fb size is recalculated
FLAG_WINDOW_ALWAYS_RUN -> not working
FLAG_VSYNC_HINT
FLAG_WINDOW_ALWAYS_RUN -> not working?
FLAG_MSAA_4X_HINT
FLAG_INTERLACED_HINT
*/
// Set configuration flags for window creation
SetConfigFlags(FLAG_WINDOW_HIGHDPI);
SetConfigFlags(FLAG_VSYNC_HINT | FLAG_MSAA_4X_HINT | FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_ALWAYS_RUN);
InitWindow(screenWidth, screenHeight, "raylib [core] example - window flags");
Vector2 ballPosition = { GetScreenWidth()/2, GetScreenHeight()/2 };
@ -46,7 +45,7 @@ int main(void)
int framesCounter = 0;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//----------------------------------------------------------
// Main game loop
@ -54,22 +53,75 @@ int main(void)
{
// Update
//-----------------------------------------------------
if (IsKeyPressed(KEY_ONE)) SetWindowState(FLAG_FULLSCREEN_MODE);
if (IsKeyPressed(KEY_TWO)) SetWindowState(FLAG_WINDOW_RESIZABLE);
if (IsKeyPressed(KEY_THREE)) SetWindowState(FLAG_WINDOW_UNDECORATED);
if (IsKeyPressed(KEY_FOUR)) { SetWindowState(FLAG_WINDOW_HIDDEN); framesCounter = 0; }
if (IsKeyPressed(KEY_FIVE)) SetWindowState(FLAG_WINDOW_MINIMIZED);
if (IsKeyPressed(KEY_SIX)) SetWindowState(FLAG_WINDOW_MAXIMIZED); // NOTE: Requires FLAG_WINDOW_RESIZABLE!
if (IsKeyPressed(KEY_SEVEN)) SetWindowState(FLAG_WINDOW_UNFOCUSED); // not working
if (IsKeyPressed(KEY_EIGHT)) SetWindowState(FLAG_WINDOW_TOPMOST);
if (IsKeyPressed(KEY_F)) ToggleFullscreen(); // modifies window size when scaling!
if (IsKeyPressed(KEY_R)) RestoreWindow();
if (IsKeyPressed(KEY_D)) DecorateWindow();
if (IsKeyPressed(KEY_R))
{
if (IsWindowState(FLAG_WINDOW_RESIZABLE)) ClearWindowState(FLAG_WINDOW_RESIZABLE);
else SetWindowState(FLAG_WINDOW_RESIZABLE);
}
if (IsKeyPressed(KEY_D))
{
if (IsWindowState(FLAG_WINDOW_UNDECORATED)) ClearWindowState(FLAG_WINDOW_UNDECORATED);
else SetWindowState(FLAG_WINDOW_UNDECORATED);
}
if (IsKeyPressed(KEY_H))
{
if (!IsWindowState(FLAG_WINDOW_HIDDEN)) SetWindowState(FLAG_WINDOW_HIDDEN);
framesCounter = 0;
}
if (IsWindowState(FLAG_WINDOW_HIDDEN))
{
framesCounter++;
if (framesCounter >= 180) UnhideWindow(); // Show window after 3 seconds
if (framesCounter >= 240) ClearWindowState(FLAG_WINDOW_HIDDEN); // Show window after 3 seconds
}
if (IsKeyPressed(KEY_N))
{
if (!IsWindowState(FLAG_WINDOW_MINIMIZED)) MinimizeWindow();
framesCounter = 0;
}
if (IsWindowState(FLAG_WINDOW_MINIMIZED))
{
framesCounter++;
if (framesCounter >= 240) RestoreWindow(); // Restore window after 3 seconds
}
if (IsKeyPressed(KEY_M))
{
// NOTE: Requires FLAG_WINDOW_RESIZABLE enabled!
if (IsWindowState(FLAG_WINDOW_MAXIMIZED)) RestoreWindow();
else MaximizeWindow();
}
if (IsKeyPressed(KEY_U))
{
if (IsWindowState(FLAG_WINDOW_UNFOCUSED)) ClearWindowState(FLAG_WINDOW_UNFOCUSED);
else SetWindowState(FLAG_WINDOW_UNFOCUSED);
}
if (IsKeyPressed(KEY_T))
{
if (IsWindowState(FLAG_WINDOW_TOPMOST)) ClearWindowState(FLAG_WINDOW_TOPMOST);
else SetWindowState(FLAG_WINDOW_TOPMOST);
}
if (IsKeyPressed(KEY_A))
{
if (IsWindowState(FLAG_WINDOW_ALWAYS_RUN)) ClearWindowState(FLAG_WINDOW_ALWAYS_RUN);
else SetWindowState(FLAG_WINDOW_ALWAYS_RUN);
}
if (IsKeyPressed(KEY_V))
{
if (IsWindowState(FLAG_VSYNC_HINT)) ClearWindowState(FLAG_VSYNC_HINT);
else SetWindowState(FLAG_VSYNC_HINT);
}
// Bouncing ball logic
@ -83,31 +135,48 @@ int main(void)
//-----------------------------------------------------
BeginDrawing();
ClearBackground(BLANK);
if (IsWindowState(FLAG_WINDOW_TRANSPARENT)) ClearBackground(BLANK);
else ClearBackground(RAYWHITE);
DrawCircleV(ballPosition, ballRadius, MAROON);
DrawRectangleLinesEx((Rectangle){ 0, 0, GetScreenWidth(), GetScreenHeight() }, 4, RAYWHITE);
DrawCircleV(GetMousePosition(), 10, DARKBLUE);
DrawFPS(10, 10);
DrawText(FormatText("Screen Width: %i", GetScreenWidth()), 10, 40, 10, GREEN);
DrawText(FormatText("Screen Height: %i", GetScreenHeight()), 10, 60, 10, GREEN);
DrawText(FormatText("Screen Size: [%i, %i]", GetScreenWidth(), GetScreenHeight()), 10, 40, 10, GREEN);
// Draw window state info
DrawText(FormatText("FLAG_FULLSCREEN_MODE: %s", IsWindowState(FLAG_FULLSCREEN_MODE)? "true" : "false"), 10, 80, 10, GREEN);
DrawText(FormatText("FLAG_WINDOW_RESIZABLE: %s", IsWindowState(FLAG_WINDOW_RESIZABLE)? "true" : "false"), 10, 100, 10, GREEN);
DrawText(FormatText("FLAG_WINDOW_UNDECORATED: %s", IsWindowState(FLAG_WINDOW_UNDECORATED)? "true" : "false"), 10, 120, 10, GREEN);
DrawText(FormatText("FLAG_WINDOW_TRANSPARENT: %s", IsWindowState(FLAG_WINDOW_TRANSPARENT)? "true" : "false"), 10, 140, 10, GREEN);
DrawText(FormatText("FLAG_WINDOW_HIDDEN: %s", IsWindowState(FLAG_WINDOW_HIDDEN)? "true" : "false"), 10, 160, 10, GREEN);
DrawText(FormatText("FLAG_WINDOW_MINIMIZED: %s", IsWindowState(FLAG_WINDOW_MINIMIZED)? "true" : "false"), 10, 180, 10, GREEN);
DrawText(FormatText("FLAG_WINDOW_MAXIMIZED: %s", IsWindowState(FLAG_WINDOW_MAXIMIZED)? "true" : "false"), 10, 200, 10, GREEN);
DrawText(FormatText("FLAG_WINDOW_UNFOCUSED: %s", IsWindowState(FLAG_WINDOW_UNFOCUSED)? "true" : "false"), 10, 220, 10, GREEN);
DrawText(FormatText("FLAG_WINDOW_TOPMOST: %s", IsWindowState(FLAG_WINDOW_TOPMOST)? "true" : "false"), 10, 240, 10, GREEN);
DrawText(FormatText("FLAG_WINDOW_HIGHDPI: %s", IsWindowState(FLAG_WINDOW_HIGHDPI)? "true" : "false"), 10, 260, 10, GREEN);
DrawText(FormatText("FLAG_WINDOW_ALWAYS_RUN: %s", IsWindowState(FLAG_WINDOW_ALWAYS_RUN)? "true" : "false"), 10, 280, 10, GREEN);
DrawText(FormatText("FLAG_VSYNC_HINT: %s", IsWindowState(FLAG_VSYNC_HINT)? "true" : "false"), 10, 300, 10, GREEN);
DrawText(FormatText("FLAG_MSAA_4X_HINT: %s", IsWindowState(FLAG_MSAA_4X_HINT)? "true" : "false"), 10, 320, 10, GREEN);
DrawText(FormatText("FLAG_INTERLACED_HINT: %s", IsWindowState(FLAG_INTERLACED_HINT)? "true" : "false"), 10, 340, 10, GREEN);
DrawText("Following flags can set after window creation:", 10, 60, 10, GRAY);
if (IsWindowState(FLAG_FULLSCREEN_MODE)) DrawText("[F] FLAG_FULLSCREEN_MODE: on", 10, 80, 10, LIME);
else DrawText("[F] FLAG_FULLSCREEN_MODE: off", 10, 80, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_RESIZABLE)) DrawText("[R] FLAG_WINDOW_RESIZABLE: on", 10, 100, 10, LIME);
else DrawText("[R] FLAG_WINDOW_RESIZABLE: off", 10, 100, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_UNDECORATED)) DrawText("[D] FLAG_WINDOW_UNDECORATED: on", 10, 120, 10, LIME);
else DrawText("[D] FLAG_WINDOW_UNDECORATED: off", 10, 120, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_HIDDEN)) DrawText("[H] FLAG_WINDOW_HIDDEN: on", 10, 140, 10, LIME);
else DrawText("[H] FLAG_WINDOW_HIDDEN: off", 10, 140, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_MINIMIZED)) DrawText("[N] FLAG_WINDOW_MINIMIZED: on", 10, 160, 10, LIME);
else DrawText("[N] FLAG_WINDOW_MINIMIZED: off", 10, 160, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_MAXIMIZED)) DrawText("[M] FLAG_WINDOW_MAXIMIZED: on", 10, 180, 10, LIME);
else DrawText("[M] FLAG_WINDOW_MAXIMIZED: off", 10, 180, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_UNFOCUSED)) DrawText("[G] FLAG_WINDOW_UNFOCUSED: on", 10, 200, 10, LIME);
else DrawText("[U] FLAG_WINDOW_UNFOCUSED: off", 10, 200, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_TOPMOST)) DrawText("[T] FLAG_WINDOW_TOPMOST: on", 10, 220, 10, LIME);
else DrawText("[T] FLAG_WINDOW_TOPMOST: off", 10, 220, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_ALWAYS_RUN)) DrawText("[A] FLAG_WINDOW_ALWAYS_RUN: on", 10, 240, 10, LIME);
else DrawText("[A] FLAG_WINDOW_ALWAYS_RUN: off", 10, 240, 10, MAROON);
if (IsWindowState(FLAG_VSYNC_HINT)) DrawText("[V] FLAG_VSYNC_HINT: on", 10, 260, 10, LIME);
else DrawText("[V] FLAG_VSYNC_HINT: off", 10, 260, 10, MAROON);
DrawText("Following flags can only be set before window creation:", 10, 300, 10, GRAY);
if (IsWindowState(FLAG_WINDOW_HIGHDPI)) DrawText("FLAG_WINDOW_HIGHDPI: on", 10, 320, 10, LIME);
else DrawText("FLAG_WINDOW_HIGHDPI: off", 10, 320, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_TRANSPARENT)) DrawText("FLAG_WINDOW_TRANSPARENT: on", 10, 340, 10, LIME);
else DrawText("FLAG_WINDOW_TRANSPARENT: off", 10, 340, 10, MAROON);
if (IsWindowState(FLAG_MSAA_4X_HINT)) DrawText("FLAG_MSAA_4X_HINT: on", 10, 360, 10, LIME);
else DrawText("FLAG_MSAA_4X_HINT: off", 10, 360, 10, MAROON);
EndDrawing();
//-----------------------------------------------------

View File

@ -919,7 +919,7 @@ bool WindowShouldClose(void)
if (CORE.Window.ready)
{
// While window minimized, stop loop execution
while (!IsWindowState(FLAG_WINDOW_ALWAYS_RUN) && IsWindowState(FLAG_WINDOW_MINIMIZED)) glfwWaitEvents();
while (IsWindowState(FLAG_WINDOW_MINIMIZED) && !IsWindowState(FLAG_WINDOW_ALWAYS_RUN)) glfwWaitEvents();
CORE.Window.shouldClose = glfwWindowShouldClose(CORE.Window.handle);
@ -1076,42 +1076,6 @@ void ToggleFullscreen(void)
#endif
}
// Set window state: hidden (only PLATFORM_DESKTOP)
void HideWindow(void)
{
#if defined(PLATFORM_DESKTOP)
glfwHideWindow(CORE.Window.handle);
CORE.Window.flags |= FLAG_WINDOW_HIDDEN;
#endif
}
// Set window state: visible (only PLATFORM_DESKTOP)
void UnhideWindow(void)
{
#if defined(PLATFORM_DESKTOP)
glfwShowWindow(CORE.Window.handle);
CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN;
#endif
}
// Set window state: decorated (only PLATFORM_DESKTOP)
void DecorateWindow(void)
{
#if defined(PLATFORM_DESKTOP)
glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_TRUE);
CORE.Window.flags &= ~FLAG_WINDOW_UNDECORATED;
#endif
}
// Set window state: undecorated (only PLATFORM_DESKTOP)
void UndecorateWindow(void)
{
#if defined(PLATFORM_DESKTOP)
glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_FALSE);
CORE.Window.flags |= FLAG_WINDOW_UNDECORATED;
#endif
}
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
void MaximizeWindow(void)
{
@ -1153,8 +1117,18 @@ void SetWindowState(unsigned int flags)
// Check previous state and requested state to apply required changes
// NOTE: In most cases the functions already change the flags internally
// State change: FLAG_VSYNC_HINT
if (((CORE.Window.flags & FLAG_VSYNC_HINT) != (flags & FLAG_VSYNC_HINT)) && ((flags & FLAG_VSYNC_HINT) > 0))
{
glfwSwapInterval(1);
CORE.Window.flags |= FLAG_VSYNC_HINT;
}
// State change: FLAG_FULLSCREEN_MODE
if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) != (flags & FLAG_FULLSCREEN_MODE)) ToggleFullscreen();
if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) != (flags & FLAG_FULLSCREEN_MODE))
{
ToggleFullscreen(); // NOTE: Window state flag updated inside function
}
// State change: FLAG_WINDOW_RESIZABLE
if (((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) != (flags & FLAG_WINDOW_RESIZABLE)) && ((flags & FLAG_WINDOW_RESIZABLE) > 0))
@ -1164,22 +1138,32 @@ void SetWindowState(unsigned int flags)
}
// State change: FLAG_WINDOW_UNDECORATED
if (((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) != (flags & FLAG_WINDOW_UNDECORATED)) && (flags & FLAG_WINDOW_UNDECORATED)) UndecorateWindow();
// State change: FLAG_WINDOW_TRANSPARENT
if (((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) != (flags & FLAG_WINDOW_TRANSPARENT)) && ((flags & FLAG_WINDOW_TRANSPARENT) > 0))
if (((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) != (flags & FLAG_WINDOW_UNDECORATED)) && (flags & FLAG_WINDOW_UNDECORATED))
{
TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only by set before window initialization");
glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_FALSE);
CORE.Window.flags |= FLAG_WINDOW_UNDECORATED;
}
// State change: FLAG_WINDOW_HIDDEN
if (((CORE.Window.flags & FLAG_WINDOW_HIDDEN) != (flags & FLAG_WINDOW_HIDDEN)) && ((flags & FLAG_WINDOW_HIDDEN) > 0)) HideWindow();
if (((CORE.Window.flags & FLAG_WINDOW_HIDDEN) != (flags & FLAG_WINDOW_HIDDEN)) && ((flags & FLAG_WINDOW_HIDDEN) > 0))
{
glfwHideWindow(CORE.Window.handle);
CORE.Window.flags |= FLAG_WINDOW_HIDDEN;
}
// State change: FLAG_WINDOW_MINIMIZED
if (((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) != (flags & FLAG_WINDOW_MINIMIZED)) && ((flags & FLAG_WINDOW_MINIMIZED) > 0)) MinimizeWindow();
if (((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) != (flags & FLAG_WINDOW_MINIMIZED)) && ((flags & FLAG_WINDOW_MINIMIZED) > 0))
{
//GLFW_ICONIFIED
MinimizeWindow(); // NOTE: Window state flag updated inside function
}
// State change: FLAG_WINDOW_MAXIMIZED
if (((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) != (flags & FLAG_WINDOW_MAXIMIZED)) && ((flags & FLAG_WINDOW_MAXIMIZED) > 0)) MaximizeWindow();
if (((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) != (flags & FLAG_WINDOW_MAXIMIZED)) && ((flags & FLAG_WINDOW_MAXIMIZED) > 0))
{
//GLFW_MAXIMIZED
MaximizeWindow(); // NOTE: Window state flag updated inside function
}
// State change: FLAG_WINDOW_UNFOCUSED
if (((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) != (flags & FLAG_WINDOW_UNFOCUSED)) && ((flags & FLAG_WINDOW_UNFOCUSED) > 0))
@ -1195,32 +1179,135 @@ void SetWindowState(unsigned int flags)
CORE.Window.flags |= FLAG_WINDOW_TOPMOST;
}
// State change: FLAG_WINDOW_ALWAYS_RUN
if (((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) != (flags & FLAG_WINDOW_ALWAYS_RUN)) && ((flags & FLAG_WINDOW_ALWAYS_RUN) > 0))
{
CORE.Window.flags |= FLAG_WINDOW_ALWAYS_RUN;
}
// The following states can not be changed after window creation
// State change: FLAG_WINDOW_TRANSPARENT
if (((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) != (flags & FLAG_WINDOW_TRANSPARENT)) && ((flags & FLAG_WINDOW_TRANSPARENT) > 0))
{
TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only by configured before window initialization");
}
// State change: FLAG_WINDOW_HIGHDPI
if (((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) != (flags & FLAG_WINDOW_HIGHDPI)) && ((flags & FLAG_WINDOW_HIGHDPI) > 0))
{
TRACELOG(LOG_WARNING, "WINDOW: High DPI can only by set before window initialization");
}
// State change: FLAG_WINDOW_ALWAYS_RUN
if (((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) != (flags & FLAG_WINDOW_ALWAYS_RUN)) && ((flags & FLAG_WINDOW_ALWAYS_RUN) > 0)) CORE.Window.flags |= FLAG_WINDOW_ALWAYS_RUN;
// State change: FLAG_VSYNC_HINT
if (((CORE.Window.flags & FLAG_VSYNC_HINT) != (flags & FLAG_VSYNC_HINT)) && ((flags & FLAG_VSYNC_HINT) > 0))
{
glfwSwapInterval(1);
CORE.Window.flags |= FLAG_VSYNC_HINT;
TRACELOG(LOG_WARNING, "WINDOW: High DPI can only by configured before window initialization");
}
// State change: FLAG_MSAA_4X_HINT
if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) != (flags & FLAG_MSAA_4X_HINT)) && ((flags & FLAG_MSAA_4X_HINT) > 0))
{
TRACELOG(LOG_WARNING, "WINDOW: MSAA can only by set before window initialization");
TRACELOG(LOG_WARNING, "WINDOW: MSAA can only by configured before window initialization");
}
// State change: FLAG_INTERLACED_HINT
if (((CORE.Window.flags & FLAG_INTERLACED_HINT) != (flags & FLAG_INTERLACED_HINT)) && ((flags & FLAG_INTERLACED_HINT) > 0))
{
TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only by set before window initialization");
TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only by configured before window initialization");
}
}
// Clear window configuration state flags
void ClearWindowState(unsigned int flags)
{
// Check previous state and requested state to apply required changes
// NOTE: In most cases the functions already change the flags internally
// State change: FLAG_VSYNC_HINT
if (((CORE.Window.flags & FLAG_VSYNC_HINT) > 0) && ((flags & FLAG_VSYNC_HINT) > 0))
{
glfwSwapInterval(0);
CORE.Window.flags ^= ~FLAG_VSYNC_HINT;
}
// State change: FLAG_FULLSCREEN_MODE
if (((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0) && ((flags & FLAG_FULLSCREEN_MODE) > 0))
{
ToggleFullscreen(); // NOTE: Window state flag updated inside function
}
// State change: FLAG_WINDOW_RESIZABLE
if (((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) > 0) && ((flags & FLAG_WINDOW_RESIZABLE) > 0))
{
glfwSetWindowAttrib(CORE.Window.handle, GLFW_RESIZABLE, GLFW_FALSE);
CORE.Window.flags &= ~FLAG_WINDOW_RESIZABLE;
}
// State change: FLAG_WINDOW_UNDECORATED
if (((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) > 0) && ((flags & FLAG_WINDOW_UNDECORATED) > 0))
{
glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_TRUE);
CORE.Window.flags &= ~FLAG_WINDOW_UNDECORATED;
}
// State change: FLAG_WINDOW_HIDDEN
if (((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0) && ((flags & FLAG_WINDOW_HIDDEN) > 0))
{
glfwShowWindow(CORE.Window.handle);
CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN;
}
// State change: FLAG_WINDOW_MINIMIZED
if (((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) && ((flags & FLAG_WINDOW_MINIMIZED) > 0))
{
RestoreWindow(); // NOTE: Window state flag updated inside function
}
// State change: FLAG_WINDOW_MAXIMIZED
if (((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0) && ((flags & FLAG_WINDOW_MAXIMIZED) > 0))
{
RestoreWindow(); // NOTE: Window state flag updated inside function
}
// State change: FLAG_WINDOW_UNFOCUSED
if (((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) > 0) && ((flags & FLAG_WINDOW_UNFOCUSED) > 0))
{
glfwSetWindowAttrib(CORE.Window.handle, GLFW_FOCUS_ON_SHOW, GLFW_TRUE);
CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED;
}
// State change: FLAG_WINDOW_TOPMOST
if (((CORE.Window.flags & FLAG_WINDOW_TOPMOST) > 0) && ((flags & FLAG_WINDOW_TOPMOST) > 0))
{
glfwSetWindowAttrib(CORE.Window.handle, GLFW_FLOATING, GLFW_FALSE);
CORE.Window.flags &= ~FLAG_WINDOW_TOPMOST;
}
// State change: FLAG_WINDOW_ALWAYS_RUN
if (((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) > 0) && ((flags & FLAG_WINDOW_ALWAYS_RUN) > 0))
{
CORE.Window.flags &= ~FLAG_WINDOW_ALWAYS_RUN;
}
// The following states can not be changed after window creation
// State change: FLAG_WINDOW_TRANSPARENT
if (((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) > 0) && ((flags & FLAG_WINDOW_TRANSPARENT) > 0))
{
TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only by configured before window initialization");
}
// State change: FLAG_WINDOW_HIGHDPI
if (((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0) && ((flags & FLAG_WINDOW_HIGHDPI) > 0))
{
TRACELOG(LOG_WARNING, "WINDOW: High DPI can only by configured before window initialization");
}
// State change: FLAG_MSAA_4X_HINT
if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) > 0) && ((flags & FLAG_MSAA_4X_HINT) > 0))
{
TRACELOG(LOG_WARNING, "WINDOW: MSAA can only by configured before window initialization");
}
// State change: FLAG_INTERLACED_HINT
if (((CORE.Window.flags & FLAG_INTERLACED_HINT) > 0) && ((flags & FLAG_INTERLACED_HINT) > 0))
{
TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only by configured before window initialization");
}
}
@ -3012,17 +3099,17 @@ static bool InitGraphicsDevice(int width, int height)
// Check window creation flags
if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0) CORE.Window.fullscreen = true;
if ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0) glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // Visible window
if ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0) glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // Visible window
else glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE); // Window initially hidden
if ((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) > 0) glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); // Border and buttons on Window
if ((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) > 0) glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); // Border and buttons on Window
else glfwWindowHint(GLFW_DECORATED, GLFW_TRUE); // Decorated window
if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) > 0) glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // Resizable window
if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) > 0) glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // Resizable window
else glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); // Avoid window being resizable
if ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0) glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
else glfwWindowHint(GLFW_MAXIMIZED, GLFW_FALSE);
if ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0) glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
else glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE);
if ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) > 0) glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE);
else glfwWindowHint(GLFW_FOCUSED, GLFW_TRUE);
@ -3176,7 +3263,7 @@ static bool InitGraphicsDevice(int width, int height)
TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height);
TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y);
}
glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback); // NOTE: Resizing not allowed by default!
glfwSetCursorEnterCallback(CORE.Window.handle, CursorEnterCallback);
glfwSetKeyCallback(CORE.Window.handle, KeyCallback);
@ -3822,6 +3909,9 @@ static bool InitGraphicsDevice(int width, int height)
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_UWP)
CORE.Window.ready = true;
#endif
if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) MinimizeWindow();
return true;
}

View File

@ -154,8 +154,6 @@
// Temporal hack to avoid breaking old codebases using
// deprecated raylib implementation of these functions
#define FormatText TextFormat
#define SubText TextSubtext
#define ShowWindow UnhideWindow
#define LoadText LoadFileText
#define GetExtension GetFileExtension
//#define Fade(c, a) ColorAlpha(c, a)
@ -466,18 +464,18 @@ typedef struct VrDeviceInfo {
// NOTE: Every bit registers one state (use it with bit masks)
// By default all flags are set to 0
typedef enum {
FLAG_VSYNC_HINT = 0x00000040, // Set to try enabling V-Sync on GPU
FLAG_FULLSCREEN_MODE = 0x00000002, // Set to run program in fullscreen
FLAG_WINDOW_RESIZABLE = 0x00000004, // Set to allow resizable window
FLAG_WINDOW_UNDECORATED = 0x00000008, // Set to disable window decoration (frame and buttons)
FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer
FLAG_WINDOW_HIDDEN = 0x00000080, // Set to hide window
FLAG_WINDOW_MINIMIZED = 0x00000200, // Set to minimize window (iconify)
FLAG_WINDOW_MAXIMIZED = 0x00000400, // Set to maximize window (expanded to monitor)
FLAG_WINDOW_UNFOCUSED = 0x00000800, // Set to window non focused
FLAG_WINDOW_TOPMOST = 0x00001000, // Set to window always on top
FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI
FLAG_WINDOW_ALWAYS_RUN = 0x00000100, // Set to allow windows running while minimized
FLAG_VSYNC_HINT = 0x00000040, // Set to try enabling V-Sync on GPU
FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer
FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI
FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X
FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D)
} ConfigFlag;
@ -899,15 +897,12 @@ RLAPI bool IsWindowMaximized(void); // Check if wi
RLAPI bool IsWindowFocused(void); // Check if window is currently focused (only PLATFORM_DESKTOP)
RLAPI bool IsWindowResized(void); // Check if window has been resized last frame
RLAPI bool IsWindowState(unsigned int flag); // Check if one specific window flag is enabled
RLAPI void SetWindowState(unsigned int flags); // Set window configuration state using flags
RLAPI void ClearWindowState(unsigned int flags); // Clear window configuration state flags
RLAPI void ToggleFullscreen(void); // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)
RLAPI void HideWindow(void); // Set window state: hidden (only PLATFORM_DESKTOP)
RLAPI void UnhideWindow(void); // Set window state: visible (only PLATFORM_DESKTOP)
RLAPI void DecorateWindow(void); // Set window state: decorated (only PLATFORM_DESKTOP)
RLAPI void UndecorateWindow(void); // Set window state: undecorated (only PLATFORM_DESKTOP)
RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
RLAPI void SetWindowState(unsigned int flags); // Set window configuration state using flags
RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP)
RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP)
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
@ -1499,12 +1494,6 @@ RLAPI void SetAudioStreamVolume(AudioStream stream, float volume); // Set vol
RLAPI void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level)
RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams
//------------------------------------------------------------------------------------
// Network (Module: network)
//------------------------------------------------------------------------------------
// IN PROGRESS: Check rnet.h for reference
#if defined(__cplusplus)
}
#endif