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

Function ReinitializeRenderer

Source/utils/display.cpp:403–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401#endif
402
403void ReinitializeRenderer()
404{
405 if (ghMainWnd == nullptr)
406 return;
407
408#ifdef USE_SDL1
409 const SDL_VideoInfo &current = *SDL_GetVideoInfo();
410 Size windowSize = { current.current_w, current.current_h };
411 AdjustToScreenGeometry(windowSize);
412#else
413 if (texture)
414 texture.reset();
415
416 FreeRenderer();
417
418 if (*sgOptions.Graphics.upscale) {
419 Uint32 rendererFlags = 0;
420
421 if (*sgOptions.Graphics.frameRateControl == FrameRateControl::VerticalSync) {
422 rendererFlags |= SDL_RENDERER_PRESENTVSYNC;
423 }
424
425 renderer = SDL_CreateRenderer(ghMainWnd, -1, rendererFlags);
426 if (renderer == nullptr) {
427 ErrSdl();
428 }
429
430 ReinitializeTexture();
431
432 if (SDL_RenderSetIntegerScale(renderer, *sgOptions.Graphics.integerScaling ? SDL_TRUE : SDL_FALSE) < 0) {
433 ErrSdl();
434 }
435
436 if (SDL_RenderSetLogicalSize(renderer, gnScreenWidth, gnScreenHeight) <= -1) {
437 ErrSdl();
438 }
439
440 Uint32 format;
441 if (SDL_QueryTexture(texture.get(), &format, nullptr, nullptr, nullptr) < 0)
442 ErrSdl();
443 RendererTextureSurface = SDLWrap::CreateRGBSurfaceWithFormat(0, gnScreenWidth, gnScreenHeight, SDL_BITSPERPIXEL(format), format);
444 } else {
445 Size windowSize = {};
446 SDL_GetWindowSize(ghMainWnd, &windowSize.width, &windowSize.height);
447 AdjustToScreenGeometry(windowSize);
448 }
449#endif
450}
451
452void SetFullscreenMode()
453{

Callers 3

SpawnWindowFunction · 0.85
SetFullscreenModeFunction · 0.85
ResizeWindowFunction · 0.85

Calls 7

AdjustToScreenGeometryFunction · 0.85
FreeRendererFunction · 0.85
ReinitializeTextureFunction · 0.85
SDL_GetWindowSizeFunction · 0.85
getMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected