The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
An obnoxious bug in SDL 1.2 and the workaround I found
LRFLEW


Joined: 10 Aug 2014
Posts: 3
Location: USA
There's an odd bug in SDL 1.2(.x) that affects a small number of users. If you are using a mac (on Mac OS X) that has dynamic graphic card switching on, then fullscreen windows will not present properly. While I had trouble finding an official bug report for SDL, I did find a few bug reports on specific games related to this bug such as this one. I could not find the source of this bug until I found this forum page that suggested disabling dynamic graphic card switching. After testing it, I was able to confirm that it did prevent the bug from appearing. From what I can tell, the bug occurs because SDL 1.2 is setting some part of the video mode before the dedicated GPU kicks in. This means that it tries to display using the integrated GPU and bugs out when the OS switches graphics cards.

While I still don't know where the bug actually occurs (so I can't actually fix it), I do know a workaround that is effective. While testing the bug, I noticed that calling SDL_SetVideoMode twice with the same arguments causes it to work fine. This makes sense, as the first call changes the graphics card and the second call actually sets up the display. With that knowledge, I devised the strangest patch. In the source for SDL_SetVideoMode, right before the last return statement (about line 920), I added the following two lines:

Code:
if ( (flags & SDL_FULLSCREEN) && !(strcmp(video->name, "Quartz")) && !(flags & 0x00080000) )
        return SDL_SetVideoMode(width, height, bpp, flags | 0x00080000);


Yes, it's not the most elegant solution, but it *does* work. Maybe if someone with more experience with Quartz and Macs worked on this, we could have an actual fix. In the meantime, this at least fixes the games that were affected by this.