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
SDL2-Questions About Full Screen Modes?
JeZ-l-Lee


Joined: 20 Sep 2009
Posts: 572
Location: Long Island, New York, United States, Earth
SDL2-Questions About Full Screen Modes?

Hi,

What is the best method to do full screen on Windows(R) & 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!
MrTAToad


Joined: 13 Feb 2014
Posts: 205
Location: Chichester, England
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.
JeZ-l-Lee


Joined: 20 Sep 2009
Posts: 572
Location: Long Island, New York, United States, Earth
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!
SDL2-Questions About Full Screen Modes?
Bob Rubbens
Guest

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:
Quote:
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


_______________________________________________
SDL mailing list

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

JeZ-l-Lee


Joined: 20 Sep 2009
Posts: 572
Location: Long Island, New York, United States, Earth
Thanks, we got it working now...