From a2a3e493c59bfeae71b2cd08c894be675c521543 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Wed, 12 Apr 2017 09:50:12 +0800 Subject: [PATCH] Add Rendering-like functions in class Surface --- MiniEngine.cpp | 29 +++++++++++++++++++++++++++++ MiniEngine.h | 6 ++++++ 2 files changed, 35 insertions(+) diff --git a/MiniEngine.cpp b/MiniEngine.cpp index f0fd209..3177b97 100644 --- a/MiniEngine.cpp +++ b/MiniEngine.cpp @@ -266,6 +266,35 @@ namespace MiniEngine 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 { _text.reset(p,SDL_DestroyTexture); diff --git a/MiniEngine.h b/MiniEngine.h index 6a9ee1b..32830fd 100644 --- a/MiniEngine.h +++ b/MiniEngine.h @@ -100,6 +100,12 @@ namespace MiniEngine int geth(); BlendMode getBlendMode(); 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: Surface() = default; private: