From 7a5361d856d29c2e68b359e6f3ec14856c14fa19 Mon Sep 17 00:00:00 2001 From: Pentarctagon Date: Mon, 8 Jun 2020 23:36:40 -0500 Subject: [PATCH] Add current video settings to the game_config::full_build_report. Backport of 11f96b3a985244936b678797d564dc1471b71f0c --- src/build_info.cpp | 7 ++++++- src/video.cpp | 25 +++++++++++++++++++++++++ src/video.hpp | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/build_info.cpp b/src/build_info.cpp index 2dae7021b8c4..61587b224a00 100644 --- a/src/build_info.cpp +++ b/src/build_info.cpp @@ -22,6 +22,7 @@ #include "formatter.hpp" #include "gettext.hpp" #include "serialization/unicode.hpp" +#include "video.hpp" #include #include @@ -481,7 +482,11 @@ std::string full_build_report() << '\n' << report_heading("Features") << '\n' - << game_config::optional_features_report(); + << game_config::optional_features_report() + << '\n' + << report_heading("Current video settings") + << '\n' + << CVideo::video_settings_report(); return o.str(); } diff --git a/src/video.cpp b/src/video.cpp index d5c4b957ad97..689de683d5d4 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -132,6 +132,31 @@ CVideo::~CVideo() LOG_DP << "called SDL_Quit()\n"; } +std::string CVideo::video_settings_report() +{ + if (singleton_ == nullptr) return "No video initialized.\n"; + if (singleton_->non_interactive()) + return "Initialized but non-interactive.\n"; + sdl::window* win = singleton_->get_window(); + if (!win) return "Interactive but no SDL window.\n"; + std::ostringstream o; + o << "Current pixel resolution: " + << singleton_->get_width() << "x" << singleton_->get_height() + << '\n' + << "Refresh rate: " << singleton_->current_refresh_rate() + << '\n'; + float hdpi, vdpi; + int returncode = SDL_GetDisplayDPI(win->get_display_index(), + nullptr, &hdpi, &vdpi); + if (returncode != 0) { + o << "SDL not supplying dots per inch.\n"; + } else { + o << "SDL reports: " << hdpi << "x" << vdpi + << " dots per inch.\n"; + } + return o.str(); +} + bool CVideo::non_interactive() const { return fake_interactive ? false : (window == nullptr); diff --git a/src/video.hpp b/src/video.hpp index 6415af05e517..90b16ba3745c 100644 --- a/src/video.hpp +++ b/src/video.hpp @@ -45,6 +45,8 @@ class CVideo return *singleton_; } + static std::string video_settings_report(); + /***** ***** ***** ***** Unit test-related functions ***** ***** ****** *****/ void make_fake();