I have two rendering engines in my game. They are custom OpenGL and DirectX 9 (I do not use anything from SDL2 except for window management) and there are certain issues when I try to go fullscreen using function SDL_SetWindowFullscreen.
Following log is acquired when I try to switch to fullscreen from maximized window in OpenGL context:
The application starts with size of 640 x 480 since it’s the minimum size set by SDL_SetWindowMinimumSize and it’s size in general. After that it is resized to 1920 x 976 because the application requested maximization (SDL_MaximizeWindow). After that I hit “fullscreen” button which calls SDL_SetWindowFullscreen and somehow the received size is 656 x 518 instead of 1920 x 1080.
In order to properly go into a fullscreen mode with OpenGL context I need to have the window maximized. In order to properly go into a fullscreen mode with DirectX I need to have the window not maximized.
The question is how to properly go into a fullscreen mode (the highest available resolution) by using function SDL_SetWindowFullscreen in both contexts?
Code:
Uint32 flags = SDL_GetWindowFlags(MainWindow) ^ SDL_WINDOW_FULLSCREEN_DESKTOP;
SDL_SetWindowFullscreen(MainWindow, flags);------------------------
ePic Character Generator - endless character stream in your games using SDL 2.0:
I did switch to SDL_WINDOW_FULLSCREEN_DESKTOP recently. However, even though I had SDL_WINDOW_FULLSCREEN_DESKTOP and size of current window was 640x480 the fullscreen instead of being 1920x1080 was 640x480. There are no events dispatched from SDL2 indicating a correct new resolution, however, sometimes it works (it depends whether the window is maximized, taking almost the whole screen, or it is a small window).
What I am currently doing is resizing the window to the size of the display and then going into a fullscreen - it seems to work most of the time, but with SDL_WINDOW_FULLSCREEN_DESKTOP I have yet another issue which did not happen on “true” fullscreen. The window seems to lose focus when going into a fullscreen at the first time from a small window. That is the window is visible at fullscreen, but my mouse events are focused at applications available at the background resulting in minimizing my window when I click anywhere on the screen, but when I go back the window has focus and everything works fine.
The issue is happening only with Direct3D context. It does not happen with OpenGL context created by the SDL2 itself.