Implement some Renderer getters

This commit is contained in:
Dmitry Marakasov 2015-01-15 16:51:17 +03:00
parent 04244eadf0
commit 8aaf1815e0
2 changed files with 139 additions and 0 deletions

View File

@ -227,4 +227,50 @@ bool Renderer::TargetSupported() {
return SDL_RenderTargetSupported(renderer_) == SDL_TRUE;
}
Rect Renderer::GetClipRect() const {
SDL_Rect rect;
SDL_RenderGetClipRect(renderer_, &rect);
return rect;
}
Point Renderer::GetLogicalSize() const {
int w, h;
SDL_RenderGetLogicalSize(renderer_, &w, &h);
return Point(w, h);
}
int Renderer::GetLogicalWidth() const {
int w;
SDL_RenderGetLogicalSize(renderer_, &w, nullptr);
return w;
}
int Renderer::GetLogicalHeight() const {
int h;
SDL_RenderGetLogicalSize(renderer_, nullptr, &h);
return h;
}
void Renderer::GetScale(float& scalex, float& scaley) const {
SDL_RenderGetScale(renderer_, &scalex, &scaley);
}
float Renderer::GetXScale() const {
float scalex;
SDL_RenderGetScale(renderer_, &scalex, nullptr);
return scalex;
}
float Renderer::GetYScale() const {
float scaley;
SDL_RenderGetScale(renderer_, nullptr, &scaley);
return scaley;
}
Rect Renderer::GetViewport() const {
SDL_Rect rect;
SDL_RenderGetViewport(renderer_, &rect);
return rect;
}
}

View File

@ -539,6 +539,99 @@ public:
///
////////////////////////////////////////////////////////////
bool TargetSupported();
////////////////////////////////////////////////////////////
/// \brief Get the clip rectangle for the current target
///
/// \returns Rect representing current clipping area
///
/// \see http://wiki.libsdl.org/SDL_RenderGetClipRect
///
////////////////////////////////////////////////////////////
Rect GetClipRect() const;
////////////////////////////////////////////////////////////
/// \brief Get device independent resolution for rendering
///
/// \returns Point representing logical resolution
///
/// \see http://wiki.libsdl.org/SDL_RenderGetClipRect
///
/// \note If this function is called on an Renderer who never had
/// its logical size set by SetLogicalSize(), this function
/// returns {0, 0}
///
////////////////////////////////////////////////////////////
Point GetLogicalSize() const;
////////////////////////////////////////////////////////////
/// \brief Get device independent width resolution for rendering
///
/// \returns Logical resolution width
///
/// \see http://wiki.libsdl.org/SDL_RenderGetClipRect
///
/// \note If this function is called on an Renderer who never had
/// its logical size set by SetLogicalSize(), this function
/// returns 0
///
////////////////////////////////////////////////////////////
int GetLogicalWidth() const;
////////////////////////////////////////////////////////////
/// \brief Get device independent width resolution for rendering
///
/// \returns Logical resolution height
///
/// \see http://wiki.libsdl.org/SDL_RenderGetClipRect
///
/// \note If this function is called on an Renderer who never had
/// its logical size set by SetLogicalSize(), this function
/// returns 0
///
////////////////////////////////////////////////////////////
int GetLogicalHeight() const;
////////////////////////////////////////////////////////////
/// \brief Get the drawing scale for the current target
///
/// \param[out] Variable to be filled with the horizontal scaling factor
/// \param[out] Variable to be filled with the vertical scaling factor
///
/// \see http://wiki.libsdl.org/SDL_RenderGetScale
///
////////////////////////////////////////////////////////////
void GetScale(float& scalex, float& scaley) const;
////////////////////////////////////////////////////////////
/// \brief Get the drawing scale for the current target
///
/// \returns Horizontal scaling factor
///
/// \see http://wiki.libsdl.org/SDL_RenderGetScale
///
////////////////////////////////////////////////////////////
float GetXScale() const;
////////////////////////////////////////////////////////////
/// \brief Get the drawing scale for the current target
///
/// \returns Vertical scaling factor
///
/// \see http://wiki.libsdl.org/SDL_RenderGetScale
///
////////////////////////////////////////////////////////////
float GetYScale() const;
////////////////////////////////////////////////////////////
/// \brief Get the drawing area for the current target
///
/// \returns Rect representing current drawing area
///
/// \see http://wiki.libsdl.org/SDL_RenderGetViewport
///
////////////////////////////////////////////////////////////
Rect GetViewport() const;
};
}