MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / SwitchRes

Method SwitchRes

engine/PoseidonGL33/EngineGL33_Lifecycle.cpp:546–623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544
545bool EngineGL33::SwitchRes(int w, int h, int bpp)
546{
547 if (_pendingExclusiveEnter && _sdlWindow)
548 {
549 SDL_DisplayID display = SDL_GetDisplayForWindow(_sdlWindow);
550 if (!display)
551 display = SDL_GetPrimaryDisplay();
552
553 if (!ApplyExclusiveDisplayMode(_sdlWindow, display, w, h, _refreshRate))
554 LOG_WARN(Graphics, "GL33: SDL_SetWindowFullscreenMode failed for {}x{}@{}: {}", w, h, _refreshRate,
555 SDL_GetError());
556 _pixelSize = bpp;
557 _w = w;
558 _h = h;
559 SDL_SetWindowFullscreen(_sdlWindow, true);
560 LogExclusiveModeStatus(_sdlWindow, w, h, _refreshRate);
561 return true;
562 }
563
564 if (_windowed && _sdlWindow)
565 {
566 WindowMetrics metrics;
567 SDL_GetWindowSize(_sdlWindow, &metrics.logicalWidth, &metrics.logicalHeight);
568 if (WindowedResolutionAlreadyApplied(metrics, w, h) && _pixelSize == bpp)
569 return true;
570 }
571 else if (w == _w && h == _h && _pixelSize == bpp)
572 {
573 return true;
574 }
575
576 _pixelSize = bpp;
577
578 if (_windowed)
579 {
580 if (_sdlWindow)
581 {
582 int logicalW = w;
583 int logicalH = h;
584 SDL_SetWindowSize(_sdlWindow, w, h);
585 SDL_GetWindowSize(_sdlWindow, &logicalW, &logicalH);
586 SDL_GetWindowSizeInPixels(_sdlWindow, &_w, &_h);
587 _windowedRestoreW = logicalW;
588 _windowedRestoreH = logicalH;
589 LOG_DEBUG(Graphics, "GL33: SwitchRes windowed request={}x{} logical={}x{} drawable={}x{}", w, h, logicalW,
590 logicalH, _w, _h);
591 }
592 else
593 {
594 _w = w;
595 _h = h;
596 _windowedRestoreW = w;
597 _windowedRestoreH = h;
598 }
599 Reset();
600 }
601 else
602 {
603 if (_sdlWindow)

Callers 1

Calls 3

LogExclusiveModeStatusFunction · 0.85

Tested by

no test coverage detected