From 2f915530682e17e5cd783ff948290aa1450961f1 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Tue, 11 Feb 2014 07:39:06 +0400 Subject: [PATCH] Implement Renderer::ReadPixels --- SDL2pp/Renderer.cc | 5 +++++ SDL2pp/Renderer.hh | 2 ++ 2 files changed, 7 insertions(+) diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index 16f17ab..f164bf9 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -209,4 +209,9 @@ void Renderer::FillRects(const Rect* rects, int count) { throw Exception("SDL_RenderFillRects failed"); } +void Renderer::ReadPixels(const Rect& rect, Uint32 format, void* pixels, int pitch) { + if (SDL_RenderReadPixels(renderer_, rect.Get(), format, pixels, pitch) != 0) + throw Exception("SDL_RenderReadPixels failed"); +} + } diff --git a/SDL2pp/Renderer.hh b/SDL2pp/Renderer.hh index 820ea7d..cc3c521 100644 --- a/SDL2pp/Renderer.hh +++ b/SDL2pp/Renderer.hh @@ -85,6 +85,8 @@ public: void FillRect(const Point& p1, const Point& p2); void FillRect(const Rect& r); void FillRects(const Rect* rects, int count); + + void ReadPixels(const Rect& rect, Uint32 format, void* pixels, int pitch); }; }