Issue Toggling Fullscreen on SDL2 on WinXP |
bazz
|
Some Research I did:
http://forums.libsdl.org/viewtopic.php?t=8787 - In Accordance to this forum posting, I tried re-updating my Textures when I decided to Toggle Fullscreen. This did not help... I tried variations on SDL_SetWindowDisplayMode before and after the Toggle, including using SDL_GetWindowDisplayMode I tried researching for some sort of "Standard example" online, but I could not find much. I even researched into MAME's SDL2 code. (it was an attempt anyways), whose program toggles fullscreen nicely (though I just realized i only know this from experience in Mac OSX) --------------------------------------------------------------------------------------------------------- Anyways, I finally have found something that at least offers some sort of solution (though it certainly requires some working new components into my game to work properly). Anybody please confirm if this is really what I need to do to get this fullscreen toggling working multiplatform.. EDIT This doesn't work.. It's buggy as all hell!!!! What works is this :
Even tho it works, I cannot tell if I am doing MORE THAN I HAVE TO . Here in this example I was experimenting. I really want confirmation before going ahead with this, because I do not currently have any kind of Texture Manager that tracks every single Texture I am currently using... it would require a lot of work.. |
|||||||||||||
|
Dominus
|
Just a word ofgeneral advice, it seems that the forum is not forwarding everything to the mailing list, which most people with the neccessary knowledge are using.
But even it were toforward everything, it certainly got to be lacking in forwarding edits to forum posts. So, perhaps consider using the mailing list or at least not editing your posts. |
|||||||||||
|
bazz
|
Thanks for the heads up Dominus.
|
|||||||||||
|
bazz
|
For those on the email list.. Basically I figured out that Destroying and creating a new Renderer after the call to Toggle the Fullscreen (SDL_SetWindowFullscreen) actually led to some pretty weird bugs...
So I truly cannot believe that there is no standard code out there for doing something as simple as a FullScreen toggle. How come I cannot find anything out there?? My God. |
|||||||||||
|
monkey0506
|
I know it's been a month, but I came across this thread while googling the same problem. Destroying and creating renderers every time I toggled felt rather wrong, and as bazz noted it can cause other unforeseen issues.
I'd actually highly recommend to anyone reading to stop using SDL_WINDOW_FULLSCREEN in favor of SDL2's lovely new SDL_WINDOW_FULLSCREEN_DESKTOP. This lets you keep the same logical resolution without having to worry about whether the monitor supports it as a native resolution, and SDL will automagically handle any necessary scaling and/or letterboxing to keep the same aspect ratio. Here's what your function should look like bazz:
You'll also want to update your IsFullScreen method to check against the right flag of course. And for what it's worth, I sorted this out for myself by reading the SDL2 Migration Guide. Even if you've already read through it, another glance couldn't hurt. |
|||||||||||||
|
macrofeet
|
Thanks for code bazz
|
|||||||||||
|
macrofeet
|
Also thanks monkey0506
int SDL_ToggleFS(SDL_Window *win, int w, int h) { Uint32 flags = (SDL_GetWindowFlags(win) ^ SDL_WINDOW_FULLSCREEN_DESKTOP); if (SDL_SetWindowFullscreen(win, flags) < 0) return -1; // NOTE: this takes FLAGS as the second param, NOT true/false! SDL_SetWindowSize(win, w, h); return 0; } |
|||||||||||
|