mirror of
https://github.com/Kiritow/MiniEngine.git
synced 2024-03-22 13:11:22 +08:00
class Renderer supports getting rendering target now.
This commit is contained in:
parent
f0cbeb9702
commit
4608508476
|
@ -779,6 +779,13 @@ namespace MiniEngine
|
||||||
updateInfo();
|
updateInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//private
|
||||||
|
void Texture::_set_no_delete(SDL_Texture* p)
|
||||||
|
{
|
||||||
|
_text.reset(p,[](SDL_Texture*){});
|
||||||
|
updateInfo();
|
||||||
|
}
|
||||||
|
|
||||||
//private
|
//private
|
||||||
void Texture::_clear()
|
void Texture::_clear()
|
||||||
{
|
{
|
||||||
|
@ -940,6 +947,13 @@ namespace MiniEngine
|
||||||
return SDL_SetRenderTarget(_get(), nullptr);
|
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)
|
int Renderer::fillRect(const Rect& rect)
|
||||||
{
|
{
|
||||||
auto inr = rect.toSDLRect();
|
auto inr = rect.toSDLRect();
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace MiniEngine
|
||||||
public:
|
public:
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
Rect(int X, int Y, int W, int H);
|
Rect(int X, int Y, int W, int H);
|
||||||
Rect(const SDL_Rect&);
|
explicit Rect(const SDL_Rect&);
|
||||||
Rect();
|
Rect();
|
||||||
SDL_Rect toSDLRect() const;
|
SDL_Rect toSDLRect() const;
|
||||||
bool isEmpty();
|
bool isEmpty();
|
||||||
|
@ -199,6 +199,8 @@ namespace MiniEngine
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<SDL_Texture> _text;
|
std::shared_ptr<SDL_Texture> _text;
|
||||||
void _set(SDL_Texture*);
|
void _set(SDL_Texture*);
|
||||||
|
/// Just used for "SDL_GetRenderTarget"
|
||||||
|
void _set_no_delete(SDL_Texture*);
|
||||||
void _clear();
|
void _clear();
|
||||||
SDL_Texture* _get() const;
|
SDL_Texture* _get() const;
|
||||||
Rect rect;
|
Rect rect;
|
||||||
|
@ -220,6 +222,7 @@ namespace MiniEngine
|
||||||
|
|
||||||
int setTarget(Texture& t);
|
int setTarget(Texture& t);
|
||||||
int setTarget();
|
int setTarget();
|
||||||
|
Texture getTarget();
|
||||||
|
|
||||||
int fillRect(const Rect& rect);
|
int fillRect(const Rect& rect);
|
||||||
int drawRect(const Rect& rect);
|
int drawRect(const Rect& rect);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user