rolmodl
C++ API for the Simple Directmedia Library 2 (SDL2)
Ren.cpp
1 #include "hpp/Ren.hpp"
2 
3 #include <algorithm>
4 #include <utility>
5 #include <cassert>
6 
7 #include "hpp/Base.hpp"
8 #include "hpp/Win.hpp"
9 #include "hpp/Tex.hpp"
10 
11 namespace rolmodl {
12  using detail::throwOnErr;
13 
14  namespace ren::driver {
15  unsigned int count() {
16  int res = SDL_GetNumRenderDrivers();
17  throwOnErr(res);
18  return static_cast<unsigned int>(res);
19  }
20 
21  Info info(const unsigned int i) {
22  if (i >= count())
23  throw std::out_of_range("rolmodl::ren::driver::info");
24  SDL_RendererInfo tmp{};
25  throwOnErr(SDL_GetRenderDriverInfo(static_cast<int>(i), &tmp));
26 
27  Info res{};
28  res.name = tmp.name;
29  res.flags = Flags::unsafeFromRaw(tmp.flags);
30 
31  res.pixelFmts = std::vector<pixelfmt::Id>(tmp.num_texture_formats);
32  for (unsigned int j = 0; j < tmp.num_texture_formats; ++j)
33  res.pixelFmts[j] = pixelfmt::id::unsafe::fromSDLEnum(tmp.texture_formats[j]);
34 
35  res.maxTexSize = geom::Size{tmp.max_texture_width, tmp.max_texture_height};
36 
37  return res;
38  }
39  }
40 
41  Ren::Ren() noexcept :
42  h_(nullptr)
43  {}
44  Ren::Ren(Win& win, int i, ren::Flags flags) :
45  h_(SDL_CreateRenderer(win.unsafeRaw(), i, flags.raw()))
46  {
47  if (h_ == nullptr)
48  throw sdlexception();
49  }
50  Ren::Ren(Win& win, ren::Flags flags) :
51  Ren(win, -1, flags) {}
52  Ren::Ren(Win& win, int i) :
53  Ren(win, i, ren::Flags()) {}
54  /*explicit*/ Ren::Ren(Win& win) :
55  Ren(win, -1) {}
56 
57  Ren::~Ren() noexcept {
58  if (h_ != nullptr)
59  SDL_DestroyRenderer(h_);
60  h_ = nullptr;
61  }
62 
63  // Ren::Ren(const Ren& that) = delete;
64  Ren::Ren(Ren&& that) noexcept :
65  Ren()
66  {
67  swap(*this, that);
68  }
69 
70  // Ren& Ren::operator=(const Ren& that) = delete;
71  Ren& Ren::operator=(Ren&& that) noexcept {
72  swap(*this, that);
73  return *this;
74  }
75 
76  void swap(Ren& a, Ren& b) noexcept {
77  using std::swap;
78  swap(a.h_, b.h_);
79  }
80 
81  // h_ can be nullptr from
82  // the private default constructor
83  // => its a rolmodl bug
84  // SDL
85  // => user should have handled the exception and not tried to use the renderer
86  SDL_Renderer* Ren::unsafeRaw() noexcept {
87  assert(h_ != nullptr);
88  return h_;
89  }
90  const SDL_Renderer* Ren::unsafeRaw() const noexcept {
91  assert(h_ != nullptr);
92  return h_;
93  }
94 
95 
96  void Ren::clear() {
97  throwOnErr(SDL_RenderClear(unsafeRaw()));
98  }
99  void Ren::present() noexcept {
100  SDL_RenderPresent(unsafeRaw());
101  }
102 
103  // copy
104  void Ren::drawTex(Tex& tex) {
105  throwOnErr(SDL_RenderCopy(unsafeRaw(), tex.unsafeRaw(), nullptr, nullptr));
106  }
107 
108  void Ren::drawTex(Tex& tex, const SrcRectWH src) {
109  SDL_Rect tmp = src.sdl();
110  throwOnErr(SDL_RenderCopy(unsafeRaw(), tex.unsafeRaw(), &tmp, nullptr));
111  }
112  void Ren::drawTex(Tex& tex, const SrcRectXY src) {
113  drawTex(tex, src.wh());
114  }
115 
116  void Ren::drawTex(Tex& tex, const DstRectWH dst) {
117  SDL_Rect tmp = dst.sdl();
118  throwOnErr(SDL_RenderCopy(unsafeRaw(), tex.unsafeRaw(), nullptr, &tmp));
119  }
120  void Ren::drawTex(Tex& tex, const DstRectXY dst) {
121  drawTex(tex, dst.wh());
122  }
123 
124  void Ren::drawTex(Tex& tex, const SrcRectWH src, const DstRectWH dst) {
125  SDL_Rect srcTmp = src.sdl();
126  SDL_Rect dstTmp = dst.sdl();
127  throwOnErr(SDL_RenderCopy(unsafeRaw(), tex.unsafeRaw(), &srcTmp, &dstTmp));
128  }
129  void Ren::drawTex(Tex& tex, const SrcRectWH src, const DstRectXY dst) {
130  drawTex(tex, src, dst.wh());
131  }
132  void Ren::drawTex(Tex& tex, const SrcRectXY src, const DstRectWH dst) {
133  drawTex(tex, src.wh(), dst);
134  }
135  void Ren::drawTex(Tex& tex, const SrcRectXY src, const DstRectXY dst) {
136  drawTex(tex, src.wh(), dst.wh());
137  }
138 
139  // copyEx
140  void Ren::drawTex(Tex& tex, const Flip flip) {
141  drawTex(tex, 0, flip);
142  }
143  void Ren::drawTex(Tex& tex, const double rot, const Flip flip/* = Flip()*/) {
144  throwOnErr(SDL_RenderCopyEx(unsafeRaw(), tex.unsafeRaw(), nullptr, nullptr, rot, nullptr, flip.toSDLEnum()));
145  }
146  void Ren::drawTex(Tex& tex, const double rot, const geom::Pos rotCenter, const Flip flip/* = Flip()*/) {
147  SDL_Point p{rotCenter.x, rotCenter.y};
148  throwOnErr(SDL_RenderCopyEx(unsafeRaw(), tex.unsafeRaw(), nullptr, nullptr, rot, &p, flip.toSDLEnum()));
149  }
150 
151  void Ren::drawTex(Tex& tex, const SrcRectWH src, const Flip flip) {
152  drawTex(tex, src, 0, flip);
153  }
154  void Ren::drawTex(Tex& tex, const SrcRectXY src, const Flip flip) {
155  drawTex(tex, src.wh(), flip);
156  }
157  void Ren::drawTex(Tex& tex, const SrcRectWH src, const double rot, const Flip flip/* = Flip()*/) {
158  SDL_Rect srcTmp = src.sdl();
159  throwOnErr(SDL_RenderCopyEx(unsafeRaw(), tex.unsafeRaw(), &srcTmp, nullptr, rot, nullptr, flip.toSDLEnum()));
160  }
161  void Ren::drawTex(Tex& tex, const SrcRectXY src, const double rot, const Flip flip/* = Flip()*/) {
162  drawTex(tex, src.wh(), rot, flip);
163  }
164  void Ren::drawTex(Tex& tex, const SrcRectWH src, const double rot, const geom::Pos rotCenter, const Flip flip/* = Flip()*/) {
165  SDL_Rect srcTmp = src.sdl();
166  SDL_Point p{rotCenter.x, rotCenter.y};
167  throwOnErr(SDL_RenderCopyEx(unsafeRaw(), tex.unsafeRaw(), &srcTmp, nullptr, rot, &p, flip.toSDLEnum()));
168  }
169  void Ren::drawTex(Tex& tex, const SrcRectXY src, const double rot, const geom::Pos rotCenter, const Flip flip/* = Flip()*/) {
170  drawTex(tex, src.wh(), rot, rotCenter, flip);
171  }
172 
173  void Ren::drawTex(Tex& tex, const DstRectWH dst, const Flip flip) {
174  drawTex(tex, dst, 0, flip);
175  }
176  void Ren::drawTex(Tex& tex, const DstRectXY dst, const Flip flip) {
177  drawTex(tex, dst.wh(), flip);
178  }
179  void Ren::drawTex(Tex& tex, const DstRectWH dst, const double rot, const Flip flip/* = Flip()*/) {
180  SDL_Rect dstTmp = dst.sdl();
181  throwOnErr(SDL_RenderCopyEx(unsafeRaw(), tex.unsafeRaw(), nullptr, &dstTmp, rot, nullptr, flip.toSDLEnum()));
182  }
183  void Ren::drawTex(Tex& tex, const DstRectXY dst, const double rot, const Flip flip/* = Flip()*/) {
184  drawTex(tex, dst.wh(), rot, flip);
185  }
186  void Ren::drawTex(Tex& tex, const DstRectWH dst, const double rot, const geom::Pos rotCenter, const Flip flip/* = Flip()*/) {
187  SDL_Rect dstTmp = dst.sdl();
188  SDL_Point p{rotCenter.x, rotCenter.y};
189  throwOnErr(SDL_RenderCopyEx(unsafeRaw(), tex.unsafeRaw(), nullptr, &dstTmp, rot, &p, flip.toSDLEnum()));
190  }
191  void Ren::drawTex(Tex& tex, const DstRectXY dst, const double rot, const geom::Pos rotCenter, const Flip flip/* = Flip()*/) {
192  drawTex(tex, dst.wh(), rot, rotCenter, flip);
193  }
194 
195  void Ren::drawTex(Tex& tex, const SrcRectWH src, const DstRectWH dst, const Flip flip) {
196  drawTex(tex, src, dst, 0, flip);
197  }
198  void Ren::drawTex(Tex& tex, const SrcRectWH src, const DstRectXY dst, const Flip flip) {
199  drawTex(tex, src, dst.wh(), flip);
200  }
201  void Ren::drawTex(Tex& tex, const SrcRectXY src, const DstRectWH dst, const Flip flip) {
202  drawTex(tex, src.wh(), dst, flip);
203  }
204  void Ren::drawTex(Tex& tex, const SrcRectXY src, const DstRectXY dst, const Flip flip) {
205  drawTex(tex, src.wh(), dst.wh(), flip);
206  }
207  void Ren::drawTex(Tex& tex, const SrcRectWH src, const DstRectWH dst, const double rot, const Flip flip/* = Flip()*/) {
208  SDL_Rect srcTmp = src.sdl();
209  SDL_Rect dstTmp = dst.sdl();
210  throwOnErr(SDL_RenderCopyEx(unsafeRaw(), tex.unsafeRaw(), &srcTmp, &dstTmp, rot, nullptr, flip.toSDLEnum()));
211  }
212  void Ren::drawTex(Tex& tex, const SrcRectWH src, const DstRectXY dst, const double rot, const Flip flip/* = Flip()*/) {
213  drawTex(tex, src, dst.wh(), rot, flip);
214  }
215  void Ren::drawTex(Tex& tex, const SrcRectXY src, const DstRectWH dst, const double rot, const Flip flip/* = Flip()*/) {
216  drawTex(tex, src.wh(), dst, rot, flip);
217  }
218  void Ren::drawTex(Tex& tex, const SrcRectXY src, const DstRectXY dst, const double rot, const Flip flip/* = Flip()*/) {
219  drawTex(tex, src.wh(), dst.wh(), rot, flip);
220  }
221  void Ren::drawTex(Tex& tex, const SrcRectWH src, const DstRectWH dst, const double rot, const geom::Pos rotCenter, const Flip flip/* = Flip()*/) {
222  SDL_Rect srcTmp = src.sdl();
223  SDL_Rect dstTmp = dst.sdl();
224  SDL_Point p{rotCenter.x, rotCenter.y};
225  throwOnErr(SDL_RenderCopyEx(unsafeRaw(), tex.unsafeRaw(), &srcTmp, &dstTmp, rot, &p, flip.toSDLEnum()));
226  }
227  void Ren::drawTex(Tex& tex, const SrcRectWH src, const DstRectXY dst, const double rot, const geom::Pos rotCenter, const Flip flip/* = Flip()*/) {
228  drawTex(tex, src, dst.wh(), rot, rotCenter, flip);
229  }
230  void Ren::drawTex(Tex& tex, const SrcRectXY src, const DstRectWH dst, const double rot, const geom::Pos rotCenter, const Flip flip/* = Flip()*/) {
231  drawTex(tex, src.wh(), dst, rot, rotCenter, flip);
232  }
233  void Ren::drawTex(Tex& tex, const SrcRectXY src, const DstRectXY dst, const double rot, const geom::Pos rotCenter, const Flip flip/* = Flip()*/) {
234  drawTex(tex, src.wh(), dst.wh(), rot, rotCenter, flip);
235  }
236 
237  void Ren::drawLine(const geom::Pos a, const geom::Pos b) {
238  throwOnErr(SDL_RenderDrawLine(unsafeRaw(), a.x, a.y, b.x, b.y));
239  }
240  // void Ren::drawLines(?); // fixme: implement this generically
241 
242  void Ren::drawPoint(const geom::Pos p) {
243  throwOnErr(SDL_RenderDrawPoint(unsafeRaw(), p.x, p.y));
244  }
245  // void Ren::drawPoints(?); // fixme: implement this generically
246 
247  void Ren::drawRect(const geom::RectWH r) {
248  SDL_Rect tmp = r.sdl();
249  throwOnErr(SDL_RenderDrawRect(unsafeRaw(), &tmp));
250  }
251  void Ren::drawRect(const geom::RectXY r) {
252  drawRect(r.wh());
253  }
254  // void Ren::drawRects(?); // fixme: implement this generically
255 
256  void Ren::fillRect(const geom::RectWH r) {
257  SDL_Rect tmp = r.sdl();
258  throwOnErr(SDL_RenderFillRect(unsafeRaw(), &tmp));
259  }
260  void Ren::fillRect(const geom::RectXY r) {
261  fillRect(r.wh());
262  }
263  // void Ren::fillRects(?); // fixme: implement this generically
264 
266  throwOnErr(SDL_RenderDrawRect(unsafeRaw(), nullptr));
267  }
269  throwOnErr(SDL_RenderFillRect(unsafeRaw(), nullptr));
270  }
271 
273  SDL_Rect tmp{};
274  SDL_RenderGetClipRect(unsafeRaw(), &tmp);
275  if (tmp.w != 0 || tmp.h != 0) // todo: what is an empty rectangle?
276  return geom::RectWH(tmp);
277  return std::nullopt;
278  }
280  SDL_Rect tmp = r.sdl();
281  throwOnErr(SDL_RenderSetClipRect(unsafeRaw(), &tmp));
282  }
284  setClipRect(r.wh());
285  }
287  throwOnErr(SDL_RenderSetClipRect(unsafeRaw(), nullptr));
288  }
289  bool Ren::isClipOn() noexcept {
290  return SDL_RenderIsClipEnabled(unsafeRaw()) == SDL_TRUE;
291  }
292 
294  geom::Size tmp{};
295  SDL_RenderGetLogicalSize(unsafeRaw(), &tmp.w, &tmp.h);
296  if (tmp.w != 0 || tmp.h != 0)
297  return tmp;
298  return std::nullopt;
299  }
301  throwOnErr(SDL_RenderSetLogicalSize(unsafeRaw(), s.w, s.h));
302  }
303 
305  geom::Size res{};
306  throwOnErr(SDL_GetRendererOutputSize(unsafeRaw(), &res.w, &res.h));
307  return res;
308  }
309 
310  RenScale Ren::scale() noexcept {
311  RenScale res{};
312  SDL_RenderGetScale(unsafeRaw(), &res.x, &res.y);
313  return res;
314  }
315  void Ren::setScale(const RenScale s) {
316  throwOnErr(SDL_RenderSetScale(unsafeRaw(), s.x, s.y));
317  }
318 
320  SDL_Rect tmp{};
321  SDL_RenderGetViewport(unsafeRaw(), &tmp);
322  return geom::RectWH(tmp);
323  }
325  SDL_Rect tmp = r.sdl();
326  throwOnErr(SDL_RenderSetViewport(unsafeRaw(), &tmp));
327  }
328 
330  SDL_BlendMode tmp = SDL_BLENDMODE_NONE;
331  throwOnErr(SDL_GetRenderDrawBlendMode(unsafeRaw(), &tmp));
332  return blendMode::unsafe::fromSDLEnum(tmp);
333  }
334  void Ren::setBlendMode(const BlendMode m) {
335  throwOnErr(SDL_SetRenderDrawBlendMode(unsafeRaw(), blendMode::unsafe::toSDLEnum(m)));
336  }
337 
338 
340  RGBA res{};
341  throwOnErr(SDL_GetRenderDrawColor(unsafeRaw(), &res.r, &res.g, &res.b, &res.a));
342  return res;
343  }
344 
345  void Ren::setColor(const RGBA c) {
346  throwOnErr(SDL_SetRenderDrawColor(unsafeRaw(), c.r, c.g, c.b, c.a));
347  }
348 
349 
350 
351  TexRen::TexRen(Win& win, int i, ren::Flags flags) :
352  Ren(win, i, flags.withToTexture()) {}
354  Ren(win, flags.withToTexture()) {}
355  TexRen::TexRen(Win& win, int i) :
356  Ren(win, i, ren::Flags().withToTexture()) {}
357  /*explicit*/ TexRen::TexRen(Win& win) :
358  Ren(win, ren::Flags().withToTexture()) {}
359 
361  throwOnErr(SDL_SetRenderTarget(unsafeRaw(), tex.unsafeRaw()));
362  }
364  throwOnErr(SDL_SetRenderTarget(unsafeRaw(), nullptr));
365  }
366 
367  SDL_Texture* TexRen::unsafeGetTarget() noexcept {
368  return SDL_GetRenderTarget(unsafeRaw());
369  }
370 }
rolmodl::RenScale
Rendering scaling factors.
Definition: Ren.hpp:248
rolmodl::Ren::~Ren
~Ren() noexcept
Free the underlying SDL_Renderer.
Definition: Ren.cpp:57
rolmodl::detail::throwOnErr
int throwOnErr(const int code)
Throw a rolmodl::sdlexception if code < 0.
Definition: Base.cpp:370
rolmodl::blendMode::unsafe::fromSDLEnum
constexpr BlendMode fromSDLEnum(const SDL_BlendMode m) noexcept
Convert an SDL_BlendMode value to a rolmodl::BlendMode value.
Definition: Ren.hpp:49
utility
rolmodl::Ren::setBlendMode
void setBlendMode(const BlendMode m)
Set the blending mode used for draw operations to m. Does not effect how textures are blended.
Definition: Ren.cpp:334
rolmodl::SrcRectWH
Rectangle specifying the source rectangle for a rendering operation by its top left corner coordinate...
Definition: Ren.hpp:256
rolmodl::TexRen::unsafeGetTarget
SDL_Texture * unsafeGetTarget() noexcept
Query the current rendering target. Unsafe because it returns a raw non-owning pointer to the texture...
Definition: Ren.cpp:367
rolmodl::Ren
Renderer class that does not support rendering to texture. Use rolmodl::TexRen for rendering to textu...
Definition: Ren.hpp:305
rolmodl::blendMode::unsafe::toSDLEnum
constexpr SDL_BlendMode toSDLEnum(const BlendMode m) noexcept
Convert a rolmodl::BlendMode value to an SDL_BlendMode value.
Definition: Ren.hpp:60
rolmodl::Ren::scale
RenScale scale() noexcept
Query the rendering scaling factors.
Definition: Ren.cpp:310
rolmodl::geom::RectWH::sdl
constexpr SDL_Rect sdl() const noexcept
Convert to an SDL_Rect.
Definition: Geom.hpp:76
std::vector< pixelfmt::Id >
rolmodl::TexRen::setTarget
void setTarget(RenTex &tex)
Set the rendering target.
Definition: Ren.cpp:360
rolmodl::TexRen::setDefaultTarget
void setDefaultTarget()
Reset the rendering target to the default one. Usually it is the window for which the renderer was cr...
Definition: Ren.cpp:363
rolmodl::RGBA
RGBA color type. Has an alpha component.
Definition: Base.hpp:377
rolmodl::Ren::fillRect
void fillRect(const geom::RectWH r)
Fill the width-height rect r with the drawing color.
Definition: Ren.cpp:256
rolmodl::DstRectXY::wh
constexpr DstRectWH wh() const noexcept
Convert to an equivalent rolmodl::DstRectWH.
Definition: Ren.hpp:292
rolmodl::DstRectWH
Rectangle specifying the destination rectangle for a rendering operation by its top left corner coord...
Definition: Ren.hpp:277
Ren.hpp
rolmodl::Ren::getRealSize
geom::Size getRealSize()
Query the target resolution in device pixels.
Definition: Ren.cpp:304
rolmodl::Ren::operator=
Ren & operator=(const Ren &that)=delete
Copying rolmodl renderers is not allowed because their lifetime is tied to the underlying SDL_Rendere...
rolmodl::geom::Size
int dimensions data type. The value is in pixels. Semantically different from rolmodl::geom::Pos.
Definition: Geom.hpp:31
rolmodl::Ren::drawRect
void drawRect(const geom::RectWH r)
Draw the outline of the width-height rect r with the drawing color.
Definition: Ren.cpp:247
rolmodl::Flip::toSDLEnum
constexpr SDL_RendererFlip toSDLEnum() const noexcept
Return the underlying bitfield representation of this configuration as the SDL enum type SDL_Renderer...
Definition: Ren.hpp:112
rolmodl::SrcRectXY::wh
constexpr SrcRectWH wh() const noexcept
Convert to an equivalent rolmodl::SrcRectWH.
Definition: Ren.hpp:271
rolmodl::Win
Window class for use with accelerated rendering (rolmodl::Ren).
Definition: Win.hpp:337
rolmodl::Ren::fillScreen
void fillScreen()
Fill the rendering target with the drawing color.
Definition: Ren.cpp:268
algorithm
rolmodl::Ren::setColor
void setColor(const RGBA c)
Set the drawing color to c.
Definition: Ren.cpp:345
rolmodl::Ren::setScale
void setScale(const RenScale s)
Set the rendering scaling factors to s.
Definition: Ren.cpp:315
rolmodl::ren::Info::name
const char * name
Name of the driver.
Definition: Ren.hpp:217
rolmodl::Ren::outlineScreen
void outlineScreen()
Draw an outline around the rendering target with the drawing color.
Definition: Ren.cpp:265
rolmodl::Ren::getBlendMode
BlendMode getBlendMode()
Get the blending mode used for draw operations. Textures have their own separate belnding mode.
Definition: Ren.cpp:329
rolmodl::geom::RectXY
Rectangle represented by its top left corner coordinates and its bottom right corner coordinates.
Definition: Geom.hpp:87
rolmodl::geom::RectWH
Rectangle represented by its top left corner coordinates, width, and height.
Definition: Geom.hpp:59
rolmodl::Ren::clear
void clear()
Paint over the entire rendering target with the current color.
Definition: Ren.cpp:96
rolmodl::Ren::drawLine
void drawLine(const geom::Pos a, const geom::Pos b)
Draw a line from point a to point b with the drawing color.
Definition: Ren.cpp:237
rolmodl::TexRen::TexRen
TexRen(Win &win, int i, ren::Flags flags)
Initialize a renderer for window win, using the ith rendering driver, with a version of configuration...
Definition: Ren.cpp:351
rolmodl::ren::driver::count
unsigned int count()
Query the amount of available rendering drivers.
Definition: Ren.cpp:15
rolmodl::ren::Info
Information about a rendering driver.
Definition: Ren.hpp:215
rolmodl::Ren::logicalSize
std::optional< geom::Size > logicalSize() noexcept
Query the device-independent resolution.
Definition: Ren.cpp:293
rolmodl::Ren::color
RGBA color()
Query the current drawing color.
Definition: Ren.cpp:339
rolmodl::Flip
Rendering flip configuration container.
Definition: Ren.hpp:74
std::nullopt
T nullopt
rolmodl::RenTex
Definition: Tex.hpp:90
rolmodl::DstRectXY
Rectangle specifying the destination rectangle for a rendering operation by its top left and bottom r...
Definition: Ren.hpp:282
rolmodl
Main namespace.
Definition: Base.cpp:7
rolmodl::Ren::isClipOn
bool isClipOn() noexcept
Query whether the clipping rectangle has been set.
Definition: Ren.cpp:289
rolmodl::Ren::setLogicalSize
void setLogicalSize(const geom::Size s)
Set the device-independent resolution to s.
Definition: Ren.cpp:300
rolmodl::Tex
Definition: Tex.hpp:40
rolmodl::Ren::disableClip
void disableClip()
Unset the clipping rectangle.
Definition: Ren.cpp:286
rolmodl::ren::Flags
Renderer configuration (flags) container.
Definition: Ren.hpp:136
std::swap
T swap(T... args)
rolmodl::Ren::drawTex
void drawTex(Tex &tex)
Copy the entire texture tex to fill the entire rendering target.
Definition: Ren.cpp:104
rolmodl::Ren::setClipRect
void setClipRect(const geom::RectWH r)
Set the clipping rectangle to r.
Definition: Ren.cpp:279
rolmodl::sdlexception
Exception type containing an error code and the last SDL error at the moment of creation.
Definition: Base.hpp:399
rolmodl::BlendMode
BlendMode
Describes how colors are combined when rendering twice to the same place.
Definition: Ren.hpp:21
rolmodl::Ren::viewport
geom::RectWH viewport() noexcept
Query the subarea of the target used for drawing.
Definition: Ren.cpp:319
rolmodl::geom::Pos
int point data type. The value is in pixels. Semantically different from rolmodl::geom::Size.
Definition: Geom.hpp:18
cassert
rolmodl::Ren::clipRect
std::optional< geom::RectWH > clipRect() noexcept
Get the clipping rectangle. std::nullopt is returned if the clipping rectangle has not been set.
Definition: Ren.cpp:272
Win.hpp
std::out_of_range
std::optional
rolmodl::Ren::present
void present() noexcept
Push the backbuffer to screen, displaying any changes made since the last present....
Definition: Ren.cpp:99
rolmodl::ren::driver::info
Info info(const unsigned int i)
Query the driver info for the ith rendering driver.
Definition: Ren.cpp:21
rolmodl::Ren::drawPoint
void drawPoint(const geom::Pos p)
Set the pixel at point p to the drawing color.
Definition: Ren.cpp:242
rolmodl::SrcRectXY
Rectangle specifying the source rectangle for a rendering operation by its top left and bottom right ...
Definition: Ren.hpp:261
rolmodl::ren::Flags::unsafeFromRaw
constexpr static Flags unsafeFromRaw(const uint32_t data) noexcept
Create a configuration representing the bitfield data. Unsafe because data is not verified as represe...
Definition: Ren.hpp:202
rolmodl::Ren::setViewport
void setViewport(const geom::RectWH r)
Set the subarea of the target used for drawing to the rectangle r.
Definition: Ren.cpp:324
Base.hpp
rolmodl::Ren::unsafeRaw
SDL_Renderer * unsafeRaw() noexcept
Get the underlying SDL_Renderer*. Unsafe because this value might be nullptr and using it with some S...
Definition: Ren.cpp:86