SDL2-Questions About Full Screen Modes?

SDL2-Questions About Full Screen Modes?

Hi,

What is the best method to do full screen on Windows® & Linux desktops/notebooks?
We currently have a game window of 640x480 and would like to add full screen mode support.
We are using SDL2 version 2.0.3.
If someone could explain the best method of implementing full screen than that would be helpful.
Thanks!------------------------
JeZ+Lee
JessePalser <AT> Gmail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

Thanks, we got it working now…------------------------
JeZ+Lee
JessePalser <AT> Gmail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

The easiest way would be with SDL_SetWindowFullscreen. However, as I posted elsewhere, if a texture is set for streaming then the change to full screen seems to wipe the data for some reason. Any other texture type has its graphics preserved.

Hi,

I did some research on the SDL2 Wiki.

I have this code now which does not entirely work properly:

Code:
//-------------------------------------------------------------------------------------------------
bool Visuals::InitializeWindowAgain(void)
{
SDL_Surface* windowIcon = SDL_LoadBMP(“data/visuals/icon.bmp”);

Window = NULL;
if (FullScreenMode == false)  Window = SDL_CreateWindow("''TetriCrisis 4 110% A.I. Turbo'' - (C)2014 By 16BitSoft Inc."
                                                       , SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_RESIZABLE);
else if (FullScreenMode == true)  Window = SDL_CreateWindow("''TetriCrisis 4 110% A.I. Turbo'' - (C)2014 By 16BitSoft Inc."
                                                           , SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_FULLSCREEN);

if (Window == NULL)
{
    printf( "SDL2 create window failed: %s\n", SDL_GetError() );
    CoreFailure = true;
    return(false);
}
else  printf("SDL2 window created.\n");

WindowWidthCurrent = 640;
WindowHeightCurrent = 480;

SDL_SetWindowIcon(Window, windowIcon);

Renderer = NULL;
Renderer = SDL_CreateRenderer(Window, -1, SDL_RENDERER_ACCELERATED);

if (Renderer == NULL)
{
    printf( "SDL2 create renderer failed: %s\n", SDL_GetError() );
    CoreFailure = true;
    return(false);
}
else  printf("SDL2 renderer created.\n");

screens->ScreenIsDirty = true;

if (LoadSpritesAndInitialize() == false)  return(false);

return(true);

}

//-------------------------------------------------------------------------------------------------

The main problem is when ever the window/full screen mode is changed a new SDL2 window is created?
How can I tell SDL2 to use the same SDL2 window as before?

Thanks!------------------------
JeZ+Lee
JessePalser <AT> Gmail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

Did you see MrTAToad’s answer? Or does it not work/is not possible?

With SDL_SetWindowFullscreen (
https://wiki.libsdl.org/SDL_SetWindowFullscreen) you can set it to full
screen, and then when the screen is fullscreen you can use
SDL_SetDisplayMode (https://wiki.libsdl.org/SDL_SetWindowDisplayMode) to
set the right resolution. Just for completeness, if you want to set the
resolution when the screen is windowed you can use SDL_SetWindowSize (
https://wiki.libsdl.org/SDL_SetWindowSize).

Regards

Bob Rubbens

2014-12-11 17:17 GMT+01:00 JeZ-l-Lee :>

Hi,

I did some research on the SDL2 Wiki.

I have this code now which does not entirely work properly:

Code:

//-------------------------------------------------------------------------------------------------
bool Visuals::InitializeWindowAgain(void)
{
SDL_Surface* windowIcon = SDL_LoadBMP(“data/visuals/icon.bmp”);

Window = NULL;
if (FullScreenMode == false)  Window = SDL_CreateWindow("''TetriCrisis

4 110% A.I. Turbo’’ - ©2014 By 16BitSoft Inc."
,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480,
SDL_WINDOW_RESIZABLE);
else if (FullScreenMode == true) Window =
SDL_CreateWindow("’‘TetriCrisis 4 110% A.I. Turbo’’ - ©2014 By 16BitSoft
Inc."
,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480,
SDL_WINDOW_FULLSCREEN);

if (Window == NULL)
{
    printf( "SDL2 create window failed: %s\n", SDL_GetError() );
    CoreFailure = true;
    return(false);
}
else  printf("SDL2 window created.\n");

WindowWidthCurrent = 640;
WindowHeightCurrent = 480;

SDL_SetWindowIcon(Window, windowIcon);

Renderer = NULL;
Renderer = SDL_CreateRenderer(Window, -1, SDL_RENDERER_ACCELERATED);

if (Renderer == NULL)
{
    printf( "SDL2 create renderer failed: %s\n", SDL_GetError() );
    CoreFailure = true;
    return(false);
}
else  printf("SDL2 renderer created.\n");

screens->ScreenIsDirty = true;

if (LoadSpritesAndInitialize() == false)  return(false);

return(true);

}

//-------------------------------------------------------------------------------------------------

The main problem is when ever the window/full screen mode is changed a new
SDL2 window is created?
How can I tell SDL2 to use the same SDL2 window as before?

Thanks!


JeZ+Lee
JessePalser Gmail com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org