rolmodl
C++ API for the Simple Directmedia Library 2 (SDL2)
Ren.hpp
Go to the documentation of this file.
1 #pragma once
2 
7 
8 #include "forwarddecl/Ren.hpp"
9 
10 #include "forwarddecl/Win.hpp"
11 #include "forwarddecl/Tex.hpp"
12 #include "forwarddecl/Base.hpp"
13 #include "Geom.hpp"
14 #include "PixelFmt.hpp"
15 
17 namespace rolmodl {
21  enum class BlendMode {
25  none,
30  blend,
35  add,
40  mod
41  };
43  namespace blendMode {
45  namespace unsafe {}
46  }
47  namespace blendMode::unsafe {
49  constexpr BlendMode fromSDLEnum(const SDL_BlendMode m) noexcept {
50  if (m == SDL_BLENDMODE_NONE)
51  return BlendMode::none;
52  if (m == SDL_BLENDMODE_BLEND)
53  return BlendMode::blend;
54  if (m == SDL_BLENDMODE_ADD)
55  return BlendMode::add;
56  // if (m == SDL_BLENDMODE_MOD)
57  return BlendMode::mod;
58  }
60  constexpr SDL_BlendMode toSDLEnum(const BlendMode m) noexcept {
61  if (m == BlendMode::none)
62  return SDL_BLENDMODE_NONE;
63  if (m == BlendMode::blend)
64  return SDL_BLENDMODE_BLEND;
65  if (m == BlendMode::add)
66  return SDL_BLENDMODE_ADD;
67  // if (m == BlendMode::mod)
68  return SDL_BLENDMODE_MOD;
69  }
70  }
71 
74  struct Flip {
75  public:
77  constexpr Flip() noexcept :
78  data_(SDL_FLIP_NONE) // todo: assumes that SDL_FLIP_NONE = 0
79  {}
80 
81  // test
83  constexpr Flip isHorizontal() const noexcept {
84  return Flip(data_ | static_cast<uint32_t>(SDL_FLIP_HORIZONTAL));
85  }
87  constexpr Flip isVertical() const noexcept {
88  return Flip(data_ | static_cast<uint32_t>(SDL_FLIP_VERTICAL));
89  }
90 
91  // set
93  constexpr Flip withHorizontal() const noexcept {
94  return Flip(data_ | static_cast<uint32_t>(SDL_FLIP_HORIZONTAL));
95  }
97  constexpr Flip withVertical() const noexcept {
98  return Flip(data_ | static_cast<uint32_t>(SDL_FLIP_VERTICAL));
99  }
100 
101  // unset
103  constexpr Flip withoutHorizontal() const noexcept {
104  return Flip(data_ & ~static_cast<uint32_t>(SDL_FLIP_HORIZONTAL));
105  }
107  constexpr Flip withoutVertical() const noexcept {
108  return Flip(data_ & ~static_cast<uint32_t>(SDL_FLIP_VERTICAL));
109  }
110 
112  constexpr SDL_RendererFlip toSDLEnum() const noexcept {
113  return static_cast<SDL_RendererFlip>(data_);
114  }
116  constexpr uint32_t raw() const noexcept {
117  return data_;
118  }
119  private:
120  explicit constexpr Flip(const uint32_t data) noexcept :
121  data_(data)
122  {}
123 
124  uint32_t data_;
125  };
126 
128  namespace ren {
136  struct Flags {
137  public:
139  constexpr Flags() noexcept :
140  data_(0)
141  {}
142 
143  // test
145  constexpr bool isSoftware() const noexcept {
146  return (data_ & static_cast<uint32_t>(SDL_RENDERER_SOFTWARE)) != 0;
147  }
149  constexpr bool isAccelerated() const noexcept {
150  return (data_ & static_cast<uint32_t>(SDL_RENDERER_ACCELERATED)) != 0;
151  }
153  constexpr bool isVsync() const noexcept {
154  return (data_ & static_cast<uint32_t>(SDL_RENDERER_PRESENTVSYNC)) != 0;
155  }
157  constexpr bool isToTexture() const noexcept {
158  return (data_ & static_cast<uint32_t>(SDL_RENDERER_TARGETTEXTURE)) != 0;
159  }
160 
161  // set
163  constexpr Flags withSoftware() const noexcept {
164  return Flags(data_ | static_cast<uint32_t>(SDL_RENDERER_SOFTWARE));
165  }
167  constexpr Flags withAccelerated() const noexcept {
168  return Flags(data_ | static_cast<uint32_t>(SDL_RENDERER_ACCELERATED));
169  }
171  constexpr Flags withVsync() const noexcept {
172  return Flags(data_ | static_cast<uint32_t>(SDL_RENDERER_PRESENTVSYNC));
173  }
175  constexpr Flags withToTexture() const noexcept {
176  return Flags(data_ | static_cast<uint32_t>(SDL_RENDERER_TARGETTEXTURE));
177  }
178 
179  // unset
181  constexpr Flags withoutSoftware() const noexcept {
182  return Flags(data_ & ~static_cast<uint32_t>(SDL_RENDERER_SOFTWARE));
183  }
185  constexpr Flags withoutAccelerated() const noexcept {
186  return Flags(data_ & ~static_cast<uint32_t>(SDL_RENDERER_ACCELERATED));
187  }
189  constexpr Flags withoutVsync() const noexcept {
190  return Flags(data_ & ~static_cast<uint32_t>(SDL_RENDERER_PRESENTVSYNC));
191  }
193  constexpr Flags withoutToTexture() const noexcept {
194  return Flags(data_ & ~static_cast<uint32_t>(SDL_RENDERER_TARGETTEXTURE));
195  }
196 
198  constexpr uint32_t raw() const noexcept {
199  return data_;
200  }
202  constexpr static Flags unsafeFromRaw(const uint32_t data) noexcept {
203  return Flags(data);
204  }
205  private:
206  explicit constexpr Flags(const uint32_t data) noexcept :
207  data_(data)
208  {}
209 
210  uint32_t data_;
211  };
212 
215  struct Info {
217  const char* name;
224  };
225 
227  namespace driver {
228  // fixme: there is something off with this and exception guarantees, not sure if its good design
229 
235  unsigned int count();
241  Info info(const unsigned int i);
242  }
243  }
244 
248  struct RenScale {
249  public:
250  float x, y;
251 
252  private:
253  };
254 
256  struct SrcRectWH : public geom::RectWH {
257  using geom::RectWH::RectWH;
258  constexpr SrcRectXY xy() const noexcept;
259  };
261  struct SrcRectXY : public geom::RectXY {
262  using geom::RectXY::RectXY;
263  constexpr SrcRectWH wh() const noexcept;
264  };
266  constexpr SrcRectXY SrcRectWH::xy() const noexcept {
268  return SrcRectXY(tmp.x, tmp.y, tmp.x1, tmp.y1);
269  }
271  constexpr SrcRectWH SrcRectXY::wh() const noexcept {
273  return SrcRectWH(tmp.x, tmp.y, tmp.w, tmp.h);
274  }
275 
277  struct DstRectWH : public geom::RectWH {
278  using geom::RectWH::RectWH;
279  constexpr DstRectXY xy() const noexcept;
280  };
282  struct DstRectXY : public geom::RectXY {
283  using geom::RectXY::RectXY;
284  constexpr DstRectWH wh() const noexcept;
285  };
287  constexpr DstRectXY DstRectWH::xy() const noexcept {
289  return DstRectXY(tmp.x, tmp.y, tmp.x1, tmp.y1);
290  }
292  constexpr DstRectWH DstRectXY::wh() const noexcept {
294  return DstRectWH(tmp.x, tmp.y, tmp.w, tmp.h);
295  }
296 
305  class Ren {
306  public:
307  // fixme: the index is unsafe here probably, i don't like that this api relies on SDL to catch out-of-bounds errors
308 
312  Ren(Win& win, int i, ren::Flags flags);
316  Ren(Win& win, ren::Flags flags);
320  Ren(Win& win, int i);
324  explicit Ren(Win& win);
327  ~Ren() noexcept;
328 
330  Ren(const Ren& that) = delete;
332  Ren(Ren&& that) noexcept;
333 
335  Ren& operator=(const Ren& that) = delete;
337  Ren& operator=(Ren&& that) noexcept;
338 
340  friend void swap(Ren& a, Ren& b) noexcept;
341 
343  SDL_Renderer* unsafeRaw() noexcept;
345  const SDL_Renderer* unsafeRaw() const noexcept;
346 
347 
350  void clear();
356  void present() noexcept;
357 
358  // copy
361  void drawTex(Tex& tex);
362 
365  void drawTex(Tex& tex, const SrcRectWH src);
368  void drawTex(Tex& tex, const SrcRectXY src);
369 
372  void drawTex(Tex& tex, const DstRectWH dst);
375  void drawTex(Tex& tex, const DstRectXY dst);
376 
379  void drawTex(Tex& tex, const SrcRectWH src, const DstRectWH dst);
382  void drawTex(Tex& tex, const SrcRectWH src, const DstRectXY dst);
385  void drawTex(Tex& tex, const SrcRectXY src, const DstRectWH dst);
388  void drawTex(Tex& tex, const SrcRectXY src, const DstRectXY dst);
389 
390  // copyEx
393  void drawTex(Tex& tex, const Flip flip);
396  void drawTex(Tex& tex, const double rot, const Flip flip = Flip());
399  void drawTex(Tex& tex, const double rot, const geom::Pos rotCenter, const Flip flip = Flip());
400 
403  void drawTex(Tex& tex, const SrcRectWH src, const Flip flip);
406  void drawTex(Tex& tex, const SrcRectXY src, const Flip flip);
409  void drawTex(Tex& tex, const SrcRectWH src, const double rot, const Flip flip = Flip());
412  void drawTex(Tex& tex, const SrcRectXY src, const double rot, const Flip flip = Flip());
415  void drawTex(Tex& tex, const SrcRectWH src, const double rot, const geom::Pos rotCenter, const Flip flip = Flip());
418  void drawTex(Tex& tex, const SrcRectXY src, const double rot, const geom::Pos rotCenter, const Flip flip = Flip());
419 
422  void drawTex(Tex& tex, const DstRectWH dst, const Flip flip);
425  void drawTex(Tex& tex, const DstRectXY dst, const Flip flip);
428  void drawTex(Tex& tex, const DstRectWH dst, const double rot, const Flip flip = Flip());
431  void drawTex(Tex& tex, const DstRectXY dst, const double rot, const Flip flip = Flip());
434  void drawTex(Tex& tex, const DstRectWH dst, const double rot, const geom::Pos rotCenter, const Flip flip = Flip());
437  void drawTex(Tex& tex, const DstRectXY dst, const double rot, const geom::Pos rotCenter, const Flip flip = Flip());
438 
441  void drawTex(Tex& tex, const SrcRectWH src, const DstRectWH dst, const Flip flip);
444  void drawTex(Tex& tex, const SrcRectWH src, const DstRectXY dst, const Flip flip);
447  void drawTex(Tex& tex, const SrcRectXY src, const DstRectWH dst, const Flip flip);
450  void drawTex(Tex& tex, const SrcRectXY src, const DstRectXY dst, const Flip flip);
453  void drawTex(Tex& tex, const SrcRectWH src, const DstRectWH dst, const double rot, const Flip flip = Flip());
456  void drawTex(Tex& tex, const SrcRectWH src, const DstRectXY dst, const double rot, const Flip flip = Flip());
459  void drawTex(Tex& tex, const SrcRectXY src, const DstRectWH dst, const double rot, const Flip flip = Flip());
462  void drawTex(Tex& tex, const SrcRectXY src, const DstRectXY dst, const double rot, const Flip flip = Flip());
465  void drawTex(Tex& tex, const SrcRectWH src, const DstRectWH dst, const double rot, const geom::Pos rotCenter, const Flip flip = Flip());
468  void drawTex(Tex& tex, const SrcRectWH src, const DstRectXY dst, const double rot, const geom::Pos rotCenter, const Flip flip = Flip());
471  void drawTex(Tex& tex, const SrcRectXY src, const DstRectWH dst, const double rot, const geom::Pos rotCenter, const Flip flip = Flip());
474  void drawTex(Tex& tex, const SrcRectXY src, const DstRectXY dst, const double rot, const geom::Pos rotCenter, const Flip flip = Flip());
475 
484  void drawLine(const geom::Pos a, const geom::Pos b);
485  // void drawLines(?) noexcept; // todo: implement this generically
486 
489  void drawPoint(const geom::Pos p);
490  // void drawPoints(?) noexcept; // todo: implement this generically
491 
494  void drawRect(const geom::RectWH r);
497  void drawRect(const geom::RectXY r);
498  // void drawRects(?) noexcept; // todo: implement this generically
499 
502  void fillRect(const geom::RectWH r);
505  void fillRect(const geom::RectXY r);
506  // void fillRects(?); // todo: implement this generically
507 
511  void outlineScreen();
516  void fillScreen();
517 
524  void setClipRect(const geom::RectWH r);
527  void setClipRect(const geom::RectXY r);
530  void disableClip();
535  bool isClipOn() noexcept;
536 
544  void setLogicalSize(const geom::Size s);
545 
546  // void setIntegralLogicalScale();
547 
552 
556  RenScale scale() noexcept;
560  void setScale(const RenScale s);
561 
566  geom::RectWH viewport() noexcept;
569  void setViewport(const geom::RectWH r);
570 
578  void setBlendMode(const BlendMode m);
579 
582  RGBA color();
585  void setColor(const RGBA c);
586 
587  private:
588  Ren() noexcept;
589 
590  SDL_Renderer* h_;
591  };
592 
593  // fixme: if the renderer driver fails to create a renderer that supports target textures, this class is invalid
601  class TexRen : public Ren { // todo: not all target-supporting renderers are TexRen
602  public:
606  TexRen(Win& win, int i, ren::Flags flags);
610  TexRen(Win& win, ren::Flags flags);
614  TexRen(Win& win, int i);
618  explicit TexRen(Win& win);
619 
622  void setTarget(RenTex& tex);
626  void setDefaultTarget();
627 
631  SDL_Texture* unsafeGetTarget() noexcept;
632 
633  private:
634  };
635 }
rolmodl::RenScale
Rendering scaling factors.
Definition: Ren.hpp:248
rolmodl::Ren::~Ren
~Ren() noexcept
Free the underlying SDL_Renderer.
Definition: Ren.cpp:57
rolmodl::ren::Flags::withToTexture
constexpr Flags withToTexture() const noexcept
Create a version of this configuration that corresponds to a renderer capable of rendering to texture...
Definition: Ren.hpp:175
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
PixelFmt.hpp
rolmodl::BlendMode::blend
Alpha-blending. Treats the alpha value as transparency. Equivalent SDL enum is SDL_BLENDMODE_BLEND.
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::Flip::raw
constexpr uint32_t raw() const noexcept
Return the underlying bitfield representation of this configuration.
Definition: Ren.hpp:116
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::Flip::withoutVertical
constexpr Flip withoutVertical() const noexcept
Create a version of this configuration that does not have vertical flipping enabled....
Definition: Ren.hpp:107
rolmodl::Ren
Renderer class that does not support rendering to texture. Use rolmodl::TexRen for rendering to textu...
Definition: Ren.hpp:305
rolmodl::ren::Flags::withoutToTexture
constexpr Flags withoutToTexture() const noexcept
Create a version of this configuration that corresponds to a renderer that is not capable of renderin...
Definition: Ren.hpp:193
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::Flags::isToTexture
constexpr bool isToTexture() const noexcept
Test whether this configuration corresponds to a renderer capable of rendering to texture....
Definition: Ren.hpp:157
rolmodl::DstRectWH::xy
constexpr DstRectXY xy() const noexcept
Convert to an equivalent rolmodl::DstRectXY.
Definition: Ren.hpp:287
rolmodl::Ren::scale
RenScale scale() noexcept
Query the rendering scaling factors.
Definition: Ren.cpp:310
rolmodl::TexRen
Renderer class that supports rendering to texture. Use rolmodl::Ren if you do not need support for re...
Definition: Ren.hpp:601
std::vector< pixelfmt::Id >
rolmodl::TexRen::setTarget
void setTarget(RenTex &tex)
Set the rendering target.
Definition: Ren.cpp:360
rolmodl::ren::Info::maxTexSize
geom::Size maxTexSize
Maximum texture size supported by the driver.
Definition: Ren.hpp:223
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::ren::Flags::withoutVsync
constexpr Flags withoutVsync() const noexcept
Create a version of this configuration that corresponds to a renderer that is not VSync....
Definition: Ren.hpp:189
rolmodl::Flip::withHorizontal
constexpr Flip withHorizontal() const noexcept
Create a version of this configuration that has horizontal flipping enabled. The SDL flag equivalent ...
Definition: Ren.hpp:93
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
rolmodl::Flip::withoutHorizontal
constexpr Flip withoutHorizontal() const noexcept
Create a version of this configuration that does not have horizontal flipping enabled....
Definition: Ren.hpp:103
rolmodl::Ren::getRealSize
geom::Size getRealSize()
Query the target resolution in device pixels.
Definition: Ren.cpp:304
rolmodl::ren::Flags::isSoftware
constexpr bool isSoftware() const noexcept
Test whether this configuration corresponds to a software renderer. The SDL flag equivalent is SDL_RE...
Definition: Ren.hpp:145
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::ren::Info::pixelFmts
std::vector< pixelfmt::Id > pixelFmts
Pixel formats supported by the driver.
Definition: Ren.hpp:221
Geom.hpp
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
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::geom::RectWH::xy
constexpr RectXY xy() const noexcept
Convert to an equivalent rolmodl::geom::RectXY.
Definition: Geom.hpp:111
rolmodl::geom::RectWH::RectWH
constexpr RectWH(const int argX, const int argY, const int argW, const int argH) noexcept
Initialize with the given top left corner x and y, width, and height.
Definition: Geom.hpp:65
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::BlendMode::add
Additive blending. Equivalent SDL enum is SDL_BLENDMODE_ADD.
rolmodl::Flip::isHorizontal
constexpr Flip isHorizontal() const noexcept
Test whether this configuration has horizontal flipping enabled. The SDL flag equivalent is SDL_FLIP_...
Definition: Ren.hpp:83
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::geom::RectXY::wh
constexpr RectWH wh() const noexcept
Convert to an equivalent rolmodl::geom::RectWH.
Definition: Geom.hpp:114
rolmodl::SrcRectWH::xy
constexpr SrcRectXY xy() const noexcept
Convert to an equivalent rolmodl::SrcRectXY.
Definition: Ren.hpp:266
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::Flip::withVertical
constexpr Flip withVertical() const noexcept
Create a version of this configuration that has vertical flipping enabled. The SDL flag equivalent is...
Definition: Ren.hpp:97
rolmodl::Ren::color
RGBA color()
Query the current drawing color.
Definition: Ren.cpp:339
rolmodl::Flip
Rendering flip configuration container.
Definition: Ren.hpp:74
rolmodl::ren::Flags::Flags
constexpr Flags() noexcept
Create a configuration corresponding to a default renderer.
Definition: Ren.hpp:139
rolmodl::ren::Flags::isVsync
constexpr bool isVsync() const noexcept
Test whether this configuration corresponds to a VSync renderer. The SDL flag equivalent is SDL_RENDE...
Definition: Ren.hpp:153
rolmodl::RenTex
Definition: Tex.hpp:90
rolmodl::BlendMode::none
Do not blend. Equivalent SDL enum is SDL_BLENDMODE_NONE.
rolmodl::DstRectXY
Rectangle specifying the destination rectangle for a rendering operation by its top left and bottom r...
Definition: Ren.hpp:282
rolmodl::ren::Flags::raw
constexpr uint32_t raw() const noexcept
Return the underlying bitfield representation of this configuration.
Definition: Ren.hpp:198
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::Flip::isVertical
constexpr Flip isVertical() const noexcept
Test whether this configuration has vertical flipping enabled. The SDL flag equivalent is SDL_FLIP_VE...
Definition: Ren.hpp:87
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
rolmodl::geom::RectXY::RectXY
constexpr RectXY(const int argX, const int argY, const int argX1, const int argY1) noexcept
Initialize with the given top left corner x and y, and the bottom right corner x and y.
Definition: Geom.hpp:93
rolmodl::ren::Flags::withAccelerated
constexpr Flags withAccelerated() const noexcept
Create a version of this configuration that corresponds to an accelerated renderer....
Definition: Ren.hpp:167
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::ren::Flags::withSoftware
constexpr Flags withSoftware() const noexcept
Create a version of this configuration that corresponds to a software renderer. The SDL flag equivale...
Definition: Ren.hpp:163
rolmodl::ren::Flags::isAccelerated
constexpr bool isAccelerated() const noexcept
Test whether this configuration corresponds to an accelerated renderer. The SDL flag equivalent is SD...
Definition: Ren.hpp:149
rolmodl::BlendMode::mod
Color modulation blending. Equivalent SDL enum is SDL_BLENDMODE_MOD.
rolmodl::Ren::viewport
geom::RectWH viewport() noexcept
Query the subarea of the target used for drawing.
Definition: Ren.cpp:319
rolmodl::BlendMode
BlendMode
Describes how colors are combined when rendering twice to the same place.
Definition: Ren.hpp:21
rolmodl::geom::Pos
int point data type. The value is in pixels. Semantically different from rolmodl::geom::Size.
Definition: Geom.hpp:18
rolmodl::ren::Flags::withoutSoftware
constexpr Flags withoutSoftware() const noexcept
Create a version of this configuration that corresponds to a renderer that is not software....
Definition: Ren.hpp:181
rolmodl::Flip::Flip
constexpr Flip() noexcept
Create a configuration corresponding to no flipping. The SDL flag equivalent is SDL_FLIP_NONE.
Definition: Ren.hpp:77
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
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::Flags::withoutAccelerated
constexpr Flags withoutAccelerated() const noexcept
Create a version of this configuration that corresponds to a renderer that is not accelerated....
Definition: Ren.hpp:185
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::withVsync
constexpr Flags withVsync() const noexcept
Create a version of this configuration that corresponds to a VSync renderer. The SDL flag equivalent ...
Definition: Ren.hpp:171
rolmodl::Ren::swap
friend void swap(Ren &a, Ren &b) noexcept
Exchange the underlying SDL_Renderer with that.
Definition: Ren.cpp:76
rolmodl::ren::Info::flags
Flags flags
Maximal renderer configuration supported by the driver.
Definition: Ren.hpp:219
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
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