SDL_SetWindowSize does not work in fullscreen

Lordhavoc wrote:

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 http://pyrodactyl.com/
Press Page http://pyrodactyl.com/pressOn Sun, Jun 1, 2014 at 12:41 AM, Arvind Raja Yadav < @Arvind_Raja_Yadav> wrote:

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 < @Arvind_Raja_Yadav> wrote:

>

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 flagsUint32 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 < @Arvind_Raja_Yadav> 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/

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: 9997478768On Sun, Jun 1, 2014 at 12:41 AM, Arvind Raja Yadav < arvindrajayadav at gmail.com> wrote:

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 < arvindrajayadav at gmail.com> wrote:

>

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 flagsUint32 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 < arvindrajayadav at gmail.com> 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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org