mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-04 03:15:59 -04:00
Added GetDisplayDPI
This commit is contained in:
parent
9b82524c1a
commit
a6208de4f8
@ -26,6 +26,17 @@
|
|||||||
#include <SDL_video.h>
|
#include <SDL_video.h>
|
||||||
|
|
||||||
namespace SDL2pp {
|
namespace SDL2pp {
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 4)
|
||||||
|
DPI GetDisplayDPI(int displayIndex) {
|
||||||
|
float diagonal = 0, horizontal = 0, vertical = 0;
|
||||||
|
if (SDL_GetDisplayDPI(displayIndex, &diagonal, &horizontal, &vertical) < 0) {
|
||||||
|
throw Exception("SDL_GetDisplayDPI");
|
||||||
|
}
|
||||||
|
|
||||||
|
return DPI{diagonal, horizontal, vertical};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||||
Rect GetDisplayUsableBounds(int displayIndex) {
|
Rect GetDisplayUsableBounds(int displayIndex) {
|
||||||
Rect result;
|
Rect result;
|
||||||
|
@ -29,6 +29,54 @@
|
|||||||
#include <SDL2pp/Rect.hh>
|
#include <SDL2pp/Rect.hh>
|
||||||
|
|
||||||
namespace SDL2pp {
|
namespace SDL2pp {
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 4)
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Read-only struct to store DPI information of a display
|
||||||
|
///
|
||||||
|
/// \ingroup graphics
|
||||||
|
///
|
||||||
|
/// \headerfile SDL2pp/Display.hh
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
struct SDL2PP_EXPORT DPI {
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief The diagonal DPI of the display
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
const float Diagonal;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief The horizontal DPI of the display
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
const float Horizontal;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief The vertical DPI of the display
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
const float Vertical;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Gets the dots/pixels per inch of a given display
|
||||||
|
///
|
||||||
|
/// \ingroup graphics
|
||||||
|
///
|
||||||
|
/// \headerfile SDL2pp/Display.hh
|
||||||
|
///
|
||||||
|
/// \param[in] displayIndex The display to retrieve the DPI
|
||||||
|
///
|
||||||
|
/// \returns A DPI object with the dpi values for the given display
|
||||||
|
///
|
||||||
|
/// \throws SDL2pp::Exception
|
||||||
|
///
|
||||||
|
/// \see https://wiki.libsdl.org/SDL_GetDisplayDPI
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
SDL2PP_EXPORT DPI GetDisplayDPI(int displayIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Gets the usable desktop area of a given display
|
/// \brief Gets the usable desktop area of a given display
|
||||||
|
Loading…
x
Reference in New Issue
Block a user