From 93358a290c7a1dca407e9193dbd3d31b755f2af8 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 3 Oct 2020 20:02:53 +0200 Subject: [PATCH] [SDL1.2] Check if an appropriate video mode exists for the given movie This lets us fall back to software scaling for devices that do not support a video mode that matches the given video. --- SourceX/storm/storm.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/SourceX/storm/storm.cpp b/SourceX/storm/storm.cpp index 99bc309e5..282a4164e 100644 --- a/SourceX/storm/storm.cpp +++ b/SourceX/storm/storm.cpp @@ -623,6 +623,30 @@ void SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HA { const auto *display = SDL_GetVideoSurface(); IsSVidVideoMode = (display->flags & (SDL_FULLSCREEN | SDL_NOFRAME)) != 0; + + if (IsSVidVideoMode) { + /* Get available fullscreen/hardware modes */ + SDL_Rect **modes = SDL_ListModes(NULL, display->flags); + + /* Check is there are any modes available */ + if(modes == (SDL_Rect **)0){ + IsSVidVideoMode = false; + } + + /* Check if our resolution is restricted */ + if(modes != (SDL_Rect **)-1){ + // Search for a usable video mode + bool UsableModeFound = false; + for (int i=0; modes[i]; i++) { + if (modes[i]->w == SVidWidth || modes[i]->h == SVidHeight) { + UsableModeFound = true; + break; + } + } + IsSVidVideoMode = UsableModeFound; + } + } + if (IsSVidVideoMode) { int w, h; if (display->w * SVidWidth > display->h * SVidHeight) {