Add Rendering-like functions in class Surface

This commit is contained in:
Kirigaya Kazuto 2017-04-12 09:50:12 +08:00
parent 40c5f0dc91
commit a2a3e493c5
2 changed files with 35 additions and 0 deletions

View File

@ -266,6 +266,35 @@ namespace MiniEngine
return IMG_SavePNG(_get(),filename.c_str()); return IMG_SavePNG(_get(),filename.c_str());
} }
int Surface::blit(Surface s,Rect src,Rect dst)
{
SDL_Rect rsrc=src.toSDLRect();
SDL_Rect rdst=dst.toSDLRect();
return SDL_BlitSurface(s._get(),&rsrc,_get(),&rdst);
}
int Surface::blitTo(Surface s,Rect dst)
{
SDL_Rect rdst=dst.toSDLRect();
return SDL_BlitSurface(s._get(),NULL,_get(),&rdst);
}
int Surface::blitTo(Surface s,Point lupoint)
{
return blitTo(s,Rect(lupoint.x,lupoint.y,s.getw(),s.geth()));
}
int Surface::blitFill(Surface s,Rect src)
{
SDL_Rect rsrc=src.toSDLRect();
return SDL_BlitSurface(s._get(),&rsrc,_get(),NULL);
}
int Surface::blitFullFill(Surface s)
{
return SDL_BlitSurface(s._get(),NULL,_get(),NULL);
}
void Texture::_set(SDL_Texture* p)//private void Texture::_set(SDL_Texture* p)//private
{ {
_text.reset(p,SDL_DestroyTexture); _text.reset(p,SDL_DestroyTexture);

View File

@ -100,6 +100,12 @@ namespace MiniEngine
int geth(); int geth();
BlendMode getBlendMode(); BlendMode getBlendMode();
int setBlendMode(BlendMode mode); int setBlendMode(BlendMode mode);
int blit(Surface s,Rect src,Rect dst);
int blitTo(Surface t, Rect dst);
int blitTo(Surface t, Point lupoint);
int blitFill(Surface t, Rect src);
int blitFullFill(Surface t);
protected: protected:
Surface() = default; Surface() = default;
private: private: