mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 19:05:59 -04:00
Renderer::GetClipRect() now returns Optional
Also add test for clipping rect
This commit is contained in:
parent
31e3c4df74
commit
a52555b927
@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
|
|||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
## 0.13.0 - unreleased
|
## 0.13.0 - unreleased
|
||||||
|
### Changed
|
||||||
|
* ```Renderer::GetClipRect``` now returns ```Optional<Rect>``` instead of (possibly empty) ```Rect```
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
* Deprecated ```Renderer::GetInfo()``` variant which takes pointer (use variant which takes reference)
|
* Deprecated ```Renderer::GetInfo()``` variant which takes pointer (use variant which takes reference)
|
||||||
|
|
||||||
|
@ -352,10 +352,14 @@ bool Renderer::TargetSupported() const {
|
|||||||
return SDL_RenderTargetSupported(renderer_) == SDL_TRUE;
|
return SDL_RenderTargetSupported(renderer_) == SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect Renderer::GetClipRect() const {
|
Optional<Rect> Renderer::GetClipRect() const {
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
SDL_RenderGetClipRect(renderer_, &rect);
|
SDL_RenderGetClipRect(renderer_, &rect);
|
||||||
return rect;
|
|
||||||
|
if (SDL_RectEmpty(&rect))
|
||||||
|
return NullOpt;
|
||||||
|
else
|
||||||
|
return Rect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point Renderer::GetLogicalSize() const {
|
Point Renderer::GetLogicalSize() const {
|
||||||
|
@ -648,12 +648,13 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the clip rectangle for the current target
|
/// \brief Get the clip rectangle for the current target
|
||||||
///
|
///
|
||||||
/// \returns Rect representing current clipping area
|
/// \returns Rect representing current clipping area or
|
||||||
|
/// NullOpt if clipping is disabled
|
||||||
///
|
///
|
||||||
/// \see http://wiki.libsdl.org/SDL_RenderGetClipRect
|
/// \see http://wiki.libsdl.org/SDL_RenderGetClipRect
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Rect GetClipRect() const;
|
Optional<Rect> GetClipRect() const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get device independent resolution for rendering
|
/// \brief Get device independent resolution for rendering
|
||||||
|
@ -205,6 +205,30 @@ BEGIN_TEST(int, char*[])
|
|||||||
SDL_Delay(1000);
|
SDL_Delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Clip rect
|
||||||
|
renderer.SetDrawColor(0, 0, 0);
|
||||||
|
renderer.Clear();
|
||||||
|
|
||||||
|
renderer.SetClipRect(Rect(1, 1, 1, 1));
|
||||||
|
|
||||||
|
renderer.SetDrawColor(255, 255, 255);
|
||||||
|
renderer.FillRect(0, 0, 10, 10);
|
||||||
|
|
||||||
|
EXPECT_TRUE(renderer.GetClipRect() && renderer.GetClipRect() == Rect(1, 1, 1, 1));
|
||||||
|
|
||||||
|
renderer.SetClipRect(NullOpt);
|
||||||
|
|
||||||
|
EXPECT_TRUE(!renderer.GetClipRect());
|
||||||
|
|
||||||
|
pixels.Retrieve(renderer);
|
||||||
|
|
||||||
|
EXPECT_TRUE(pixels.Test3x3(1, 1, 0x020, 255, 255, 255));
|
||||||
|
|
||||||
|
renderer.Present();
|
||||||
|
SDL_Delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Blend
|
// Blend
|
||||||
renderer.SetDrawColor(0, 0, 0);
|
renderer.SetDrawColor(0, 0, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user