SDL_WINDOW_FULLSCREEN_DESKTOP on Linux

Hi guys.

I’m following the advice to use SDL_WINDOW_FULLSCREEN_DESKTOP mode. The
code is working fine on OSX.

However on Linux (Mint 14, Cinnamon) a transition to fullscreen often
(but not always) fails, resulting in a black screen.

     SDL_GetDesktopDisplayMode(0, &desktop_display_mode);
     SDL_SetWindowDisplayMode(game_window, &desktop_display_mode);
     SDL_SetWindowSize(game_window, desktop_display_mode.w, 

desktop_display_mode.h);

     if (SDL_SetWindowFullscreen(game_window, 

SDL_WINDOW_FULLSCREEN_DESKTOP) != 0)
{
std::cout << "Unable to switch window mode: " <<
SDL_GetError() << std::endl;
SDL_ClearError();
}

Transitions from fullscreen to windowed mode also fail, leaving the
screen black.

     if (SDL_SetWindowFullscreen(game_window, 0) != 0)
     {
         std::cout << "Unable to switch window mode: " << 

SDL_GetError() << std::endl;
SDL_ClearError();
}

     CalculateWindowSize(w, h);
     SDL_SetWindowSize(game_window, w, h);

SDL_SetWindowFullscreen() returns true, even when the new window mode is
not displayed correctly.

Any advice on what I or my system is doing wrong would be gratefully
received.

Tony

If y ou are using SDL_FULLSCREEN_DESKTOP then you do not need to use GetDesktopDisplay/SetWindowDisplay/SetWindow size AT ALL.

You simply create your window @ say 1280x720 then just use

SDL_SetWindowFullscreen(game_window, SDL_WINDOW_FULLSCREEN_DESKTOP);

And SDL will take care to maximize the window to the full desktop size etc… (and it’ll fire off an SDL_WINDOWEVENT to inform you of the new size change (e.g. for adjusting glViewport etc…)

Then to pop out of fullscreen simply call

SDL_SetWindowFullscreen(game_window, 0);

This will restore the original windowed size of 1280x720. e.g. there is no need to manage that yourself.On Jul 8, 2013, at 2:39 , Tony Park wrote:

Hi guys.

I’m following the advice to use SDL_WINDOW_FULLSCREEN_DESKTOP mode. The code is working fine on OSX.

However on Linux (Mint 14, Cinnamon) a transition to fullscreen often (but not always) fails, resulting in a black screen.

   SDL_GetDesktopDisplayMode(0, &desktop_display_mode);
   SDL_SetWindowDisplayMode(game_window, &desktop_display_mode);
   SDL_SetWindowSize(game_window, desktop_display_mode.w, desktop_display_mode.h);

   if (SDL_SetWindowFullscreen(game_window, SDL_WINDOW_FULLSCREEN_DESKTOP) != 0)
   {
       std::cout << "Unable to switch window mode: " << SDL_GetError() << std::endl;
       SDL_ClearError();
   }

Transitions from fullscreen to windowed mode also fail, leaving the screen black.

   if (SDL_SetWindowFullscreen(game_window, 0) != 0)
   {
       std::cout << "Unable to switch window mode: " << SDL_GetError() << std::endl;
       SDL_ClearError();
   }

   CalculateWindowSize(w, h);
   SDL_SetWindowSize(game_window, w, h);

SDL_SetWindowFullscreen() returns true, even when the new window mode is not displayed correctly.

Any advice on what I or my system is doing wrong would be gratefully received.

Tony


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

Edward Rudd
OutOfOrder.cc
Skype: outoforder_cc
317-674-3296

1 Like