From 782254470121cb6aeefc19467c77bfe92438f9f7 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Thu, 25 May 2017 18:34:59 +0800 Subject: [PATCH] Add More Functions to class Surface --- MiniEngine.cpp | 20 +++++++++++++++++++- MiniEngine.h | 6 +++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/MiniEngine.cpp b/MiniEngine.cpp index 4bcc1a1..334c184 100644 --- a/MiniEngine.cpp +++ b/MiniEngine.cpp @@ -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(); } diff --git a/MiniEngine.h b/MiniEngine.h index 822015e..54200c9 100644 --- a/MiniEngine.h +++ b/MiniEngine.h @@ -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 _surf; void _set(SDL_Surface*);