Skip to content

Commit

Permalink
SDL1: Fix windowed video mode
Browse files Browse the repository at this point in the history
On Ubuntu 24.04 when running in a window,
`SDL_GetVideoInfo` returns the display size rather than the window size,
resulting in incorrect scaling.

Using `SDL_GetVideoSurface` instead of `SDL_GetVideoInfo` fixes this.
  • Loading branch information
glebm committed Jun 19, 2024
1 parent a30f7c0 commit 706905f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Source/utils/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,12 @@ void SetVideoMode(int width, int height, int bpp, uint32_t flags)
if (ghMainWnd == nullptr) {
ErrSdl();
}
const SDL_VideoInfo &current = *SDL_GetVideoInfo();
Log("Video mode is now {}x{} bpp={} flags=0x{:08X}",
current.current_w, current.current_h, current.vfmt->BitsPerPixel, SDL_GetVideoSurface()->flags);
const SDL_Surface *surface = SDL_GetVideoSurface();
if (surface == nullptr) {
ErrSdl();
}
Log("Video surface is now {}x{} bpp={} flags=0x{:08X}",
surface->w, surface->h, surface->format->BitsPerPixel, surface->flags);
}

void SetVideoModeToPrimary(bool fullscreen, int width, int height)
Expand Down Expand Up @@ -410,9 +413,11 @@ void ReinitializeRenderer()
return;

#ifdef USE_SDL1
const SDL_VideoInfo &current = *SDL_GetVideoInfo();
Size windowSize = { current.current_w, current.current_h };
AdjustToScreenGeometry(windowSize);
const SDL_Surface *surface = SDL_GetVideoSurface();
if (surface == nullptr) {
ErrSdl();
}
AdjustToScreenGeometry(Size(surface->w, surface->h));
#else
if (texture)
texture.reset();
Expand Down

0 comments on commit 706905f

Please sign in to comment.