I’m writing an app/game in SDL2/C++ in which the user can change the resolution as well as toggle fullscreen. For debug purposes, I’m writing text to the screen which displays the current resolution, retrieving the X/Y with SDL_GetWindowSize()
The resolutions I currently have enabled as options are:
To change resolutions, I’m using SDL_SetWindowSize(myWindow, x, y);
Changing resolutions is working as expected when in windowed mode. When I change res, the debug text displaying the resolution matches with the resolution the user chose. The problems begin with Fullscreen mode.
To toggle Fullscreen, I’m using SDL_SetWindowFullscreen(myWindow, 1);
This works with caveats, if I’m in 320x240 and I fullscreen, it works, but the debug resolution text displays 640x480, well, I assume that’s simply because 320x240 is too small of a res for the monitor to fullscreen, so maybe SDL adapts and picks the next-smallest supported res, being 640x480, so that’s fine if that’s what’s happening. But from this fullscreened state, if I opt to change resolution again, nothing seems to change or update. The window size debug text still shows “640, 480” and that’s even if I choose different resolutions, while already fullscreened, that is.
Oddly, if I back out back to windowed mode, and then firstly change my resolution, for example to 960x720, and then go back into fullscreen, now the window size debug text updates, but even stranger, the dimensions don’t match up: “1024, 768” is now displayed in debug text. I tested all resolutions this way, and these are the results:
320x240, then choose fullscreen = 640, 480 640x480, then choose fullscreen = 640, 480 960x720, then choose fullscreen = 1024, 768 1152x720, then choose fullscreen = 1280, 720 1280x720, then choose fullscreen = 1280, 720
To recap the two issues, the first is that changing res while fullscreened seems to not update anything. The second problem is unwanted/mismatched fullscreened window sizes on some, but not all, of my res choices. Thank you for any advice!