Skip to content

Commit

Permalink
Add More Functions to class Surface
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiritow committed May 25, 2017
1 parent 709e67a commit 7822544
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
20 changes: 19 additions & 1 deletion MiniEngine.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -716,7 +734,7 @@ namespace MiniEngine
}

/// Experimental
SDL_Surface* Surface::getRawPointer()
SDL_Surface* Surface::getRawPointer() const
{
return _get();
}
Expand Down
6 changes: 5 additions & 1 deletion MiniEngine.h
Expand Up @@ -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();

Expand All @@ -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*);
Expand Down

0 comments on commit 7822544

Please sign in to comment.