class Renderer supports getting rendering target now.

This commit is contained in:
Kirigaya Kazuto 2017-06-07 19:52:37 +08:00
parent f0cbeb9702
commit 4608508476
2 changed files with 18 additions and 1 deletions

View File

@ -779,6 +779,13 @@ namespace MiniEngine
updateInfo();
}
//private
void Texture::_set_no_delete(SDL_Texture* p)
{
_text.reset(p,[](SDL_Texture*){});
updateInfo();
}
//private
void Texture::_clear()
{
@ -940,6 +947,13 @@ namespace MiniEngine
return SDL_SetRenderTarget(_get(), nullptr);
}
Texture Renderer::getTarget()
{
Texture t;
t._set_no_delete(SDL_GetRenderTarget(_get()));
return t;
}
int Renderer::fillRect(const Rect& rect)
{
auto inr = rect.toSDLRect();

View File

@ -15,7 +15,7 @@ namespace MiniEngine
public:
int x, y, w, h;
Rect(int X, int Y, int W, int H);
Rect(const SDL_Rect&);
explicit Rect(const SDL_Rect&);
Rect();
SDL_Rect toSDLRect() const;
bool isEmpty();
@ -199,6 +199,8 @@ namespace MiniEngine
private:
std::shared_ptr<SDL_Texture> _text;
void _set(SDL_Texture*);
/// Just used for "SDL_GetRenderTarget"
void _set_no_delete(SDL_Texture*);
void _clear();
SDL_Texture* _get() const;
Rect rect;
@ -220,6 +222,7 @@ namespace MiniEngine
int setTarget(Texture& t);
int setTarget();
Texture getTarget();
int fillRect(const Rect& rect);
int drawRect(const Rect& rect);