SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL3pp_surface.h
1#ifndef SDL3PP_SURFACE_H_
2#define SDL3PP_SURFACE_H_
3
4#include <SDL3/SDL_surface.h>
5#include "SDL3pp_blendmode.h"
6#include "SDL3pp_error.h"
7#include "SDL3pp_iostream.h"
8#include "SDL3pp_optionalRef.h"
9#include "SDL3pp_pixels.h"
10#include "SDL3pp_properties.h"
11#include "SDL3pp_rect.h"
12#include "SDL3pp_spanRef.h"
13#include "SDL3pp_strings.h"
14#include "SDL3pp_version.h"
15
16namespace SDL {
17
42// Forward decl
43struct Surface;
44
46using SurfaceRaw = SDL_Surface*;
47
48// Forward decl
49struct SurfaceRef;
50
53{
55
58 : value(value)
59 {
60 }
61
63 constexpr SurfaceConstRef(std::nullptr_t = nullptr)
64 : value(nullptr)
65 {
66 }
67
69 constexpr explicit operator bool() const { return !!value; }
70
72 constexpr auto operator<=>(const SurfaceConstRef& other) const = default;
73
75 constexpr operator const SurfaceRaw() const { return value; }
76
78 constexpr auto operator->() { return value; }
79};
80
81// Forward decl
82struct SurfaceLock;
83
92
94 SDL_SURFACE_PREALLOCATED;
95
97 SDL_SURFACE_LOCK_NEEDED;
98
100 SDL_SURFACE_LOCKED;
101
103constexpr SurfaceFlags SURFACE_SIMD_ALIGNED = SDL_SURFACE_SIMD_ALIGNED;
104
110constexpr bool MustLock(SurfaceConstRef S) { return SDL_MUSTLOCK((S.value)); }
111
117using ScaleMode = SDL_ScaleMode;
118
119#if SDL_VERSION_ATLEAST(3, 2, 10)
120
121constexpr ScaleMode SCALEMODE_INVALID = SDL_SCALEMODE_INVALID;
122
123#endif // SDL_VERSION_ATLEAST(3, 2, 10)
124
126 SDL_SCALEMODE_NEAREST;
127
129 SDL_SCALEMODE_LINEAR;
130
131#if SDL_VERSION_ATLEAST(3, 4, 0)
132
137constexpr ScaleMode SCALEMODE_PIXELART = SDL_SCALEMODE_PIXELART;
138
139#endif // SDL_VERSION_ATLEAST(3, 4, 0)
140
146using FlipMode = SDL_FlipMode;
147
148constexpr FlipMode FLIP_NONE = SDL_FLIP_NONE;
149
150constexpr FlipMode FLIP_HORIZONTAL = SDL_FLIP_HORIZONTAL;
151
152constexpr FlipMode FLIP_VERTICAL = SDL_FLIP_VERTICAL;
153
154#if SDL_VERSION_ATLEAST(3, 4, 0)
155
158 SDL_FLIP_HORIZONTAL_AND_VERTICAL;
159
160#endif // SDL_VERSION_ATLEAST(3, 4, 0)
161
191{
192 SurfaceRaw m_resource = nullptr;
193
194public:
196 constexpr Surface(std::nullptr_t = nullptr) noexcept
197 : m_resource(0)
198 {
199 }
200
208 constexpr explicit Surface(const SurfaceRaw resource) noexcept
209 : m_resource(resource)
210 {
211 }
212
214 constexpr Surface(const Surface& other)
215 : m_resource(other.m_resource)
216 {
217 if (m_resource) ++m_resource->refcount;
218 }
219
221 constexpr Surface(Surface&& other) noexcept
222 : Surface(other.release())
223 {
224 }
225
226 constexpr Surface(const SurfaceRef& other) = delete;
227
228 constexpr Surface(SurfaceRef&& other) = delete;
229
246 Surface(const PointRaw& size, PixelFormat format);
247
274 Surface(const PointRaw& size, PixelFormat format, void* pixels, int pitch);
275
312 Surface(StringParam file);
313
361 Surface(IOStreamRef src, bool closeio = false);
362
370 static constexpr Surface Borrow(SurfaceRaw resource)
371 {
372 if (resource) {
373 ++resource->refcount;
374 return Surface(resource);
375 }
376 return {};
377 }
378
399 static Surface LoadBMP(IOStreamRef src, bool closeio = false);
400
419 static Surface LoadBMP(StringParam file);
420
421#if SDL_VERSION_ATLEAST(3, 4, 0)
422
444 static Surface LoadPNG(IOStreamRef src, bool closeio = false);
445
468 static Surface LoadPNG(StringParam file);
469
470#endif // SDL_VERSION_ATLEAST(3, 4, 0)
471
473 constexpr const SurfaceRaw operator->() const noexcept { return m_resource; }
474
476 constexpr SurfaceRaw operator->() noexcept { return m_resource; }
477
479 constexpr operator SurfaceConstRef() const noexcept { return m_resource; }
480
482 ~Surface() { SDL_DestroySurface(m_resource); }
483
485 constexpr Surface& operator=(Surface&& other) noexcept
486 {
487 std::swap(m_resource, other.m_resource);
488 return *this;
489 }
490
492 constexpr Surface& operator=(const Surface& other) noexcept = default;
493
495 constexpr SurfaceRaw get() const noexcept { return m_resource; }
496
498 constexpr SurfaceRaw release() noexcept
499 {
500 auto r = m_resource;
501 m_resource = nullptr;
502 return r;
503 }
504
506 constexpr auto operator<=>(const Surface& other) const noexcept = default;
507
509 constexpr explicit operator bool() const noexcept { return !!m_resource; }
510
523 void Destroy();
524
530 constexpr bool MustLock() const { return SDL::MustLock(m_resource); }
531
570
587 void SetColorspace(Colorspace colorspace);
588
607
636
656 void SetPalette(PaletteRef palette);
657
670 Palette GetPalette() const;
671
695 void AddAlternateImage(SurfaceRef image);
696
710 bool HasAlternateImages() const;
711
731
748
774
786 void Unlock(SurfaceLock&& lock);
787
810 void SaveBMP(IOStreamRef dst, bool closeio = false) const;
811
832 void SaveBMP(StringParam file) const;
833
834#if SDL_VERSION_ATLEAST(3, 4, 0)
835
852 void SavePNG(IOStreamRef dst, bool closeio = false) const;
853
868 void SavePNG(StringParam file) const;
869
870#endif // SDL_VERSION_ATLEAST(3, 4, 0)
871
890 void SetRLE(bool enabled);
891
905 bool HasRLE() const;
906
928 void SetColorKey(std::optional<Uint32> key);
929
939 void ClearColorKey();
940
953 bool HasColorKey() const;
954
973 std::optional<Uint32> GetColorKey() const;
974
997 void SetColorMod(Uint8 r, Uint8 g, Uint8 b);
998
1015 void GetColorMod(Uint8* r, Uint8* g, Uint8* b) const;
1016
1036 void SetAlphaMod(Uint8 alpha);
1037
1050 Uint8 GetAlphaMod() const;
1051
1066 void SetMod(Color color);
1067
1075 Color GetMod() const;
1076
1094 void SetBlendMode(BlendMode blendMode);
1095
1108 BlendMode GetBlendMode() const;
1109
1133
1139 void ResetClipRect();
1140
1158 Rect GetClipRect() const;
1159
1171 void Flip(FlipMode flip);
1172
1173#if SDL_VERSION_ATLEAST(3, 4, 0)
1174
1201 Surface Rotate(float angle);
1202
1203#endif // SDL_VERSION_ATLEAST(3, 4, 0)
1204
1221 Surface Duplicate() const;
1222
1239 Surface Scale(const PointRaw& size, ScaleMode scaleMode) const;
1240
1267 Surface Convert(PixelFormat format) const;
1268
1297 PaletteRef palette,
1298 Colorspace colorspace,
1299 PropertiesRef props) const;
1300
1315 void PremultiplyAlpha(bool linear);
1316
1333 void Clear(const FColorRaw& c);
1334
1359 void FillRect(OptionalRef<const RectRaw> rect, Uint32 color);
1360
1371 void Fill(Uint32 color);
1372
1396 void FillRects(SpanRef<const RectRaw> rects, Uint32 color);
1397
1467 void Blit(SurfaceRef src,
1470
1541 void BlitAt(SurfaceRef src,
1543 const PointRaw& dstpos);
1544
1565 void BlitUnchecked(SurfaceRef src,
1566 const RectRaw& srcrect,
1567 const RectRaw& dstrect);
1568
1589 void BlitScaled(SurfaceRef src,
1592 ScaleMode scaleMode);
1593
1616 const RectRaw& srcrect,
1617 const RectRaw& dstrect,
1618 ScaleMode scaleMode);
1619
1620#if SDL_VERSION_ATLEAST(3, 4, 0)
1621
1641 void Stretch(SurfaceRef src,
1642 OptionalRef<RectRaw> srcrect,
1643 OptionalRef<RectRaw> dstrect,
1644 ScaleMode scaleMode);
1645
1646#endif // SDL_VERSION_ATLEAST(3, 4, 0)
1647
1669 void BlitTiled(SurfaceRef src,
1672
1700 float scale,
1701 ScaleMode scaleMode,
1703
1736 void Blit9Grid(SurfaceRef src,
1738 int left_width,
1739 int right_width,
1740 int top_height,
1741 int bottom_height,
1743 float scale = 1,
1744 ScaleMode scaleMode = SCALEMODE_NEAREST);
1745
1776 Uint32 MapRGB(Uint8 r, Uint8 g, Uint8 b) const;
1777
1806 Uint32 MapRGBA(ColorRaw c) const;
1807
1833 void ReadPixel(const PointRaw& p,
1834 Uint8* r,
1835 Uint8* g,
1836 Uint8* b,
1837 Uint8* a) const;
1838
1854 Color ReadPixel(const PointRaw& p) const;
1855
1878 void ReadPixelFloat(const PointRaw& p,
1879 float* r,
1880 float* g,
1881 float* b,
1882 float* a) const;
1883
1899 FColor ReadPixelFloat(const PointRaw& p) const;
1900
1919 void WritePixel(const PointRaw& p, ColorRaw c);
1920
1936 void WritePixelFloat(const PointRaw& p, const FColorRaw& c);
1937
1939 constexpr int GetWidth() const;
1940
1942 constexpr int GetHeight() const;
1943
1945 constexpr Point GetSize() const;
1946
1948 constexpr int GetPitch() const;
1949
1951 constexpr PixelFormat GetFormat() const;
1952
1954 constexpr void* GetPixels() const;
1955};
1956
1963{
1964 using Surface::Surface;
1965
1973 SurfaceRef(SurfaceRaw resource) noexcept
1974 : Surface(resource)
1975 {
1976 }
1977
1985 constexpr SurfaceRef(const Surface& resource) noexcept
1986 : Surface(resource.get())
1987 {
1988 }
1989
1991 constexpr SurfaceRef(const SurfaceRef& other) noexcept
1992 : Surface(other.get())
1993 {
1994 }
1995
1997 constexpr SurfaceRef(SurfaceRef&& other) noexcept
1998 : Surface(other.release())
1999 {
2000 }
2001
2004
2006 constexpr SurfaceRef& operator=(SurfaceRef other) noexcept
2007 {
2008 std::swap(*this, other);
2009 return *this;
2010 }
2011
2013 constexpr operator SurfaceRaw() const noexcept { return get(); }
2014};
2015
2034{
2035 SurfaceRef m_lock;
2036
2037public:
2063 SurfaceLock(SurfaceRef resource);
2064
2066 SurfaceLock(const SurfaceLock& other) = delete;
2067
2069 constexpr SurfaceLock(SurfaceLock&& other) noexcept
2070 : m_lock(other.m_lock)
2071 {
2072 other.m_lock = {};
2073 }
2074
2087
2088 SurfaceLock& operator=(const SurfaceLock& other) = delete;
2089
2092 {
2093 std::swap(m_lock, other.m_lock);
2094 return *this;
2095 }
2096
2098 constexpr operator bool() const { return bool(m_lock); }
2099
2125 void ReadPixel(const PointRaw& p,
2126 Uint8* r,
2127 Uint8* g,
2128 Uint8* b,
2129 Uint8* a) const
2130 {
2131 m_lock.ReadPixel(p, r, g, b, a);
2132 }
2133
2152 Color ReadPixel(const PointRaw& p) const { return m_lock.ReadPixel(p); }
2153
2177 float* r,
2178 float* g,
2179 float* b,
2180 float* a) const
2181 {
2182 m_lock.ReadPixelFloat(p, r, g, b, a);
2183 }
2184
2201 {
2202 return m_lock.ReadPixelFloat(p);
2203 }
2204
2223 void WritePixel(const PointRaw& p, ColorRaw c) { m_lock.WritePixel(p, c); }
2224
2240 void WritePixelFloat(const PointRaw& p, const FColorRaw& c)
2241 {
2242 m_lock.WritePixelFloat(p, c);
2243 }
2244
2246 constexpr int GetWidth() const { return m_lock.GetWidth(); }
2247
2249 constexpr int GetHeight() const { return m_lock.GetHeight(); }
2250
2252 constexpr Point GetSize() const { return m_lock.GetSize(); }
2253
2255 constexpr int GetPitch() const { return m_lock.GetPitch(); }
2256
2258 constexpr PixelFormat GetFormat() const { return m_lock.GetFormat(); }
2259
2261 constexpr void* GetPixels() const { return m_lock.GetPixels(); }
2262
2274 void reset();
2275
2277 SurfaceRef get() { return m_lock; }
2278
2280 void release() { m_lock.release(); }
2281};
2282
2300inline Surface CreateSurface(const PointRaw& size, PixelFormat format)
2301{
2302 return Surface(size, format);
2303}
2304
2305inline Surface::Surface(const PointRaw& size, PixelFormat format)
2306 : m_resource(CheckError(SDL_CreateSurface(size.x, size.y, format)))
2307{
2308}
2309
2310inline Surface::Surface(const PointRaw& size,
2311 PixelFormat format,
2312 void* pixels,
2313 int pitch)
2314 : m_resource(
2315 CheckError(SDL_CreateSurfaceFrom(size.x, size.y, format, pixels, pitch)))
2316{
2317}
2318
2346 PixelFormat format,
2347 void* pixels,
2348 int pitch)
2349{
2350 return Surface(size, format, pixels, pitch);
2351}
2352
2367inline void DestroySurface(SurfaceRaw surface) { SDL_DestroySurface(surface); }
2368
2370
2409{
2410 return {CheckError(SDL_GetSurfaceProperties(surface))};
2411}
2412
2414{
2415 return SDL::GetSurfaceProperties(m_resource);
2416}
2417
2418namespace prop::Surface {
2419
2420constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT;
2421
2422constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT;
2423
2424constexpr auto TONEMAP_OPERATOR_STRING =
2425 SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING;
2426
2427#if SDL_VERSION_ATLEAST(3, 2, 6)
2428
2429constexpr auto HOTSPOT_X_NUMBER = SDL_PROP_SURFACE_HOTSPOT_X_NUMBER;
2430
2431constexpr auto HOTSPOT_Y_NUMBER = SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER;
2432
2433#endif // SDL_VERSION_ATLEAST(3, 2, 6)
2434
2435#if SDL_VERSION_ATLEAST(3, 4, 0)
2436
2437constexpr auto ROTATION_FLOAT = SDL_PROP_SURFACE_ROTATION_FLOAT;
2438
2439#endif // SDL_VERSION_ATLEAST(3, 4, 0)
2440
2441} // namespace prop::Surface
2442
2460inline void SetSurfaceColorspace(SurfaceRef surface, Colorspace colorspace)
2461{
2462 CheckError(SDL_SetSurfaceColorspace(surface, colorspace));
2463}
2464
2465inline void Surface::SetColorspace(Colorspace colorspace)
2466{
2467 SDL::SetSurfaceColorspace(m_resource, colorspace);
2468}
2469
2489{
2490 return SDL_GetSurfaceColorspace(surface);
2491}
2492
2494{
2495 return SDL::GetSurfaceColorspace(m_resource);
2496}
2497
2526{
2527 return Palette::Borrow(CheckError(SDL_CreateSurfacePalette(surface)));
2528}
2529
2531{
2532 return SDL::CreateSurfacePalette(m_resource);
2533}
2534
2555inline void SetSurfacePalette(SurfaceRef surface, PaletteRef palette)
2556{
2557 CheckError(SDL_SetSurfacePalette(surface, palette));
2558}
2559
2561{
2562 SDL::SetSurfacePalette(m_resource, palette);
2563}
2564
2579{
2580 return Palette::Borrow(SDL_GetSurfacePalette(surface));
2581}
2582
2584{
2585 return SDL::GetSurfacePalette(m_resource);
2586}
2587
2614{
2615 CheckError(SDL_AddSurfaceAlternateImage(surface, image));
2616}
2617
2619{
2620 SDL::AddSurfaceAlternateImage(m_resource, image);
2621}
2622
2638{
2639 return SDL_SurfaceHasAlternateImages(surface);
2640}
2641
2643{
2644 return SDL::SurfaceHasAlternateImages(m_resource);
2645}
2646
2671{
2672 int count = 0;
2673 auto data = SDL_GetSurfaceImages(surface, &count);
2674 return OwnArray<SurfaceRaw>(CheckError(data), count);
2675}
2676
2678{
2679 return SDL::GetSurfaceImages(m_resource);
2680}
2681
2700{
2701 SDL_RemoveSurfaceAlternateImages(surface);
2702}
2703
2705{
2707}
2708
2734inline void LockSurface(SurfaceRef surface)
2735{
2736 CheckError(SDL_LockSurface(surface));
2737}
2738
2739inline SurfaceLock Surface::Lock() { return {SurfaceRef(*this)}; }
2740
2742 : m_lock(std::move(resource))
2743{
2744 LockSurface(m_lock);
2745}
2746
2760inline void UnlockSurface(SurfaceRef surface) { SDL_UnlockSurface(surface); }
2761
2762inline void Surface::Unlock(SurfaceLock&& lock)
2763{
2764 SDL_assert_paranoid(lock.get() == *this);
2765 lock.reset();
2766}
2767
2769{
2770 if (!m_lock) return;
2771 UnlockSurface(m_lock);
2772 m_lock = {};
2773}
2774
2775#ifndef SDL3PP_ENABLE_IMAGE
2776#if SDL_VERSION_ATLEAST(3, 4, 0)
2777
2797inline Surface LoadSurface(IOStreamRef src, bool closeio = false)
2798{
2799 return Surface{SDL_LoadSurface_IO(src, closeio)};
2800}
2801
2819inline Surface LoadSurface(StringParam file)
2820{
2821 return Surface{SDL_LoadSurface(file)};
2822}
2823#endif // SDL_VERSION_ATLEAST(3, 4, 0)
2824#endif // SDL3PP_ENABLE_IMAGE
2825
2846inline Surface LoadBMP(IOStreamRef src, bool closeio = false)
2847{
2848 return Surface(SDL_LoadBMP_IO(src, closeio));
2849}
2850
2869inline Surface LoadBMP(StringParam file) { return Surface(SDL_LoadBMP(file)); }
2870
2871inline Surface Surface::LoadBMP(IOStreamRef src, bool closeio)
2872{
2873 return SDL::LoadBMP(src, closeio);
2874}
2875
2877{
2878 return SDL::LoadBMP(std::move(file));
2879}
2880
2904inline void SaveBMP(SurfaceConstRef surface,
2905 IOStreamRef dst,
2906 bool closeio = false)
2907{
2908 CheckError(SDL_SaveBMP_IO(surface, dst, closeio));
2909}
2910
2932inline void SaveBMP(SurfaceConstRef surface, StringParam file)
2933{
2934 CheckError(SDL_SaveBMP(surface, file));
2935}
2936
2937inline void Surface::SaveBMP(IOStreamRef dst, bool closeio) const
2938{
2939 SDL::SaveBMP(m_resource, dst, closeio);
2940}
2941
2942inline void Surface::SaveBMP(StringParam file) const
2943{
2944 SDL::SaveBMP(m_resource, std::move(file));
2945}
2946
2947#if SDL_VERSION_ATLEAST(3, 4, 0)
2948
2973inline Surface LoadPNG(IOStreamRef src, bool closeio = false)
2974{
2975 return Surface(SDL_LoadPNG_IO(src, closeio));
2976}
2977
3000inline Surface LoadPNG(StringParam file) { return Surface(SDL_LoadPNG(file)); }
3001
3002inline Surface Surface::LoadPNG(IOStreamRef src, bool closeio)
3003{
3004 return SDL::LoadPNG(src, closeio);
3005}
3006
3008{
3009 return SDL::LoadPNG(std::move(file));
3010}
3011
3029inline void SavePNG(SurfaceConstRef surface,
3030 IOStreamRef dst,
3031 bool closeio = false)
3032{
3033 CheckError(SDL_SavePNG_IO(surface, dst, closeio));
3034}
3035
3051inline void SavePNG(SurfaceConstRef surface, StringParam file)
3052{
3053 CheckError(SDL_SavePNG(surface, file));
3054}
3055
3056inline void Surface::SavePNG(IOStreamRef dst, bool closeio) const
3057{
3058 SDL::SavePNG(m_resource, dst, closeio);
3059}
3060
3061inline void Surface::SavePNG(StringParam file) const
3062{
3063 SDL::SavePNG(m_resource, std::move(file));
3064}
3065
3066#endif // SDL_VERSION_ATLEAST(3, 4, 0)
3067
3087inline void SetSurfaceRLE(SurfaceRef surface, bool enabled)
3088{
3089 CheckError(SDL_SetSurfaceRLE(surface, enabled));
3090}
3091
3092inline void Surface::SetRLE(bool enabled)
3093{
3094 SDL::SetSurfaceRLE(m_resource, enabled);
3095}
3096
3111inline bool SurfaceHasRLE(SurfaceConstRef surface)
3112{
3113 return SDL_SurfaceHasRLE(surface);
3114}
3115
3116inline bool Surface::HasRLE() const { return SDL::SurfaceHasRLE(m_resource); }
3117
3140inline void SetSurfaceColorKey(SurfaceRef surface, std::optional<Uint32> key)
3141{
3142 CheckError(SDL_SetSurfaceColorKey(surface, key.has_value(), key.value_or(0)));
3143}
3144
3145inline void Surface::SetColorKey(std::optional<Uint32> key)
3146{
3147 SDL::SetSurfaceColorKey(m_resource, key);
3148}
3149
3161{
3162 SetSurfaceColorKey(surface, std::nullopt);
3163}
3164
3166
3183{
3184 return SDL_SurfaceHasColorKey(surface);
3185}
3186
3187inline bool Surface::HasColorKey() const
3188{
3189 return SDL::SurfaceHasColorKey(m_resource);
3190}
3191
3211inline std::optional<Uint32> GetSurfaceColorKey(SurfaceConstRef surface)
3212{
3213 if (Uint32 key; SDL_GetSurfaceColorKey(surface, &key)) return key;
3214 return std::nullopt;
3215}
3216
3217inline std::optional<Uint32> Surface::GetColorKey() const
3218{
3219 return SDL::GetSurfaceColorKey(m_resource);
3220}
3221
3245inline void SetSurfaceColorMod(SurfaceRef surface, Uint8 r, Uint8 g, Uint8 b)
3246{
3247 CheckError(SDL_SetSurfaceColorMod(surface, r, g, b));
3248}
3249
3251{
3252 SDL::SetSurfaceColorMod(m_resource, r, g, b);
3253}
3254
3273 Uint8* r,
3274 Uint8* g,
3275 Uint8* b)
3276{
3277 CheckError(SDL_GetSurfaceColorMod(surface, r, g, b));
3278}
3279
3280inline void Surface::GetColorMod(Uint8* r, Uint8* g, Uint8* b) const
3281{
3282 SDL::GetSurfaceColorMod(m_resource, r, g, b);
3283}
3284
3305inline void SetSurfaceAlphaMod(SurfaceRef surface, Uint8 alpha)
3306{
3307 CheckError(SDL_SetSurfaceAlphaMod(surface, alpha));
3308}
3309
3310inline void Surface::SetAlphaMod(Uint8 alpha)
3311{
3312 SDL::SetSurfaceAlphaMod(m_resource, alpha);
3313}
3314
3330{
3331 Uint8 alpha;
3332 CheckError(SDL_GetSurfaceAlphaMod(surface, &alpha));
3333 return alpha;
3334}
3335
3337{
3338 return SDL::GetSurfaceAlphaMod(m_resource);
3339}
3340
3356inline void SetSurfaceMod(SurfaceRef surface, Color color)
3357{
3358 SetSurfaceColorMod(surface, color.r, color.g, color.b);
3359 SetSurfaceAlphaMod(surface, color.a);
3360}
3361
3362inline void Surface::SetMod(Color color) { SetSurfaceMod(m_resource, color); }
3363
3373{
3374 Color c;
3375 GetSurfaceColorMod(surface, &c.r, &c.g, &c.b);
3376 c.a = GetSurfaceAlphaMod(surface);
3377 return c;
3378}
3379
3380inline Color Surface::GetMod() const { return SDL::GetSurfaceMod(m_resource); }
3381
3400inline void SetSurfaceBlendMode(SurfaceRef surface, BlendMode blendMode)
3401{
3402 CheckError(SDL_SetSurfaceBlendMode(surface, blendMode));
3403}
3404
3405inline void Surface::SetBlendMode(BlendMode blendMode)
3406{
3407 SDL::SetSurfaceBlendMode(m_resource, blendMode);
3408}
3409
3424{
3425 BlendMode blendmode;
3426 CheckError(SDL_GetSurfaceBlendMode(surface, &blendmode));
3427 return blendmode;
3428}
3429
3431{
3432 return SDL::GetSurfaceBlendMode(m_resource);
3433}
3434
3457inline bool SetSurfaceClipRect(SurfaceRef surface,
3459{
3460 return SDL_SetSurfaceClipRect(surface, rect);
3461}
3462
3464{
3465 return SDL::SetSurfaceClipRect(m_resource, rect);
3466}
3467
3474{
3475 SetSurfaceClipRect(surface, std::nullopt);
3476}
3477
3479
3499{
3500 Rect r;
3501 CheckError(SDL_GetSurfaceClipRect(surface, &r));
3502 return r;
3503}
3504
3506{
3507 return SDL::GetSurfaceClipRect(m_resource);
3508}
3509
3522inline void FlipSurface(SurfaceRef surface, FlipMode flip)
3523{
3524 CheckError(SDL_FlipSurface(surface, flip));
3525}
3526
3527inline void Surface::Flip(FlipMode flip) { SDL::FlipSurface(m_resource, flip); }
3528
3529#if SDL_VERSION_ATLEAST(3, 4, 0)
3530
3558inline Surface RotateSurface(SurfaceRef surface, float angle)
3559{
3560 return Surface{SDL_RotateSurface(surface, angle)};
3561}
3562
3563inline Surface Surface::Rotate(float angle)
3564{
3565 return SDL::RotateSurface(m_resource, angle);
3566}
3567
3568#endif // SDL_VERSION_ATLEAST(3, 4, 0)
3569
3590{
3591 return Surface(SDL_DuplicateSurface(surface));
3592}
3593
3595{
3596 return SDL::DuplicateSurface(m_resource);
3597}
3598
3619 const PointRaw& size,
3620 ScaleMode scaleMode)
3621{
3622 return Surface(SDL_ScaleSurface(surface, size.x, size.y, scaleMode));
3623}
3624
3625inline Surface Surface::Scale(const PointRaw& size, ScaleMode scaleMode) const
3626{
3627 return SDL::ScaleSurface(m_resource, size, scaleMode);
3628}
3629
3658{
3659 return Surface(SDL_ConvertSurface(surface, format));
3660}
3661
3663{
3664 return SDL::ConvertSurface(m_resource, format);
3665}
3666
3696 PixelFormat format,
3697 PaletteRef palette,
3698 Colorspace colorspace,
3699 PropertiesRef props)
3700{
3701 return Surface{SDL_ConvertSurfaceAndColorspace(
3702 surface, format, palette, colorspace, props)};
3703}
3704
3706 PaletteRef palette,
3707 Colorspace colorspace,
3708 PropertiesRef props) const
3709{
3711 m_resource, format, palette, colorspace, props);
3712}
3713
3734inline void ConvertPixels(const PointRaw& size,
3735 PixelFormat src_format,
3736 const void* src,
3737 int src_pitch,
3738 PixelFormat dst_format,
3739 void* dst,
3740 int dst_pitch)
3741{
3742 CheckError(SDL_ConvertPixels(
3743 size.x, size.y, src_format, src, src_pitch, dst_format, dst, dst_pitch));
3744}
3745
3775inline void ConvertPixelsAndColorspace(const PointRaw& size,
3776 PixelFormat src_format,
3777 Colorspace src_colorspace,
3778 PropertiesRef src_properties,
3779 const void* src,
3780 int src_pitch,
3781 PixelFormat dst_format,
3782 Colorspace dst_colorspace,
3783 PropertiesRef dst_properties,
3784 void* dst,
3785 int dst_pitch)
3786{
3787 CheckError(SDL_ConvertPixelsAndColorspace(size.x,
3788 size.y,
3789 src_format,
3790 src_colorspace,
3791 src_properties,
3792 src,
3793 src_pitch,
3794 dst_format,
3795 dst_colorspace,
3796 dst_properties,
3797 dst,
3798 dst_pitch));
3799}
3800
3823inline void PremultiplyAlpha(const PointRaw& size,
3824 PixelFormat src_format,
3825 const void* src,
3826 int src_pitch,
3827 PixelFormat dst_format,
3828 void* dst,
3829 int dst_pitch,
3830 bool linear)
3831{
3832 CheckError(SDL_PremultiplyAlpha(size.x,
3833 size.y,
3834 src_format,
3835 src,
3836 src_pitch,
3837 dst_format,
3838 dst,
3839 dst_pitch,
3840 linear));
3841}
3842
3858inline void PremultiplySurfaceAlpha(SurfaceRef surface, bool linear)
3859{
3860 CheckError(SDL_PremultiplySurfaceAlpha(surface, linear));
3861}
3862
3863inline void Surface::PremultiplyAlpha(bool linear)
3864{
3865 SDL::PremultiplySurfaceAlpha(m_resource, linear);
3866}
3867
3885inline void ClearSurface(SurfaceRef surface, const FColorRaw& c)
3886{
3887 CheckError(SDL_ClearSurface(surface, c.r, c.g, c.b, c.a));
3888}
3889
3890inline void Surface::Clear(const FColorRaw& c)
3891{
3892 SDL::ClearSurface(m_resource, c);
3893}
3894
3922 Uint32 color)
3923{
3924 CheckError(SDL_FillSurfaceRect(dst, rect, color));
3925}
3926
3928{
3929 SDL::FillSurfaceRect(m_resource, rect, color);
3930}
3931
3943inline void FillSurface(SurfaceRef dst, Uint32 color)
3944{
3945 FillSurfaceRect(dst, std::nullopt, color);
3946}
3947
3948inline void Surface::Fill(Uint32 color) { SDL::FillSurface(m_resource, color); }
3949
3976 Uint32 color)
3977{
3978 CheckError(SDL_FillSurfaceRects(dst, rects.data(), rects.size(), color));
3979}
3980
3982{
3983 SDL::FillSurfaceRects(m_resource, rects, color);
3984}
3985
4056inline void BlitSurface(SurfaceRef src,
4058 SurfaceRef dst,
4060{
4061 CheckError(SDL_BlitSurface(src, srcrect, dst, dstrect));
4062}
4063
4067{
4068 SDL::BlitSurface(src, srcrect, m_resource, dstrect);
4069}
4070
4073 const PointRaw& dstpos)
4074{
4075 Blit(src, srcrect, Rect{dstpos, {}});
4076}
4077
4147 SurfaceRef dst,
4148 const PointRaw& dstpos)
4149{
4150 BlitSurface(src, srcrect, dst, SDL_Rect{dstpos.x, dstpos.y});
4151}
4152
4175 const RectRaw& srcrect,
4176 SurfaceRef dst,
4177 const RectRaw& dstrect)
4178{
4179 CheckError(SDL_BlitSurfaceUnchecked(src, &srcrect, dst, &dstrect));
4180}
4181
4183 const RectRaw& srcrect,
4184 const RectRaw& dstrect)
4185{
4186 SDL::BlitSurfaceUnchecked(src, srcrect, m_resource, dstrect);
4187}
4188
4212 SurfaceRef dst,
4214 ScaleMode scaleMode)
4215{
4216 CheckError(SDL_BlitSurfaceScaled(src, srcrect, dst, dstrect, scaleMode));
4217}
4218
4222 ScaleMode scaleMode)
4223{
4224 SDL::BlitSurfaceScaled(src, srcrect, m_resource, dstrect, scaleMode);
4225}
4226
4250 const RectRaw& srcrect,
4251 SurfaceRef dst,
4252 const RectRaw& dstrect,
4253 ScaleMode scaleMode)
4254{
4255 CheckError(
4256 SDL_BlitSurfaceUncheckedScaled(src, &srcrect, dst, &dstrect, scaleMode));
4257}
4258
4260 const RectRaw& srcrect,
4261 const RectRaw& dstrect,
4262 ScaleMode scaleMode)
4263{
4264 SDL::BlitSurfaceUncheckedScaled(src, srcrect, m_resource, dstrect, scaleMode);
4265}
4266
4267#if SDL_VERSION_ATLEAST(3, 4, 0)
4268
4290 OptionalRef<RectRaw> srcrect,
4291 SurfaceRef dst,
4292 OptionalRef<RectRaw> dstrect,
4293 ScaleMode scaleMode)
4294{
4295 CheckError(SDL_StretchSurface(src, srcrect, dst, dstrect, scaleMode));
4296}
4297
4299 OptionalRef<RectRaw> srcrect,
4300 OptionalRef<RectRaw> dstrect,
4301 ScaleMode scaleMode)
4302{
4303 SDL::StretchSurface(src, srcrect, m_resource, dstrect, scaleMode);
4304}
4305
4306#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4307
4332 SurfaceRef dst,
4334{
4335 CheckError(SDL_BlitSurfaceTiled(src, srcrect, dst, dstrect));
4336}
4337
4341{
4342 SDL::BlitSurfaceTiled(src, srcrect, m_resource, dstrect);
4343}
4344
4373 float scale,
4374 ScaleMode scaleMode,
4375 SurfaceRef dst,
4377{
4378 CheckError(SDL_BlitSurfaceTiledWithScale(
4379 src, srcrect, scale, scaleMode, dst, dstrect));
4380}
4381
4384 float scale,
4385 ScaleMode scaleMode,
4387{
4389 src, srcrect, scale, scaleMode, m_resource, dstrect);
4390}
4391
4427 int left_width,
4428 int right_width,
4429 int top_height,
4430 int bottom_height,
4431 SurfaceRef dst,
4433 float scale = 1,
4434 ScaleMode scaleMode = SCALEMODE_NEAREST)
4435{
4436 CheckError(SDL_BlitSurface9Grid(src,
4437 srcrect,
4438 left_width,
4439 right_width,
4440 top_height,
4441 bottom_height,
4442 scale,
4443 scaleMode,
4444 dst,
4445 dstrect));
4446}
4447
4450 int left_width,
4451 int right_width,
4452 int top_height,
4453 int bottom_height,
4455 float scale,
4456 ScaleMode scaleMode)
4457{
4459 srcrect,
4460 left_width,
4461 right_width,
4462 top_height,
4463 bottom_height,
4464 m_resource,
4465 dstrect,
4466 scale,
4467 scaleMode);
4468}
4469
4502{
4503 return SDL_MapSurfaceRGB(surface, r, g, b);
4504}
4505
4507{
4508 return SDL::MapSurfaceRGB(m_resource, r, g, b);
4509}
4510
4541{
4542 return SDL_MapSurfaceRGBA(surface, c.r, c.g, c.b, c.a);
4543}
4544
4546{
4547 return SDL::MapSurfaceRGBA(m_resource, c);
4548}
4549
4577 const PointRaw& p,
4578 Uint8* r,
4579 Uint8* g,
4580 Uint8* b,
4581 Uint8* a)
4582{
4583 CheckError(SDL_ReadSurfacePixel(surface, p.x, p.y, r, g, b, a));
4584}
4585
4606{
4607 Color c;
4608 ReadSurfacePixel(surface, p, &c.r, &c.g, &c.b, &c.a);
4609 return c;
4610}
4611
4638inline void ReadSurfacePixel(const SurfaceLock& lock,
4639 const PointRaw& p,
4640 Uint8* r,
4641 Uint8* g,
4642 Uint8* b,
4643 Uint8* a)
4644{
4645 lock.ReadPixel(p, r, g, b, a);
4646}
4647
4667inline Color ReadSurfacePixel(const SurfaceLock& lock, const PointRaw& p)
4668{
4669 return lock.ReadPixel(p);
4670}
4671
4672inline void Surface::ReadPixel(const PointRaw& p,
4673 Uint8* r,
4674 Uint8* g,
4675 Uint8* b,
4676 Uint8* a) const
4677{
4678 SDL::ReadSurfacePixel(m_resource, p, r, g, b, a);
4679}
4680
4681inline Color Surface::ReadPixel(const PointRaw& p) const
4682{
4683 return SDL::ReadSurfacePixel(m_resource, p);
4684}
4685
4710 const PointRaw& p,
4711 float* r,
4712 float* g,
4713 float* b,
4714 float* a)
4715{
4716 CheckError(SDL_ReadSurfacePixelFloat(surface, p.x, p.y, r, g, b, a));
4717}
4718
4736{
4737 FColor c;
4738 ReadSurfacePixelFloat(surface, p, &c.r, &c.g, &c.b, &c.a);
4739 return c;
4740}
4741
4765inline void ReadSurfacePixelFloat(const SurfaceLock& lock,
4766 const PointRaw& p,
4767 float* r,
4768 float* g,
4769 float* b,
4770 float* a)
4771{
4772 lock.ReadPixelFloat(p, r, g, b, a);
4773}
4774
4792{
4793 return lock.ReadPixelFloat(p);
4794}
4795
4797 float* r,
4798 float* g,
4799 float* b,
4800 float* a) const
4801{
4802 SDL::ReadSurfacePixelFloat(m_resource, p, r, g, b, a);
4803}
4804
4806{
4807 return SDL::ReadSurfacePixelFloat(m_resource, p);
4808}
4809
4829inline void WriteSurfacePixel(SurfaceRef surface, const PointRaw& p, ColorRaw c)
4830{
4831 CheckError(SDL_WriteSurfacePixel(surface, p.x, p.y, c.r, c.g, c.b, c.a));
4832}
4833
4853inline void WriteSurfacePixel(SurfaceLock& lock, const PointRaw& p, ColorRaw c)
4854{
4855 lock.WritePixel(p, c);
4856}
4857
4858inline void Surface::WritePixel(const PointRaw& p, ColorRaw c)
4859{
4860 SDL::WriteSurfacePixel(m_resource, p, c);
4861}
4862
4880 const PointRaw& p,
4881 const FColorRaw& c)
4882{
4883 CheckError(SDL_WriteSurfacePixelFloat(surface, p.x, p.y, c.r, c.g, c.b, c.a));
4884}
4885
4903 const PointRaw& p,
4904 const FColorRaw& c)
4905{
4906 lock.WritePixelFloat(p, c);
4907}
4908
4909inline void Surface::WritePixelFloat(const PointRaw& p, const FColorRaw& c)
4910{
4911 SDL::WriteSurfacePixelFloat(m_resource, p, c);
4912}
4913
4915constexpr int GetSurfaceWidth(SurfaceConstRef surface) { return surface->w; }
4916
4918constexpr int GetSurfaceWidth(const SurfaceLock& lock)
4919{
4920 return lock.GetWidth();
4921}
4922
4923constexpr int Surface::GetWidth() const
4924{
4925 return SDL::GetSurfaceWidth(m_resource);
4926}
4927
4929constexpr int GetSurfaceHeight(SurfaceConstRef surface) { return surface->h; }
4930
4932constexpr int GetSurfaceHeight(const SurfaceLock& lock)
4933{
4934 return lock.GetHeight();
4935}
4936
4937constexpr int Surface::GetHeight() const
4938{
4939 return SDL::GetSurfaceHeight(m_resource);
4940}
4941
4944{
4945 return Point(surface->w, surface->h);
4946}
4947
4949constexpr Point GetSurfaceSize(const SurfaceLock& lock)
4950{
4951 return lock.GetSize();
4952}
4953
4954constexpr Point Surface::GetSize() const
4955{
4956 return SDL::GetSurfaceSize(m_resource);
4957}
4958
4960constexpr int GetSurfacePitch(SurfaceConstRef surface)
4961{
4962 return surface->pitch;
4963}
4964
4966constexpr int GetSurfacePitch(const SurfaceLock& lock)
4967{
4968 return lock.GetPitch();
4969}
4970
4971constexpr int Surface::GetPitch() const
4972{
4973 return SDL::GetSurfacePitch(m_resource);
4974}
4975
4978{
4979 return surface->format;
4980}
4981
4984{
4985 return lock.GetFormat();
4986}
4987
4989{
4990 return SDL::GetSurfaceFormat(m_resource);
4991}
4992
4994constexpr void* GetSurfacePixels(SurfaceConstRef surface)
4995{
4996 return surface->pixels;
4997}
4998
5000constexpr void* GetSurfacePixels(const SurfaceLock& lock)
5001{
5002 return lock.GetPixels();
5003}
5004
5005constexpr void* Surface::GetPixels() const
5006{
5007 return SDL::GetSurfacePixels(m_resource);
5008}
5009
5011
5012} // namespace SDL
5013
5014#endif /* SDL3PP_SURFACE_H_ */
Colorspace definitions.
Definition: SDL3pp_pixels.h:1628
Optional-like shim for references.
Definition: SDL3pp_optionalRef.h:20
Base class for SDL memory allocated array wrap.
Definition: SDL3pp_ownPtr.h:44
A set of indexed colors representing a palette.
Definition: SDL3pp_pixels.h:2482
static constexpr Palette Borrow(PaletteRaw resource)
Safely borrows the from PaletteRaw.
Definition: SDL3pp_pixels.h:2547
Pixel format.
Definition: SDL3pp_pixels.h:379
span-like for empty-derived structs
Definition: SDL3pp_spanRef.h:24
constexpr T * data() const
Retrieves contained data.
Definition: SDL3pp_spanRef.h:75
constexpr size_t size() const
Retrieves contained size.
Definition: SDL3pp_spanRef.h:69
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
Set up a surface for directly accessing the pixels.
Definition: SDL3pp_surface.h:2034
constexpr PixelFormat GetFormat() const
Get the pixel format.
Definition: SDL3pp_surface.h:2258
FColor ReadPixelFloat(const PointRaw &p) const
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:2200
~SurfaceLock()
Release a surface after directly accessing the pixels.
Definition: SDL3pp_surface.h:2086
constexpr int GetHeight() const
Get the height in pixels.
Definition: SDL3pp_surface.h:2249
constexpr int GetWidth() const
Get the width in pixels.
Definition: SDL3pp_surface.h:2246
SurfaceRef get()
Get the reference to locked resource.
Definition: SDL3pp_surface.h:2277
constexpr void * GetPixels() const
Get the pixels.
Definition: SDL3pp_surface.h:2261
void release()
Releases the lock without unlocking.
Definition: SDL3pp_surface.h:2280
void ReadPixel(const PointRaw &p, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:2125
constexpr SurfaceLock(SurfaceLock &&other) noexcept
Move constructor.
Definition: SDL3pp_surface.h:2069
void WritePixelFloat(const PointRaw &p, const FColorRaw &c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:2240
SurfaceLock & operator=(SurfaceLock &&other) noexcept
Assignment operator.
Definition: SDL3pp_surface.h:2091
void WritePixel(const PointRaw &p, ColorRaw c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:2223
constexpr Point GetSize() const
Get the size in pixels.
Definition: SDL3pp_surface.h:2252
Color ReadPixel(const PointRaw &p) const
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:2152
SurfaceLock(const SurfaceLock &other)=delete
Copy constructor.
void ReadPixelFloat(const PointRaw &p, float *r, float *g, float *b, float *a) const
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:2176
constexpr int GetPitch() const
Get pitch in bytes.
Definition: SDL3pp_surface.h:2255
A collection of pixels used in software blitting.
Definition: SDL3pp_surface.h:191
constexpr const SurfaceRaw operator->() const noexcept
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:473
static constexpr Surface Borrow(SurfaceRaw resource)
Safely borrows the from SurfaceRaw.
Definition: SDL3pp_surface.h:370
constexpr SurfaceRaw release() noexcept
Retrieves underlying SurfaceRaw and clear this.
Definition: SDL3pp_surface.h:498
constexpr Surface & operator=(Surface &&other) noexcept
Assignment operator.
Definition: SDL3pp_surface.h:485
constexpr Surface(const Surface &other)
Copy constructor.
Definition: SDL3pp_surface.h:214
constexpr SurfaceRaw operator->() noexcept
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:476
constexpr Surface(Surface &&other) noexcept
Move constructor.
Definition: SDL3pp_surface.h:221
constexpr Surface(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_surface.h:196
constexpr Surface(const SurfaceRaw resource) noexcept
Constructs from SurfaceRef.
Definition: SDL3pp_surface.h:208
~Surface()
Destructor.
Definition: SDL3pp_surface.h:482
constexpr auto operator<=>(const Surface &other) const noexcept=default
Comparison.
constexpr Surface & operator=(const Surface &other) noexcept=default
Assignment operator.
constexpr SurfaceRaw get() const noexcept
Retrieves underlying SurfaceRaw.
Definition: SDL3pp_surface.h:495
constexpr bool MustLock() const
Evaluates to true if the surface needs to be locked before access.
Definition: SDL3pp_surface.h:530
#define SDL_assert_paranoid(condition)
An assertion test that is performed only when built with paranoid settings.
Definition: SDL3pp_assert.h:383
Uint32 BlendMode
A set of blend modes used in drawing operations.
Definition: SDL3pp_blendmode.h:35
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:197
SDL_FColor FColorRaw
Alias to raw representation for FColor.
Definition: SDL3pp_pixels.h:90
SDL_Color ColorRaw
Alias to raw representation for Color.
Definition: SDL3pp_pixels.h:84
SDL_Rect RectRaw
Alias to raw representation for Rect.
Definition: SDL3pp_rect.h:34
SDL_Point PointRaw
Alias to raw representation for Point.
Definition: SDL3pp_rect.h:22
Surface LoadPNG(IOStreamRef src)
Load a PNG image directly.
Definition: SDL3pp_image.h:1761
void SaveBMP(SurfaceRef surface, StringParam file)
Save an Surface into a BMP image file.
Definition: SDL3pp_image.h:2270
void SavePNG(SurfaceRef surface, StringParam file)
Save an Surface into a PNG image file.
Definition: SDL3pp_image.h:2484
Surface LoadSurface(StringParam file)
Load an image from a filesystem path into a software surface.
Definition: SDL3pp_image.h:167
Surface LoadBMP(IOStreamRef src)
Load a BMP image directly.
Definition: SDL3pp_image.h:1489
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:280
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:228
SurfaceLock(SurfaceRef resource)
Set up a surface for directly accessing the pixels.
Definition: SDL3pp_surface.h:2741
Rect GetClipRect() const
Get the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:3505
Palette GetPalette() const
Get the palette used by a surface.
Definition: SDL3pp_surface.h:2583
std::optional< Uint32 > GetColorKey() const
Get the color key (transparent pixel) for a surface.
Definition: SDL3pp_surface.h:3217
static Surface LoadBMP(IOStreamRef src, bool closeio=false)
Load a BMP image from a seekable SDL data stream.
Definition: SDL3pp_surface.h:2871
void BlitTiled(SurfaceRef src, OptionalRef< const RectRaw > srcrect, OptionalRef< const RectRaw > dstrect)
Perform a tiled blit to a destination surface, which may be of a different format.
Definition: SDL3pp_surface.h:4338
Palette CreateSurfacePalette(SurfaceRef surface)
Create a palette and associate it with a surface.
Definition: SDL3pp_surface.h:2525
constexpr FlipMode FLIP_VERTICAL
flip vertically
Definition: SDL3pp_surface.h:152
constexpr PixelFormat GetFormat() const
Get the pixel format.
Definition: SDL3pp_surface.h:4988
void Destroy()
Free a surface.
Definition: SDL3pp_surface.h:2369
void SetSurfaceColorKey(SurfaceRef surface, std::optional< Uint32 > key)
Set the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:3140
void AddAlternateImage(SurfaceRef image)
Add an alternate version of a surface.
Definition: SDL3pp_surface.h:2618
void WriteSurfacePixel(SurfaceRef surface, const PointRaw &p, ColorRaw c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:4829
void BlitSurfaceAt(SurfaceRef src, OptionalRef< const RectRaw > srcrect, SurfaceRef dst, const PointRaw &dstpos)
Performs a fast blit from the source surface to the destination surface with clipping.
Definition: SDL3pp_surface.h:4145
void BlitTiledWithScale(SurfaceRef src, OptionalRef< const RectRaw > srcrect, float scale, ScaleMode scaleMode, OptionalRef< const RectRaw > dstrect)
Perform a scaled and tiled blit to a destination surface, which may be of a different format.
Definition: SDL3pp_surface.h:4382
void AddSurfaceAlternateImage(SurfaceRef surface, SurfaceRef image)
Add an alternate version of a surface.
Definition: SDL3pp_surface.h:2613
void GetSurfaceColorMod(SurfaceConstRef surface, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:3272
void SetSurfaceMod(SurfaceRef surface, Color color)
Set an additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:3356
constexpr SurfaceFlags SURFACE_SIMD_ALIGNED
Surface uses pixel memory allocated with aligned_alloc()
Definition: SDL3pp_surface.h:103
BlendMode GetBlendMode() const
Get the blend mode used for blit operations.
Definition: SDL3pp_surface.h:3430
Uint32 MapSurfaceRGB(SurfaceConstRef surface, Uint8 r, Uint8 g, Uint8 b)
Map an RGB triple to an opaque pixel value for a surface.
Definition: SDL3pp_surface.h:4501
constexpr SurfaceFlags SURFACE_LOCK_NEEDED
Surface needs to be locked to access pixels.
Definition: SDL3pp_surface.h:96
void SetSurfaceAlphaMod(SurfaceRef surface, Uint8 alpha)
Set an additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:3305
BlendMode GetSurfaceBlendMode(SurfaceConstRef surface)
Get the blend mode used for blit operations.
Definition: SDL3pp_surface.h:3423
void RemoveSurfaceAlternateImages(SurfaceRef surface)
Remove all alternate versions of a surface.
Definition: SDL3pp_surface.h:2699
void DestroySurface(SurfaceRaw surface)
Free a surface.
Definition: SDL3pp_surface.h:2367
void ClearSurface(SurfaceRef surface, const FColorRaw &c)
Clear a surface with a specific color, with floating point precision.
Definition: SDL3pp_surface.h:3885
void FillRects(SpanRef< const RectRaw > rects, Uint32 color)
Perform a fast fill of a set of rectangles with a specific color.
Definition: SDL3pp_surface.h:3981
Uint32 MapRGB(Uint8 r, Uint8 g, Uint8 b) const
Map an RGB triple to an opaque pixel value for a surface.
Definition: SDL3pp_surface.h:4506
bool HasRLE() const
Returns whether the surface is RLE enabled.
Definition: SDL3pp_surface.h:3116
void LockSurface(SurfaceRef surface)
Set up a surface for directly accessing the pixels.
Definition: SDL3pp_surface.h:2734
constexpr int GetHeight() const
Get the height in pixels.
Definition: SDL3pp_surface.h:4937
constexpr FlipMode FLIP_NONE
Do not flip.
Definition: SDL3pp_surface.h:148
void BlitSurface(SurfaceRef src, OptionalRef< const RectRaw > srcrect, SurfaceRef dst, OptionalRef< const RectRaw > dstrect)
Performs a fast blit from the source surface to the destination surface with clipping.
Definition: SDL3pp_surface.h:4056
void BlitSurface9Grid(SurfaceRef src, OptionalRef< const RectRaw > srcrect, int left_width, int right_width, int top_height, int bottom_height, SurfaceRef dst, OptionalRef< const RectRaw > dstrect, float scale=1, ScaleMode scaleMode=SCALEMODE_NEAREST)
Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a differen...
Definition: SDL3pp_surface.h:4425
OwnArray< SurfaceRaw > GetSurfaceImages(SurfaceConstRef surface)
Get an array including all versions of a surface.
Definition: SDL3pp_surface.h:2670
constexpr bool MustLock(SurfaceConstRef S)
Evaluates to true if the surface needs to be locked before access.
Definition: SDL3pp_surface.h:110
constexpr int GetSurfaceWidth(SurfaceConstRef surface)
Get the width in pixels.
Definition: SDL3pp_surface.h:4915
Surface RotateSurface(SurfaceRef surface, float angle)
Return a copy of a surface rotated clockwise a number of degrees.
Definition: SDL3pp_surface.h:3558
void FillSurfaceRect(SurfaceRef dst, OptionalRef< const RectRaw > rect, Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3920
void PremultiplySurfaceAlpha(SurfaceRef surface, bool linear)
Premultiply the alpha in a surface.
Definition: SDL3pp_surface.h:3858
constexpr SurfaceFlags SURFACE_PREALLOCATED
Surface uses preallocated pixel memory.
Definition: SDL3pp_surface.h:93
bool HasColorKey() const
Returns whether the surface has a color key.
Definition: SDL3pp_surface.h:3187
constexpr ScaleMode SCALEMODE_LINEAR
linear filtering
Definition: SDL3pp_surface.h:128
void SetColorKey(std::optional< Uint32 > key)
Set the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:3145
void PremultiplyAlpha(bool linear)
Premultiply the alpha in a surface.
Definition: SDL3pp_surface.h:3863
void BlitSurfaceUnchecked(SurfaceRef src, const RectRaw &srcrect, SurfaceRef dst, const RectRaw &dstrect)
Perform low-level surface blitting only.
Definition: SDL3pp_surface.h:4174
Palette CreatePalette()
Create a palette and associate it with a surface.
Definition: SDL3pp_surface.h:2530
void reset()
Release a surface after directly accessing the pixels.
Definition: SDL3pp_surface.h:2768
void WriteSurfacePixelFloat(SurfaceRef surface, const PointRaw &p, const FColorRaw &c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:4879
bool SetSurfaceClipRect(SurfaceRef surface, OptionalRef< const RectRaw > rect)
Set the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:3457
Colorspace GetColorspace() const
Get the colorspace used by a surface.
Definition: SDL3pp_surface.h:2493
constexpr PixelFormat GetSurfaceFormat(SurfaceConstRef surface)
Get the pixel format.
Definition: SDL3pp_surface.h:4977
void SetSurfacePalette(SurfaceRef surface, PaletteRef palette)
Set the palette used by a surface.
Definition: SDL3pp_surface.h:2555
constexpr ScaleMode SCALEMODE_NEAREST
nearest pixel sampling
Definition: SDL3pp_surface.h:125
void Flip(FlipMode flip)
Flip a surface vertically or horizontally.
Definition: SDL3pp_surface.h:3527
Surface CreateSurfaceFrom(const PointRaw &size, PixelFormat format, void *pixels, int pitch)
Allocate a new surface with a specific pixel format and existing pixel data.
Definition: SDL3pp_surface.h:2345
void Blit(SurfaceRef src, OptionalRef< const RectRaw > srcrect, OptionalRef< const RectRaw > dstrect)
Performs a fast blit from the source surface to the destination surface with clipping.
Definition: SDL3pp_surface.h:4064
PropertiesRef GetSurfaceProperties(SurfaceConstRef surface)
Get the properties associated with a surface.
Definition: SDL3pp_surface.h:2408
void BlitSurfaceTiledWithScale(SurfaceRef src, OptionalRef< const RectRaw > srcrect, float scale, ScaleMode scaleMode, SurfaceRef dst, OptionalRef< const RectRaw > dstrect)
Perform a scaled and tiled blit to a destination surface, which may be of a different format.
Definition: SDL3pp_surface.h:4371
void ConvertPixelsAndColorspace(const PointRaw &size, PixelFormat src_format, Colorspace src_colorspace, PropertiesRef src_properties, const void *src, int src_pitch, PixelFormat dst_format, Colorspace dst_colorspace, PropertiesRef dst_properties, void *dst, int dst_pitch)
Copy a block of pixels of one format and colorspace to another format and colorspace.
Definition: SDL3pp_surface.h:3775
Colorspace GetSurfaceColorspace(SurfaceConstRef surface)
Get the colorspace used by a surface.
Definition: SDL3pp_surface.h:2488
void BlitSurfaceScaled(SurfaceRef src, OptionalRef< const RectRaw > srcrect, SurfaceRef dst, OptionalRef< const RectRaw > dstrect, ScaleMode scaleMode)
Perform a scaled blit to a destination surface, which may be of a different format.
Definition: SDL3pp_surface.h:4210
void ResetClipRect()
Disable the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:3478
void BlitSurfaceTiled(SurfaceRef src, OptionalRef< const RectRaw > srcrect, SurfaceRef dst, OptionalRef< const RectRaw > dstrect)
Perform a tiled blit to a destination surface, which may be of a different format.
Definition: SDL3pp_surface.h:4330
Surface ConvertSurface(SurfaceConstRef surface, PixelFormat format)
Copy an existing surface to a new surface of the specified format.
Definition: SDL3pp_surface.h:3657
PropertiesRef GetProperties() const
Get the properties associated with a surface.
Definition: SDL3pp_surface.h:2413
Surface DuplicateSurface(SurfaceConstRef surface)
Creates a new surface identical to the existing surface.
Definition: SDL3pp_surface.h:3589
constexpr ScaleMode SCALEMODE_PIXELART
nearest pixel sampling with improved scaling for pixel art, available since SDL 3....
Definition: SDL3pp_surface.h:137
Palette GetSurfacePalette(SurfaceConstRef surface)
Get the palette used by a surface.
Definition: SDL3pp_surface.h:2578
Surface ScaleSurface(SurfaceConstRef surface, const PointRaw &size, ScaleMode scaleMode)
Creates a new surface identical to the existing surface, scaled to the desired size.
Definition: SDL3pp_surface.h:3618
constexpr SurfaceFlags SURFACE_LOCKED
Surface is currently locked.
Definition: SDL3pp_surface.h:99
bool HasAlternateImages() const
Return whether a surface has alternate versions available.
Definition: SDL3pp_surface.h:2642
SDL_Surface * SurfaceRaw
Alias to raw representation for Surface.
Definition: SDL3pp_surface.h:46
constexpr int GetPitch() const
Get pitch in bytes.
Definition: SDL3pp_surface.h:4971
void BlitUncheckedScaled(SurfaceRef src, const RectRaw &srcrect, const RectRaw &dstrect, ScaleMode scaleMode)
Perform low-level surface scaled blitting only.
Definition: SDL3pp_surface.h:4259
Uint8 GetSurfaceAlphaMod(SurfaceConstRef surface)
Get the additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:3329
bool SurfaceHasColorKey(SurfaceConstRef surface)
Returns whether the surface has a color key.
Definition: SDL3pp_surface.h:3182
void Stretch(SurfaceRef src, OptionalRef< RectRaw > srcrect, OptionalRef< RectRaw > dstrect, ScaleMode scaleMode)
Perform a stretched pixel copy from one surface to another.
Definition: SDL3pp_surface.h:4298
void RemoveAlternateImages()
Remove all alternate versions of a surface.
Definition: SDL3pp_surface.h:2704
Surface Convert(PixelFormat format) const
Copy an existing surface to a new surface of the specified format.
Definition: SDL3pp_surface.h:3662
constexpr Point GetSize() const
Get the size in pixels.
Definition: SDL3pp_surface.h:4954
void SavePNG(IOStreamRef dst, bool closeio=false) const
Save a surface to a seekable SDL data stream in PNG format.
Definition: SDL3pp_surface.h:3056
void SetSurfaceBlendMode(SurfaceRef surface, BlendMode blendMode)
Set the blend mode used for blit operations.
Definition: SDL3pp_surface.h:3400
void SaveBMP(IOStreamRef dst, bool closeio=false) const
Save a surface to a seekable SDL data stream in BMP format.
Definition: SDL3pp_surface.h:2937
Uint8 GetAlphaMod() const
Get the additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:3336
Surface Duplicate() const
Creates a new surface identical to the existing surface.
Definition: SDL3pp_surface.h:3594
void Clear(const FColorRaw &c)
Clear a surface with a specific color, with floating point precision.
Definition: SDL3pp_surface.h:3890
void UnlockSurface(SurfaceRef surface)
Release a surface after directly accessing the pixels.
Definition: SDL3pp_surface.h:2760
void SetMod(Color color)
Set an additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:3362
SDL_FlipMode FlipMode
The flip mode.
Definition: SDL3pp_surface.h:146
static Surface LoadPNG(IOStreamRef src, bool closeio=false)
Load a PNG image from a seekable SDL data stream.
Definition: SDL3pp_surface.h:3002
bool SurfaceHasAlternateImages(SurfaceConstRef surface)
Return whether a surface has alternate versions available.
Definition: SDL3pp_surface.h:2637
bool SurfaceHasRLE(SurfaceConstRef surface)
Returns whether the surface is RLE enabled.
Definition: SDL3pp_surface.h:3111
void GetColorMod(Uint8 *r, Uint8 *g, Uint8 *b) const
Get the additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:3280
void StretchSurface(SurfaceRef src, OptionalRef< RectRaw > srcrect, SurfaceRef dst, OptionalRef< RectRaw > dstrect, ScaleMode scaleMode)
Perform a stretched pixel copy from one surface to another.
Definition: SDL3pp_surface.h:4289
SurfaceLock Lock()
Set up a surface for directly accessing the pixels.
Definition: SDL3pp_surface.h:2739
constexpr ScaleMode SCALEMODE_INVALID
INVALID.
Definition: SDL3pp_surface.h:121
constexpr int GetWidth() const
Get the width in pixels.
Definition: SDL3pp_surface.h:4923
void SetColorMod(Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:3250
void ClearSurfaceColorKey(SurfaceRef surface)
Unset the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:3160
void PremultiplyAlpha(const PointRaw &size, PixelFormat src_format, const void *src, int src_pitch, PixelFormat dst_format, void *dst, int dst_pitch, bool linear)
Premultiply the alpha on a block of pixels.
Definition: SDL3pp_surface.h:3823
void SetBlendMode(BlendMode blendMode)
Set the blend mode used for blit operations.
Definition: SDL3pp_surface.h:3405
OwnArray< SurfaceRaw > GetImages() const
Get an array including all versions of a surface.
Definition: SDL3pp_surface.h:2677
Surface Rotate(float angle)
Return a copy of a surface rotated clockwise a number of degrees.
Definition: SDL3pp_surface.h:3563
Surface CreateSurface(const PointRaw &size, PixelFormat format)
Allocate a new surface with a specific pixel format.
Definition: SDL3pp_surface.h:2300
void SetSurfaceColorMod(SurfaceRef surface, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:3245
void FillSurfaceRects(SurfaceRef dst, SpanRef< const RectRaw > rects, Uint32 color)
Perform a fast fill of a set of rectangles with a specific color.
Definition: SDL3pp_surface.h:3974
void SetPalette(PaletteRef palette)
Set the palette used by a surface.
Definition: SDL3pp_surface.h:2560
void BlitSurfaceUncheckedScaled(SurfaceRef src, const RectRaw &srcrect, SurfaceRef dst, const RectRaw &dstrect, ScaleMode scaleMode)
Perform low-level surface scaled blitting only.
Definition: SDL3pp_surface.h:4249
constexpr FlipMode FLIP_HORIZONTAL
flip horizontally
Definition: SDL3pp_surface.h:150
void SetSurfaceRLE(SurfaceRef surface, bool enabled)
Set the RLE acceleration hint for a surface.
Definition: SDL3pp_surface.h:3087
Surface ConvertSurfaceAndColorspace(SurfaceConstRef surface, PixelFormat format, PaletteRef palette, Colorspace colorspace, PropertiesRef props)
Copy an existing surface to a new surface of the specified format and colorspace.
Definition: SDL3pp_surface.h:3695
void ReadPixel(const PointRaw &p, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:4672
constexpr void * GetSurfacePixels(SurfaceConstRef surface)
Get the pixels.
Definition: SDL3pp_surface.h:4994
void Fill(Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3948
constexpr int GetSurfaceHeight(SurfaceConstRef surface)
Get the height in pixels.
Definition: SDL3pp_surface.h:4929
Uint32 MapRGBA(ColorRaw c) const
Map an RGBA quadruple to a pixel value for a surface.
Definition: SDL3pp_surface.h:4545
Surface Scale(const PointRaw &size, ScaleMode scaleMode) const
Creates a new surface identical to the existing surface, scaled to the desired size.
Definition: SDL3pp_surface.h:3625
void Blit9Grid(SurfaceRef src, OptionalRef< const RectRaw > srcrect, int left_width, int right_width, int top_height, int bottom_height, OptionalRef< const RectRaw > dstrect, float scale=1, ScaleMode scaleMode=SCALEMODE_NEAREST)
Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a differen...
Definition: SDL3pp_surface.h:4448
void SetColorspace(Colorspace colorspace)
Set the colorspace used by a surface.
Definition: SDL3pp_surface.h:2465
void ClearColorKey()
Unset the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:3165
Uint32 SurfaceFlags
The flags on an Surface.
Definition: SDL3pp_surface.h:91
void WritePixel(const PointRaw &p, ColorRaw c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:4858
void ReadSurfacePixelFloat(SurfaceConstRef surface, const PointRaw &p, float *r, float *g, float *b, float *a)
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:4709
void ReadSurfacePixel(SurfaceConstRef surface, const PointRaw &p, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:4576
void BlitUnchecked(SurfaceRef src, const RectRaw &srcrect, const RectRaw &dstrect)
Perform low-level surface blitting only.
Definition: SDL3pp_surface.h:4182
Color GetSurfaceMod(SurfaceConstRef surface)
Get the additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:3372
void BlitScaled(SurfaceRef src, OptionalRef< const RectRaw > srcrect, OptionalRef< const RectRaw > dstrect, ScaleMode scaleMode)
Perform a scaled blit to a destination surface, which may be of a different format.
Definition: SDL3pp_surface.h:4219
void FillRect(OptionalRef< const RectRaw > rect, Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3927
constexpr int GetSurfacePitch(SurfaceConstRef surface)
Get pitch in bytes.
Definition: SDL3pp_surface.h:4960
void Unlock(SurfaceLock &&lock)
Release a surface after directly accessing the pixels.
Definition: SDL3pp_surface.h:2762
constexpr Point GetSurfaceSize(SurfaceConstRef surface)
Get the size in pixels.
Definition: SDL3pp_surface.h:4943
void ResetSurfaceClipRect(SurfaceRef surface)
Disable the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:3473
void ReadPixelFloat(const PointRaw &p, float *r, float *g, float *b, float *a) const
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:4796
std::optional< Uint32 > GetSurfaceColorKey(SurfaceConstRef surface)
Get the color key (transparent pixel) for a surface.
Definition: SDL3pp_surface.h:3211
void SetAlphaMod(Uint8 alpha)
Set an additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:3310
constexpr void * GetPixels() const
Get the pixels.
Definition: SDL3pp_surface.h:5005
void BlitAt(SurfaceRef src, OptionalRef< const RectRaw > srcrect, const PointRaw &dstpos)
Performs a fast blit from the source surface to the destination surface with clipping.
Definition: SDL3pp_surface.h:4071
SDL_ScaleMode ScaleMode
The scaling mode.
Definition: SDL3pp_surface.h:117
void SetSurfaceColorspace(SurfaceRef surface, Colorspace colorspace)
Set the colorspace used by a surface.
Definition: SDL3pp_surface.h:2460
void SetRLE(bool enabled)
Set the RLE acceleration hint for a surface.
Definition: SDL3pp_surface.h:3092
Uint32 MapSurfaceRGBA(SurfaceConstRef surface, ColorRaw c)
Map an RGBA quadruple to a pixel value for a surface.
Definition: SDL3pp_surface.h:4540
void ConvertPixels(const PointRaw &size, PixelFormat src_format, const void *src, int src_pitch, PixelFormat dst_format, void *dst, int dst_pitch)
Copy a block of pixels of one format to another format.
Definition: SDL3pp_surface.h:3734
Color GetMod() const
Get the additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:3380
void FlipSurface(SurfaceRef surface, FlipMode flip)
Flip a surface vertically or horizontally.
Definition: SDL3pp_surface.h:3522
constexpr FlipMode FLIP_HORIZONTAL_AND_VERTICAL
flip horizontally and vertically (not a diagonal flip)
Definition: SDL3pp_surface.h:157
bool SetClipRect(OptionalRef< const RectRaw > rect)
Set the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:3463
Rect GetSurfaceClipRect(SurfaceConstRef surface)
Get the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:3498
void FillSurface(SurfaceRef dst, Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3943
void WritePixelFloat(const PointRaw &p, const FColorRaw &c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:4909
Main include header for the SDL3pp library.
A structure that represents a color as RGBA components.
Definition: SDL3pp_pixels.h:2166
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition: SDL3pp_pixels.h:2339
Reference for IOStream.
Definition: SDL3pp_iostream.h:1631
Reference for Palette.
Definition: SDL3pp_pixels.h:2648
The structure that defines a point (using integers).
Definition: SDL3pp_rect.h:83
Reference for Properties.
Definition: SDL3pp_properties.h:690
A rectangle, with the origin at the upper left (using integers).
Definition: SDL3pp_rect.h:845
Safely wrap Surface for non owning const parameters.
Definition: SDL3pp_surface.h:53
constexpr auto operator<=>(const SurfaceConstRef &other) const =default
Comparison.
constexpr SurfaceConstRef(const SurfaceRaw value)
Constructs from const SurfaceRaw.
Definition: SDL3pp_surface.h:57
constexpr auto operator->()
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:78
constexpr SurfaceConstRef(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_surface.h:63
const SurfaceRaw value
parameter's const SurfaceRaw
Definition: SDL3pp_surface.h:54
Reference for Surface.
Definition: SDL3pp_surface.h:1963
~SurfaceRef()
Destructor.
Definition: SDL3pp_surface.h:2003
constexpr SurfaceRef(const Surface &resource) noexcept
Constructs from Surface.
Definition: SDL3pp_surface.h:1985
constexpr SurfaceRef & operator=(SurfaceRef other) noexcept
Assignment operator.
Definition: SDL3pp_surface.h:2006
SurfaceRef(SurfaceRaw resource) noexcept
Constructs from raw Surface.
Definition: SDL3pp_surface.h:1973
constexpr SurfaceRef(const SurfaceRef &other) noexcept
Copy constructor.
Definition: SDL3pp_surface.h:1991
constexpr SurfaceRef(SurfaceRef &&other) noexcept
Move constructor.
Definition: SDL3pp_surface.h:1997