From 7ae6b3442aa70b7282c5ee65703d7dfeeca25543 Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Tue, 21 Mar 2017 17:03:03 +0800 Subject: [PATCH] Add SuperCopy. Use: SDL_RenderCopyEx --- MiniEngine.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ MiniEngine.h | 12 +++++++----- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/MiniEngine.cpp b/MiniEngine.cpp index 884dfa3..18fd869 100644 --- a/MiniEngine.cpp +++ b/MiniEngine.cpp @@ -306,6 +306,46 @@ namespace MiniEngine return SDL_RenderCopy(rnd.get(), t.text.get(), NULL, NULL); } + int Renderer::supercopy(Texture t,bool srcfull,Rect src,bool dstfull,Rect dst,double angle,bool haspoint,Point center,FlipMode mode) + { + SDL_Rect R1,R2; + SDL_Point P; + SDL_Rect* pR1=nullptr; + SDL_Rect* pR2=nullptr; + SDL_Point* pPoint=nullptr; + SDL_RendererFlip flip; + if(srcfull) + { + R1=src.toSDLRect(); + pR1=&R1; + } + if(dstfull) + { + R2=dst.toSDLRect(); + pR2=&R2; + } + if(haspoint) + { + P=center.toSDLPoint(); + pPoint=&P; + } + + switch(mode) + { + case FlipMode::None: + flip=SDL_FLIP_NONE; + break; + case FlipMode::Horizontal: + flip=SDL_FLIP_HORIZONTAL; + break; + case FlipMode::Vertical: + flip=SDL_FLIP_VERTICAL; + break; + } + + return SDL_RenderCopyEx(rnd.get(),t.text.get(),pR1,pR2,angle,pPoint,flip); + } + Surface Renderer::loadSurface(std::string FileName) throw(ErrorViewer) { Surface surf; diff --git a/MiniEngine.h b/MiniEngine.h index 1f69c7b..bb02b4f 100644 --- a/MiniEngine.h +++ b/MiniEngine.h @@ -129,6 +129,8 @@ namespace MiniEngine TargetTexture = SDL_RENDERER_TARGETTEXTURE }; + enum class FlipMode { None, Horizontal, Vertical }; + class Renderer { public: @@ -143,13 +145,18 @@ namespace MiniEngine int fillRect(Rect rect); int drawRect(Rect rect); int drawPoint(Point p); + int clear(); void update(); + int copy(Texture t, Rect src, Rect dst); int copyTo(Texture t, Rect dst); int copyTo(Texture t, Point lupoint); int copyFill(Texture t, Rect src); int copyFullFill(Texture t); + + int supercopy(Texture t,bool srcfull,Rect src,bool dstfull,Rect dst,double angle,bool haspoint,Point center,FlipMode mode); + Surface loadSurface(std::string FileName) throw(ErrorViewer); Texture render(Surface surf) throw (ErrorViewer); Texture loadTexture(std::string FileName) throw(ErrorViewer); @@ -261,7 +268,6 @@ namespace MiniEngine }; }; - class AudioPlayer { public: @@ -279,8 +285,6 @@ namespace MiniEngine static int _sysAudioCounter; }; - - /// Forward Declaration class Music { @@ -370,8 +374,6 @@ namespace MiniEngine Event waitfor(int ms); }; - - namespace EventHandle { using DispatcherType = std::function;