Added GetDisplayName

This commit is contained in:
Vraiment 2017-07-24 23:59:12 -07:00
parent a6208de4f8
commit 5068355832
2 changed files with 30 additions and 0 deletions

View File

@ -25,7 +25,18 @@
#include <SDL_video.h>
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;

View File

@ -27,8 +27,27 @@
#include <SDL_version.h>
#include <SDL2pp/Rect.hh>
#include <string>
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