src/core/winrt/SDL_winrtapp.cpp
changeset 8490 b05c6db83a07
parent 8489 7fd62b320c31
child 8491 50b0bdce11cd
equal deleted inserted replaced
8489:7fd62b320c31 8490:b05c6db83a07
   300         // window-resize event as it appeared the SDL window didn't change
   300         // window-resize event as it appeared the SDL window didn't change
   301         // size, and the Direct3D 11.1 renderer wouldn't resize its swap
   301         // size, and the Direct3D 11.1 renderer wouldn't resize its swap
   302         // chain.
   302         // chain.
   303         //
   303         //
   304         // TODO, WinRT: consider dropping old display modes after the fullscreen window changes size (from rotations, etc.)
   304         // TODO, WinRT: consider dropping old display modes after the fullscreen window changes size (from rotations, etc.)
   305         m_sdlWindowData->sdlWindow->fullscreen_mode = SDL_WinRTGlobalApp->GetMainDisplayMode();
   305         m_sdlWindowData->sdlWindow->fullscreen_mode = GetMainDisplayMode();
   306         SDL_AddDisplayMode(&m_sdlVideoDevice->displays[0], &m_sdlWindowData->sdlWindow->fullscreen_mode);
   306         SDL_AddDisplayMode(&m_sdlVideoDevice->displays[0], &m_sdlWindowData->sdlWindow->fullscreen_mode);
   307 
       
   308         // HACK, Feb 19, 2013: SDL_WINDOWEVENT_RESIZED events, when sent,
       
   309         // will attempt to fix the values of the main window's renderer's
       
   310         // viewport.  While this can be good, it does appear to be buggy,
       
   311         // and can cause a fullscreen viewport to become corrupted.  This
       
   312         // behavior was noticed on a Surface RT while rotating the device
       
   313         // from landscape to portrait.  Oddly enough, this did not occur
       
   314         // in the Windows Simulator.
       
   315         //
       
   316         // Backing up, then restoring, the main renderer's 'resized' flag
       
   317         // seems to fix fullscreen viewport problems when rotating a
       
   318         // Windows device.
       
   319         //
       
   320         // Commencing hack in 3... 2... 1...
       
   321         //
       
   322         // UPDATE, SDL 2.0.0 update: the 'resized' flag is now gone.  This
       
   323         // hack might not be necessary any more.
       
   324         //
       
   325         //SDL_Renderer * rendererForMainWindow = SDL_GetRenderer(m_sdlWindowData->sdlWindow);
       
   326         // For now, limit the hack to when the Direct3D 11.1 is getting used:
       
   327         //const bool usingD3D11Renderer = \
       
   328         //    (rendererForMainWindow != NULL) &&
       
   329         //    (SDL_strcmp(rendererForMainWindow->info.name, "direct3d 11.1") == 0);
       
   330         //SDL_bool wasD3D11RendererResized = SDL_FALSE;
       
   331         //if (usingD3D11Renderer) {
       
   332         //    wasD3D11RendererResized = rendererForMainWindow->resized;
       
   333         //}
       
   334 
   307 
   335         // Send the window-resize event to the rest of SDL, and to apps:
   308         // Send the window-resize event to the rest of SDL, and to apps:
   336         const int windowWidth = (int) ceil(args->Size.Width);
   309         const int windowWidth = (int) ceil(args->Size.Width);
   337         const int windowHeight = (int) ceil(args->Size.Height);
   310         const int windowHeight = (int) ceil(args->Size.Height);
   338         SDL_SendWindowEvent(
   311         SDL_SendWindowEvent(
   339             m_sdlWindowData->sdlWindow,
   312             m_sdlWindowData->sdlWindow,
   340             SDL_WINDOWEVENT_RESIZED,
   313             SDL_WINDOWEVENT_RESIZED,
   341             windowWidth,
   314             windowWidth,
   342             windowHeight);
   315             windowHeight);
   343 
       
   344         //// Viewport hack, part two:
       
   345         //if (usingD3D11Renderer) {
       
   346         //    rendererForMainWindow->resized = wasD3D11RendererResized;
       
   347         //}
       
   348     }
   316     }
   349 }
   317 }
   350 
   318 
   351 void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
   319 void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
   352 {
   320 {