Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions SDL2pp/Window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ Window& Window::SetFullscreen(Uint32 flags) {
return *this;
}

Window& Window::ToggleFullscreen() {
Uint32 const fullscreenFlag = SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP;
bool const isFullscreen = SDL_GetWindowFlags(window_) & fullscreenFlag;
if (SDL_SetWindowFullscreen(window_, isFullscreen ? SDL_FALSE : SDL_WINDOW_FULLSCREEN_DESKTOP) != 0)
throw Exception("SDL_SetWindowFullscreen");
return *this;
}

Window& Window::SetSize(int w, int h) {
SDL_SetWindowSize(window_, w, h);
return *this;
Expand Down
12 changes: 12 additions & 0 deletions SDL2pp/Window.hh
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,18 @@ public:
////////////////////////////////////////////////////////////
Window& SetFullscreen(Uint32 flags);

////////////////////////////////////////////////////////////
/// \brief Toggle the window's fullscreen state
///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception
///
/// \see http://wiki.libsdl.org/SDL_SetWindowFullscreen
///
////////////////////////////////////////////////////////////
Window& ToggleFullscreen();

////////////////////////////////////////////////////////////
/// \brief Set the size of a window's client area
///
Expand Down