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