MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / ResizeWindow

Function ResizeWindow

Source/utils/display.cpp:499–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497}
498
499void ResizeWindow()
500{
501 if (ghMainWnd == nullptr)
502 return;
503
504 Size windowSize = GetPreferredWindowSize();
505
506#ifdef USE_SDL1
507 SetVideoModeToPrimary(*sgOptions.Graphics.fullscreen, windowSize.width, windowSize.height);
508#else
509 // For "true fullscreen" windows, the window resizes automatically based on the display mode
510 bool trueFullscreen = *sgOptions.Graphics.fullscreen && !*sgOptions.Graphics.upscale;
511 if (trueFullscreen) {
512 SDL_DisplayMode displayMode = GetNearestDisplayMode(windowSize);
513 if (SDL_SetWindowDisplayMode(ghMainWnd, &displayMode) != 0)
514 ErrSdl();
515 }
516
517 // Handle switching between "fake fullscreen" and "true fullscreen" when upscale is toggled
518 bool upscaleChanged = *sgOptions.Graphics.upscale != (renderer != nullptr);
519 if (upscaleChanged && *sgOptions.Graphics.fullscreen) {
520 Uint32 flags = *sgOptions.Graphics.upscale ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN;
521 if (SDL_SetWindowFullscreen(ghMainWnd, flags) != 0)
522 ErrSdl();
523 if (!*sgOptions.Graphics.fullscreen)
524 SDL_RestoreWindow(ghMainWnd); // Avoid window being maximized before resizing
525 }
526
527 if (!trueFullscreen)
528 SDL_SetWindowSize(ghMainWnd, windowSize.width, windowSize.height);
529#endif
530
531 ReinitializeRenderer();
532
533#ifndef USE_SDL1
534 SDL_SetWindowResizable(ghMainWnd, renderer != nullptr ? SDL_TRUE : SDL_FALSE);
535 InitializeVirtualGamepad();
536#endif
537
538 CreateBackBuffer();
539 RedrawEverything();
540}
541
542SDL_Surface *GetOutputSurface()
543{

Calls 7

GetPreferredWindowSizeFunction · 0.85
SetVideoModeToPrimaryFunction · 0.85
GetNearestDisplayModeFunction · 0.85
ReinitializeRendererFunction · 0.85
InitializeVirtualGamepadFunction · 0.85
CreateBackBufferFunction · 0.85
RedrawEverythingFunction · 0.85

Tested by

no test coverage detected