The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Window -> FullScreen_Desktop Inconsistent issues
Magnet


Joined: 14 May 2014
Posts: 20
I've noticed several issues or inconsistencies between Windows, Linux, OSX when switching between Window Mode and FullScreen_Desktop.

The basic's on ALT + ENTER. I set (3) Switches.
The Initial Window starts in Window Mode 1280x800 rez.

ALT + ENTER will loop (3) separate display modes.
1. FullScreen_Desktop
2. 640x400
3. 1280x800
Then go back to 1.

Code:

First:
SDL_SetWindowFullscreen(globalWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
RedrawTextureAndRender();  // Basic Function to redraw the screen.

Second:
SDL_SetWindowFullscreen(globalWindow, 0);
SDL_SetWindowSize(globalWindow, 640, 400);
RedrawTextureAndRender();

Third:
SDL_SetWindowFullscreen(globalWindow, 0);
SDL_SetWindowSize(globalWindow, 1280, 800);
RedrawTextureAndRender();


Now this basic code works in windows, But when you get to Linux and OSX it's goes to the crapper.

Frist, the last resolution before going full screen was 1280x800. This seems to cause issues when exiting full screen, and changing to 640x480 in Linux and OSX. Instead of going to 640x480, it automatically keeps the 1280x800 window size. Then when you hit ALT+ENTER again, it's cycles again to 1280x800.

So to fix this. before going full screen, I set the window size to 640x400, then go full screen like:

Code:

First:
SDL_SetWindowSize(TheTerminal::Instance()->getWindow(), 640, 400);  // Go to 640x400 before full screen.
SDL_SetWindowFullscreen(globalWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
RedrawTextureAndRender();  // Basic Function to redraw the screen.

Second:
SDL_SetWindowFullscreen(globalWindow, 0);
SDL_SetWindowSize(globalWindow, 640, 400);
RedrawTextureAndRender();

Third:
SDL_SetWindowFullscreen(globalWindow, 0);
SDL_SetWindowSize(globalWindow, 1280, 800);
RedrawTextureAndRender();


Ok, so now the Windows are resizing properly when I switch each mode in windows and osx. However, back in Linux, the screen is all garbled on the redraws, like the texture was corrupted when switching modes.

So back to the drawing board, I create a new function to clear the texture and try again.

Now it looks like:

Code:

First:
SDL_SetWindowSize(TheTerminal::Instance()->getWindow(), 640, 400);
SDL_SetWindowFullscreen(globalWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);

RecreateTexture();      // Destroy and Recreate
RedrawTextureAndRender();  // Basic Function to redraw the screen.

Second:
SDL_SetWindowFullscreen(globalWindow, 0);
SDL_SetWindowSize(globalWindow, 640, 400);
[b]RecreateTexture();[/b]
RedrawTextureAndRender();

Third:
SDL_SetWindowFullscreen(globalWindow, 0);
SDL_SetWindowSize(globalWindow, 1280, 800);
RecreateTexture();
RedrawTextureAndRender();


Now everything is working nice in Windows and Linux when switching all the modes. Back to OSX. Now OSX is like hmm, trying to be fancy now forget it!!! Now switching to FULLSCREEN_DESKTOP, you see it redraw fine it does it's fancy animation as it maximizes the window, then bam, the entire screen goes white. If I take out the RedrawTextureAndRender(); to see what it does, it goes white before the windows animates and resizes. So I know it's not a drawing problem.

Now keep in mind I've checked all Window sizing and general events and have no screen redraws. I've event added a few like after maximized to redraw it again, nothing works until a key is hit, then it redraws normally with the program.

So there is nothing else going on, No matter what I comment out, the screen goes white for no reason. If I take out the switching to 640x400 before going full screen, then the next video modes goes all white. It's a nasty chain of events where stuff doesn't want to work.

So then I try one last thing after a very long night. I made a new function now to destroy the window and renderer, and recreate them each for the specific mode instead of relying on the window mode switching.

Eureka it works. But now switching is a little slower, and this seems pretty hackish to me. But its been the only way to get (3) mode toggles to work across all (3) Platforms.

Has anyone else ran into these problems across OSX/Linux/Windows? I really don't want to settle with destroying and recreating the window, renderer, texture each time just so it works the same across OSX, Linux and Windows. But I will use It for now to keep things consistent.