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 SurfaceParam(std::nullptr_t = nullptr)
64 : value(nullptr)
65 {
66 }
67
69 constexpr explicit operator bool() const { return !!value; }
70
72 constexpr auto operator<=>(const SurfaceParam& other) const = default;
73
75 constexpr operator SurfaceRaw() const { return value; }
76
78 constexpr auto operator->() { return value; }
79};
80
83{
85
88 : value(value)
89 {
90 }
91
95 {
96 }
97
99 constexpr SurfaceConstParam(std::nullptr_t = nullptr)
100 : value(nullptr)
101 {
102 }
103
105 constexpr explicit operator bool() const { return !!value; }
106
108 constexpr auto operator<=>(const SurfaceConstParam& other) const = default;
109
111 constexpr operator const SurfaceRaw() const { return value; }
112
114 constexpr auto operator->() { return value; }
115};
116
117// Forward decl
118struct SurfaceLock;
119
128
130 SDL_SURFACE_PREALLOCATED;
131
133 SDL_SURFACE_LOCK_NEEDED;
134
136 SDL_SURFACE_LOCKED;
137
139constexpr SurfaceFlags SURFACE_SIMD_ALIGNED = SDL_SURFACE_SIMD_ALIGNED;
140
146constexpr bool MustLock(SurfaceConstParam S) { return SDL_MUSTLOCK((S.value)); }
147
153using ScaleMode = SDL_ScaleMode;
154
155#if SDL_VERSION_ATLEAST(3, 2, 10)
156
157constexpr ScaleMode SCALEMODE_INVALID = SDL_SCALEMODE_INVALID;
158
159#endif // SDL_VERSION_ATLEAST(3, 2, 10)
160
162 SDL_SCALEMODE_NEAREST;
163
165 SDL_SCALEMODE_LINEAR;
166
167#if SDL_VERSION_ATLEAST(3, 4, 0)
168
173constexpr ScaleMode SCALEMODE_PIXELART = SDL_SCALEMODE_PIXELART;
174
175#endif // SDL_VERSION_ATLEAST(3, 4, 0)
176
182using FlipMode = SDL_FlipMode;
183
184constexpr FlipMode FLIP_NONE = SDL_FLIP_NONE;
185
186constexpr FlipMode FLIP_HORIZONTAL = SDL_FLIP_HORIZONTAL;
187
188constexpr FlipMode FLIP_VERTICAL = SDL_FLIP_VERTICAL;
189
190#if SDL_VERSION_ATLEAST(3, 4, 0)
191
194 SDL_FLIP_HORIZONTAL_AND_VERTICAL;
195
196#endif // SDL_VERSION_ATLEAST(3, 4, 0)
197
227{
228 SurfaceRaw m_resource = nullptr;
229
230public:
232 constexpr Surface(std::nullptr_t = nullptr) noexcept
233 : m_resource(0)
234 {
235 }
236
244 constexpr explicit Surface(const SurfaceRaw resource) noexcept
245 : m_resource(resource)
246 {
247 }
248
250 constexpr Surface(const Surface& other)
251 : m_resource(other.m_resource)
252 {
253 ++m_resource->refcount;
254 }
255
257 constexpr Surface(Surface&& other) noexcept
258 : Surface(other.release())
259 {
260 }
261
278 Surface(const PointRaw& size, PixelFormat format)
279 : m_resource(CheckError(SDL_CreateSurface(size.x, size.y, format)))
280 {
281 }
282
309 Surface(const PointRaw& size, PixelFormat format, void* pixels, int pitch)
310 : m_resource(CheckError(
311 SDL_CreateSurfaceFrom(size.x, size.y, format, pixels, pitch)))
312 {
313 }
314
352 Surface(StringParam file);
353
402 Surface(IOStreamParam src, bool closeio = false);
403
411 static constexpr Surface Borrow(SurfaceParam resource)
412 {
413 if (resource) {
414 ++resource.value->refcount;
415 return Surface(resource.value);
416 }
417 return {};
418 }
419
440 static Surface LoadBMP(IOStreamParam src, bool closeio = false);
441
460 static Surface LoadBMP(StringParam file);
461
462#if SDL_VERSION_ATLEAST(3, 4, 0)
463
485 static Surface LoadPNG(IOStreamParam src, bool closeio = false);
486
509 static Surface LoadPNG(StringParam file);
510
511#endif // SDL_VERSION_ATLEAST(3, 4, 0)
512
514 constexpr const SurfaceRaw operator->() const noexcept { return m_resource; }
515
517 constexpr SurfaceRaw operator->() noexcept { return m_resource; }
518
520 ~Surface() { SDL_DestroySurface(m_resource); }
521
523 constexpr Surface& operator=(Surface&& other) noexcept
524 {
525 std::swap(m_resource, other.m_resource);
526 return *this;
527 }
528
530 constexpr Surface& operator=(const Surface& other) noexcept = default;
531
533 constexpr SurfaceRaw get() const noexcept { return m_resource; }
534
536 constexpr SurfaceRaw release() noexcept
537 {
538 auto r = m_resource;
539 m_resource = nullptr;
540 return r;
541 }
542
544 constexpr auto operator<=>(const Surface& other) const noexcept = default;
545
547 constexpr explicit operator bool() const noexcept { return !!m_resource; }
548
550 constexpr operator SurfaceParam() const noexcept { return {m_resource}; }
551
564 void Destroy();
565
571 constexpr bool MustLock() const { return SDL::MustLock(m_resource); }
572
611
628 void SetColorspace(Colorspace colorspace);
629
648
677
697 void SetPalette(PaletteParam palette);
698
711 Palette GetPalette() const;
712
737
751 bool HasAlternateImages() const;
752
772
789
815
827 void Unlock(SurfaceLock&& lock);
828
851 void SaveBMP(IOStreamParam dst, bool closeio = false) const;
852
873 void SaveBMP(StringParam file) const;
874
875#if SDL_VERSION_ATLEAST(3, 4, 0)
876
893 void SavePNG(IOStreamParam dst, bool closeio = false) const;
894
909 void SavePNG(StringParam file) const;
910
911#endif // SDL_VERSION_ATLEAST(3, 4, 0)
912
931 void SetRLE(bool enabled);
932
946 bool HasRLE() const;
947
969 void SetColorKey(std::optional<Uint32> key);
970
980 void ClearColorKey();
981
994 bool HasColorKey() const;
995
1014 std::optional<Uint32> GetColorKey() const;
1015
1038 void SetColorMod(Uint8 r, Uint8 g, Uint8 b);
1039
1056 void GetColorMod(Uint8* r, Uint8* g, Uint8* b) const;
1057
1077 void SetAlphaMod(Uint8 alpha);
1078
1091 Uint8 GetAlphaMod() const;
1092
1107 void SetMod(Color color);
1108
1116 Color GetMod() const;
1117
1135 void SetBlendMode(BlendMode blendMode);
1136
1149 BlendMode GetBlendMode() const;
1150
1174
1180 void ResetClipRect();
1181
1199 Rect GetClipRect() const;
1200
1212 void Flip(FlipMode flip);
1213
1214#if SDL_VERSION_ATLEAST(3, 4, 0)
1215
1242 Surface Rotate(float angle);
1243
1244#endif // SDL_VERSION_ATLEAST(3, 4, 0)
1245
1262 Surface Duplicate() const;
1263
1280 Surface Scale(const PointRaw& size, ScaleMode scaleMode) const;
1281
1308 Surface Convert(PixelFormat format) const;
1309
1338 PaletteParam palette,
1339 Colorspace colorspace,
1340 PropertiesParam props) const;
1341
1356 void PremultiplyAlpha(bool linear);
1357
1374 void Clear(const FColorRaw& c);
1375
1400 void FillRect(OptionalRef<const RectRaw> rect, Uint32 color);
1401
1412 void Fill(Uint32 color);
1413
1437 void FillRects(SpanRef<const RectRaw> rects, Uint32 color);
1438
1508 void Blit(SurfaceParam src,
1511
1582 void BlitAt(SurfaceParam src,
1584 const PointRaw& dstpos);
1585
1606 void BlitUnchecked(SurfaceParam src,
1607 const RectRaw& srcrect,
1608 const RectRaw& dstrect);
1609
1630 void BlitScaled(SurfaceParam src,
1633 ScaleMode scaleMode);
1634
1657 const RectRaw& srcrect,
1658 const RectRaw& dstrect,
1659 ScaleMode scaleMode);
1660
1661#if SDL_VERSION_ATLEAST(3, 4, 0)
1662
1682 void Stretch(SurfaceParam src,
1683 OptionalRef<RectRaw> srcrect,
1684 OptionalRef<RectRaw> dstrect,
1685 ScaleMode scaleMode);
1686
1687#endif // SDL_VERSION_ATLEAST(3, 4, 0)
1688
1710 void BlitTiled(SurfaceParam src,
1713
1741 float scale,
1742 ScaleMode scaleMode,
1744
1777 void Blit9Grid(SurfaceParam src,
1779 int left_width,
1780 int right_width,
1781 int top_height,
1782 int bottom_height,
1784 float scale = 1,
1785 ScaleMode scaleMode = SCALEMODE_NEAREST);
1786
1817 Uint32 MapRGB(Uint8 r, Uint8 g, Uint8 b) const;
1818
1847 Uint32 MapRGBA(ColorRaw c) const;
1848
1874 void ReadPixel(const PointRaw& p,
1875 Uint8* r,
1876 Uint8* g,
1877 Uint8* b,
1878 Uint8* a) const;
1879
1895 Color ReadPixel(const PointRaw& p) const;
1896
1919 void ReadPixelFloat(const PointRaw& p,
1920 float* r,
1921 float* g,
1922 float* b,
1923 float* a) const;
1924
1940 FColor ReadPixelFloat(const PointRaw& p) const;
1941
1960 void WritePixel(const PointRaw& p, ColorRaw c);
1961
1977 void WritePixelFloat(const PointRaw& p, const FColorRaw& c);
1978
1980 constexpr int GetWidth() const;
1981
1983 constexpr int GetHeight() const;
1984
1986 constexpr Point GetSize() const;
1987
1989 constexpr int GetPitch() const;
1990
1992 constexpr PixelFormat GetFormat() const;
1993
1995 constexpr void* GetPixels() const;
1996};
1997
2000{
2001 using Surface::Surface;
2002
2010 SurfaceRef(SurfaceRaw resource) noexcept
2011 : Surface(Borrow(resource))
2012 {
2013 }
2014
2016 SurfaceRef(Surface resource) noexcept
2017 : Surface(std::move(resource))
2018 {
2019 }
2020};
2021
2040{
2041 SurfaceRef m_lock;
2042
2043public:
2069 SurfaceLock(SurfaceRef resource);
2070
2072 SurfaceLock(const SurfaceLock& other) = delete;
2073
2075 constexpr SurfaceLock(SurfaceLock&& other) noexcept
2076 : m_lock(other.m_lock)
2077 {
2078 other.m_lock = {};
2079 }
2080
2093
2094 SurfaceLock& operator=(const SurfaceLock& other) = delete;
2095
2098 {
2099 std::swap(m_lock, other.m_lock);
2100 return *this;
2101 }
2102
2104 constexpr operator bool() const { return bool(m_lock); }
2105
2131 void ReadPixel(const PointRaw& p,
2132 Uint8* r,
2133 Uint8* g,
2134 Uint8* b,
2135 Uint8* a) const
2136 {
2137 m_lock.ReadPixel(p, r, g, b, a);
2138 }
2139
2158 Color ReadPixel(const PointRaw& p) const { return m_lock.ReadPixel(p); }
2159
2183 float* r,
2184 float* g,
2185 float* b,
2186 float* a) const
2187 {
2188 m_lock.ReadPixelFloat(p, r, g, b, a);
2189 }
2190
2207 {
2208 return m_lock.ReadPixelFloat(p);
2209 }
2210
2229 void WritePixel(const PointRaw& p, ColorRaw c) { m_lock.WritePixel(p, c); }
2230
2246 void WritePixelFloat(const PointRaw& p, const FColorRaw& c)
2247 {
2248 m_lock.WritePixelFloat(p, c);
2249 }
2250
2252 constexpr int GetWidth() const { return m_lock.GetWidth(); }
2253
2255 constexpr int GetHeight() const { return m_lock.GetHeight(); }
2256
2258 constexpr Point GetSize() const { return m_lock.GetSize(); }
2259
2261 constexpr int GetPitch() const { return m_lock.GetPitch(); }
2262
2264 constexpr PixelFormat GetFormat() const { return m_lock.GetFormat(); }
2265
2267 constexpr void* GetPixels() const { return m_lock.GetPixels(); }
2268
2280 void reset();
2281
2283 SurfaceRef get() { return m_lock; }
2284
2286 void release() { m_lock.release(); }
2287};
2288
2306inline Surface CreateSurface(const PointRaw& size, PixelFormat format)
2307{
2308 return Surface(size, format);
2309}
2310
2338 PixelFormat format,
2339 void* pixels,
2340 int pitch)
2341{
2342 return Surface(size, format, pixels, pitch);
2343}
2344
2359inline void DestroySurface(SurfaceRaw surface) { SDL_DestroySurface(surface); }
2360
2362
2401{
2402 return {CheckError(SDL_GetSurfaceProperties(surface))};
2403}
2404
2406{
2407 return SDL::GetSurfaceProperties(m_resource);
2408}
2409
2410namespace prop::Surface {
2411
2412constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT;
2413
2414constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT;
2415
2416constexpr auto TONEMAP_OPERATOR_STRING =
2417 SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING;
2418
2419#if SDL_VERSION_ATLEAST(3, 2, 6)
2420
2421constexpr auto HOTSPOT_X_NUMBER = SDL_PROP_SURFACE_HOTSPOT_X_NUMBER;
2422
2423constexpr auto HOTSPOT_Y_NUMBER = SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER;
2424
2425#endif // SDL_VERSION_ATLEAST(3, 2, 6)
2426
2427#if SDL_VERSION_ATLEAST(3, 4, 0)
2428
2429constexpr auto ROTATION_FLOAT = SDL_PROP_SURFACE_ROTATION_FLOAT;
2430
2431#endif // SDL_VERSION_ATLEAST(3, 4, 0)
2432
2433} // namespace prop::Surface
2434
2452inline void SetSurfaceColorspace(SurfaceParam surface, Colorspace colorspace)
2453{
2454 CheckError(SDL_SetSurfaceColorspace(surface, colorspace));
2455}
2456
2457inline void Surface::SetColorspace(Colorspace colorspace)
2458{
2459 SDL::SetSurfaceColorspace(m_resource, colorspace);
2460}
2461
2481{
2482 return SDL_GetSurfaceColorspace(surface);
2483}
2484
2486{
2487 return SDL::GetSurfaceColorspace(m_resource);
2488}
2489
2518{
2519 return Palette::Borrow(CheckError(SDL_CreateSurfacePalette(surface)));
2520}
2521
2523{
2524 return SDL::CreateSurfacePalette(m_resource);
2525}
2526
2547inline void SetSurfacePalette(SurfaceParam surface, PaletteParam palette)
2548{
2549 CheckError(SDL_SetSurfacePalette(surface, palette));
2550}
2551
2553{
2554 SDL::SetSurfacePalette(m_resource, palette);
2555}
2556
2571{
2572 return Palette::Borrow(SDL_GetSurfacePalette(surface));
2573}
2574
2576{
2577 return SDL::GetSurfacePalette(m_resource);
2578}
2579
2606{
2607 CheckError(SDL_AddSurfaceAlternateImage(surface, image));
2608}
2609
2611{
2612 SDL::AddSurfaceAlternateImage(m_resource, image);
2613}
2614
2630{
2631 return SDL_SurfaceHasAlternateImages(surface);
2632}
2633
2635{
2636 return SDL::SurfaceHasAlternateImages(m_resource);
2637}
2638
2663{
2664 int count = 0;
2665 auto data = SDL_GetSurfaceImages(surface, &count);
2666 return OwnArray<SurfaceRaw>(CheckError(data), count);
2667}
2668
2670{
2671 return SDL::GetSurfaceImages(m_resource);
2672}
2673
2692{
2693 SDL_RemoveSurfaceAlternateImages(surface);
2694}
2695
2697{
2699}
2700
2726inline void LockSurface(SurfaceParam surface)
2727{
2728 CheckError(SDL_LockSurface(surface));
2729}
2730
2731inline SurfaceLock Surface::Lock() { return {SurfaceRef(*this)}; }
2732
2734 : m_lock(std::move(resource))
2735{
2736 LockSurface(m_lock);
2737}
2738
2752inline void UnlockSurface(SurfaceParam surface) { SDL_UnlockSurface(surface); }
2753
2754inline void Surface::Unlock(SurfaceLock&& lock)
2755{
2756 SDL_assert_paranoid(lock.get() == *this);
2757 lock.reset();
2758}
2759
2761{
2762 if (!m_lock) return;
2763 UnlockSurface(m_lock);
2764 m_lock = {};
2765}
2766
2767#ifndef SDL3PP_ENABLE_IMAGE
2768#if SDL_VERSION_ATLEAST(3, 4, 0)
2769
2789inline Surface LoadSurface(IOStreamParam src, bool closeio = false)
2790{
2791 return Surface{SDL_LoadSurface_IO(src, closeio)};
2792}
2793
2811inline Surface LoadSurface(StringParam file)
2812{
2813 return Surface{SDL_LoadSurface(file)};
2814}
2815#endif // SDL_VERSION_ATLEAST(3, 4, 0)
2816#endif // SDL3PP_ENABLE_IMAGE
2817
2838inline Surface LoadBMP(IOStreamParam src, bool closeio = false)
2839{
2840 return Surface(SDL_LoadBMP_IO(src, closeio));
2841}
2842
2861inline Surface LoadBMP(StringParam file) { return Surface(SDL_LoadBMP(file)); }
2862
2863inline Surface Surface::LoadBMP(IOStreamParam src, bool closeio)
2864{
2865 return SDL::LoadBMP(src, closeio);
2866}
2867
2869{
2870 return SDL::LoadBMP(std::move(file));
2871}
2872
2896inline void SaveBMP(SurfaceConstParam surface,
2897 IOStreamParam dst,
2898 bool closeio = false)
2899{
2900 CheckError(SDL_SaveBMP_IO(surface, dst, closeio));
2901}
2902
2924inline void SaveBMP(SurfaceConstParam surface, StringParam file)
2925{
2926 CheckError(SDL_SaveBMP(surface, file));
2927}
2928
2929inline void Surface::SaveBMP(IOStreamParam dst, bool closeio) const
2930{
2931 SDL::SaveBMP(m_resource, dst, closeio);
2932}
2933
2934inline void Surface::SaveBMP(StringParam file) const
2935{
2936 SDL::SaveBMP(m_resource, std::move(file));
2937}
2938
2939#if SDL_VERSION_ATLEAST(3, 4, 0)
2940
2965inline Surface LoadPNG(IOStreamParam src, bool closeio = false)
2966{
2967 return Surface(SDL_LoadPNG_IO(src, closeio));
2968}
2969
2992inline Surface LoadPNG(StringParam file) { return Surface(SDL_LoadPNG(file)); }
2993
2994inline Surface Surface::LoadPNG(IOStreamParam src, bool closeio)
2995{
2996 return SDL::LoadPNG(src, closeio);
2997}
2998
3000{
3001 return SDL::LoadPNG(std::move(file));
3002}
3003
3021inline void SavePNG(SurfaceConstParam surface,
3022 IOStreamParam dst,
3023 bool closeio = false)
3024{
3025 CheckError(SDL_SavePNG_IO(surface, dst, closeio));
3026}
3027
3043inline void SavePNG(SurfaceConstParam surface, StringParam file)
3044{
3045 CheckError(SDL_SavePNG(surface, file));
3046}
3047
3048inline void Surface::SavePNG(IOStreamParam dst, bool closeio) const
3049{
3050 SDL::SavePNG(m_resource, dst, closeio);
3051}
3052
3053inline void Surface::SavePNG(StringParam file) const
3054{
3055 SDL::SavePNG(m_resource, std::move(file));
3056}
3057
3058#endif // SDL_VERSION_ATLEAST(3, 4, 0)
3059
3079inline void SetSurfaceRLE(SurfaceParam surface, bool enabled)
3080{
3081 CheckError(SDL_SetSurfaceRLE(surface, enabled));
3082}
3083
3084inline void Surface::SetRLE(bool enabled)
3085{
3086 SDL::SetSurfaceRLE(m_resource, enabled);
3087}
3088
3104{
3105 return SDL_SurfaceHasRLE(surface);
3106}
3107
3108inline bool Surface::HasRLE() const { return SDL::SurfaceHasRLE(m_resource); }
3109
3132inline void SetSurfaceColorKey(SurfaceParam surface, std::optional<Uint32> key)
3133{
3134 CheckError(SDL_SetSurfaceColorKey(surface, key.has_value(), key.value_or(0)));
3135}
3136
3137inline void Surface::SetColorKey(std::optional<Uint32> key)
3138{
3139 SDL::SetSurfaceColorKey(m_resource, key);
3140}
3141
3153{
3154 SetSurfaceColorKey(surface, std::nullopt);
3155}
3156
3158
3175{
3176 return SDL_SurfaceHasColorKey(surface);
3177}
3178
3179inline bool Surface::HasColorKey() const
3180{
3181 return SDL::SurfaceHasColorKey(m_resource);
3182}
3183
3203inline std::optional<Uint32> GetSurfaceColorKey(SurfaceConstParam surface)
3204{
3205 if (Uint32 key; SDL_GetSurfaceColorKey(surface, &key)) return key;
3206 return std::nullopt;
3207}
3208
3209inline std::optional<Uint32> Surface::GetColorKey() const
3210{
3211 return SDL::GetSurfaceColorKey(m_resource);
3212}
3213
3237inline void SetSurfaceColorMod(SurfaceParam surface, Uint8 r, Uint8 g, Uint8 b)
3238{
3239 CheckError(SDL_SetSurfaceColorMod(surface, r, g, b));
3240}
3241
3243{
3244 SDL::SetSurfaceColorMod(m_resource, r, g, b);
3245}
3246
3265 Uint8* r,
3266 Uint8* g,
3267 Uint8* b)
3268{
3269 CheckError(SDL_GetSurfaceColorMod(surface, r, g, b));
3270}
3271
3272inline void Surface::GetColorMod(Uint8* r, Uint8* g, Uint8* b) const
3273{
3274 SDL::GetSurfaceColorMod(m_resource, r, g, b);
3275}
3276
3297inline void SetSurfaceAlphaMod(SurfaceParam surface, Uint8 alpha)
3298{
3299 CheckError(SDL_SetSurfaceAlphaMod(surface, alpha));
3300}
3301
3302inline void Surface::SetAlphaMod(Uint8 alpha)
3303{
3304 SDL::SetSurfaceAlphaMod(m_resource, alpha);
3305}
3306
3322{
3323 Uint8 alpha;
3324 CheckError(SDL_GetSurfaceAlphaMod(surface, &alpha));
3325 return alpha;
3326}
3327
3329{
3330 return SDL::GetSurfaceAlphaMod(m_resource);
3331}
3332
3348inline void SetSurfaceMod(SurfaceParam surface, Color color)
3349{
3350 SetSurfaceColorMod(surface, color.r, color.g, color.b);
3351 SetSurfaceAlphaMod(surface, color.a);
3352}
3353
3354inline void Surface::SetMod(Color color) { SetSurfaceMod(m_resource, color); }
3355
3365{
3366 Color c;
3367 GetSurfaceColorMod(surface, &c.r, &c.g, &c.b);
3368 c.a = GetSurfaceAlphaMod(surface);
3369 return c;
3370}
3371
3372inline Color Surface::GetMod() const { return SDL::GetSurfaceMod(m_resource); }
3373
3392inline void SetSurfaceBlendMode(SurfaceParam surface, BlendMode blendMode)
3393{
3394 CheckError(SDL_SetSurfaceBlendMode(surface, blendMode));
3395}
3396
3397inline void Surface::SetBlendMode(BlendMode blendMode)
3398{
3399 SDL::SetSurfaceBlendMode(m_resource, blendMode);
3400}
3401
3416{
3417 BlendMode blendmode;
3418 CheckError(SDL_GetSurfaceBlendMode(surface, &blendmode));
3419 return blendmode;
3420}
3421
3423{
3424 return SDL::GetSurfaceBlendMode(m_resource);
3425}
3426
3451{
3452 return SDL_SetSurfaceClipRect(surface, rect);
3453}
3454
3456{
3457 return SDL::SetSurfaceClipRect(m_resource, rect);
3458}
3459
3466{
3467 SetSurfaceClipRect(surface, std::nullopt);
3468}
3469
3471
3491{
3492 Rect r;
3493 CheckError(SDL_GetSurfaceClipRect(surface, &r));
3494 return r;
3495}
3496
3498{
3499 return SDL::GetSurfaceClipRect(m_resource);
3500}
3501
3514inline void FlipSurface(SurfaceParam surface, FlipMode flip)
3515{
3516 CheckError(SDL_FlipSurface(surface, flip));
3517}
3518
3519inline void Surface::Flip(FlipMode flip) { SDL::FlipSurface(m_resource, flip); }
3520
3521#if SDL_VERSION_ATLEAST(3, 4, 0)
3522
3550inline Surface RotateSurface(SurfaceParam surface, float angle)
3551{
3552 return Surface{SDL_RotateSurface(surface, angle)};
3553}
3554
3555inline Surface Surface::Rotate(float angle)
3556{
3557 return SDL::RotateSurface(m_resource, angle);
3558}
3559
3560#endif // SDL_VERSION_ATLEAST(3, 4, 0)
3561
3582{
3583 return Surface(SDL_DuplicateSurface(surface));
3584}
3585
3587{
3588 return SDL::DuplicateSurface(m_resource);
3589}
3590
3611 const PointRaw& size,
3612 ScaleMode scaleMode)
3613{
3614 return Surface(SDL_ScaleSurface(surface, size.x, size.y, scaleMode));
3615}
3616
3617inline Surface Surface::Scale(const PointRaw& size, ScaleMode scaleMode) const
3618{
3619 return SDL::ScaleSurface(m_resource, size, scaleMode);
3620}
3621
3650{
3651 return Surface(SDL_ConvertSurface(surface, format));
3652}
3653
3655{
3656 return SDL::ConvertSurface(m_resource, format);
3657}
3658
3688 PixelFormat format,
3689 PaletteParam palette,
3690 Colorspace colorspace,
3691 PropertiesParam props)
3692{
3693 return Surface{SDL_ConvertSurfaceAndColorspace(
3694 surface, format, palette, colorspace, props)};
3695}
3696
3698 PaletteParam palette,
3699 Colorspace colorspace,
3700 PropertiesParam props) const
3701{
3703 m_resource, format, palette, colorspace, props);
3704}
3705
3726inline void ConvertPixels(const PointRaw& size,
3727 PixelFormat src_format,
3728 const void* src,
3729 int src_pitch,
3730 PixelFormat dst_format,
3731 void* dst,
3732 int dst_pitch)
3733{
3734 CheckError(SDL_ConvertPixels(
3735 size.x, size.y, src_format, src, src_pitch, dst_format, dst, dst_pitch));
3736}
3737
3767inline void ConvertPixelsAndColorspace(const PointRaw& size,
3768 PixelFormat src_format,
3769 Colorspace src_colorspace,
3770 PropertiesParam src_properties,
3771 const void* src,
3772 int src_pitch,
3773 PixelFormat dst_format,
3774 Colorspace dst_colorspace,
3775 PropertiesParam dst_properties,
3776 void* dst,
3777 int dst_pitch)
3778{
3779 CheckError(SDL_ConvertPixelsAndColorspace(size.x,
3780 size.y,
3781 src_format,
3782 src_colorspace,
3783 src_properties,
3784 src,
3785 src_pitch,
3786 dst_format,
3787 dst_colorspace,
3788 dst_properties,
3789 dst,
3790 dst_pitch));
3791}
3792
3815inline void PremultiplyAlpha(const PointRaw& size,
3816 PixelFormat src_format,
3817 const void* src,
3818 int src_pitch,
3819 PixelFormat dst_format,
3820 void* dst,
3821 int dst_pitch,
3822 bool linear)
3823{
3824 CheckError(SDL_PremultiplyAlpha(size.x,
3825 size.y,
3826 src_format,
3827 src,
3828 src_pitch,
3829 dst_format,
3830 dst,
3831 dst_pitch,
3832 linear));
3833}
3834
3850inline void PremultiplySurfaceAlpha(SurfaceParam surface, bool linear)
3851{
3852 CheckError(SDL_PremultiplySurfaceAlpha(surface, linear));
3853}
3854
3855inline void Surface::PremultiplyAlpha(bool linear)
3856{
3857 SDL::PremultiplySurfaceAlpha(m_resource, linear);
3858}
3859
3877inline void ClearSurface(SurfaceParam surface, const FColorRaw& c)
3878{
3879 CheckError(SDL_ClearSurface(surface, c.r, c.g, c.b, c.a));
3880}
3881
3882inline void Surface::Clear(const FColorRaw& c)
3883{
3884 SDL::ClearSurface(m_resource, c);
3885}
3886
3914 Uint32 color)
3915{
3916 CheckError(SDL_FillSurfaceRect(dst, rect, color));
3917}
3918
3920{
3921 SDL::FillSurfaceRect(m_resource, rect, color);
3922}
3923
3935inline void FillSurface(SurfaceParam dst, Uint32 color)
3936{
3937 FillSurfaceRect(dst, std::nullopt, color);
3938}
3939
3940inline void Surface::Fill(Uint32 color) { SDL::FillSurface(m_resource, color); }
3941
3968 Uint32 color)
3969{
3970 CheckError(SDL_FillSurfaceRects(dst, rects.data(), rects.size(), color));
3971}
3972
3974{
3975 SDL::FillSurfaceRects(m_resource, rects, color);
3976}
3977
4050 SurfaceParam dst,
4052{
4053 CheckError(SDL_BlitSurface(src, srcrect, dst, dstrect));
4054}
4055
4059{
4060 SDL::BlitSurface(src, srcrect, m_resource, dstrect);
4061}
4062
4065 const PointRaw& dstpos)
4066{
4067 Blit(src, srcrect, Rect{dstpos, {}});
4068}
4069
4139 SurfaceParam dst,
4140 const PointRaw& dstpos)
4141{
4142 BlitSurface(src, srcrect, dst, SDL_Rect{dstpos.x, dstpos.y});
4143}
4144
4167 const RectRaw& srcrect,
4168 SurfaceParam dst,
4169 const RectRaw& dstrect)
4170{
4171 CheckError(SDL_BlitSurfaceUnchecked(src, &srcrect, dst, &dstrect));
4172}
4173
4175 const RectRaw& srcrect,
4176 const RectRaw& dstrect)
4177{
4178 SDL::BlitSurfaceUnchecked(src, srcrect, m_resource, dstrect);
4179}
4180
4204 SurfaceParam dst,
4206 ScaleMode scaleMode)
4207{
4208 CheckError(SDL_BlitSurfaceScaled(src, srcrect, dst, dstrect, scaleMode));
4209}
4210
4214 ScaleMode scaleMode)
4215{
4216 SDL::BlitSurfaceScaled(src, srcrect, m_resource, dstrect, scaleMode);
4217}
4218
4242 const RectRaw& srcrect,
4243 SurfaceParam dst,
4244 const RectRaw& dstrect,
4245 ScaleMode scaleMode)
4246{
4247 CheckError(
4248 SDL_BlitSurfaceUncheckedScaled(src, &srcrect, dst, &dstrect, scaleMode));
4249}
4250
4252 const RectRaw& srcrect,
4253 const RectRaw& dstrect,
4254 ScaleMode scaleMode)
4255{
4256 SDL::BlitSurfaceUncheckedScaled(src, srcrect, m_resource, dstrect, scaleMode);
4257}
4258
4259#if SDL_VERSION_ATLEAST(3, 4, 0)
4260
4282 OptionalRef<RectRaw> srcrect,
4283 SurfaceParam dst,
4284 OptionalRef<RectRaw> dstrect,
4285 ScaleMode scaleMode)
4286{
4287 CheckError(SDL_StretchSurface(src, srcrect, dst, dstrect, scaleMode));
4288}
4289
4291 OptionalRef<RectRaw> srcrect,
4292 OptionalRef<RectRaw> dstrect,
4293 ScaleMode scaleMode)
4294{
4295 SDL::StretchSurface(src, srcrect, m_resource, dstrect, scaleMode);
4296}
4297
4298#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4299
4324 SurfaceParam dst,
4326{
4327 CheckError(SDL_BlitSurfaceTiled(src, srcrect, dst, dstrect));
4328}
4329
4333{
4334 SDL::BlitSurfaceTiled(src, srcrect, m_resource, dstrect);
4335}
4336
4365 float scale,
4366 ScaleMode scaleMode,
4367 SurfaceParam dst,
4369{
4370 CheckError(SDL_BlitSurfaceTiledWithScale(
4371 src, srcrect, scale, scaleMode, dst, dstrect));
4372}
4373
4376 float scale,
4377 ScaleMode scaleMode,
4379{
4381 src, srcrect, scale, scaleMode, m_resource, dstrect);
4382}
4383
4419 int left_width,
4420 int right_width,
4421 int top_height,
4422 int bottom_height,
4423 SurfaceParam dst,
4425 float scale = 1,
4426 ScaleMode scaleMode = SCALEMODE_NEAREST)
4427{
4428 CheckError(SDL_BlitSurface9Grid(src,
4429 srcrect,
4430 left_width,
4431 right_width,
4432 top_height,
4433 bottom_height,
4434 scale,
4435 scaleMode,
4436 dst,
4437 dstrect));
4438}
4439
4442 int left_width,
4443 int right_width,
4444 int top_height,
4445 int bottom_height,
4447 float scale,
4448 ScaleMode scaleMode)
4449{
4451 srcrect,
4452 left_width,
4453 right_width,
4454 top_height,
4455 bottom_height,
4456 m_resource,
4457 dstrect,
4458 scale,
4459 scaleMode);
4460}
4461
4494 Uint8 r,
4495 Uint8 g,
4496 Uint8 b)
4497{
4498 return SDL_MapSurfaceRGB(surface, r, g, b);
4499}
4500
4502{
4503 return SDL::MapSurfaceRGB(m_resource, r, g, b);
4504}
4505
4536{
4537 return SDL_MapSurfaceRGBA(surface, c.r, c.g, c.b, c.a);
4538}
4539
4541{
4542 return SDL::MapSurfaceRGBA(m_resource, c);
4543}
4544
4572 const PointRaw& p,
4573 Uint8* r,
4574 Uint8* g,
4575 Uint8* b,
4576 Uint8* a)
4577{
4578 CheckError(SDL_ReadSurfacePixel(surface, p.x, p.y, r, g, b, a));
4579}
4580
4601{
4602 Color c;
4603 ReadSurfacePixel(surface, p, &c.r, &c.g, &c.b, &c.a);
4604 return c;
4605}
4606
4633inline void ReadSurfacePixel(const SurfaceLock& lock,
4634 const PointRaw& p,
4635 Uint8* r,
4636 Uint8* g,
4637 Uint8* b,
4638 Uint8* a)
4639{
4640 lock.ReadPixel(p, r, g, b, a);
4641}
4642
4662inline Color ReadSurfacePixel(const SurfaceLock& lock, const PointRaw& p)
4663{
4664 return lock.ReadPixel(p);
4665}
4666
4667inline void Surface::ReadPixel(const PointRaw& p,
4668 Uint8* r,
4669 Uint8* g,
4670 Uint8* b,
4671 Uint8* a) const
4672{
4673 SDL::ReadSurfacePixel(m_resource, p, r, g, b, a);
4674}
4675
4676inline Color Surface::ReadPixel(const PointRaw& p) const
4677{
4678 return SDL::ReadSurfacePixel(m_resource, p);
4679}
4680
4705 const PointRaw& p,
4706 float* r,
4707 float* g,
4708 float* b,
4709 float* a)
4710{
4711 CheckError(SDL_ReadSurfacePixelFloat(surface, p.x, p.y, r, g, b, a));
4712}
4713
4731 const PointRaw& p)
4732{
4733 FColor c;
4734 ReadSurfacePixelFloat(surface, p, &c.r, &c.g, &c.b, &c.a);
4735 return c;
4736}
4737
4761inline void ReadSurfacePixelFloat(const SurfaceLock& lock,
4762 const PointRaw& p,
4763 float* r,
4764 float* g,
4765 float* b,
4766 float* a)
4767{
4768 lock.ReadPixelFloat(p, r, g, b, a);
4769}
4770
4788{
4789 return lock.ReadPixelFloat(p);
4790}
4791
4793 float* r,
4794 float* g,
4795 float* b,
4796 float* a) const
4797{
4798 SDL::ReadSurfacePixelFloat(m_resource, p, r, g, b, a);
4799}
4800
4802{
4803 return SDL::ReadSurfacePixelFloat(m_resource, p);
4804}
4805
4826 const PointRaw& p,
4827 ColorRaw c)
4828{
4829 CheckError(SDL_WriteSurfacePixel(surface, p.x, p.y, c.r, c.g, c.b, c.a));
4830}
4831
4851inline void WriteSurfacePixel(SurfaceLock& lock, const PointRaw& p, ColorRaw c)
4852{
4853 lock.WritePixel(p, c);
4854}
4855
4856inline void Surface::WritePixel(const PointRaw& p, ColorRaw c)
4857{
4858 SDL::WriteSurfacePixel(m_resource, p, c);
4859}
4860
4878 const PointRaw& p,
4879 const FColorRaw& c)
4880{
4881 CheckError(SDL_WriteSurfacePixelFloat(surface, p.x, p.y, c.r, c.g, c.b, c.a));
4882}
4883
4901 const PointRaw& p,
4902 const FColorRaw& c)
4903{
4904 lock.WritePixelFloat(p, c);
4905}
4906
4907inline void Surface::WritePixelFloat(const PointRaw& p, const FColorRaw& c)
4908{
4909 SDL::WriteSurfacePixelFloat(m_resource, p, c);
4910}
4911
4913constexpr int GetSurfaceWidth(SurfaceConstParam surface) { return surface->w; }
4914
4916constexpr int GetSurfaceWidth(const SurfaceLock& lock)
4917{
4918 return lock.GetWidth();
4919}
4920
4921constexpr int Surface::GetWidth() const
4922{
4923 return SDL::GetSurfaceWidth(m_resource);
4924}
4925
4927constexpr int GetSurfaceHeight(SurfaceConstParam surface) { return surface->h; }
4928
4930constexpr int GetSurfaceHeight(const SurfaceLock& lock)
4931{
4932 return lock.GetHeight();
4933}
4934
4935constexpr int Surface::GetHeight() const
4936{
4937 return SDL::GetSurfaceHeight(m_resource);
4938}
4939
4942{
4943 return Point(surface->w, surface->h);
4944}
4945
4947constexpr Point GetSurfaceSize(const SurfaceLock& lock)
4948{
4949 return lock.GetSize();
4950}
4951
4952constexpr Point Surface::GetSize() const
4953{
4954 return SDL::GetSurfaceSize(m_resource);
4955}
4956
4959{
4960 return surface->pitch;
4961}
4962
4964constexpr int GetSurfacePitch(const SurfaceLock& lock)
4965{
4966 return lock.GetPitch();
4967}
4968
4969constexpr int Surface::GetPitch() const
4970{
4971 return SDL::GetSurfacePitch(m_resource);
4972}
4973
4976{
4977 return surface->format;
4978}
4979
4982{
4983 return lock.GetFormat();
4984}
4985
4987{
4988 return SDL::GetSurfaceFormat(m_resource);
4989}
4990
4992constexpr void* GetSurfacePixels(SurfaceConstParam surface)
4993{
4994 return surface->pixels;
4995}
4996
4998constexpr void* GetSurfacePixels(const SurfaceLock& lock)
4999{
5000 return lock.GetPixels();
5001}
5002
5003constexpr void* Surface::GetPixels() const
5004{
5005 return SDL::GetSurfacePixels(m_resource);
5006}
5007
5009
5010} // namespace SDL
5011
5012#endif /* SDL3PP_SURFACE_H_ */
Colorspace definitions.
Definition: SDL3pp_pixels.h:1657
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:2479
static constexpr Palette Borrow(PaletteParam resource)
Safely borrows the from PaletteParam.
Definition: SDL3pp_pixels.h:2543
Pixel format.
Definition: SDL3pp_pixels.h:414
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:2040
constexpr PixelFormat GetFormat() const
Get the pixel format.
Definition: SDL3pp_surface.h:2264
FColor ReadPixelFloat(const PointRaw &p) const
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:2206
~SurfaceLock()
Release a surface after directly accessing the pixels.
Definition: SDL3pp_surface.h:2092
constexpr int GetHeight() const
Get the height in pixels.
Definition: SDL3pp_surface.h:2255
constexpr int GetWidth() const
Get the width in pixels.
Definition: SDL3pp_surface.h:2252
SurfaceRef get()
Get the reference to locked resource.
Definition: SDL3pp_surface.h:2283
constexpr void * GetPixels() const
Get the pixels.
Definition: SDL3pp_surface.h:2267
void release()
Releases the lock without unlocking.
Definition: SDL3pp_surface.h:2286
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:2131
constexpr SurfaceLock(SurfaceLock &&other) noexcept
Move constructor.
Definition: SDL3pp_surface.h:2075
void WritePixelFloat(const PointRaw &p, const FColorRaw &c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:2246
SurfaceLock & operator=(SurfaceLock &&other) noexcept
Assignment operator.
Definition: SDL3pp_surface.h:2097
void WritePixel(const PointRaw &p, ColorRaw c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:2229
constexpr Point GetSize() const
Get the size in pixels.
Definition: SDL3pp_surface.h:2258
Color ReadPixel(const PointRaw &p) const
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:2158
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:2182
constexpr int GetPitch() const
Get pitch in bytes.
Definition: SDL3pp_surface.h:2261
A collection of pixels used in software blitting.
Definition: SDL3pp_surface.h:227
constexpr const SurfaceRaw operator->() const noexcept
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:514
Surface(const PointRaw &size, PixelFormat format)
Allocate a new surface with a specific pixel format.
Definition: SDL3pp_surface.h:278
constexpr SurfaceRaw release() noexcept
Retrieves underlying SurfaceRaw and clear this.
Definition: SDL3pp_surface.h:536
constexpr Surface & operator=(Surface &&other) noexcept
Assignment operator.
Definition: SDL3pp_surface.h:523
constexpr Surface(const Surface &other)
Copy constructor.
Definition: SDL3pp_surface.h:250
constexpr SurfaceRaw operator->() noexcept
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:517
constexpr Surface(Surface &&other) noexcept
Move constructor.
Definition: SDL3pp_surface.h:257
constexpr Surface(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_surface.h:232
constexpr Surface(const SurfaceRaw resource) noexcept
Constructs from SurfaceParam.
Definition: SDL3pp_surface.h:244
~Surface()
Destructor.
Definition: SDL3pp_surface.h:520
constexpr auto operator<=>(const Surface &other) const noexcept=default
Comparison.
constexpr Surface & operator=(const Surface &other) noexcept=default
Assignment operator.
Surface(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:309
static constexpr Surface Borrow(SurfaceParam resource)
Safely borrows the from SurfaceParam.
Definition: SDL3pp_surface.h:411
constexpr SurfaceRaw get() const noexcept
Retrieves underlying SurfaceRaw.
Definition: SDL3pp_surface.h:533
constexpr bool MustLock() const
Evaluates to true if the surface needs to be locked before access.
Definition: SDL3pp_surface.h:571
#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:89
SDL_Color ColorRaw
Alias to raw representation for Color.
Definition: SDL3pp_pixels.h:83
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 LoadBMP(IOStreamParam src)
Load a BMP image directly.
Definition: SDL3pp_image.h:1349
Surface LoadPNG(IOStreamParam src)
Load a PNG image directly.
Definition: SDL3pp_image.h:1571
Surface LoadSurface(StringParam file)
Load an image from a filesystem path into a software surface.
Definition: SDL3pp_image.h:241
void SavePNG(SurfaceParam surface, StringParam file)
Save an Surface into a PNG image file.
Definition: SDL3pp_image.h:2020
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:341
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:289
SurfaceLock(SurfaceRef resource)
Set up a surface for directly accessing the pixels.
Definition: SDL3pp_surface.h:2733
void ResetSurfaceClipRect(SurfaceParam surface)
Disable the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:3465
constexpr int GetSurfaceHeight(SurfaceConstParam surface)
Get the height in pixels.
Definition: SDL3pp_surface.h:4927
void BlitSurfaceUnchecked(SurfaceParam src, const RectRaw &srcrect, SurfaceParam dst, const RectRaw &dstrect)
Perform low-level surface blitting only.
Definition: SDL3pp_surface.h:4166
Uint32 MapSurfaceRGBA(SurfaceConstParam surface, ColorRaw c)
Map an RGBA quadruple to a pixel value for a surface.
Definition: SDL3pp_surface.h:4535
Rect GetSurfaceClipRect(SurfaceConstParam surface)
Get the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:3490
Surface ScaleSurface(SurfaceConstParam surface, const PointRaw &size, ScaleMode scaleMode)
Creates a new surface identical to the existing surface, scaled to the desired size.
Definition: SDL3pp_surface.h:3610
Rect GetClipRect() const
Get the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:3497
void ClearSurface(SurfaceParam surface, const FColorRaw &c)
Clear a surface with a specific color, with floating point precision.
Definition: SDL3pp_surface.h:3877
Uint8 GetSurfaceAlphaMod(SurfaceConstParam surface)
Get the additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:3321
Palette CreateSurfacePalette(SurfaceParam surface)
Create a palette and associate it with a surface.
Definition: SDL3pp_surface.h:2517
Palette GetPalette() const
Get the palette used by a surface.
Definition: SDL3pp_surface.h:2575
std::optional< Uint32 > GetColorKey() const
Get the color key (transparent pixel) for a surface.
Definition: SDL3pp_surface.h:3209
void SetSurfaceMod(SurfaceParam surface, Color color)
Set an additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:3348
constexpr FlipMode FLIP_VERTICAL
flip vertically
Definition: SDL3pp_surface.h:188
bool SetSurfaceClipRect(SurfaceParam surface, OptionalRef< const RectRaw > rect)
Set the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:3449
constexpr PixelFormat GetFormat() const
Get the pixel format.
Definition: SDL3pp_surface.h:4986
void Destroy()
Free a surface.
Definition: SDL3pp_surface.h:2361
void BlitSurfaceScaled(SurfaceParam src, OptionalRef< const RectRaw > srcrect, SurfaceParam 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:4202
void SavePNG(IOStreamParam dst, bool closeio=false) const
Save a surface to a seekable SDL data stream in PNG format.
Definition: SDL3pp_surface.h:3048
bool SurfaceHasAlternateImages(SurfaceConstParam surface)
Return whether a surface has alternate versions available.
Definition: SDL3pp_surface.h:2629
void FillSurfaceRects(SurfaceParam dst, SpanRef< const RectRaw > rects, Uint32 color)
Perform a fast fill of a set of rectangles with a specific color.
Definition: SDL3pp_surface.h:3966
constexpr SurfaceFlags SURFACE_SIMD_ALIGNED
Surface uses pixel memory allocated with aligned_alloc()
Definition: SDL3pp_surface.h:139
BlendMode GetBlendMode() const
Get the blend mode used for blit operations.
Definition: SDL3pp_surface.h:3422
constexpr SurfaceFlags SURFACE_LOCK_NEEDED
Surface needs to be locked to access pixels.
Definition: SDL3pp_surface.h:132
constexpr void * GetSurfacePixels(SurfaceConstParam surface)
Get the pixels.
Definition: SDL3pp_surface.h:4992
void SetSurfacePalette(SurfaceParam surface, PaletteParam palette)
Set the palette used by a surface.
Definition: SDL3pp_surface.h:2547
bool SurfaceHasRLE(SurfaceConstParam surface)
Returns whether the surface is RLE enabled.
Definition: SDL3pp_surface.h:3103
void DestroySurface(SurfaceRaw surface)
Free a surface.
Definition: SDL3pp_surface.h:2359
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:3973
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:4501
void BlitSurfaceUncheckedScaled(SurfaceParam src, const RectRaw &srcrect, SurfaceParam dst, const RectRaw &dstrect, ScaleMode scaleMode)
Perform low-level surface scaled blitting only.
Definition: SDL3pp_surface.h:4241
bool HasRLE() const
Returns whether the surface is RLE enabled.
Definition: SDL3pp_surface.h:3108
constexpr int GetHeight() const
Get the height in pixels.
Definition: SDL3pp_surface.h:4935
constexpr FlipMode FLIP_NONE
Do not flip.
Definition: SDL3pp_surface.h:184
void WriteSurfacePixel(SurfaceParam surface, const PointRaw &p, ColorRaw c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:4825
bool SurfaceHasColorKey(SurfaceConstParam surface)
Returns whether the surface has a color key.
Definition: SDL3pp_surface.h:3174
BlendMode GetSurfaceBlendMode(SurfaceConstParam surface)
Get the blend mode used for blit operations.
Definition: SDL3pp_surface.h:3415
void Blit9Grid(SurfaceParam 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:4440
void BlitTiledWithScale(SurfaceParam 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:4374
constexpr SurfaceFlags SURFACE_PREALLOCATED
Surface uses preallocated pixel memory.
Definition: SDL3pp_surface.h:129
void BlitSurfaceAt(SurfaceParam src, OptionalRef< const RectRaw > srcrect, SurfaceParam dst, const PointRaw &dstpos)
Performs a fast blit from the source surface to the destination surface with clipping.
Definition: SDL3pp_surface.h:4137
constexpr PixelFormat GetSurfaceFormat(SurfaceConstParam surface)
Get the pixel format.
Definition: SDL3pp_surface.h:4975
bool HasColorKey() const
Returns whether the surface has a color key.
Definition: SDL3pp_surface.h:3179
void BlitUncheckedScaled(SurfaceParam src, const RectRaw &srcrect, const RectRaw &dstrect, ScaleMode scaleMode)
Perform low-level surface scaled blitting only.
Definition: SDL3pp_surface.h:4251
constexpr ScaleMode SCALEMODE_LINEAR
linear filtering
Definition: SDL3pp_surface.h:164
void SetColorKey(std::optional< Uint32 > key)
Set the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:3137
void PremultiplyAlpha(bool linear)
Premultiply the alpha in a surface.
Definition: SDL3pp_surface.h:3855
void SaveBMP(IOStreamParam dst, bool closeio=false) const
Save a surface to a seekable SDL data stream in BMP format.
Definition: SDL3pp_surface.h:2929
Colorspace GetSurfaceColorspace(SurfaceConstParam surface)
Get the colorspace used by a surface.
Definition: SDL3pp_surface.h:2480
Surface DuplicateSurface(SurfaceConstParam surface)
Creates a new surface identical to the existing surface.
Definition: SDL3pp_surface.h:3581
std::optional< Uint32 > GetSurfaceColorKey(SurfaceConstParam surface)
Get the color key (transparent pixel) for a surface.
Definition: SDL3pp_surface.h:3203
Palette CreatePalette()
Create a palette and associate it with a surface.
Definition: SDL3pp_surface.h:2522
void reset()
Release a surface after directly accessing the pixels.
Definition: SDL3pp_surface.h:2760
void Blit(SurfaceParam 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:4056
void SetSurfaceColorspace(SurfaceParam surface, Colorspace colorspace)
Set the colorspace used by a surface.
Definition: SDL3pp_surface.h:2452
Colorspace GetColorspace() const
Get the colorspace used by a surface.
Definition: SDL3pp_surface.h:2485
void ReadSurfacePixel(SurfaceConstParam surface, const PointRaw &p, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:4571
constexpr ScaleMode SCALEMODE_NEAREST
nearest pixel sampling
Definition: SDL3pp_surface.h:161
void Flip(FlipMode flip)
Flip a surface vertically or horizontally.
Definition: SDL3pp_surface.h:3519
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:2337
void FlipSurface(SurfaceParam surface, FlipMode flip)
Flip a surface vertically or horizontally.
Definition: SDL3pp_surface.h:3514
void ResetClipRect()
Disable the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:3470
PropertiesRef GetProperties() const
Get the properties associated with a surface.
Definition: SDL3pp_surface.h:2405
constexpr ScaleMode SCALEMODE_PIXELART
nearest pixel sampling with improved scaling for pixel art, available since SDL 3....
Definition: SDL3pp_surface.h:173
constexpr SurfaceFlags SURFACE_LOCKED
Surface is currently locked.
Definition: SDL3pp_surface.h:135
Surface ConvertSurface(SurfaceConstParam surface, PixelFormat format)
Copy an existing surface to a new surface of the specified format.
Definition: SDL3pp_surface.h:3649
constexpr Point GetSurfaceSize(SurfaceConstParam surface)
Get the size in pixels.
Definition: SDL3pp_surface.h:4941
constexpr int GetSurfaceWidth(SurfaceConstParam surface)
Get the width in pixels.
Definition: SDL3pp_surface.h:4913
bool HasAlternateImages() const
Return whether a surface has alternate versions available.
Definition: SDL3pp_surface.h:2634
void FillSurface(SurfaceParam dst, Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3935
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:4969
void SetSurfaceColorMod(SurfaceParam surface, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:3237
Surface ConvertSurfaceAndColorspace(SurfaceConstParam surface, PixelFormat format, PaletteParam palette, Colorspace colorspace, PropertiesParam props)
Copy an existing surface to a new surface of the specified format and colorspace.
Definition: SDL3pp_surface.h:3687
void BlitSurface9Grid(SurfaceParam src, OptionalRef< const RectRaw > srcrect, int left_width, int right_width, int top_height, int bottom_height, SurfaceParam 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:4417
void RemoveAlternateImages()
Remove all alternate versions of a surface.
Definition: SDL3pp_surface.h:2696
Surface Convert(PixelFormat format) const
Copy an existing surface to a new surface of the specified format.
Definition: SDL3pp_surface.h:3654
void Stretch(SurfaceParam src, OptionalRef< RectRaw > srcrect, OptionalRef< RectRaw > dstrect, ScaleMode scaleMode)
Perform a stretched pixel copy from one surface to another.
Definition: SDL3pp_surface.h:4290
constexpr Point GetSize() const
Get the size in pixels.
Definition: SDL3pp_surface.h:4952
void SetSurfaceAlphaMod(SurfaceParam surface, Uint8 alpha)
Set an additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:3297
Uint8 GetAlphaMod() const
Get the additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:3328
constexpr bool MustLock(SurfaceConstParam S)
Evaluates to true if the surface needs to be locked before access.
Definition: SDL3pp_surface.h:146
Surface Duplicate() const
Creates a new surface identical to the existing surface.
Definition: SDL3pp_surface.h:3586
static Surface LoadBMP(IOStreamParam src, bool closeio=false)
Load a BMP image from a seekable SDL data stream.
Definition: SDL3pp_surface.h:2863
void Clear(const FColorRaw &c)
Clear a surface with a specific color, with floating point precision.
Definition: SDL3pp_surface.h:3882
Surface RotateSurface(SurfaceParam surface, float angle)
Return a copy of a surface rotated clockwise a number of degrees.
Definition: SDL3pp_surface.h:3550
void BlitSurfaceTiled(SurfaceParam src, OptionalRef< const RectRaw > srcrect, SurfaceParam dst, OptionalRef< const RectRaw > dstrect)
Perform a tiled blit to a destination surface, which may be of a different format.
Definition: SDL3pp_surface.h:4322
void SetSurfaceColorKey(SurfaceParam surface, std::optional< Uint32 > key)
Set the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:3132
static Surface LoadPNG(IOStreamParam src, bool closeio=false)
Load a PNG image from a seekable SDL data stream.
Definition: SDL3pp_surface.h:2994
void SetSurfaceRLE(SurfaceParam surface, bool enabled)
Set the RLE acceleration hint for a surface.
Definition: SDL3pp_surface.h:3079
void SetMod(Color color)
Set an additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:3354
SDL_FlipMode FlipMode
The flip mode.
Definition: SDL3pp_surface.h:182
Uint32 MapSurfaceRGB(SurfaceConstParam surface, Uint8 r, Uint8 g, Uint8 b)
Map an RGB triple to an opaque pixel value for a surface.
Definition: SDL3pp_surface.h:4493
void GetColorMod(Uint8 *r, Uint8 *g, Uint8 *b) const
Get the additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:3272
SurfaceLock Lock()
Set up a surface for directly accessing the pixels.
Definition: SDL3pp_surface.h:2731
constexpr ScaleMode SCALEMODE_INVALID
INVALID.
Definition: SDL3pp_surface.h:157
constexpr int GetWidth() const
Get the width in pixels.
Definition: SDL3pp_surface.h:4921
void UnlockSurface(SurfaceParam surface)
Release a surface after directly accessing the pixels.
Definition: SDL3pp_surface.h:2752
void PremultiplySurfaceAlpha(SurfaceParam surface, bool linear)
Premultiply the alpha in a surface.
Definition: SDL3pp_surface.h:3850
void SetColorMod(Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:3242
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:3815
void BlitAt(SurfaceParam 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:4063
void BlitSurfaceTiledWithScale(SurfaceParam src, OptionalRef< const RectRaw > srcrect, float scale, ScaleMode scaleMode, SurfaceParam 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:4363
void SetBlendMode(BlendMode blendMode)
Set the blend mode used for blit operations.
Definition: SDL3pp_surface.h:3397
OwnArray< SurfaceRaw > GetImages() const
Get an array including all versions of a surface.
Definition: SDL3pp_surface.h:2669
Surface Rotate(float angle)
Return a copy of a surface rotated clockwise a number of degrees.
Definition: SDL3pp_surface.h:3555
Surface CreateSurface(const PointRaw &size, PixelFormat format)
Allocate a new surface with a specific pixel format.
Definition: SDL3pp_surface.h:2306
OwnArray< SurfaceRaw > GetSurfaceImages(SurfaceConstParam surface)
Get an array including all versions of a surface.
Definition: SDL3pp_surface.h:2662
constexpr int GetSurfacePitch(SurfaceConstParam surface)
Get pitch in bytes.
Definition: SDL3pp_surface.h:4958
constexpr FlipMode FLIP_HORIZONTAL
flip horizontally
Definition: SDL3pp_surface.h:186
void BlitScaled(SurfaceParam 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:4211
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:4667
void ReadSurfacePixelFloat(SurfaceConstParam surface, const PointRaw &p, float *r, float *g, float *b, float *a)
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:4704
Palette GetSurfacePalette(SurfaceConstParam surface)
Get the palette used by a surface.
Definition: SDL3pp_surface.h:2570
void StretchSurface(SurfaceParam src, OptionalRef< RectRaw > srcrect, SurfaceParam dst, OptionalRef< RectRaw > dstrect, ScaleMode scaleMode)
Perform a stretched pixel copy from one surface to another.
Definition: SDL3pp_surface.h:4281
void FillSurfaceRect(SurfaceParam dst, OptionalRef< const RectRaw > rect, Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3912
Color GetSurfaceMod(SurfaceConstParam surface)
Get the additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:3364
void Fill(Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3940
Uint32 MapRGBA(ColorRaw c) const
Map an RGBA quadruple to a pixel value for a surface.
Definition: SDL3pp_surface.h:4540
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:3617
void ConvertPixelsAndColorspace(const PointRaw &size, PixelFormat src_format, Colorspace src_colorspace, PropertiesParam src_properties, const void *src, int src_pitch, PixelFormat dst_format, Colorspace dst_colorspace, PropertiesParam 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:3767
void SetColorspace(Colorspace colorspace)
Set the colorspace used by a surface.
Definition: SDL3pp_surface.h:2457
void BlitTiled(SurfaceParam 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:4330
void SaveBMP(SurfaceConstParam surface, IOStreamParam dst, bool closeio=false)
Save a surface to a seekable SDL data stream in BMP format.
Definition: SDL3pp_surface.h:2896
void ClearColorKey()
Unset the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:3157
void AddSurfaceAlternateImage(SurfaceParam surface, SurfaceParam image)
Add an alternate version of a surface.
Definition: SDL3pp_surface.h:2605
Uint32 SurfaceFlags
The flags on an Surface.
Definition: SDL3pp_surface.h:127
void WritePixel(const PointRaw &p, ColorRaw c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:4856
PropertiesRef GetSurfaceProperties(SurfaceConstParam surface)
Get the properties associated with a surface.
Definition: SDL3pp_surface.h:2400
void BlitSurface(SurfaceParam src, OptionalRef< const RectRaw > srcrect, SurfaceParam dst, OptionalRef< const RectRaw > dstrect)
Performs a fast blit from the source surface to the destination surface with clipping.
Definition: SDL3pp_surface.h:4048
void FillRect(OptionalRef< const RectRaw > rect, Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3919
void Unlock(SurfaceLock &&lock)
Release a surface after directly accessing the pixels.
Definition: SDL3pp_surface.h:2754
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:4792
void GetSurfaceColorMod(SurfaceConstParam surface, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:3264
void SetAlphaMod(Uint8 alpha)
Set an additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:3302
constexpr void * GetPixels() const
Get the pixels.
Definition: SDL3pp_surface.h:5003
SDL_ScaleMode ScaleMode
The scaling mode.
Definition: SDL3pp_surface.h:153
void SetRLE(bool enabled)
Set the RLE acceleration hint for a surface.
Definition: SDL3pp_surface.h:3084
void BlitUnchecked(SurfaceParam src, const RectRaw &srcrect, const RectRaw &dstrect)
Perform low-level surface blitting only.
Definition: SDL3pp_surface.h:4174
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:3726
void ClearSurfaceColorKey(SurfaceParam surface)
Unset the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:3152
void WriteSurfacePixelFloat(SurfaceParam surface, const PointRaw &p, const FColorRaw &c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:4877
void SetPalette(PaletteParam palette)
Set the palette used by a surface.
Definition: SDL3pp_surface.h:2552
Color GetMod() const
Get the additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:3372
void LockSurface(SurfaceParam surface)
Set up a surface for directly accessing the pixels.
Definition: SDL3pp_surface.h:2726
constexpr FlipMode FLIP_HORIZONTAL_AND_VERTICAL
flip horizontally and vertically (not a diagonal flip)
Definition: SDL3pp_surface.h:193
void SetSurfaceBlendMode(SurfaceParam surface, BlendMode blendMode)
Set the blend mode used for blit operations.
Definition: SDL3pp_surface.h:3392
bool SetClipRect(OptionalRef< const RectRaw > rect)
Set the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:3455
void AddAlternateImage(SurfaceParam image)
Add an alternate version of a surface.
Definition: SDL3pp_surface.h:2610
void WritePixelFloat(const PointRaw &p, const FColorRaw &c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:4907
void RemoveSurfaceAlternateImages(SurfaceParam surface)
Remove all alternate versions of a surface.
Definition: SDL3pp_surface.h:2691
Main include header for the SDL3pp library.
A structure that represents a color as RGBA components.
Definition: SDL3pp_pixels.h:2192
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition: SDL3pp_pixels.h:2365
Safely wrap IOStream for non owning parameters.
Definition: SDL3pp_iostream.h:34
Safely wrap Palette for non owning parameters.
Definition: SDL3pp_pixels.h:105
The structure that defines a point (using integers).
Definition: SDL3pp_rect.h:83
Safely wrap Properties for non owning parameters.
Definition: SDL3pp_properties.h:53
Semi-safe reference for Properties.
Definition: SDL3pp_properties.h:716
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:83
constexpr SurfaceConstParam(const SurfaceRaw value)
Constructs from SurfaceRaw.
Definition: SDL3pp_surface.h:87
constexpr SurfaceConstParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_surface.h:99
constexpr SurfaceConstParam(SurfaceParam value)
Constructs from SurfaceParam.
Definition: SDL3pp_surface.h:93
const SurfaceRaw value
parameter's const SurfaceRaw
Definition: SDL3pp_surface.h:84
constexpr auto operator<=>(const SurfaceConstParam &other) const =default
Comparison.
constexpr auto operator->()
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:114
Safely wrap Surface for non owning parameters.
Definition: SDL3pp_surface.h:53
SurfaceRaw value
parameter's SurfaceRaw
Definition: SDL3pp_surface.h:54
constexpr auto operator->()
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:78
constexpr SurfaceParam(SurfaceRaw value)
Constructs from SurfaceRaw.
Definition: SDL3pp_surface.h:57
constexpr SurfaceParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_surface.h:63
constexpr auto operator<=>(const SurfaceParam &other) const =default
Comparison.
Safe reference for Surface.
Definition: SDL3pp_surface.h:2000
SurfaceRef(Surface resource) noexcept
Constructs from Surface.
Definition: SDL3pp_surface.h:2016
SurfaceRef(SurfaceRaw resource) noexcept
Constructs from SurfaceRaw.
Definition: SDL3pp_surface.h:2010