title: SDL2 - how to get the appropriate display resolution
body: <p>I'm trying to open a fullscreen window using SDL2. I've thoroughly looked at the documentation on Display and window management ( <a href="https://wiki.libsdl.org/CategoryVideo" rel="nofollow noreferrer">https://wiki.libsdl.org/CategoryVideo</a> )... however I don't understand what the best practice would be to get the display resolution I am actually working on.</p>
  
  <p>I have the following sample code:</p>
  
  <pre><code>SDL_DisplayMode mMode;
  SDL_Rect mRect;
  
  int ret0 = SDL_GetDisplayBounds(0, &amp;mRect);
  std::cout &lt;&lt; "bounds w and h are: " &lt;&lt; mRect.w &lt;&lt; " x " &lt;&lt; mRect.h &lt;&lt; std::endl;
  int ret2 = SDL_GetCurrentDisplayMode(0, &amp;mMode);
  std::cout &lt;&lt; "current display res w and h are: " &lt;&lt; mMode.w &lt;&lt; " x " &lt;&lt; mMode.h &lt;&lt; std::endl;
  int ret3 = SDL_GetDisplayMode(0, 0, &amp;mMode);
  std::cout &lt;&lt; "display mode res w and h are: " &lt;&lt; mMode.w &lt;&lt; " x " &lt;&lt; mMode.h &lt;&lt; std::endl;
  </code></pre>
  
  <p>I am working on a single display that has a resolution of 1920x1080. However, the printed results are:</p>
  
  <p><a href="https://i.stack.imgur.com/ZgWKx.png" rel="nofollow noreferrer">program output</a></p>
  
  <p>It seems that SDL_GetDisplayMode() is the only function that displays the correct resolution, so I'd be inclined to use that one. However, I've read that when it comes to SDL_GetDisplayMode(), display modes are sorted according to a certain priority, so that calling it with a 0 returns the largest supported resolution for the display, which is not necessarily the actual resolution (see also: <a href="https://stackoverflow.com/questions/37722003/sdl-desktop-resolution-detection-in-linux">SDL desktop resolution detection in Linux</a> ).</p>
  
  <p>My question is: what is the best practice to obtain the correct resolution? </p>