Add SuperCopy.

Use: SDL_RenderCopyEx
This commit is contained in:
Kirigaya Kazuto 2017-03-21 17:03:03 +08:00
parent 2c1f055a49
commit 7ae6b3442a
2 changed files with 47 additions and 5 deletions

View File

@ -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;

View File

@ -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<void(SDL_Event e, int& running, int& update)>;