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 DualMonitor Mode Switch/Res Switch issue, need help
DGSA


Joined: 24 Mar 2014
Posts: 4
Hi everyone, : )
Currenly I'm working on a game under Linux - Debian.
And I engage 3 Mode/Resolution switch issues, and don't know how to solve them.
So I need some help from u guys.... Orz........
DGSA


Joined: 24 Mar 2014
Posts: 4
Code:

Due to the complexity of the mode/res switch and in order to make the descriptions more clear and simple and accurate,
I'll use some simplified form:

    LG - for the Game App runing at the left monitor
    RG - for the Game App runing at the right monitor
    SG - for the Game App on Single Monitor

    LM - for the left  Monitor
    RM - for the right Monitor   
    SM - for Single Monitor
   
    F - for Fullscreen mode
    W - for Windowed mode
   
And suppose Monitor support the following 3 resolutions:
    1920 x 1080
    1280 x 720
    1024 x 768

And suppose Game app support the following 3 resolutions on both windowed/fullscreen mode:
    1920 x 1080
    1280 x 720
    1024 x 768

Some example:   
    LGW - 1920 x 1080
    means the games is running at the left monitor, at windowed mode and the resolution of the tame is 1920 x 1080
   
    RMF - 1024 x 768
    means the right monitor is at fullscreen mode (a game is running in it) and the current resolution of the monitor is 1024 x 768
   
    SMF - 1920 x 1080 / SGF - 1024 x 768
    means the monitor/game are both fullscreen, only 1 monitor.
    And the monitor res is 1920 x 1080, but the game res is 1024 x 768 (show up in left up counor of the monitor)


