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

Changing display mode during fullscreen for some modes produces a black screen #11557

Open
flowCRANE opened this issue Nov 29, 2024 · 2 comments

Comments

@flowCRANE
Copy link

flowCRANE commented Nov 29, 2024

Windows 10 (64-bit)
SDL 3.1.6 (64-bit)

To display a window in exclusive full screen, I get the target mode data and start full screen mode like this:

SDL_SetWindowFullscreen     (Window, True);
SDL_SetWindowFullscreenMode (Window, TargetMode);
SDL_SyncWindow              (Window);

Everything works, no problems, on any display. Now if I want to change the resolution of such an exclusive full screen mode, I define a new target display mode and set it, like this:

SDL_SetWindowFullscreenMode (Window, NewTargetMode);
SDL_SyncWindow              (Window);

And here is the problem. Although the new target display mode is applied, for some modes the screen remains black. The resolution is consistent with the mode, the window size as well (I checked by getting the client window size — no inconsistencies), but the screen remains black and the system cursor is not visible. In order for the window to actually appear on the screen, I have to deactivate it (Alt+Tab or by clicking on another screen), then it will minimize, and then restore it from the taskbar.

Interestingly, this issue only occurs for certain modes (almost half of those supported by my monitor), but I haven't found any data to tell me if there's any consistency to this — it just seems a bit random at the moment. The only temporary hack I've found that fixes this issue is to disable and re-enable fullscreen just before applying the new target display mode:

SDL_SetWindowFullscreen     (Window, False);
SDL_SetWindowFullscreen     (Window, True);
SDL_SetWindowFullscreenMode (Window, NewTargetMode);
SDL_SyncWindow              (Window);

The screen flashes a little longer, but at least it finally shows a window on it.


Edit: such a black screen only occurs with some drivers — if I don't specify any (I give null as the driver name) or I use the gpu driver name, the black screen occurs. In case of opengl, direct3d11 and direct3d12 everything works perfectly fine.

@Squall-Leonhart
Copy link

Why does this sound like you're applying how you'd set up an SDL2 video driver on SDL3?

SDL_GetRenderDriverInfo() has been removed, since most of the information it reported were estimates and could not be accurate before creating a renderer. Often times this function was used to figure out the index of a driver, so one would call it in a for-loop, looking for the driver named "opengl" or whatnot. SDL_GetRenderDriver() has been added for this functionality, which returns only the name of the driver.

SDL_CreateRenderer()'s second argument is no longer an integer index, but a const char * representing a renderer's name; if you were just using a for-loop to find which index is the "opengl" or whatnot driver, you can just pass that string directly here, now. Passing NULL is the same as passing -1 here in SDL2, to signify you want SDL to decide for you.

@flowCRANE
Copy link
Author

flowCRANE commented Dec 1, 2024

Because I'm using the basic SDL3 renderer, which is nothing wrong and nothing special. I don't do anything that isn't officially supported by SDL3. I got the names of all drivers supported by my machine using the SDL_GetRenderDriver function (based on the SDL_GetNumRenderDrivers result to know how many there are) and I have the following at my disposal:

gpu, 
direct3d11, 
direct3d12, 
direct3d, 
opengl, 
opengles2, 
vulkan, 
software

I checked how fullscreen support looks like and encountered problems with changing the resolution when the renderer is created without specifying the name of a driver (i.e. when SDL is to select it automatically) or if I specify the driver name as gpu.

Edit: if I do not specify the driver name myself, SDL automatically selects the gpu driver for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants