From 198b0bbbc8b091d540cd3058223f95cdaad308a9 Mon Sep 17 00:00:00 2001 From: Carsten Elton Sorensen Date: Wed, 14 Oct 2015 22:09:34 +0200 Subject: [PATCH 1/3] Added GetDrawableSize, GetDrawableWidth and GetDrawableHeight for HiDPI support --- SDL2pp/Window.cc | 18 ++++++++++++++++++ SDL2pp/Window.hh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/SDL2pp/Window.cc b/SDL2pp/Window.cc index d02807b..458e8a9 100644 --- a/SDL2pp/Window.cc +++ b/SDL2pp/Window.cc @@ -76,6 +76,24 @@ int Window::GetHeight() const { return h; } +Point Window::GetDrawableSize() const { + int w, h; + SDL_GL_GetDrawableSize(window_, &w, &h); + return Point(w, h); +} + +int Window::GetDrawableWidth() const { + int w, h; + SDL_GL_GetDrawableSize(window_, &w, &h); + return w; +} + +int Window::GetDrawableHeight() const { + int w, h; + SDL_GL_GetDrawableSize(window_, &w, &h); + return h; +} + Window& Window::SetTitle(const std::string& title) { SDL_SetWindowTitle(window_, title.c_str()); return *this; diff --git a/SDL2pp/Window.hh b/SDL2pp/Window.hh index 0a8ed6f..52ceb72 100644 --- a/SDL2pp/Window.hh +++ b/SDL2pp/Window.hh @@ -173,6 +173,37 @@ public: //////////////////////////////////////////////////////////// int GetHeight() const; + //////////////////////////////////////////////////////////// + /// \brief Get drawable dimensions of the window + /// + /// \returns SDL2pp::Point representing dimensions (width and + /// height) of the window in pixels + /// + /// \see http://wiki.libsdl.org/SDL_GL_GetDrawableSize + /// + //////////////////////////////////////////////////////////// + Point GetDrawableSize() const; + + //////////////////////////////////////////////////////////// + /// \brief Get drawable width of the window + /// + /// \returns Width of the window in pixels + /// + /// \see http://wiki.libsdl.org/SDL_GL_GetDrawableSize + /// + //////////////////////////////////////////////////////////// + int GetDrawableWidth() const; + + //////////////////////////////////////////////////////////// + /// \brief Get drawable height of the window + /// + /// \returns Height of the window in pixels + /// + /// \see http://wiki.libsdl.org/SDL_GL_GetDrawableSize + /// + //////////////////////////////////////////////////////////// + int GetDrawableHeight() const; + //////////////////////////////////////////////////////////// /// \brief Set window title /// From 549de6c2627a265374046a3d4c6a2e839e356c74 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Thu, 15 Oct 2015 12:35:30 +0300 Subject: [PATCH 2/3] Fix return value descripions --- SDL2pp/Window.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SDL2pp/Window.hh b/SDL2pp/Window.hh index 52ceb72..7ef1bb3 100644 --- a/SDL2pp/Window.hh +++ b/SDL2pp/Window.hh @@ -177,7 +177,7 @@ public: /// \brief Get drawable dimensions of the window /// /// \returns SDL2pp::Point representing dimensions (width and - /// height) of the window in pixels + /// height) of the window drawable area in pixels /// /// \see http://wiki.libsdl.org/SDL_GL_GetDrawableSize /// @@ -187,7 +187,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Get drawable width of the window /// - /// \returns Width of the window in pixels + /// \returns Width of the window drawable area in pixels /// /// \see http://wiki.libsdl.org/SDL_GL_GetDrawableSize /// @@ -197,7 +197,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Get drawable height of the window /// - /// \returns Height of the window in pixels + /// \returns Height of the window drawable area in pixels /// /// \see http://wiki.libsdl.org/SDL_GL_GetDrawableSize /// From e4fbc901b92a98ea591a7735f8162cff83390105 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Thu, 15 Oct 2015 12:37:06 +0300 Subject: [PATCH 3/3] Add new contributor --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ae03e49..b100b87 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,7 @@ Projects using libSDL2pp: * [Aargonian](https://github.com/Aargonian) * [Carl Schwope](https://github.com/Lowest0ne) +* [Carsten Elton Sorensen](https://github.com/csoren) * [kumar8600](https://github.com/kumar8600) * [Vladimir Gamalian](https://github.com/vladimirgamalian)