From e5c74863f0f11b867645d99824a0c681d327491d Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Thu, 15 Jan 2015 17:12:46 +0300 Subject: [PATCH] Implement Renderer Output size getters --- SDL2pp/Renderer.cc | 21 +++++++++++++++++++++ SDL2pp/Renderer.hh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index d057ec2..1322420 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -285,4 +285,25 @@ void Renderer::GetDrawColor(Uint8& r, Uint8& g, Uint8& b, Uint8& a) const { throw Exception("SDL_GetRenderDrawColor failed"); } +Point Renderer::GetOutputSize() const { + int w, h; + if (SDL_GetRendererOutputSize(renderer_, &w, &h) != 0) + throw Exception("SDL_GetRendererOutputSize failed"); + return Point(w, h); +} + +int Renderer::GetOutputWidth() const { + int w; + if (SDL_GetRendererOutputSize(renderer_, &w, nullptr) != 0) + throw Exception("SDL_GetRendererOutputSize failed"); + return w; +} + +int Renderer::GetOutputHeight() const { + int h; + if (SDL_GetRendererOutputSize(renderer_, nullptr, &h) != 0) + throw Exception("SDL_GetRendererOutputSize failed"); + return h; +} + } diff --git a/SDL2pp/Renderer.hh b/SDL2pp/Renderer.hh index 0bb0f9e..807d569 100644 --- a/SDL2pp/Renderer.hh +++ b/SDL2pp/Renderer.hh @@ -659,6 +659,42 @@ public: /// //////////////////////////////////////////////////////////// void GetDrawColor(Uint8& r, Uint8& g, Uint8& b, Uint8& a) const; + + //////////////////////////////////////////////////////////// + /// \brief Get the output size of a rendering context + /// + /// \returns Point representing output size + /// + /// \throws SDL2pp::Exception + /// + /// \see http://wiki.libsdl.org/SDL_GetRendererOutputSize + /// + //////////////////////////////////////////////////////////// + Point GetOutputSize() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the output width of a rendering context + /// + /// \returns Output width + /// + /// \throws SDL2pp::Exception + /// + /// \see http://wiki.libsdl.org/SDL_RenderGetClipRect + /// + //////////////////////////////////////////////////////////// + int GetOutputWidth() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the output height of a rendering context + /// + /// \returns Output height + /// + /// \throws SDL2pp::Exception + /// + /// \see http://wiki.libsdl.org/SDL_RenderGetClipRect + /// + //////////////////////////////////////////////////////////// + int GetOutputHeight() const; }; }