From 50683558324c351edf4d08a909db35aa6c16e67b Mon Sep 17 00:00:00 2001 From: Vraiment Date: Mon, 24 Jul 2017 23:59:12 -0700 Subject: [PATCH] Added GetDisplayName --- SDL2pp/Display.cc | 11 +++++++++++ SDL2pp/Display.hh | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/SDL2pp/Display.cc b/SDL2pp/Display.cc index cecccf2..7905fd3 100644 --- a/SDL2pp/Display.cc +++ b/SDL2pp/Display.cc @@ -25,7 +25,18 @@ #include +using std::string; + namespace SDL2pp { +string GetDisplayName(int displayIndex) { + const char* name = SDL_GetDisplayName(displayIndex); + if (name == nullptr) { + throw Exception("SDL_GetDisplayName"); + } + + return string{name}; +} + #if SDL_VERSION_ATLEAST(2, 0, 4) DPI GetDisplayDPI(int displayIndex) { float diagonal = 0, horizontal = 0, vertical = 0; diff --git a/SDL2pp/Display.hh b/SDL2pp/Display.hh index de584b7..85647ac 100644 --- a/SDL2pp/Display.hh +++ b/SDL2pp/Display.hh @@ -27,8 +27,27 @@ #include #include +#include namespace SDL2pp { + //////////////////////////////////////////////////////////// + /// \brief Gets the name of a given display + /// + /// \ingroup graphics + /// + /// \headerfile SDL2pp/Display.hh + /// + /// \param[in] displayIndex The display to retrieve its name + /// + /// \returns A string with the name of the given display + /// + /// \throws SDL2pp::Exception + /// + /// \see https://wiki.libsdl.org/SDL_GetDisplayName + /// + //////////////////////////////////////////////////////////// + SDL2PP_EXPORT std::string GetDisplayName(int displayIndex); + #if SDL_VERSION_ATLEAST(2, 0, 4) //////////////////////////////////////////////////////////// /// \brief Read-only struct to store DPI information of a display