libSDL2pp
C++ bindings/wrapper for SDL2
Loading...
Searching...
No Matches
Renderer.hh
1/*
2 libSDL2pp - C++ bindings/wrapper for SDL2
3 Copyright (C) 2013-2016 Dmitry Marakasov <amdmi3@amdmi3.ru>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22#ifndef SDL2PP_RENDERER_HH
23#define SDL2PP_RENDERER_HH
24
25#include <SDL_stdinc.h>
26#include <SDL_blendmode.h>
27
28#include <SDL2pp/Config.hh>
29#include <SDL2pp/Optional.hh>
30#include <SDL2pp/Point.hh>
31#include <SDL2pp/Rect.hh>
32#include <SDL2pp/Export.hh>
33#include <SDL2pp/Color.hh>
34
35struct SDL_RendererInfo;
36struct SDL_Renderer;
37
38namespace SDL2pp {
39
40class Window;
41class Texture;
42class Point;
43
52class SDL2PP_EXPORT Renderer {
53private:
54 SDL_Renderer* renderer_;
55
56public:
63 explicit Renderer(SDL_Renderer* renderer);
64
79 Renderer(Window& window, int index, Uint32 flags);
80
87 virtual ~Renderer();
88
95 Renderer(Renderer&& other) noexcept;
96
105 Renderer& operator=(Renderer&& other) noexcept;
106
113 Renderer(const Renderer& other) = delete;
114
121 Renderer& operator=(const Renderer& other) = delete;
122
129 SDL_Renderer* Get() const;
130
151 Renderer& Present();
152
163 Renderer& Clear();
164
176 void GetInfo(SDL_RendererInfo& info);
177
194 Renderer& Copy(Texture& texture, const Optional<Rect>& srcrect = NullOpt, const Optional<Rect>& dstrect = NullOpt);
195
211 Renderer& Copy(Texture& texture, const Optional<Rect>& srcrect, const Point& dstpoint);
212
237 Renderer& Copy(Texture& texture, const Optional<Rect>& srcrect, const Optional<Rect>& dstrect, double angle, const Optional<Point>& center = NullOpt, int flip = 0);
238
263 Renderer& Copy(Texture& texture, const Optional<Rect>& srcrect, const SDL2pp::Point& dstpoint, double angle, const Optional<Point>& center = NullOpt, int flip = 0);
264
286 Renderer& FillCopy(Texture& texture, const Optional<Rect>& srcrect = NullOpt, const Optional<Rect>& dstrect = NullOpt, const Point& offset = Point(0, 0), int flip = 0);
287
303 Renderer& SetDrawColor(Uint8 r = 0, Uint8 g = 0, Uint8 b = 0, Uint8 a = 255);
304
317 Renderer& SetDrawColor(const Color& color);
318
329 Renderer& SetTarget();
330
344 Renderer& SetTarget(Texture& texture);
345
359 Renderer& SetDrawBlendMode(SDL_BlendMode blendMode = SDL_BLENDMODE_NONE);
360
374 Renderer& DrawPoint(int x, int y);
375
388 Renderer& DrawPoint(const Point& p);
389
403 Renderer& DrawPoints(const Point* points, int count);
404
420 Renderer& DrawLine(int x1, int y1, int x2, int y2);
421
435 Renderer& DrawLine(const Point& p1, const Point& p2);
436
450 Renderer& DrawLines(const Point* points, int count);
451
467 Renderer& DrawRect(int x1, int y1, int x2, int y2);
468
482 Renderer& DrawRect(const Point& p1, const Point& p2);
483
496 Renderer& DrawRect(const Rect& r);
497
511 Renderer& DrawRects(const Rect* rects, int count);
512
528 Renderer& FillRect(int x1, int y1, int x2, int y2);
529
543 Renderer& FillRect(const Point& p1, const Point& p2);
544
557 Renderer& FillRect(const Rect& r);
558
572 Renderer& FillRects(const Rect* rects, int count);
573
591 void ReadPixels(const Optional<Rect>& rect, Uint32 format, void* pixels, int pitch);
592
606 Renderer& SetClipRect(const Optional<Rect>& rect = NullOpt);
607
621 Renderer& SetLogicalSize(int w, int h);
622
636 Renderer& SetScale(float scaleX, float scaleY);
637
651 Renderer& SetViewport(const Optional<Rect>& rect = NullOpt);
652
662 bool TargetSupported() const;
663
673 Optional<Rect> GetClipRect() const;
674
687 Point GetLogicalSize() const;
688
701 int GetLogicalWidth() const;
702
715 int GetLogicalHeight() const;
716
726 void GetScale(float& scalex, float& scaley) const;
727
736 float GetXScale() const;
737
746 float GetYScale() const;
747
756 Rect GetViewport() const;
757
768 SDL_BlendMode GetDrawBlendMode() const;
769
780 Color GetDrawColor() const;
781
795 void GetDrawColor(Uint8& r, Uint8& g, Uint8& b, Uint8& a) const;
796
807 Point GetOutputSize() const;
808
819 int GetOutputWidth() const;
820
831 int GetOutputHeight() const;
832};
833
834}
835
836#endif
RGB color with Alpha.
Definition: Color.hh:48
2D point
Definition: Point.hh:51
2D rectangle
Definition: Rect.hh:50
2D rendering context
Definition: Renderer.hh:52
Renderer & operator=(const Renderer &other)=delete
Deleted assignment operator.
Renderer(const Renderer &other)=delete
Deleted copy constructor.
Image stored in the graphics card memory that can be used for fast drawing.
Definition: Texture.hh:53
GUI window object.
Definition: Window.hh:67