Window Decorations and Borders

Decorations in fullscreen modes

How do window decorations affect fullscreen modes?

Abstract art representing computer programming

In fullscreen modes, window decorations are typically irrelevant because the window is either resized to match the screen resolution (exclusive fullscreen) or displayed borderless on top of other windows (fullscreen desktop).

SDL2 provides two fullscreen modes:

  1. Exclusive Fullscreen (SDL_WINDOW_FULLSCREEN): The window occupies the entire screen resolution, and all decorations are removed.
  2. Fullscreen Desktop (SDL_WINDOW_FULLSCREEN_DESKTOP): The window behaves as a borderless window but matches the desktop resolution.

Example of switching between fullscreen modes:

#include <SDL.h>

int main() {
  SDL_Init(SDL_INIT_VIDEO);

  SDL_Window* Window{SDL_CreateWindow(
    "Fullscreen Demo",
    SDL_WINDOWPOS_CENTERED,
    SDL_WINDOWPOS_CENTERED,
    800, 600,
    SDL_WINDOW_SHOWN 
  )};

  SDL_SetWindowFullscreen(
    Window, SDL_WINDOW_FULLSCREEN_DESKTOP); 
  
  // Display fullscreen for 3 seconds
  SDL_Delay(3000);
  
  // Restore windowed mode
  SDL_SetWindowFullscreen(Window, 0); 
  SDL_Delay(3000);

  SDL_DestroyWindow(Window);
  SDL_Quit();
}
Displays fullscreen desktop mode, then returns to windowed mode.

In fullscreen desktop mode, decorations are completely absent, and the window is effectively borderless. Exclusive fullscreen mode always removes decorations because it takes complete control of the display.

This Question is from the Lesson:

Window Decorations and Borders

An introduction to managing SDL2 window decorations, borders, and client areas.

Answers to questions are automatically generated and may not have been reviewed.

This Question is from the Lesson:

Window Decorations and Borders

An introduction to managing SDL2 window decorations, borders, and client areas.

sdl2-promo.jpg
Part of the course:

Game Dev with SDL2

Learn C++ and SDL development by creating hands on, practical projects inspired by classic retro games

Free, unlimited access

This course includes:

  • 67 Lessons
  • 100+ Code Samples
  • 91% Positive Reviews
  • Regularly Updated
  • Help and FAQ
Free, Unlimited Access

Professional C++

Comprehensive course covering advanced concepts, and how to use them on large-scale projects.

Screenshot from Warhammer: Total War
Screenshot from Tomb Raider
Screenshot from Jedi: Fallen Order
Contact|Privacy Policy|Terms of Use
Copyright © 2024 - All Rights Reserved