Ticket #544 (closed task: fixed)

Opened 3 years ago

Last modified 3 years ago

Fall back to windowed mode if fullscreen fails

Reported by: Philip Owned by:
Priority: Nice to Have Milestone:
Component: Core engine Keywords: simple
Cc:

Description

Someone reports startup errors:

ERROR: SetVideoMode failed: 2960x1050:24 1 ("No video mode large enough for 2960x1050")
ERROR: SetVideoMode failed: 2960x1050:24 1 ("No video mode large enough for 2960x1050")
terminate called after throwing an instance of 'PSERROR_System_VmodeFailed'
  what():  System_VmodeFailed

Probably CVideoMode should determine when fullscreen mode fails, then try windowed mode instead of giving up entirely.

Attachments

windowed_fallback.patch (1.6 KB) - added by oln 3 years ago.
Fallback to windowed mode patch
windowed_fallback2.patch (3.1 KB) - added by oln 3 years ago.
Windowed fallback patch (tested with wsdl)

Change History

comment:1 Changed 3 years ago by oln

  • Keywords simple, review added; simple removed

Attached a simple fix. This may also fix #532, though the window didn't auto-resize on ubuntu, so i haven't been able to test.

comment:2 follow-up: ↓ 3 Changed 3 years ago by Cygal

I tested the patch, it does fix this issue, but does not fix #532.

comment:3 in reply to: ↑ 2 Changed 3 years ago by Cygal

Replying to Cygal:

I tested the patch, it does fix this issue, but does not fix #532.

In fact maybe it does; I misunderstood issue #532, sorry about that.

comment:4 Changed 3 years ago by Philip

  • Keywords simple added; simple, review removed

Thanks for the patch, but it looks like this will fail to compile on Windows: we have a custom implementation of a subset of the SDL API (see source/lib/sysdep/os/win/wsdl.h) which doesn't provide SDL_VideoModeOK.

I think we need to either just use SDL_SetVideoMode/SDL_GetVideoInfo (no new API functions) and retry if it fails; or reimplement SDL_VideoModeOK on Windows (I have no idea how hard that is); or switch to using real SDL instead of wsdl on Windows (that might be quite tricky, and I think there were plausible reasons why we used wsdl in the first place (though I forget exactly what they were)).

comment:5 Changed 3 years ago by oln

  • Summary Fall back to windowed mode if fullscreen fails deleted

I see, wasn't aware that you used a custom implementation on windows. Should be simple to change the function to not use SDL_VideoModeOK. I'll have a look at this and the custom implementation tomorrow. I suppose this is the reason for having the part of the code in CVideoMode that reattempts with a lower BPP as well? (I could be wrong, but plain SDL should just revert to a lower BPP on it's own.) Looking at lib/config2.h i can see there are plausible reasons for using the emulated SDL. Though, using a custom SDL implementation could possibly cause more issues later, e.g with implementing resolution switching in the options menu which i was planning on doing some work on. I suppose i will have a look at this as well, if it would be possible to switch to the actualy SDL library on windows as well, that would be helpful for future upkeep.

comment:6 Changed 3 years ago by oln

  • Summary set to Fall back to windowed mode if fullscreen fails

Firefox messed up

comment:7 Changed 3 years ago by Philip

The fallback code in CVideoMode for 16-bit depth buffers was needed for Linux (in VMware with no hardware accelerated graphics) - SDL didn't do that fallback itself.

Ah, I wasn't aware lib/config2.h had relevant comments. wsdl was much simpler when we started, since we didn't need much from it, and since then it's been easier to incrementally add features rather than switch everything over to standard SDL and debug and fix any problems it introduces. I don't know what'll be better in the long term. If someone had a patch that made standard SDL work without any functionality/performance regressions then I'd prefer to switch, but I probably don't want to spend any significant effort on that myself.

comment:8 Changed 3 years ago by oln

Added a new patch that should compile with wsdl as well. (Will test later today when i get home.)

Changed 3 years ago by oln

Fallback to windowed mode patch

comment:9 Changed 3 years ago by oln

Apparently not, as SDL_SetVideoMode returns an int in windows. Which means some more changes are needed.

Changed 3 years ago by oln

Windowed fallback patch (tested with wsdl)

comment:10 Changed 3 years ago by Philip

Looks good, thanks! I haven't tested it on Windows myself but I'll believe it works there. Just made a few stylistic alterations to better match the surrounding code.

Is anyone able to reproduce the bug in #532 before this patch, and confirm whether the patch does or doesn't fix it? (I forgot what platform I found that bug on :-( )

comment:11 Changed 3 years ago by philip

  • Status changed from new to closed
  • Resolution set to fixed

(In [8072]) Fix #544 (Fall back to windowed mode if fullscreen fails), based on patch from oln

comment:12 Changed 3 years ago by anonymous

  • Milestone Unclassified deleted

Milestone Unclassified deleted

Note: See TracTickets for help on using tickets.