@@ -103,7 +103,7 @@ void VideoSDL2::UpdateCurrentSizes()
103103 SetNewSize (VideoMode (w, h), Extent (w2, h2));
104104}
105105
106- bool VideoSDL2::CreateScreen (const std::string& title, const VideoMode& size, bool fullscreen )
106+ bool VideoSDL2::CreateScreen (const std::string& title, const VideoMode& size, DisplayMode displayMode )
107107{
108108 if (!initialized)
109109 return false ;
@@ -125,18 +125,19 @@ bool VideoSDL2::CreateScreen(const std::string& title, const VideoMode& size, bo
125125 CHECK_SDL (SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 8 ));
126126 CHECK_SDL (SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1 ));
127127
128- int wndPos = SDL_WINDOWPOS_CENTERED;
129-
128+ const int wndPos = SDL_WINDOWPOS_CENTERED;
129+ const auto fullscreen = bitset::isSet (displayMode, DisplayMode::Fullscreen);
130130 const auto requestedSize = fullscreen ? FindClosestVideoMode (size) : size;
131-
131+ const unsigned commonFlags = SDL_WINDOW_OPENGL;
132+ const unsigned fullscreenFlag = (fullscreen ? SDL_WINDOW_FULLSCREEN : 0 );
132133 window = SDL_CreateWindow (title.c_str (), wndPos, wndPos, requestedSize.width , requestedSize.height ,
133- SDL_WINDOW_OPENGL | (fullscreen ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE) );
134+ commonFlags | fullscreenFlag );
134135
135136 // Fallback to non-fullscreen
136137 if (!window && fullscreen)
137138 {
138- window = SDL_CreateWindow (title. c_str (), wndPos, wndPos, requestedSize. width , requestedSize. height ,
139- SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE );
139+ window =
140+ SDL_CreateWindow (title. c_str (), wndPos, wndPos, requestedSize. width , requestedSize. height , commonFlags );
140141 }
141142
142143 if (!window)
@@ -145,10 +146,11 @@ bool VideoSDL2::CreateScreen(const std::string& title, const VideoMode& size, bo
145146 return false ;
146147 }
147148
148- isFullscreen_ = (SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 ;
149+ displayMode_ =
150+ bitset::set (displayMode_, DisplayMode::Fullscreen, (SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 );
149151 UpdateCurrentSizes ();
150152
151- if (!isFullscreen_ )
153+ if (!bitset::isSet (displayMode_, DisplayMode::Fullscreen) )
152154 MoveWindowToCenter ();
153155
154156 SDL_Surface* iconSurf =
@@ -173,16 +175,19 @@ bool VideoSDL2::CreateScreen(const std::string& title, const VideoMode& size, bo
173175 return true ;
174176}
175177
176- bool VideoSDL2::ResizeScreen (const VideoMode& newSize, bool fullscreen )
178+ bool VideoSDL2::ResizeScreen (const VideoMode& newSize, DisplayMode displayMode )
177179{
178180 if (!initialized)
179181 return false ;
180182
181- if (isFullscreen_ != fullscreen)
183+ const auto newFullscreen = bitset::isSet (displayMode, DisplayMode::Fullscreen);
184+ auto fullscreen = bitset::isSet (displayMode_, DisplayMode::Fullscreen);
185+ if (fullscreen != newFullscreen)
182186 {
183- SDL_SetWindowFullscreen (window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0 );
184- isFullscreen_ = (SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 ;
185- if (!isFullscreen_)
187+ SDL_SetWindowFullscreen (window, newFullscreen ? SDL_WINDOW_FULLSCREEN : 0 );
188+ fullscreen = (SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 ;
189+ displayMode_ = bitset::set (displayMode_, DisplayMode::Fullscreen, fullscreen);
190+ if (!fullscreen)
186191 {
187192#if SDL_VERSION_ATLEAST(2, 0, 5)
188193 SDL_SetWindowResizable (window, SDL_TRUE);
@@ -193,7 +198,7 @@ bool VideoSDL2::ResizeScreen(const VideoMode& newSize, bool fullscreen)
193198
194199 if (newSize != GetWindowSize ())
195200 {
196- if (isFullscreen_ )
201+ if (fullscreen )
197202 {
198203 auto const targetMode = FindClosestVideoMode (newSize);
199204 SDL_DisplayMode target;
@@ -267,7 +272,8 @@ bool VideoSDL2::MessageLoop()
267272 {
268273 case SDL_WINDOWEVENT_RESIZED:
269274 {
270- isFullscreen_ = (SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 ;
275+ displayMode_ = bitset::set (displayMode_, DisplayMode::Fullscreen,
276+ (SDL_GetWindowFlags (window) & SDL_WINDOW_FULLSCREEN) != 0 );
271277 VideoMode newSize (ev.window .data1 , ev.window .data2 );
272278 if (newSize != GetWindowSize ())
273279 {
0 commit comments