On this page:
21.1 Display Enumeration
get-displays
primary-display
display-name
21.2 Display Bounds
display-bounds
display-usable-bounds
21.3 Display Modes
current-display-mode
desktop-display-mode
fullscreen-display-modes
display-mode-resolution
display-mode-refresh-rate
21.4 Window-Display Relationship
window-display
display-content-scale
window-display-scale
21.5 Display Mode Struct Accessors
SDL_  Display  Mode-display  ID
SDL_  Display  Mode-format
SDL_  Display  Mode-w
SDL_  Display  Mode-h
SDL_  Display  Mode-pixel_  density
SDL_  Display  Mode-refresh_  rate
SDL_  Display  Mode-refresh_  rate_  numerator
SDL_  Display  Mode-refresh_  rate_  denominator
9.0.0.11

21 Display Information🔗ℹ

This section covers display/monitor enumeration and information.

21.1 Display Enumeration🔗ℹ

Returns a list of display IDs for all connected monitors.

(for ([id (get-displays)])
  (printf "Display ~a: ~a~n" id (display-name id)))

Returns the ID of the primary display.

procedure

(display-name display-id)  string?

  display-id : exact-nonnegative-integer?
Returns the name of a display.

21.2 Display Bounds🔗ℹ

Returns the desktop area represented by a display.

Returns (values x y width height) in screen coordinates.

(define-values (x y w h) (display-bounds (primary-display)))
(printf "Primary display: ~ax~a at (~a, ~a)~n" w h x y)

Returns the usable desktop area (excludes taskbar, dock, etc.).

Returns (values x y width height).

21.3 Display Modes🔗ℹ

Display modes describe the resolution and refresh rate of a display.

procedure

(current-display-mode display-id)  cpointer?

  display-id : exact-nonnegative-integer?
Returns the current display mode.

The returned pointer is owned by SDL and should not be freed.

procedure

(desktop-display-mode display-id)  cpointer?

  display-id : exact-nonnegative-integer?
Returns the desktop display mode (the mode at SDL initialization).

The returned pointer is owned by SDL and should not be freed.

procedure

(fullscreen-display-modes display-id)  (listof cpointer?)

  display-id : exact-nonnegative-integer?
Returns all available fullscreen display modes for a display.

procedure

(display-mode-resolution mode)  
exact-integer? exact-integer?
  mode : cpointer?
Returns the width and height of a display mode.

(define mode (current-display-mode (primary-display)))
(define-values (w h) (display-mode-resolution mode))
(printf "Current resolution: ~ax~a~n" w h)

procedure

(display-mode-refresh-rate mode)  real?

  mode : cpointer?
Returns the refresh rate of a display mode in Hz.

21.4 Window-Display Relationship🔗ℹ

procedure

(window-display win)  exact-nonnegative-integer?

  win : window?
Returns the display ID for the display containing the center of a window.

procedure

(display-content-scale display-id)  real?

  display-id : exact-nonnegative-integer?
Returns the content scale factor for a display.

This is 1.0 for standard displays, 2.0 for Retina/HiDPI displays.

(define scale (display-content-scale (primary-display)))
(when (> scale 1.0)
  (printf "HiDPI display detected (scale: ~a)~n" scale))

procedure

(window-display-scale win)  real?

  win : window?
Returns the display scale for a window.

21.5 Display Mode Struct Accessors🔗ℹ

These functions access fields of the SDL_DisplayMode struct:

procedure

(SDL_DisplayMode-displayID mode)  exact-nonnegative-integer?

  mode : cpointer?
Returns the display ID this mode belongs to.

procedure

(SDL_DisplayMode-format mode)  exact-nonnegative-integer?

  mode : cpointer?
Returns the pixel format.

procedure

(SDL_DisplayMode-w mode)  exact-integer?

  mode : cpointer?
Returns the width in pixels.

procedure

(SDL_DisplayMode-h mode)  exact-integer?

  mode : cpointer?
Returns the height in pixels.

procedure

(SDL_DisplayMode-pixel_density mode)  real?

  mode : cpointer?
Returns the pixel density (pixels per point).

procedure

(SDL_DisplayMode-refresh_rate mode)  real?

  mode : cpointer?
Returns the refresh rate in Hz.

procedure

(SDL_DisplayMode-refresh_rate_numerator mode)  exact-integer?

  mode : cpointer?
Returns the numerator of the exact refresh rate fraction.

procedure

(SDL_DisplayMode-refresh_rate_denominator mode)

  exact-integer?
  mode : cpointer?
Returns the denominator of the exact refresh rate fraction.