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 - SDL_GetDisplayMode fails to report mode.format when using Wayland backend
Summary: SDL_GetDisplayMode fails to report mode.format when using Wayland backend
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.1
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-14 14:40 UTC by sebby2k
Modified: 2017-01-03 08:44 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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