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
SDL_SetWindowSize does not work in fullscreen
pyroary


Joined: 18 Mar 2014
Posts: 7
Hi,


I'm making an SDL2 application, and SDL_SetWindowSize doesn't seem to work in fullscreen mode at all (using SDL_WINDOW_FULLSCREEN) across Windows, OS X and Linux.


I searched Bugzilla, and found this bug ( https://bugzilla.libsdl.org/show_bug.cgi?id=1742 ) which looks like the issue I'm experiencing. It supposedly has a patch to fix it too, however it is almost an year old.


Any help with fixing this issue would be really appreciated.



Thanks,
Arvind Raja Yadav
Pyrodactyl Games
SDL_SetWindowSize does not work in fullscreen
Pallav Nawani


Joined: 19 May 2011
Posts: 122
Location: Dehradun, India
What exactly are you trying to do? You might want to call SDL_SetWindowSize​​()​ before​ calling ​going fullscreen. Or SDL_RenderSetLogicalSize(​) might be what you're looking for.


Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter:  http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768



On Fri, May 30, 2014 at 9:19 PM, Arvind Raja Yadav wrote:
Quote:
Hi,


I'm making an SDL2 application, and SDL_SetWindowSize doesn't seem to work in fullscreen mode at all (using SDL_WINDOW_FULLSCREEN) across Windows, OS X and Linux.


I searched Bugzilla, and found this bug ( https://bugzilla.libsdl.org/show_bug.cgi?id=1742 ) which looks like the issue I'm experiencing. It supposedly has a patch to fix it too, however it is almost an year old.


Any help with fixing this issue would be really appreciated.



Thanks,
Arvind Raja Yadav
Pyrodactyl Games







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL_SetWindowSize does not work in fullscreen
pyroary


Joined: 18 Mar 2014
Posts: 7
Quote:
What exactly are you trying to do? You might want to call SDL_SetWindowSize​​()​ before​ calling ​going fullscreen. Or SDL_RenderSetLogicalSize(​) might be what you're looking for.

My application has a general options screen like this: http://i.imgur.com/rbEVpEI.jpg

If the user changes resolution before going fullscreen, everything works as expected. However, switching to fullscreen first and then changing resolution doesn't work at all.

Since this options screen is operated by the user, I cannot know what order the Resolution and Fullscreen commands will be executed in. I think both orders "Set Resolution -> Fullscreen" and "Fullscreen -> Set Resolution" are valid, there doesn't seem any reason to restrict one of these for any reason.


My ApplySettings() function is a simple function like this:
Quote:
if (fullscreen)
{
videoflags = SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN;
}
else
{
if (border)
videoflags = SDL_WINDOW_SHOWN;
else
videoflags = SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS;
}SDL_SetWindowSize(window, cur.w, cur.h);
SDL_SetWindowFullscreen(window, videoflags);
SDL_SetWindowBrightness(window, gamma);

Thanks,
Arvind Raja Yadav
Pyrodactyl Games


P.S. I don't think SDL_RenderSetLogicalSize applies here, because I don't use the logical size feature at all.
SDL_SetWindowSize does not work in fullscreen
Pallav Nawani


Joined: 19 May 2011
Posts: 122
Location: Dehradun, India
Yes, SDL Doesn't allow resolution change once it goes fullscreen.


You could just use the Desktop Resolution instead. Then you can use SDL_RenderSetLogicalSize() to maintain the aspect ratio.
If you really want to change resolution then you could go: Fullscreen -> Windowed -> (delay) -> Size Change -> (Delay) -> Fullscreen.


 

Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter:  http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768



On Sat, May 31, 2014 at 3:49 PM, Arvind Raja Yadav wrote:
Quote:
Quote:
What exactly are you trying to do? You might want to call SDL_SetWindowSize​​()​ before​ calling ​going fullscreen. Or SDL_RenderSetLogicalSize(​) might be what you're looking for.

My application has a general options screen like this: http://i.imgur.com/rbEVpEI.jpg

If the user changes resolution before going fullscreen, everything works as expected. However, switching to fullscreen first and then changing resolution doesn't work at all.

Since this options screen is operated by the user, I cannot know what order the Resolution and Fullscreen commands will be executed in. I think both orders "Set Resolution -> Fullscreen" and "Fullscreen -> Set Resolution" are valid, there doesn't seem any reason to restrict one of these for any reason.


My ApplySettings() function is a simple function like this:
Quote:
if (fullscreen)
{
videoflags = SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN;
}
else
{
if (border)
videoflags = SDL_WINDOW_SHOWN;
else
videoflags = SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS;
}SDL_SetWindowSize(window, cur.w, cur.h);
SDL_SetWindowFullscreen(window, videoflags);
SDL_SetWindowBrightness(window, gamma);

Thanks,
Arvind Raja Yadav
Pyrodactyl Games


P.S. I don't think SDL_RenderSetLogicalSize applies here, because I don't use the logical size feature at all.




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL_SetWindowSize does not work in fullscreen
pyroary


Joined: 18 Mar 2014
Posts: 7
Quote:
Yes, SDL Doesn't allow resolution change once it goes fullscreen.

You could just use the Desktop Resolution instead. Then you can use SDL_RenderSetLogicalSize() to maintain the aspect ratio.
If you really want to change resolution then you could go: Fullscreen -> Windowed -> (delay) -> Size Change -> (Delay) -> Fullscreen.


I cannot use the logical size portion of the SDL Renderer, as I handle the size/aspect ration stuff in code myself.


To me, this is definitely a bug in SDL2 - nothing in the documentation suggests you can't change resolution while in fullscreen mode. Changing resolution while in fullscreen is a fairly common scenario as well - lots of other games allow you to do the same thing.
Arvind Raja Yadav
Pyrodactyl Games
SDL_SetWindowSize does not work in fullscreen
Sik


Joined: 26 Nov 2011
Posts: 905
2014-05-31 8:09 GMT-03:00, Arvind Raja Yadav:
Quote:
To me, this is definitely a bug in SDL2 - nothing in the documentation
suggests you can't change resolution while in fullscreen mode. Changing
resolution while in fullscreen is a fairly common scenario as well - lots
of other games allow you to do the same thing.

Generally you reinitialize the video system to change resolution. It
*is* a change of the current video mode, after all, with everything
that entails (including losing the textures and such).

But yeah, this should be documented.
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_SetWindowSize does not work in fullscreen
Alex Szpakowski
Guest

No you don’t.

You can use the SDL_SetWindowDisplayMode function, although you’ll have to take the window out of fullscreen and back (via SDL_SetWindowFullscreen), or you can destroy and recreate the window.

On May 31, 2014, at 12:30 PM, Sik the hedgehog wrote:

Quote:
2014-05-31 8:09 GMT-03:00, Arvind Raja Yadav:
Quote:
To me, this is definitely a bug in SDL2 - nothing in the documentation
suggests you can't change resolution while in fullscreen mode. Changing
resolution while in fullscreen is a fairly common scenario as well - lots
of other games allow you to do the same thing.

Generally you reinitialize the video system to change resolution. It
*is* a change of the current video mode, after all, with everything
that entails (including losing the textures and such).

But yeah, this should be documented.
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_SetWindowSize does not work in fullscreen
Stefanos A.
Guest

Or SDL could gain an API to decouple mode changes from fullscreen modes:


SDL_SetDisplayMode(int displayIndex, int modeIndex);

where modeIndex is a valid mode returned by SDL_GetDisplayMode().


This API already exists internally. Destroying and recreating a window (including reloading resources from disk) is simply terrible terrible workaround for an issue that shouldn't be there in the first place.




2014-05-31 17:33 GMT+02:00 Alex Szpakowski:
Quote:
No you don’t.

You can use the SDL_SetWindowDisplayMode function, although you’ll have to take the window out of fullscreen and back (via SDL_SetWindowFullscreen), or you can destroy and recreate the window.

On May 31, 2014, at 12:30 PM, Sik the hedgehog wrote:

Quote:
2014-05-31 8:09 GMT-03:00, Arvind Raja Yadav:
Quote:
To me, this is definitely a bug in SDL2 - nothing in the documentation
suggests you can't change resolution while in fullscreen mode. Changing
resolution while in fullscreen is a fairly common scenario as well - lots
of other games allow you to do the same thing.

Generally you reinitialize the video system to change resolution. It
*is* a change of the current video mode, after all, with everything
that entails (including losing the textures and such).

But yeah, this should be documented.
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL_SetWindowSize does not work in fullscreen
Alex Szpakowski
Guest

Well, as I mentioned you don’t need to destroy the window to change its fullscreen resolution.


I am not really sure about adding an API to change the display mode without having a fullscreen window, I think it might be too easy to do the ‘wrong’ thing with it (from the user’s perspective.)

On May 31, 2014, at 1:45 PM, Stefanos A. wrote:
Quote:
Or SDL could gain an API to decouple mode changes from fullscreen modes:


SDL_SetDisplayMode(int displayIndex, int modeIndex);

where modeIndex is a valid mode returned by SDL_GetDisplayMode().


This API already exists internally. Destroying and recreating a window (including reloading resources from disk) is simply terrible terrible workaround for an issue that shouldn't be there in the first place.


SDL_SetWindowSize does not work in fullscreen
Stefanos A.
Guest

Changing resolution is always wrong from a user's perspective, fullscreen window or not. Still, there are valid uses for that.


Having a separate API means that developers cannot inadvertently change resolutions (as everyone is doing now via SDL_WINDOW_FULLSCREEN.)



2014-05-31 18:48 GMT+02:00 Alex Szpakowski:
Quote:
Well, as I mentioned you don’t need to destroy the window to change its fullscreen resolution.


I am not really sure about adding an API to change the display mode without having a fullscreen window, I think it might be too easy to do the ‘wrong’ thing with it (from the user’s perspective.)

On May 31, 2014, at 1:45 PM, Stefanos A. wrote:

Quote:
Or SDL could gain an API to decouple mode changes from fullscreen modes:


SDL_SetDisplayMode(int displayIndex, int modeIndex);

where modeIndex is a valid mode returned by SDL_GetDisplayMode().


This API already exists internally. Destroying and recreating a window (including reloading resources from disk) is simply terrible terrible workaround for an issue that shouldn't be there in the first place.







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL_SetWindowSize does not work in fullscreen
LordHavoc


Joined: 05 Feb 2014
Posts: 23
Location: USA
Unless you're making a display reconfiguration app (which is a bit beyond the scope of SDL2, and you should probably use the underlying platform-specific functions for), I don't see any reason to
dissociate mode changes from the window.

The window having a display mode is largely to mimic D3D functionality that does the same thing (where a window has a desired display mode and Windows takes care of changing the display mode when that
window is focused).

From my past experiences as a Linux/OSX porting contractor, it is undesirable for any app or game to change display mode by default and the user should always have to opt-in to such behavior, because
it has many side effects; while the age of destroying your monitor with an invalid sync rate is decades past, it still rearranges icons and windows on your desktop, and has a habit of turning off
secondary monitors on Linux.

For the aforementioned reasons I always advise game developers to never change video mode, and for performance reasons you can still do very simple reduced resolution rendering (in OpenGL this is
little more than using a smaller viewport and using glCopyTexImage2D, then drawing a quad over the whole screen - or for more performance, use a framebuffer object, which also gives you more control
over antialiasing and bit depth), in the case of the SDL_renderer it takes care of this for you.

There is some old gnarly lowend hardware from the 2006-ish era where they just don't have the memory bandwidth to run at desktop resolution efficiently, where video mode changes really are necessary
for any sort of realistic performance expectations (literally I used to see a 3x fps difference between 640x480 windowed and 640x480 fullscreen on some of those lowend cards), but designing for that
hardware isn't usually a goal.

On 05/31/2014 09:48 AM, Alex Szpakowski wrote:
Quote:
Well, as I mentioned you don’t need to destroy the window to change its fullscreen resolution.

I am not really sure about adding an API to change the display mode without having a fullscreen window, I think it might be too easy to do the ‘wrong’ thing with it (from the user’s perspective.)

On May 31, 2014, at 1:45 PM, Stefanos A. <mailto:> wrote:

Quote:
Or SDL could gain an API to decouple mode changes from fullscreen modes:

SDL_SetDisplayMode(int displayIndex, int modeIndex);

where modeIndex is a valid mode returned by SDL_GetDisplayMode().

This API already exists internally. Destroying and recreating a window (including reloading resources from disk) is simply terrible terrible workaround for an issue that shouldn't be there in the
first place.



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



--
LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_SetWindowSize does not work in fullscreen
David Gow
Guest

My understanding (as the guy who wrote the patch to change the
SDL_SetWindowSize/SDL_SetWindowDisplayMode fullscreen behaviour) was
that ideally those functions should work in fullscreen, but that as the
patch didn't land in time for 2.0, it's not worth breaking existing
things by changing it before 2.1. Feel free to apply the patch (it might
need some tweaking) to your own builds in the meantime, though. It'd be
great to get it tested: no-one seemed that keen when I first wrote it.

Personally, I'm now using OpenGL FBOs to render to the resolution the
user requests when in fullscreen mode, and scaling that with a
framebuffer blit to whatever size my FULLSCREEN_DESKTOP window is. If
you're using the SDL drawing api, SDL_RenderSetLogicalSize() (or doing
something similar internally) seems the (if you'll pardon the pun)
logical choice. Actually changing the resolution is not nearly as
sensible a default as it once was.

I don't think it's a good idea to support changing resolution without
tying it to a window. It'd make a lot of work for getting alt+tab and
friends working properly, and you'd need to remember to clean a lot of
things up. Furthermore, there was talk of having an X11 extension which
would actually associate resolution changes with windows, so I think
such a thing would be more trouble than it's worth.

Cheers,
— David

On 01/06/14 01:03, Stefanos A. wrote:
Quote:
Changing resolution is always wrong from a user's perspective, fullscreen
window or not. Still, there are valid uses for that.

Having a separate API means that developers cannot inadvertently change
resolutions (as everyone is doing now via SDL_WINDOW_FULLSCREEN.)


2014-05-31 18:48 GMT+02:00 Alex Szpakowski:

Quote:
Well, as I mentioned you don’t need to destroy the window to change its
fullscreen resolution.

I am not really sure about adding an API to change the display mode
without having a fullscreen window, I think it might be too easy to do the
‘wrong’ thing with it (from the user’s perspective.)

On May 31, 2014, at 1:45 PM, Stefanos A. wrote:

Or SDL could gain an API to decouple mode changes from fullscreen modes:

SDL_SetDisplayMode(int displayIndex, int modeIndex);

where modeIndex is a valid mode returned by SDL_GetDisplayMode().

This API already exists internally. Destroying and recreating a window
(including reloading resources from disk) is simply terrible terrible
workaround for an issue that shouldn't be there in the first place.



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_SetWindowSize does not work in fullscreen
Stefanos A.
Guest

2014-05-31 19:20 GMT+02:00 Forest Hale:
Quote:
From my past experiences as a Linux/OSX porting contractor, it is undesirable for any app or game to change display mode by default and the user should always have to opt-in to such behavior, because
it has many side effects




Agreed 100%. Which is why changing the resolution should require a discrete action by the developer, not something done by default in the common codepath (SDL_WINDOW_FULLSCREEN.)


As long as SDL_WINDOW_FULLSCREEN is there, people will (mis)use it even when SDL_WINDOW_FULLSCREEN + FBO or SDL_RenderSetLogicalSize() are in all ways superior. The recurring discussions on this list are proof enough of that...
SDL_SetWindowSize does not work in fullscreen
Stefanos A.
Guest

Where by "SDL_WINDOW_FULLSCREEN + FBO" I obviously meant "SDL_WINDOW_FULLSCREEN_DESKTOP + FBO".



2014-05-31 19:35 GMT+02:00 Stefanos A.:
Quote:

2014-05-31 19:20 GMT+02:00 Forest Hale:
Quote:
From my past experiences as a Linux/OSX porting contractor, it is undesirable for any app or game to change display mode by default and the user should always have to opt-in to such behavior, because
it has many side effects





Agreed 100%. Which is why changing the resolution should require a discrete action by the developer, not something done by default in the common codepath (SDL_WINDOW_FULLSCREEN.)


As long as SDL_WINDOW_FULLSCREEN is there, people will (mis)use it even when SDL_WINDOW_FULLSCREEN + FBO or SDL_RenderSetLogicalSize() are in all ways superior. The recurring discussions on this list are proof enough of that...

SDL_SetWindowSize does not work in fullscreen
pyroary


Joined: 18 Mar 2014
Posts: 7
Quote:
<The discussion above>


So if I understood the discussion correctly, SDL_SetWindowSize is not a valid function to call when in fullscreen mode (the documentation needs to be updated for this, I believe).


I have to use the "classical" fullscreen mode in my application, which is why I cannot use SDL_FULLSCREEN_DESKTOP sadly.


I could use some help on a valid way to change resolution while in fullscreen mode. Here's the method I tried using SDL_DisplayMode, which didn't work - the resolution stays the same no matter what values I give to mode.w and mode.h :
Quote:
Quote:
//Check the current window flags
Uint32 flags = SDL_GetWindowFlags(gWindow);

//Are we in fullscreen mode right now?
if ((flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN)
{
//Use the DisplayMode way of resizing screen
SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(0, &mode);

mode.w = gScreenSettings.cur.w;
mode.h = gScreenSettings.cur.h;

SDL_SetWindowDisplayMode(gWindow, &mode);
}
else
{
SDL_SetWindowSize(gWindow, gScreenSettings.cur.w, gScreenSettings.cur.h);
SDL_SetWindowPosition(gWindow, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
 Did I just use SDL_SetWindowDisplayMode incorrectly, or is something else wrong?


Arvind Raja Yadav
Pyrodactyl Games
Press Page




On Sat, May 31, 2014 at 4:39 PM, Arvind Raja Yadav wrote:
Quote:
Quote:
Yes, SDL Doesn't allow resolution change once it goes fullscreen.

You could just use the Desktop Resolution instead. Then you can use SDL_RenderSetLogicalSize() to maintain the aspect ratio.
If you really want to change resolution then you could go: Fullscreen -> Windowed -> (delay) -> Size Change -> (Delay) -> Fullscreen.


I cannot use the logical size portion of the SDL Renderer, as I handle the size/aspect ration stuff in code myself.


To me, this is definitely a bug in SDL2 - nothing in the documentation suggests you can't change resolution while in fullscreen mode. Changing resolution while in fullscreen is a fairly common scenario as well - lots of other games allow you to do the same thing.
Arvind Raja Yadav
Pyrodactyl Games





SDL_SetWindowSize does not work in fullscreen
Daniel Gibson
Guest

Just switch to windowed and immediately back to fullscreen at the new
resolution.

Cheers,
Daniel

Am 31.05.2014 20:41, schrieb Arvind Raja Yadav:
Quote:
<The discussion above>


So if I understood the discussion correctly, SDL_SetWindowSize is not a
valid function to call when in fullscreen mode (the documentation needs
to be updated for this, I believe).

I have to use the "classical" fullscreen mode in my application, which
is why I cannot use SDL_FULLSCREEN_DESKTOP sadly.

I could use some help on a valid way to change resolution while in
fullscreen mode. Here's the method I tried using SDL_DisplayMode, which
didn't work - the resolution stays the same no matter what values I give
to mode.w and mode.h :

//Check the current window flags
Uint32 flags = SDL_GetWindowFlags(gWindow);

//Are we in fullscreen mode right now?
if ((flags &SDL_WINDOW_FULLSCREEN) ==SDL_WINDOW_FULLSCREEN)
{
//Use the DisplayMode way of resizing screen
SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(0, &mode);

mode.w = gScreenSettings.cur.w;
mode.h = gScreenSettings.cur.h;

SDL_SetWindowDisplayMode(gWindow, &mode);
}
else
{
SDL_SetWindowSize(gWindow, gScreenSettings.cur.w, gScreenSettings.cur.h);
SDL_SetWindowPosition(gWindow,SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED);
}

Did I just use SDL_SetWindowDisplayMode incorrectly, or is something
else wrong?

Arvind Raja Yadav
Pyrodactyl Games <http://pyrodactyl.com/>
Press Page <http://pyrodactyl.com/press>


On Sat, May 31, 2014 at 4:39 PM, Arvind Raja Yadav
<mailto:> wrote:

Yes, SDL Doesn't allow resolution change once it goes fullscreen.

You could just use the Desktop Resolution instead. Then you can
use SDL_RenderSetLogicalSize() to maintain the aspect ratio.
If you really want to change resolution then you could go:
Fullscreen -> Windowed -> (delay) -> Size Change -> (Delay) ->
Fullscreen.


I cannot use the logical size portion of the SDL Renderer, as I
handle the size/aspect ration stuff in code myself.

To me, this is definitely a bug in SDL2 - nothing in the
documentation suggests you can't change resolution while in
fullscreen mode. Changing resolution while in fullscreen is a fairly
common scenario as well - lots of other games allow you to do the
same thing.

Arvind Raja Yadav
Pyrodactyl Games <http://pyrodactyl.com/>




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_SetWindowSize does not work in fullscreen
David Gow
Guest

Quote:
So if I understood the discussion correctly, SDL_SetWindowSize is not a
valid function to call when in fullscreen mode (the documentation needs to
be updated for this, I believe).

I have to use the "classical" fullscreen mode in my application, which is
why I cannot use SDL_FULLSCREEN_DESKTOP sadly.

If you can hack around having to use a real mode switch, that'd be best.
Usually it can be emulated in one way or another.

Quote:
I could use some help on a valid way to change resolution while in
fullscreen mode.

The easiest way is to set windowed mode, set the size and re-enter
fullscreen[1].

There are a couple of tricks if you're going to be toggling fullscreen
at the same time as changing resolution to minimise the number of mode
switches.

SDL_SetWindowDisplayMode also, IIRC, only works in windowed mode, and
changes the display mode the next time the window changes from
windowed->fullscreen.

— David

[1]: You'll get two modeswitches here, but I don't think there's any way
around that.

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_SetWindowSize does not work in fullscreen
Alex Szpakowski
Guest

I believe this should work (untested code):

if ((flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN)
{
//Use the DisplayMode way of resizing screen
SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(0, &mode);

mode.w = gScreenSettings.cur.w;
mode.h = gScreenSettings.cur.h;

if (SDL_GetClosestDisplayMode(0, &mode, &mode) != NULL)
{
SDL_SetWindowFullscreen(gWindow, 0);
SDL_SetWindowDisplayMode(gWindow, &mode);
SDL_SetWindowFullscreen(gWindow, SDL_WINDOW_FULLSCREEN);
}
}

On May 31, 2014, at 3:41 PM, Arvind Raja Yadav wrote:
Quote:

I could use some help on a valid way to change resolution while in fullscreen mode. Here's the method I tried using SDL_DisplayMode, which didn't work - the resolution stays the same no matter what values I give to mode.w and mode.h :

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_SetWindowSize does not work in fullscreen
pyroary


Joined: 18 Mar 2014
Posts: 7
Quote:
Just switch to windowed and immediately back to fullscreen at the new resolution.


I tried this, and it seems to work. ( Thanks! ) However, I'm encountering a strange situation:

Starting the application in fullscreen mode and then going to windowed mode results in the SDL app losing all its textures, and I need to reload them. However, starting the application in windowed mode lets me switch back and forth between fullscreen and windowed mode any number of times without any need to reload textures.


Is this expected behavior, and is there any way to avoid this loss of textures?


Arvind Raja Yadav
Pyrodactyl Games
Press Page




On Sun, Jun 1, 2014 at 12:11 AM, Arvind Raja Yadav wrote:
Quote:
Quote:
<The discussion above>


So if I understood the discussion correctly, SDL_SetWindowSize is not a valid function to call when in fullscreen mode (the documentation needs to be updated for this, I believe).


I have to use the "classical" fullscreen mode in my application, which is why I cannot use SDL_FULLSCREEN_DESKTOP sadly.


I could use some help on a valid way to change resolution while in fullscreen mode. Here's the method I tried using SDL_DisplayMode, which didn't work - the resolution stays the same no matter what values I give to mode.w and mode.h :
Quote:
Quote:
//Check the current window flags
Uint32 flags = SDL_GetWindowFlags(gWindow);

//Are we in fullscreen mode right now?
if ((flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN)
{
//Use the DisplayMode way of resizing screen
SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(0, &mode);

mode.w = gScreenSettings.cur.w;
mode.h = gScreenSettings.cur.h;

SDL_SetWindowDisplayMode(gWindow, &mode);
}
else
{
SDL_SetWindowSize(gWindow, gScreenSettings.cur.w, gScreenSettings.cur.h);
SDL_SetWindowPosition(gWindow, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
 Did I just use SDL_SetWindowDisplayMode incorrectly, or is something else wrong?


Arvind Raja Yadav
Pyrodactyl Games

Press Page




On Sat, May 31, 2014 at 4:39 PM, Arvind Raja Yadav wrote:
Quote:
Quote:
Yes, SDL Doesn't allow resolution change once it goes fullscreen.

You could just use the Desktop Resolution instead. Then you can use SDL_RenderSetLogicalSize() to maintain the aspect ratio.
If you really want to change resolution then you could go: Fullscreen -> Windowed -> (delay) -> Size Change -> (Delay) -> Fullscreen.


I cannot use the logical size portion of the SDL Renderer, as I handle the size/aspect ration stuff in code myself.


To me, this is definitely a bug in SDL2 - nothing in the documentation suggests you can't change resolution while in fullscreen mode. Changing resolution while in fullscreen is a fairly common scenario as well - lots of other games allow you to do the same thing.
Arvind Raja Yadav
Pyrodactyl Games










SDL_SetWindowSize does not work in fullscreen
LordHavoc


Joined: 05 Feb 2014
Posts: 23
Location: USA
This means your video driver is doing a context reset. The GL_ARB_robustness extension can inform you of this event having occurred, but it's still up to you to restore all your textures.

Starting in windowed mode may be your better bet, but it likely produces a different swap-chain that runs slower.

When playing a fullscreen game in Windows you get special behavior from the video driver where it does not merely show the desktop and blit the game's backbuffer to that on each SDL_GL_SwapWindow,
instead it allocates a second framebuffer and alternately renders to one or the other (this skips the blit-to-desktop), or even may allocate three such buffers (triple buffering) if vsync is enabled.

Side effects of double-buffering/triple-buffering of fullscreen games:
1. increased framerate (the reason they do this!).
2. any popup window will not be visible over the game. (this is why a game that crashes tends to appear to just freeze, but hitting Enter will generally dismiss the game - because the Enter key is
going to the crash dialog, which is hidden by double-buffering/triple-buffering fullscreen games).
3. drivers can do elaborate tricks with the buffer swapping (such as stereo flipping for shutter glasses to get a 3D display).

Apparently on at least some configurations, you get a device reset when switching away from such a double-buffered fullscreen window?

On 05/31/2014 12:11 PM, Arvind Raja Yadav wrote:
Quote:
Just switch to windowed and immediately back to fullscreen at the new resolution.


I tried this, and it seems to work. ( Thanks! ) However, I'm encountering a strange situation:

Starting the application in fullscreen mode and then going to windowed mode results in the SDL app losing all its textures, and I need to reload them. However, starting the application in windowed
mode lets me switch back and forth between fullscreen and windowed mode any number of times without any need to reload textures.

Is this expected behavior, and is there any way to avoid this loss of textures?

Arvind Raja Yadav
Pyrodactyl Games <http://pyrodactyl.com/>
Press Page <http://pyrodactyl.com/press>


On Sun, Jun 1, 2014 at 12:11 AM, Arvind Raja Yadav <mailto:> wrote:

<The discussion above>


So if I understood the discussion correctly, SDL_SetWindowSize is not a valid function to call when in fullscreen mode (the documentation needs to be updated for this, I believe).

I have to use the "classical" fullscreen mode in my application, which is why I cannot use SDL_FULLSCREEN_DESKTOP sadly.

I could use some help on a valid way to change resolution while in fullscreen mode. Here's the method I tried using SDL_DisplayMode, which didn't work - the resolution stays the same no matter
what values I give to mode.w and mode.h :

//Check the current window flags
Uint32 flags = SDL_GetWindowFlags(gWindow);

//Are we in fullscreen mode right now?
if ((flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN)
{
//Use the DisplayMode way of resizing screen
SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(0, &mode);

mode.w = gScreenSettings.cur.w;
mode.h = gScreenSettings.cur.h;

SDL_SetWindowDisplayMode(gWindow, &mode);
}
else
{
SDL_SetWindowSize(gWindow, gScreenSettings.cur.w, gScreenSettings.cur.h);
SDL_SetWindowPosition(gWindow, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}

Did I just use SDL_SetWindowDisplayMode incorrectly, or is something else wrong?

Arvind Raja Yadav
Pyrodactyl Games <http://pyrodactyl.com/>
Press Page <http://pyrodactyl.com/press>


On Sat, May 31, 2014 at 4:39 PM, Arvind Raja Yadav <mailto:> wrote:

Yes, SDL Doesn't allow resolution change once it goes fullscreen.

You could just use the Desktop Resolution instead. Then you can use SDL_RenderSetLogicalSize() to maintain the aspect ratio.
If you really want to change resolution then you could go: Fullscreen -> Windowed -> (delay) -> Size Change -> (Delay) -> Fullscreen.


I cannot use the logical size portion of the SDL Renderer, as I handle the size/aspect ration stuff in code myself.

To me, this is definitely a bug in SDL2 - nothing in the documentation suggests you can't change resolution while in fullscreen mode. Changing resolution while in fullscreen is a fairly common
scenario as well - lots of other games allow you to do the same thing.

Arvind Raja Yadav
Pyrodactyl Games <http://pyrodactyl.com/>





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



--
LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_SetWindowSize does not work in fullscreen
pyroary


Joined: 18 Mar 2014
Posts: 7
Quote:
Lordhavoc wrote: <snip>

Thanks for the help!

On further examination, it seems like all textures loaded while the application is fullscreen are lost on context switch, while textures loaded while windowed are not. It may be worth it for someone to double check and document this.


Arvind Raja Yadav
Pyrodactyl Games
Press Page




On Sun, Jun 1, 2014 at 12:41 AM, Arvind Raja Yadav wrote:
Quote:
Quote:
Just switch to windowed and immediately back to fullscreen at the new resolution.


I tried this, and it seems to work. ( Thanks! ) However, I'm encountering a strange situation:

Starting the application in fullscreen mode and then going to windowed mode results in the SDL app losing all its textures, and I need to reload them. However, starting the application in windowed mode lets me switch back and forth between fullscreen and windowed mode any number of times without any need to reload textures.


Is this expected behavior, and is there any way to avoid this loss of textures?


Arvind Raja Yadav
Pyrodactyl Games
Press Page





On Sun, Jun 1, 2014 at 12:11 AM, Arvind Raja Yadav wrote:
Quote:
Quote:
<The discussion above>


So if I understood the discussion correctly, SDL_SetWindowSize is not a valid function to call when in fullscreen mode (the documentation needs to be updated for this, I believe).


I have to use the "classical" fullscreen mode in my application, which is why I cannot use SDL_FULLSCREEN_DESKTOP sadly.


I could use some help on a valid way to change resolution while in fullscreen mode. Here's the method I tried using SDL_DisplayMode, which didn't work - the resolution stays the same no matter what values I give to mode.w and mode.h :
Quote:
Quote:
//Check the current window flags
Uint32 flags = SDL_GetWindowFlags(gWindow);

//Are we in fullscreen mode right now?
if ((flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN)
{
//Use the DisplayMode way of resizing screen
SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(0, &mode);

mode.w = gScreenSettings.cur.w;
mode.h = gScreenSettings.cur.h;

SDL_SetWindowDisplayMode(gWindow, &mode);
}
else
{
SDL_SetWindowSize(gWindow, gScreenSettings.cur.w, gScreenSettings.cur.h);
SDL_SetWindowPosition(gWindow, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
 Did I just use SDL_SetWindowDisplayMode incorrectly, or is something else wrong?


Arvind Raja Yadav
Pyrodactyl Games

Press Page




On Sat, May 31, 2014 at 4:39 PM, Arvind Raja Yadav wrote:
Quote:
Quote:
Yes, SDL Doesn't allow resolution change once it goes fullscreen.

You could just use the Desktop Resolution instead. Then you can use SDL_RenderSetLogicalSize() to maintain the aspect ratio.
If you really want to change resolution then you could go: Fullscreen -> Windowed -> (delay) -> Size Change -> (Delay) -> Fullscreen.


I cannot use the logical size portion of the SDL Renderer, as I handle the size/aspect ration stuff in code myself.


To me, this is definitely a bug in SDL2 - nothing in the documentation suggests you can't change resolution while in fullscreen mode. Changing resolution while in fullscreen is a fairly common scenario as well - lots of other games allow you to do the same thing.
Arvind Raja Yadav
Pyrodactyl Games















SDL_SetWindowSize does not work in fullscreen
Pallav Nawani


Joined: 19 May 2011
Posts: 122
Location: Dehradun, India
It is a DirectX quirk. Window size changes, resolution changes etc. cause the video device to be lost. You need to reset it & load all the textures again.  If you don't want to re-load all textures, there are three solutions.


1. Start in windowed mode, check whether user was Fullscreen last time & if so, switch to fullscreen.


Or, the solution I originally recommended:
2. Create a Fullscreen Desktop window (SDL_FULLSCREEN_DESKTOP flag ) & use SDL_RenderSetLogicalSize().


Or,
3. Use OpenGL instead of DirectX (SDL_SetHints())





Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter:  http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768



On Sun, Jun 1, 2014 at 12:41 AM, Arvind Raja Yadav wrote:
Quote:
Quote:
Just switch to windowed and immediately back to fullscreen at the new resolution.


I tried this, and it seems to work. ( Thanks! ) However, I'm encountering a strange situation:

Starting the application in fullscreen mode and then going to windowed mode results in the SDL app losing all its textures, and I need to reload them. However, starting the application in windowed mode lets me switch back and forth between fullscreen and windowed mode any number of times without any need to reload textures.


Is this expected behavior, and is there any way to avoid this loss of textures?


Arvind Raja Yadav
Pyrodactyl Games
Press Page




On Sun, Jun 1, 2014 at 12:11 AM, Arvind Raja Yadav wrote:
Quote:
Quote:
<The discussion above>


So if I understood the discussion correctly, SDL_SetWindowSize is not a valid function to call when in fullscreen mode (the documentation needs to be updated for this, I believe).


I have to use the "classical" fullscreen mode in my application, which is why I cannot use SDL_FULLSCREEN_DESKTOP sadly.


I could use some help on a valid way to change resolution while in fullscreen mode. Here's the method I tried using SDL_DisplayMode, which didn't work - the resolution stays the same no matter what values I give to mode.w and mode.h :
Quote:
Quote:
//Check the current window flags
Uint32 flags = SDL_GetWindowFlags(gWindow);

//Are we in fullscreen mode right now?
if ((flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN)
{
//Use the DisplayMode way of resizing screen
SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(0, &mode);

mode.w = gScreenSettings.cur.w;
mode.h = gScreenSettings.cur.h;

SDL_SetWindowDisplayMode(gWindow, &mode);
}
else
{
SDL_SetWindowSize(gWindow, gScreenSettings.cur.w, gScreenSettings.cur.h);
SDL_SetWindowPosition(gWindow, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
 Did I just use SDL_SetWindowDisplayMode incorrectly, or is something else wrong?


Arvind Raja Yadav
Pyrodactyl Games

Press Page




On Sat, May 31, 2014 at 4:39 PM, Arvind Raja Yadav wrote:
Quote:
Quote:
Yes, SDL Doesn't allow resolution change once it goes fullscreen.

You could just use the Desktop Resolution instead. Then you can use SDL_RenderSetLogicalSize() to maintain the aspect ratio.
If you really want to change resolution then you could go: Fullscreen -> Windowed -> (delay) -> Size Change -> (Delay) -> Fullscreen.


I cannot use the logical size portion of the SDL Renderer, as I handle the size/aspect ration stuff in code myself.


To me, this is definitely a bug in SDL2 - nothing in the documentation suggests you can't change resolution while in fullscreen mode. Changing resolution while in fullscreen is a fairly common scenario as well - lots of other games allow you to do the same thing.
Arvind Raja Yadav
Pyrodactyl Games














_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org