Add More Functions to class Surface

This commit is contained in:
Kirigaya Kazuto 2017-05-25 18:34:59 +08:00
parent 709e67a40f
commit 7822544701
2 changed files with 24 additions and 2 deletions

View File

@ -651,6 +651,24 @@ namespace MiniEngine
return SDL_BlitScaled(s._get(),NULL,_get(),NULL);
}
int Surface::setClipRect(const Rect& clipRect)
{
auto m=clipRect.toSDLRect();
return (SDL_SetClipRect(_get(),&m) == SDL_TRUE) ? 0 : -1;
}
Rect Surface::getClipRect() const
{
SDL_Rect rect;
SDL_GetClipRect(_get(),&rect);
return Rect(rect);
}
void Surface::disableClipping()
{
SDL_SetClipRect(_get(),NULL);
}
int Surface::setAlphaMode(int alpha)
{
return SDL_SetSurfaceAlphaMod(_get(),alpha);
@ -716,7 +734,7 @@ namespace MiniEngine
}
/// Experimental
SDL_Surface* Surface::getRawPointer()
SDL_Surface* Surface::getRawPointer() const
{
return _get();
}

View File

@ -128,6 +128,10 @@ namespace MiniEngine
int blitScaledFill(Surface t, Rect src);
int blitScaledFullFill(Surface t);
int setClipRect(const Rect& clipRect);
Rect getClipRect() const;
void disableClipping();
int setAlphaMode(int alpha);
int getAlphaMode();
@ -144,7 +148,7 @@ namespace MiniEngine
void release();
/// Experimental : Get SDL_Surface Pointer and then do anything you want!
SDL_Surface* getRawPointer();
SDL_Surface* getRawPointer() const;
private:
std::shared_ptr<SDL_Surface> _surf;
void _set(SDL_Surface*);