Here are the issues I'm currenty encoutering:

    //----------------------------------------------------------------------------------------------
    //  Issue 1 - Game Res switch under fullscreen mode on the right Monitor not works properly

    Way to reproduce:
        Player has dual monitors
        Start the game on L/R monitor and go fullscreen
        Switch game resolution under fullscreen
        Fullscreen parameter in code layer - SDL_WINDOW_FULLSCREEN

    Test case 1: Everything works well on the left monitor
        Start Game              LGW - 1920 x 1080   /   LMW - 1920 x 1080
        Switch to fullscreen    LGF - 1920 x 1080   /   LMF - 1920 x 1080   (works well, everything matches)
        Switch res of game      LGF - 1280 x 720    /   LMF - 1280 x 720    (works well, everything matches)
        Switch res of game      LGF - 1024 x 768    /   LMF - 1024 x 768    (works well, everything matches)

    Test case 2: On the right monitor, it works like - SDL_WINDOW_FULLSCREEN_DESKTOP
        Start Game              RGW - 1920 x 1080   /   RMW - 1920 x 1080
        Switch to fullscreen    RGF - 1920 x 1080   /   RMF - 1920 x 1080   (works well, everything matches)
        Switch res of game      RGF - 1280 x 720    /   RMF - 1920 x 1080   (not good, res of monitor remains 1920 x 1080 )
        Switch res of game      RGF - 1024 x 768    /   RMF - 1920 x 1080   (not good, res of monitor remains 1920 x 1080 )

    The res of the window/game content will be switched properly
    But the res of the right monitor always remain the same.
    It behaves SDL_WINDOW_FULLSCREEN_DESKTOP (keep the current desktop resolution)
    But the parameter I use is SDL_WINDOW_FULLSCREEN...  -_-b
   
    //----------------------------------------------------------------------------------------------
    //  Issue 2 - Res switch under fullscreen mode not works well on none native monitor resolution
   
    Way to reproduce:
        Player have 1 monitor and it's best resolution is 1920 x 1080

    Test case 1: Everything works well
        Start Game              SGW - 1920 x 1080   /   SMW - 1920 x 1080   (works well, monitor is at native res)
        Switch to fullscreen    SGF - 1920 x 1080   /   SMF - 1920 x 1080   (works well, everything matches)
        Switch res of game      SGF - 1280 x 720    /   SMF - 1280 x 720    (works well, everything matches)
        Switch res of game      SGF - 1024 x 768    /   SMF - 1024 x 768    (works well, everything matches)

    Test case 2: The res of the monitor could only down scale
        Start Game              SGW - 1280 x 720    /   SMW - 1280 x 720    (works well, but monitor is not at native res)
        Switch to fullscreen    SGF - 1280 x 720    /   SMF - 1280 x 720    (works well, everything matches)
        Switch res of game      SGF - 1024 x 768    /   SMF - 1024 x 768    (works well, everything matches)
        Switch res of game      SGF - 1920 x 1080   /   SMF - 1280 x 720    (not good, the monitor res couldn't upscale to 1920 x 1080)

    Test case 3: The res of the monitor could only down scale
        Start Game              SGW - 1024 x 768    /   SMW - 1024 x 768    (works well, but monitor is not at native res)
        Switch to fullscreen    SGF - 1024 x 768    /   SMF - 1024 x 768    (works well, everything matches)
        Switch res of game      SGF - 1280 x 720    /   SMF - 1024 x 768    (not good, the monitor res couldn't upscale to 1280 x 720)
        Switch res of game      SGF - 1920 x 1080   /   SMF - 1024 x 768    (not good, the monitor res couldn't upscale to 1920 x 1080)

    So the problem of Case 2 and Case 3 is:
        If current monitor's res(like 1280 x 720) is lower than the best/native(1920 x 1080) res.
        Start the game and switch the res under fullscreen, (should be lower or eaqual 1280 x 720)
        Player could only switch down scale, couldn't switch upscale.
        On Nvidia the game could still running, only res not matches. On ATI tha game may hang over there forever

    Before the switch, I call SDL_GetDisplayMode() to enumerate all the supported res.
    It always allow me to use the best match one.
    But the result turns out that it doesn't work.

    //----------------------------------------------------------------------------------------------
    //   Issue 3 - The update region(rect) of the window not work properly under fullscreen mode.   
    This is a bug exist when player have dual monitor or start the game at a none-native res monitor.
   
    Way to reproduce:

    Condition:
        Dual monitor + ATI
        Dual monitor + Nvidia
        1 monitor - none native res + Nvidia
   
    Init desk top res 1920 x 1080

    Test case 1: Everything works well.
        Start Game              LGW - 1920 x 1080   /   LMW - 1920 x 1080   (works well, monitor is at native res)
        Switch to fullscreen    LGF - 1920 x 1080   /   LMF - 1920 x 1080   (works well, everything matches)
        Switch res of game      LGF - 1280 x 720    /   LMF - 1280 x 720    (works well, everything matches)
        Switch res of game      LGF - 1024 x 768    /   LMF - 1024 x 768    (works well, everything matches)

    Test case 2: Res switch works well, but the update rect/region does not match
        Start Game              LGW - 1024 x 768    /   LMW - 1920 x 1080   (works well, monitor is at native res)
        Switch to fullscreen    LGF - 1024 x 768    /   LMF - 1024 x 768    (works well, everything matches)
        Switch res of game      LGF - 1280 x 720    /   LMF - 1280 x 720    (res matches, but only 1024 x 768 at the left up cornor of the screen is updated)
        Switch res of game      LGF - 1920 x 1080   /   LMF - 1920 x 1080   (res matches, but only 1024 x 768 at the left up cornor of the screen is updated)
   
    Test case 3: Res switch works well, but the update rect/region does not match
        Start Game              LGW - 1280 x 720    /   LMW - 1920 x 1080   (works well, monitor is at native res)
        Switch to fullscreen    LGF - 1280 x 720    /   LMF - 1280 x 720    (works well, everything matches)
        Switch res of game      LGF - 1024 x 768    /   LMF - 1024 x 768    (res matches, but only 1024 x 720 at center of the screen is updated)
        Switch res of game      LGF - 1920 x 1080   /   LMF - 1920 x 1080   (res matches, but only 1280 x 720 at the left up cornor of the screen is updated)

    In case 2 and 3, every time switch res, the content of the game and size of the window/monitor are switched properly.
    But the update rect of the window is not updated. ( remain the size of the windowed mode )

    SDL_WINDOWEVENT_EXPOSED was sent every time when switch, which equals to WM_Paint on Win32 API.
    So the entire window should be redraw....
   
    //----------------------------------------------------------------------------------------------
    //   ....
    Thank u so much for taking time reading all the question above
    and thank u so much for post ur solutions here...  T_T