diff --git a/MiniEngine.cpp b/MiniEngine.cpp index e731c3f..6949751 100644 --- a/MiniEngine.cpp +++ b/MiniEngine.cpp @@ -25,6 +25,14 @@ namespace MiniEngine h = H; } + Rect::Rect(SDL_Rect rect) + { + x=rect.x; + y=rect.y; + w=rect.w; + h=rect.h; + } + Rect::Rect() { x = y = w = h = 0; @@ -272,6 +280,11 @@ namespace MiniEngine return SDL_RenderDrawPoint(rnd.lock().get(),p.x,p.y); } + int Renderer::drawLine(Point a,Point b) + { + return SDL_RenderDrawLine(rnd.lock().get(),a.x,a.y,b.x,b.y); + } + int Renderer::clear() { return SDL_RenderClear(rnd.lock().get()); @@ -410,6 +423,47 @@ namespace MiniEngine return t; } + int Renderer::setViewport(Rect viewPort) + { + SDL_Rect rect=viewPort.toSDLRect(); + return SDL_RenderSetViewport(rnd.lock().get(),&rect); + } + + int Renderer::setViewport() + { + return SDL_RenderSetViewport(rnd.lock().get(),NULL); + } + + Rect Renderer::getViewport() + { + SDL_Rect rect; + SDL_RenderGetViewport(rnd.lock().get(),&rect); + return Rect(rect); + } + + int Renderer::setClipRect(Rect cliparea) + { + SDL_Rect rect=cliparea.toSDLRect(); + return SDL_RenderSetClipRect(rnd.lock().get(),&rect); + } + + Rect Renderer::getClipRect() + { + SDL_Rect rect; + SDL_RenderGetClipRect(rnd.lock().get(),&rect); + return Rect(rect); + } + + bool Renderer::isClipEnabled() + { + return SDL_RenderIsClipEnabled(rnd.lock().get())==SDL_TRUE; + } + + void Renderer::disableClip() + { + SDL_RenderSetClipRect(rnd.lock().get(),NULL); + } + bool Renderer::isReady() { return !rnd.expired(); diff --git a/MiniEngine.h b/MiniEngine.h index cd934ba..f2b4b8c 100644 --- a/MiniEngine.h +++ b/MiniEngine.h @@ -20,6 +20,7 @@ namespace MiniEngine public: int x, y, w, h; Rect(int X, int Y, int W, int H); + Rect(SDL_Rect); Rect(); SDL_Rect toSDLRect(); }; @@ -147,6 +148,7 @@ namespace MiniEngine int fillRect(Rect rect); int drawRect(Rect rect); int drawPoint(Point p); + int drawLine(Point a,Point b); int clear(); void update(); @@ -164,6 +166,15 @@ namespace MiniEngine Texture loadTexture(std::string FileName) throw(ErrorViewer); Texture createTexture(int Width, int Height) throw(ErrorViewer); + int setViewport(Rect viewport); + int setViewport(); + Rect getViewport(); + + int setClipRect(Rect cliprect); + Rect getClipRect(); + bool isClipEnabled(); + void disableClip(); + bool isReady(); private: std::weak_ptr rnd;