Implement Renderer Output size getters

This commit is contained in:
Dmitry Marakasov 2015-01-15 17:12:46 +03:00
parent b6781c3d93
commit e5c74863f0
2 changed files with 57 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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;
};
}