We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3519

Summary: SDL_GetDisplayMode fails to report mode.format when using Wayland backend
Product: SDL Reporter: sebby2k <shopper2k>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   

Description sebby2k 2016-12-14 14:40:29 UTC
= Description

SDL_DisplayMode returned by SDL_GetDisplayMode reports mode.format as 0 when using Wayland backend (SDL_VIDEODRIVER=wayland). Format is reported properly by X11 backend.

= Environment

Fedora 25 running Gnome Wayland session.

Name        : gnome-shell
Arch        : x86_64
Epoch       : 0
Version     : 3.22.2
Release     : 2.fc25

Name        : SDL2
Arch        : x86_64
Epoch       : 0
Version     : 2.0.5
Release     : 2.fc25

= Output 

X11 Backend Output:

Mode 1920 1080 0x16161804 60

Wayland Backend Output:

Mode 1920 1080 0000000000 60

= Test Driver

#include <stdio.h>
#include <SDL2/SDL.h>

void dump_disp_mode(SDL_DisplayMode &mode) {
  printf("Mode %d %d %#010x %d\n",
         mode.w,
         mode.h,
         mode.format,
         mode.refresh_rate);
}

int test_sdl() {
  int ret;

  ret = SDL_InitSubSystem(SDL_INIT_VIDEO);
  if (ret < 0) {
    fprintf(stderr, "Failed to init SDL video: %s\n", SDL_GetError());
    return 1;
  }

  SDL_DisplayMode mode;
  ret = SDL_GetDesktopDisplayMode(0, &mode);
  if (ret < 0) {
    fprintf(stderr, "Failed to get desktop display mode: %s\n", SDL_GetError());
    return 1;
  }
  dump_disp_mode(mode);

  int modes_num = SDL_GetNumDisplayModes(0);
  for (int i = 0; i < modes_num; i++) {
    ret = SDL_GetDisplayMode(0, i, &mode);
    if (ret < 0) {
      fprintf(stderr, "Failed to get display mode: %s\n", SDL_GetError());
      return 1;
    }
    dump_disp_mode(mode);
  }

  SDL_QuitSubSystem(SDL_INIT_VIDEO);
}

int main(int argc, char **argv) {
  test_sdl();
  return 0;
}
Comment 1 Sam Lantinga 2017-01-03 08:44:42 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/f42f107a6035