Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcore_desktop] Upon entering fullscreen, uses original window size #3929

Open
Tracked by #4147
OilyFishMan opened this issue Apr 22, 2024 · 9 comments
Open
Tracked by #4147
Labels
help needed - please! I need help with this issue windowing Issues about the window system

Comments

@OilyFishMan
Copy link

OilyFishMan commented Apr 22, 2024

Issue description

Upon running the procedure ToggleFullscreen(), raylib reports "GetScreenWidth()" and "GetScreenHeight()" as values set before SetWindowSize(x, y). However, without ToggleFullscreen(), the original values are kept for one frame then immediately restored to correct full resolution.

Environment

Platform backend: DESKTOP (GLFW)
OS: Fedora 39 x86_64
Desktop: Gnome X11
OpenGL version: 4.6
GPU: Integrated

Issue Screenshot

Screencast from 2024-04-22 18-22-46.webm
Screencast from 2024-04-22 18-26-19.webm

Code Example

#include <stdio.h>
#include <raylib.h>

int main(void)
{
    InitWindow(1, 1, "Application");
    int display = GetCurrentMonitor();
    SetWindowSize(GetMonitorWidth(display), GetMonitorHeight(display));
    ToggleFullscreen();
    while (!WindowShouldClose()) {
        BeginDrawing();
        DrawRectangle(0, 0, GetMonitorWidth(display), GetMonitorHeight(display), RAYWHITE);
        printf("%d %d\n", GetScreenWidth(), GetScreenHeight());
        DrawRectangle(0, 0, GetScreenWidth() / 2, GetScreenHeight() / 2, RED);
        EndDrawing();
    }
    CloseWindow();
    return 0;
}
@MagiRomanya
Copy link

It seems that the actual resizing of the window contents is done in the WindowSizeCallback after the first call to EndDrawing() in the game loop.
However, there is this line that prevents CORE.Window.screen.width and height to be updated in the callback:

if (IsWindowFullscreen()) return;

Commenting this line solved the issue for me, but I presume is there for a reason.

@OilyFishMan
Copy link
Author

That's really strange. To me this definitely doesn't seem like expected behavior.

@raysan5
Copy link
Owner

raysan5 commented Apr 25, 2024

Commenting this line solved the issue for me, but I presume is there for a reason.

There should probably be a comment there explaining that reason... I don't know at the moment...

@raysan5 raysan5 added the help needed - please! I need help with this issue label May 5, 2024
@archewashi
Copy link
Contributor

I ran the sample code under msys2 and Fedora.
It worked well in msys2. GetScreenWidth() and GetScreenHeight() would return the correct full resolution at the first frame. However, the same situation like this issue occurred in Fedora.

I found the reason is when WindowSizeCallback() is called.
In msys2, WindowSizeCallback() will be called after calling SetWindowSize() ( just before ToggleFullScreen()), but in Fedora, it will be called after EndDrawing().
Because of that, we can get the correct value after ToggleFullScreen() in msys2 but can't in Fedora.

@raysan5
Copy link
Owner

raysan5 commented May 6, 2024

@archewashi Thanks for the further investigation and provided details! It seems a platform-dependant issue, that's usually difficult to address...

@archewashi
Copy link
Contributor

I guess the reason is the glfw commands to X11 are asynchronous (X11 handle commands asynchronously). XFlush may solve this problem, but it should be a bit dangerous.

@Parzival-3141
Copy link

I'm running into the same issue (coincidentally with the same environment specs!), and I've found using GetRenderWidth/Height() is a suitable workaround.

@SuperUserNameMan
Copy link
Contributor

maybe it is ok to update the values of CORE.window.screen.width/height directly into ToggleFullscreen() and ToggleBorderlessWindowed() like I proposed into this PR https://github.com/raysan5/raylib/pull/4151/files ?

@archewashi
Copy link
Contributor

@raysan5 I found this PR #4074 , and logically, this issue should have been resolved. I tested it on Fedora in a VM, and no problems occurred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help needed - please! I need help with this issue windowing Issues about the window system
Projects
None yet
Development

No branches or pull requests

6 participants