SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL3pp_render.h
1#ifndef SDL3PP_RENDER_H_
2#define SDL3PP_RENDER_H_
3
4#include <SDL3/SDL_render.h>
5#include "SDL3pp_blendmode.h"
6#include "SDL3pp_events.h"
7#include "SDL3pp_gpu.h"
8#include "SDL3pp_pixels.h"
9#include "SDL3pp_video.h"
10
11namespace SDL {
12
43// Forward decl
44struct Renderer;
45
47using RendererRaw = SDL_Renderer*;
48
49// Forward decl
50struct RendererRef;
51
54{
56
59 : value(value)
60 {
61 }
62
64 constexpr RendererParam(std::nullptr_t = nullptr)
65 : value(nullptr)
66 {
67 }
68
70 constexpr explicit operator bool() const { return !!value; }
71
73 constexpr auto operator<=>(const RendererParam& other) const = default;
74
76 constexpr operator RendererRaw() const { return value; }
77};
78
79// Forward decl
80struct Texture;
81
83using TextureRaw = SDL_Texture*;
84
85// Forward decl
86struct TextureRef;
87
90{
92
95 : value(value)
96 {
97 }
98
100 constexpr TextureParam(std::nullptr_t = nullptr)
101 : value(nullptr)
102 {
103 }
104
106 constexpr explicit operator bool() const { return !!value; }
107
109 constexpr auto operator<=>(const TextureParam& other) const = default;
110
112 constexpr operator TextureRaw() const { return value; }
113
115 constexpr auto operator->() { return value; }
116};
117
120{
122
125 : value(value)
126 {
127 }
128
131 : value(value.value)
132 {
133 }
134
136 constexpr TextureConstParam(std::nullptr_t = nullptr)
137 : value(nullptr)
138 {
139 }
140
142 constexpr explicit operator bool() const { return !!value; }
143
145 constexpr auto operator<=>(const TextureConstParam& other) const = default;
146
148 constexpr operator const TextureRaw() const { return value; }
149
151 constexpr auto operator->() { return value; }
152};
153
154#if SDL_VERSION_ATLEAST(3, 3, 6)
155
156// Forward decl
157struct GPURenderState;
158
160using GPURenderStateRaw = SDL_GPURenderState*;
161
162// Forward decl
163struct GPURenderStateRef;
164
167{
169
172 : value(value)
173 {
174 }
175
177 constexpr GPURenderStateParam(std::nullptr_t = nullptr)
178 : value(nullptr)
179 {
180 }
181
183 constexpr explicit operator bool() const { return !!value; }
184
186 constexpr auto operator<=>(const GPURenderStateParam& other) const = default;
187
189 constexpr operator GPURenderStateRaw() const { return value; }
190};
191
192#endif // SDL_VERSION_ATLEAST(3, 3, 6)
193
194// Forward decl
195struct TextureSurfaceLock;
196
197// Forward decl
198struct TextureLock;
199
205constexpr auto SOFTWARE_RENDERER = SDL_SOFTWARE_RENDERER;
206
207#if SDL_VERSION_ATLEAST(3, 4, 0)
208
214constexpr auto GPU_RENDERER = SDL_GPU_RENDERER;
215
216#endif // SDL_VERSION_ATLEAST(3, 4, 0)
217
223using Vertex = SDL_Vertex;
224
230using TextureAccess = SDL_TextureAccess;
231
233 SDL_TEXTUREACCESS_STATIC;
234
236 SDL_TEXTUREACCESS_STREAMING;
237
239 SDL_TEXTUREACCESS_TARGET;
240
241#if SDL_VERSION_ATLEAST(3, 4, 0)
242
254using TextureAddressMode = SDL_TextureAddressMode;
255
257 SDL_TEXTURE_ADDRESS_INVALID;
258
263constexpr TextureAddressMode TEXTURE_ADDRESS_AUTO = SDL_TEXTURE_ADDRESS_AUTO;
264
266constexpr TextureAddressMode TEXTURE_ADDRESS_CLAMP = SDL_TEXTURE_ADDRESS_CLAMP;
267
269 SDL_TEXTURE_ADDRESS_WRAP;
270
271#endif // SDL_VERSION_ATLEAST(3, 4, 0)
272
278using RendererLogicalPresentation = SDL_RendererLogicalPresentation;
279
281 SDL_LOGICAL_PRESENTATION_DISABLED;
282
285 SDL_LOGICAL_PRESENTATION_STRETCH;
286
292 SDL_LOGICAL_PRESENTATION_LETTERBOX;
293
299 SDL_LOGICAL_PRESENTATION_OVERSCAN;
300
306 SDL_LOGICAL_PRESENTATION_INTEGER_SCALE;
307
308#if SDL_VERSION_ATLEAST(3, 4, 0)
309
317using GPURenderStateCreateInfo = SDL_GPURenderStateCreateInfo;
318
319#endif // SDL_VERSION_ATLEAST(3, 4, 0)
320
329{
330 RendererRaw m_resource = nullptr;
331
332public:
334 constexpr Renderer(std::nullptr_t = nullptr) noexcept
335 : m_resource(0)
336 {
337 }
338
346 constexpr explicit Renderer(const RendererRaw resource) noexcept
347 : m_resource(resource)
348 {
349 }
350
351protected:
353 constexpr Renderer(const Renderer& other) noexcept = default;
354
355public:
357 constexpr Renderer(Renderer&& other) noexcept
358 : Renderer(other.release())
359 {
360 }
361
362 constexpr Renderer(const RendererRef& other) = delete;
363
364 constexpr Renderer(RendererRef&& other) = delete;
365
398 : m_resource(CheckError(SDL_CreateRenderer(window, nullptr)))
399 {
400 }
401
435 : m_resource(CheckError(SDL_CreateRenderer(window, name)))
436 {
437 }
438
501 : m_resource(CheckError(SDL_CreateRendererWithProperties(props)))
502 {
503 }
504
524 : m_resource(CheckError(SDL_CreateSoftwareRenderer(surface)))
525 {
526 }
527
529 ~Renderer() { SDL_DestroyRenderer(m_resource); }
530
532 constexpr Renderer& operator=(Renderer&& other) noexcept
533 {
534 std::swap(m_resource, other.m_resource);
535 return *this;
536 }
537
538protected:
540 constexpr Renderer& operator=(const Renderer& other) noexcept = default;
541
542public:
544 constexpr RendererRaw get() const noexcept { return m_resource; }
545
547 constexpr RendererRaw release() noexcept
548 {
549 auto r = m_resource;
550 m_resource = nullptr;
551 return r;
552 }
553
555 constexpr auto operator<=>(const Renderer& other) const noexcept = default;
556
558 constexpr explicit operator bool() const noexcept { return !!m_resource; }
559
561 constexpr operator RendererParam() const noexcept { return {m_resource}; }
562
575 void Destroy();
576
577#if SDL_VERSION_ATLEAST(3, 4, 0)
578
590
591#endif // SDL_VERSION_ATLEAST(3, 4, 0)
592
604
617 const char* GetName() const;
618
704
724 void GetOutputSize(int* w, int* h) const;
725
744 Point GetOutputSize() const;
745
765 void GetCurrentOutputSize(int* w, int* h) const;
766
786
809 TextureAccess access,
810 const PointRaw& size);
811
837
963
987 void SetTarget(TextureParam texture);
988
1003 void ResetTarget();
1004
1020 Texture GetTarget() const;
1021
1064 void SetLogicalPresentation(const PointRaw& size,
1066
1088 void GetLogicalPresentation(int* w,
1089 int* h,
1090 RendererLogicalPresentation* mode) const;
1091
1114
1136
1158 FPoint RenderCoordinatesFromWindow(const FPointRaw& window_coord) const;
1159
1182 FPoint RenderCoordinatesToWindow(const FPointRaw& coord) const;
1183
1216 void ConvertEventToRenderCoordinates(Event* event) const;
1217
1242
1258 void ResetViewport();
1259
1276 Rect GetViewport() const;
1277
1297 bool ViewportSet() const;
1298
1316 Rect GetSafeArea() const;
1317
1337
1353 void ResetClipRect();
1354
1372 Rect GetClipRect() const;
1373
1390 bool IsClipEnabled() const;
1391
1415 void SetScale(const FPointRaw& scale);
1416
1433 void GetScale(float* scaleX, float* scaleY) const;
1434
1450 FPoint GetScale() const;
1451
1468 void SetDrawColor(ColorRaw c);
1469
1486 void SetDrawColorFloat(const FColorRaw& c);
1487
1508 void GetDrawColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const;
1509
1523 Color GetDrawColor() const;
1524
1545 void GetDrawColorFloat(float* r, float* g, float* b, float* a) const;
1546
1560 FColor GetDrawColorFloat() const;
1561
1582 void SetColorScale(float scale);
1583
1596 float GetColorScale() const;
1597
1612 void SetDrawBlendMode(BlendMode blendMode);
1613
1627
1644 void RenderClear();
1645
1658 void RenderPoint(const FPointRaw& p);
1659
1673
1687 void RenderLine(const FPointRaw& p1, const FPointRaw& p2);
1688
1703
1718
1733
1749
1764
1783 void RenderTexture(TextureParam texture,
1786
1814 double angle,
1816 FlipMode flip = FlipMode::SDL_FLIP_NONE);
1817
1842 void RenderTextureAffine(TextureParam texture,
1847
1871 void RenderTextureTiled(TextureParam texture,
1873 float scale,
1875
1907 void RenderTexture9Grid(TextureParam texture,
1909 float left_width,
1910 float right_width,
1911 float top_height,
1912 float bottom_height,
1913 float scale,
1915
1916#if SDL_VERSION_ATLEAST(3, 4, 0)
1917
1953 const FRectRaw& srcrect,
1954 float left_width,
1955 float right_width,
1956 float top_height,
1957 float bottom_height,
1958 float scale,
1959 const FRectRaw& dstrect,
1960 float tileScale);
1961
1962#endif // SDL_VERSION_ATLEAST(3, 4, 0)
1963
1983 void RenderGeometry(TextureParam texture,
1984 std::span<const Vertex> vertices,
1985 std::span<const int> indices = {});
1986
2014 void RenderGeometryRaw(TextureParam texture,
2015 const float* xy,
2016 int xy_stride,
2017 const FColor* color,
2018 int color_stride,
2019 const float* uv,
2020 int uv_stride,
2021 int num_vertices,
2022 const void* indices,
2023 int num_indices,
2024 int size_indices);
2025
2026#if SDL_VERSION_ATLEAST(3, 4, 0)
2027
2044 TextureAddressMode v_mode);
2045
2062 TextureAddressMode* v_mode);
2063
2064#endif // SDL_VERSION_ATLEAST(3, 4, 0)
2065
2090 Surface ReadPixels(OptionalRef<const RectRaw> rect = {}) const;
2091
2137 void Present();
2138
2168 void Flush();
2169
2185 void* GetRenderMetalLayer();
2186
2208
2235 void AddVulkanRenderSemaphores(Uint32 wait_stage_mask,
2236 Sint64 wait_semaphore,
2237 Sint64 signal_semaphore);
2238
2260 void SetVSync(int vsync);
2261
2274 int GetVSync() const;
2275
2313 void RenderDebugText(const FPointRaw& p, StringParam str);
2314
2340 template<class... ARGS>
2341 void RenderDebugTextFormat(const FPointRaw& p,
2342 std::string_view fmt,
2343 ARGS... args);
2344
2345#if SDL_VERSION_ATLEAST(3, 4, 0)
2346
2361 void SetDefaultTextureScaleMode(ScaleMode scale_mode);
2362
2377 void GetDefaultTextureScaleMode(ScaleMode* scale_mode);
2378
2395 GPURenderState CreateGPURenderState(GPURenderStateCreateInfo* createinfo);
2396
2412 void SetGPURenderState(GPURenderStateParam state);
2413
2414#endif // SDL_VERSION_ATLEAST(3, 4, 0)
2415};
2416
2419{
2420 using Renderer::Renderer;
2421
2429 RendererRef(RendererParam resource) noexcept
2430 : Renderer(resource.value)
2431 {
2432 }
2433
2441 RendererRef(RendererRaw resource) noexcept
2442 : Renderer(resource)
2443 {
2444 }
2445
2447 constexpr RendererRef(const RendererRef& other) noexcept = default;
2448
2451};
2452
2466{
2467 TextureRaw m_resource = nullptr;
2468
2469public:
2471 constexpr Texture(std::nullptr_t = nullptr) noexcept
2472 : m_resource(0)
2473 {
2474 }
2475
2483 constexpr explicit Texture(const TextureRaw resource) noexcept
2484 : m_resource(resource)
2485 {
2486 }
2487
2489 constexpr Texture(const Texture& other)
2490 : m_resource(other.m_resource)
2491 {
2492 if (m_resource) ++m_resource->refcount;
2493 }
2494
2496 constexpr Texture(Texture&& other) noexcept
2497 : Texture(other.release())
2498 {
2499 }
2500
2523 PixelFormat format,
2524 TextureAccess access,
2525 const PointRaw& size)
2526 : m_resource(
2527 CheckError(SDL_CreateTexture(renderer, format, access, size.x, size.y)))
2528 {
2529 }
2530
2555 : m_resource(CheckError(SDL_CreateTextureFromSurface(renderer, surface)))
2556 {
2557 }
2558
2684 : m_resource(CheckError(SDL_CreateTextureWithProperties(renderer, props)))
2685 {
2686 }
2687
2717 Texture(RendererParam renderer, StringParam file);
2718
2759 Texture(RendererParam renderer, IOStreamParam src, bool closeio = false);
2760
2768 static constexpr Texture Borrow(TextureParam resource)
2769 {
2770 if (resource) {
2771 ++resource.value->refcount;
2772 return Texture(resource.value);
2773 }
2774 return {};
2775 }
2776
2778 constexpr const TextureRaw operator->() const noexcept { return m_resource; }
2779
2781 constexpr TextureRaw operator->() noexcept { return m_resource; }
2782
2784 ~Texture() { SDL_DestroyTexture(m_resource); }
2785
2787 constexpr Texture& operator=(Texture&& other) noexcept
2788 {
2789 std::swap(m_resource, other.m_resource);
2790 return *this;
2791 }
2792
2794 constexpr Texture& operator=(const Texture& other) noexcept = default;
2795
2797 constexpr TextureRaw get() const noexcept { return m_resource; }
2798
2800 constexpr TextureRaw release() noexcept
2801 {
2802 auto r = m_resource;
2803 m_resource = nullptr;
2804 return r;
2805 }
2806
2808 constexpr auto operator<=>(const Texture& other) const noexcept = default;
2809
2811 constexpr explicit operator bool() const noexcept { return !!m_resource; }
2812
2814 constexpr operator TextureParam() const noexcept { return {m_resource}; }
2815
2829 void Destroy();
2830
2928
2939 RendererRef GetRenderer() const;
2940
2954 void GetSize(float* w, float* h) const;
2955
2957 Point GetSize() const;
2958
2960 FPoint GetSizeFloat() const;
2961
2963 int GetWidth() const;
2964
2966 int GetHeight() const;
2967
2969 PixelFormat GetFormat() const;
2970
2971#if SDL_VERSION_ATLEAST(3, 4, 0)
2972
2991 void SetPalette(PaletteParam palette);
2992
3006
3007#endif // SDL_VERSION_ATLEAST(3, 4, 0)
3008
3034 void SetColorMod(Uint8 r, Uint8 g, Uint8 b);
3035
3061 void SetColorModFloat(float r, float g, float b);
3062
3079 void GetColorMod(Uint8* r, Uint8* g, Uint8* b) const;
3080
3097 void GetColorModFloat(float* r, float* g, float* b) const;
3098
3121 void SetAlphaMod(Uint8 alpha);
3122
3145 void SetAlphaModFloat(float alpha);
3146
3161 Uint8 GetAlphaMod() const;
3162
3177 float GetAlphaModFloat() const;
3178
3201 void SetMod(Color c);
3202
3225 void SetModFloat(FColor c);
3226
3240 Color GetMod() const;
3241
3255 FColor GetModFloat() const;
3256
3272 void SetBlendMode(BlendMode blendMode);
3273
3286 BlendMode GetBlendMode() const;
3287
3304 void SetScaleMode(ScaleMode scaleMode);
3305
3318 ScaleMode GetScaleMode() const;
3319
3350 void Update(OptionalRef<const RectRaw> rect, const void* pixels, int pitch);
3351
3381 void Update(SurfaceConstParam surface,
3382 OptionalRef<const RectRaw> rect = std::nullopt);
3383
3413 const Uint8* Yplane,
3414 int Ypitch,
3415 const Uint8* Uplane,
3416 int Upitch,
3417 const Uint8* Vplane,
3418 int Vpitch);
3419
3445 const Uint8* Yplane,
3446 int Ypitch,
3447 const Uint8* UVplane,
3448 int UVpitch);
3449
3475 TextureLock Lock(OptionalRef<const RectRaw> rect, void** pixels, int* pitch);
3476
3508 OptionalRef<const RectRaw> rect = std::nullopt);
3509
3527 void Unlock(TextureLock&& lock);
3528
3546 void Unlock(TextureSurfaceLock&& lock);
3547};
3548
3551{
3552 using Texture::Texture;
3553
3561 TextureRef(TextureRaw resource) noexcept
3562 : Texture(Borrow(resource))
3563 {
3564 }
3565
3567 TextureRef(Texture resource) noexcept
3568 : Texture(std::move(resource))
3569 {
3570 }
3571};
3572
3603{
3604 TextureRef m_lock;
3605
3606public:
3636 TextureLock(TextureRef resource,
3638 void** pixels,
3639 int* pitch);
3640
3642 TextureLock(const TextureLock& other) = delete;
3643
3645 constexpr TextureLock(TextureLock&& other) noexcept
3646 : m_lock(other.m_lock)
3647 {
3648 other.m_lock = {};
3649 }
3650
3669
3670 TextureLock& operator=(const TextureLock& other) = delete;
3671
3674 {
3675 std::swap(m_lock, other.m_lock);
3676 return *this;
3677 }
3678
3680 constexpr operator bool() const { return bool(m_lock); }
3681
3699 void reset();
3700
3702 TextureRef get() { return m_lock; }
3703
3705 void release() { m_lock.release(); }
3706};
3707
3731{
3732 TextureRef m_lock;
3733
3734public:
3768 OptionalRef<const RectRaw> rect = std::nullopt);
3769
3772
3774 constexpr TextureSurfaceLock(TextureSurfaceLock&& other) noexcept
3775 : Surface(std::move(other))
3776 , m_lock(other.m_lock)
3777 {
3778 other.m_lock = {};
3779 }
3780
3799
3800 TextureSurfaceLock& operator=(const TextureSurfaceLock& other) = delete;
3801
3804 {
3805 std::swap(m_lock, other.m_lock);
3806 Surface::operator=(std::move(other));
3807 return *this;
3808 }
3809
3811 constexpr operator bool() const { return bool(m_lock); }
3812
3830 void reset();
3831
3833 TextureRef get() { return m_lock; }
3834
3836 void release()
3837 {
3839 m_lock.release();
3840 }
3841};
3842
3861inline int GetNumRenderDrivers() { return SDL_GetNumRenderDrivers(); }
3862
3885inline const char* GetRenderDriver(int index)
3886{
3887 return SDL_GetRenderDriver(index);
3888}
3889
3909 const PointRaw& size,
3910 WindowFlags window_flags,
3911 WindowRaw* window,
3912 RendererRaw* renderer)
3913{
3914 CheckError(SDL_CreateWindowAndRenderer(
3915 title, size.x, size.y, window_flags, window, renderer));
3916}
3917
3937 const PointRaw& size,
3938 WindowFlags window_flags,
3939 Window* window,
3940 Renderer* renderer)
3941{
3942 SDL_Window* windowRaw = nullptr;
3943 SDL_Renderer* rendererRaw = nullptr;
3945 std::move(title), size, window_flags, &windowRaw, &rendererRaw);
3946 if (window) *window = Window{windowRaw};
3947 if (renderer) *renderer = Renderer{rendererRaw};
3948}
3949
3967inline std::pair<Window, Renderer> CreateWindowAndRenderer(
3968 StringParam title,
3969 const PointRaw& size,
3970 WindowFlags window_flags = 0)
3971{
3972 SDL_Window* window = nullptr;
3973 SDL_Renderer* renderer = nullptr;
3975 std::move(title), size, window_flags, &window, &renderer);
3976 return {Window{window}, Renderer(renderer)};
3977}
3978
3998 const PointRaw& size,
3999 WindowFlags window_flags,
4000 Renderer* renderer)
4001{
4002 Window window;
4004 std::move(title), size, window_flags, &window, renderer);
4005 return window;
4006}
4007
4009 const PointRaw& size,
4010 WindowFlags window_flags,
4011 RendererRef* renderer)
4012 : Window(
4013 CreateWindowAndRenderer(std::move(title), size, window_flags, renderer))
4014{
4015}
4016
4051{
4052 return Renderer(window, std::move(name));
4053}
4054
4118{
4119 return Renderer(props);
4120}
4121
4122namespace prop::Renderer {
4123
4124constexpr auto CREATE_NAME_STRING = SDL_PROP_RENDERER_CREATE_NAME_STRING;
4125
4126constexpr auto CREATE_WINDOW_POINTER = SDL_PROP_RENDERER_CREATE_WINDOW_POINTER;
4127
4128constexpr auto CREATE_SURFACE_POINTER =
4129 SDL_PROP_RENDERER_CREATE_SURFACE_POINTER;
4130
4131constexpr auto CREATE_OUTPUT_COLORSPACE_NUMBER =
4132 SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER;
4133
4134constexpr auto CREATE_PRESENT_VSYNC_NUMBER =
4135 SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER;
4136
4137#if SDL_VERSION_ATLEAST(3, 4, 0)
4138
4139constexpr auto CREATE_GPU_DEVICE_POINTER =
4140 SDL_PROP_RENDERER_CREATE_GPU_DEVICE_POINTER;
4141
4142constexpr auto CREATE_GPU_SHADERS_SPIRV_BOOLEAN =
4143 SDL_PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN;
4144
4145constexpr auto CREATE_GPU_SHADERS_DXIL_BOOLEAN =
4146 SDL_PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN;
4147
4148constexpr auto CREATE_GPU_SHADERS_MSL_BOOLEAN =
4149 SDL_PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN;
4150
4151#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4152
4153constexpr auto CREATE_VULKAN_INSTANCE_POINTER =
4154 SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER;
4155
4156constexpr auto CREATE_VULKAN_SURFACE_NUMBER =
4157 SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER;
4158
4159constexpr auto CREATE_VULKAN_PHYSICAL_DEVICE_POINTER =
4160 SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER;
4161
4162constexpr auto CREATE_VULKAN_DEVICE_POINTER =
4163 SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER;
4164
4165constexpr auto CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER =
4166 SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER;
4167
4168constexpr auto CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER =
4169 SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER;
4170
4171constexpr auto NAME_STRING = SDL_PROP_RENDERER_NAME_STRING;
4172
4173constexpr auto WINDOW_POINTER = SDL_PROP_RENDERER_WINDOW_POINTER;
4174
4175constexpr auto SURFACE_POINTER = SDL_PROP_RENDERER_SURFACE_POINTER;
4176
4177constexpr auto VSYNC_NUMBER = SDL_PROP_RENDERER_VSYNC_NUMBER;
4178
4179constexpr auto MAX_TEXTURE_SIZE_NUMBER =
4180 SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER;
4181
4182constexpr auto TEXTURE_FORMATS_POINTER =
4183 SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER;
4184
4185#if SDL_VERSION_ATLEAST(3, 4, 0)
4186
4187constexpr auto TEXTURE_WRAPPING_BOOLEAN =
4188 SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN;
4189
4190#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4191
4192constexpr auto OUTPUT_COLORSPACE_NUMBER =
4193 SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER;
4194
4195constexpr auto HDR_ENABLED_BOOLEAN = SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN;
4196
4197constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT;
4198
4199constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT;
4200
4201constexpr auto D3D9_DEVICE_POINTER = SDL_PROP_RENDERER_D3D9_DEVICE_POINTER;
4202
4203constexpr auto D3D11_DEVICE_POINTER = SDL_PROP_RENDERER_D3D11_DEVICE_POINTER;
4204
4205constexpr auto D3D11_SWAPCHAIN_POINTER =
4206 SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER;
4207
4208constexpr auto D3D12_DEVICE_POINTER = SDL_PROP_RENDERER_D3D12_DEVICE_POINTER;
4209
4210constexpr auto D3D12_SWAPCHAIN_POINTER =
4211 SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER;
4212
4213constexpr auto D3D12_COMMAND_QUEUE_POINTER =
4214 SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER;
4215
4216constexpr auto VULKAN_INSTANCE_POINTER =
4217 SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER;
4218
4219constexpr auto VULKAN_SURFACE_NUMBER = SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER;
4220
4221constexpr auto VULKAN_PHYSICAL_DEVICE_POINTER =
4222 SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER;
4223
4224constexpr auto VULKAN_DEVICE_POINTER = SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER;
4225
4226constexpr auto VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER =
4227 SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER;
4228
4229constexpr auto VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER =
4230 SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER;
4231
4232constexpr auto VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER =
4233 SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER;
4234
4235constexpr auto GPU_DEVICE_POINTER = SDL_PROP_RENDERER_GPU_DEVICE_POINTER;
4236
4237} // namespace prop::Renderer
4238
4239#if SDL_VERSION_ATLEAST(3, 4, 0)
4240
4274{
4275 return SDL_CreateGPURenderer(device, window);
4276}
4277
4290{
4291 return SDL_GetGPURendererDevice(renderer);
4292}
4293
4295{
4296 return SDL::GetGPURendererDevice(m_resource);
4297}
4298
4299#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4300
4321{
4322 return Renderer(surface);
4323}
4324
4326{
4327 return {CheckError(SDL_GetRenderer(m_resource))};
4328}
4329
4342{
4343 return {CheckError(SDL_GetRenderWindow(renderer))};
4344}
4345
4347{
4348 return SDL::GetRenderWindow(m_resource);
4349}
4350
4365inline const char* GetRendererName(RendererParam renderer)
4366{
4367 return SDL_GetRendererName(renderer);
4368}
4369
4370inline const char* Renderer::GetName() const
4371{
4372 return SDL::GetRendererName(m_resource);
4373}
4374
4461{
4462 return {CheckError(SDL_GetRendererProperties(renderer))};
4463}
4464
4466{
4467 return SDL::GetRendererProperties(m_resource);
4468}
4469
4490inline void GetRenderOutputSize(RendererParam renderer, int* w, int* h)
4491{
4492 CheckError(SDL_GetRenderOutputSize(renderer, w, h));
4493}
4494
4515{
4516 Point p;
4517 GetRenderOutputSize(renderer, &p.x, &p.y);
4518 return p;
4519}
4520
4521inline void Renderer::GetOutputSize(int* w, int* h) const
4522{
4523 SDL::GetRenderOutputSize(m_resource, w, h);
4524}
4525
4527{
4528 return SDL::GetRenderOutputSize(m_resource);
4529}
4530
4551inline void GetCurrentRenderOutputSize(RendererParam renderer, int* w, int* h)
4552{
4553 CheckError(SDL_GetCurrentRenderOutputSize(renderer, w, h));
4554}
4555
4576{
4577 Point p;
4578 GetCurrentRenderOutputSize(renderer, &p.x, &p.y);
4579 return p;
4580}
4581
4582inline void Renderer::GetCurrentOutputSize(int* w, int* h) const
4583{
4584 SDL::GetCurrentRenderOutputSize(m_resource, w, h);
4585}
4586
4588{
4589 return SDL::GetCurrentRenderOutputSize(m_resource);
4590}
4591
4615 PixelFormat format,
4616 TextureAccess access,
4617 const PointRaw& size)
4618{
4619 return Texture(renderer, format, access, size);
4620}
4621
4623 TextureAccess access,
4624 const PointRaw& size)
4625{
4626 return Texture(m_resource, format, access, size);
4627}
4628
4655 SurfaceParam surface)
4656{
4657 return Texture(renderer, surface);
4658}
4659
4661{
4662 return Texture(m_resource, surface);
4663}
4664
4789 PropertiesParam props)
4790{
4791 return Texture(renderer, props);
4792}
4793
4795{
4796 return Texture(m_resource, props);
4797}
4798
4799namespace prop::Texture {
4800
4801constexpr auto CREATE_COLORSPACE_NUMBER =
4802 SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER;
4803
4804constexpr auto CREATE_FORMAT_NUMBER = SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER;
4805
4806constexpr auto CREATE_ACCESS_NUMBER = SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER;
4807
4808constexpr auto CREATE_WIDTH_NUMBER = SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER;
4809
4810constexpr auto CREATE_HEIGHT_NUMBER = SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER;
4811
4812#if SDL_VERSION_ATLEAST(3, 4, 0)
4813
4814constexpr auto CREATE_PALETTE_POINTER = SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER;
4815
4816#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4817
4818constexpr auto CREATE_SDR_WHITE_POINT_FLOAT =
4819 SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT;
4820
4821constexpr auto CREATE_HDR_HEADROOM_FLOAT =
4822 SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT;
4823
4824constexpr auto CREATE_D3D11_TEXTURE_POINTER =
4825 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER;
4826
4827constexpr auto CREATE_D3D11_TEXTURE_U_POINTER =
4828 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER;
4829
4830constexpr auto CREATE_D3D11_TEXTURE_V_POINTER =
4831 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER;
4832
4833constexpr auto CREATE_D3D12_TEXTURE_POINTER =
4834 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER;
4835
4836constexpr auto CREATE_D3D12_TEXTURE_U_POINTER =
4837 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER;
4838
4839constexpr auto CREATE_D3D12_TEXTURE_V_POINTER =
4840 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER;
4841
4842constexpr auto CREATE_METAL_PIXELBUFFER_POINTER =
4843 SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER;
4844
4845constexpr auto CREATE_OPENGL_TEXTURE_NUMBER =
4846 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER;
4847
4848constexpr auto CREATE_OPENGL_TEXTURE_UV_NUMBER =
4849 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER;
4850
4851constexpr auto CREATE_OPENGL_TEXTURE_U_NUMBER =
4852 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER;
4853
4854constexpr auto CREATE_OPENGL_TEXTURE_V_NUMBER =
4855 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER;
4856
4857constexpr auto CREATE_OPENGLES2_TEXTURE_NUMBER =
4858 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER;
4859
4860constexpr auto CREATE_OPENGLES2_TEXTURE_UV_NUMBER =
4861 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER;
4862
4863constexpr auto CREATE_OPENGLES2_TEXTURE_U_NUMBER =
4864 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER;
4865
4866constexpr auto CREATE_OPENGLES2_TEXTURE_V_NUMBER =
4867 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER;
4868
4869constexpr auto CREATE_VULKAN_TEXTURE_NUMBER =
4870 SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER;
4871
4872#if SDL_VERSION_ATLEAST(3, 4, 0)
4873
4874constexpr auto CREATE_VULKAN_LAYOUT_NUMBER =
4875 SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER;
4876
4877#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4878
4879#if SDL_VERSION_ATLEAST(3, 4, 0)
4880
4881constexpr auto CREATE_GPU_TEXTURE_POINTER =
4882 SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER;
4883
4884constexpr auto CREATE_GPU_TEXTURE_UV_POINTER =
4885 SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_POINTER;
4886
4887constexpr auto CREATE_GPU_TEXTURE_U_POINTER =
4888 SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_POINTER;
4889
4890constexpr auto CREATE_GPU_TEXTURE_V_POINTER =
4891 SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_POINTER;
4892
4893#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4894
4895constexpr auto COLORSPACE_NUMBER = SDL_PROP_TEXTURE_COLORSPACE_NUMBER;
4896
4897constexpr auto FORMAT_NUMBER = SDL_PROP_TEXTURE_FORMAT_NUMBER;
4898
4899constexpr auto ACCESS_NUMBER = SDL_PROP_TEXTURE_ACCESS_NUMBER;
4900
4901constexpr auto WIDTH_NUMBER = SDL_PROP_TEXTURE_WIDTH_NUMBER;
4902
4903constexpr auto HEIGHT_NUMBER = SDL_PROP_TEXTURE_HEIGHT_NUMBER;
4904
4905constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT;
4906
4907constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT;
4908
4909constexpr auto D3D11_TEXTURE_POINTER = SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER;
4910
4911constexpr auto D3D11_TEXTURE_U_POINTER =
4912 SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER;
4913
4914constexpr auto D3D11_TEXTURE_V_POINTER =
4915 SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER;
4916
4917constexpr auto D3D12_TEXTURE_POINTER = SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER;
4918
4919constexpr auto D3D12_TEXTURE_U_POINTER =
4920 SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER;
4921
4922constexpr auto D3D12_TEXTURE_V_POINTER =
4923 SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER;
4924
4925constexpr auto OPENGL_TEXTURE_NUMBER = SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER;
4926
4927constexpr auto OPENGL_TEXTURE_UV_NUMBER =
4928 SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER;
4929
4930constexpr auto OPENGL_TEXTURE_U_NUMBER =
4931 SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER;
4932
4933constexpr auto OPENGL_TEXTURE_V_NUMBER =
4934 SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER;
4935
4936constexpr auto OPENGL_TEXTURE_TARGET_NUMBER =
4937 SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER;
4938
4939constexpr auto OPENGL_TEX_W_FLOAT = SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT;
4940
4941constexpr auto OPENGL_TEX_H_FLOAT = SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT;
4942
4943constexpr auto OPENGLES2_TEXTURE_NUMBER =
4944 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER;
4945
4946constexpr auto OPENGLES2_TEXTURE_UV_NUMBER =
4947 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER;
4948
4949constexpr auto OPENGLES2_TEXTURE_U_NUMBER =
4950 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER;
4951
4952constexpr auto OPENGLES2_TEXTURE_V_NUMBER =
4953 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER;
4954
4955constexpr auto OPENGLES2_TEXTURE_TARGET_NUMBER =
4956 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER;
4957
4958constexpr auto VULKAN_TEXTURE_NUMBER = SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER;
4959
4960#if SDL_VERSION_ATLEAST(3, 4, 0)
4961
4962constexpr auto GPU_TEXTURE_POINTER = SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER;
4963
4964constexpr auto GPU_TEXTURE_UV_POINTER = SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER;
4965
4966constexpr auto GPU_TEXTURE_U_POINTER = SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER;
4967
4968constexpr auto GPU_TEXTURE_V_POINTER = SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER;
4969
4970#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4971
4972} // namespace prop::Texture
4973
5070{
5071 return {CheckError(SDL_GetTextureProperties(texture))};
5072}
5073
5075{
5076 return SDL::GetTextureProperties(m_resource);
5077}
5078
5091{
5092 return {SDL_GetRendererFromTexture(texture)};
5093}
5094
5096{
5097 return SDL::GetRendererFromTexture(m_resource);
5098}
5099
5114inline void GetTextureSize(TextureConstParam texture, float* w, float* h)
5115{
5116 CheckError(SDL_GetTextureSize(texture, w, h));
5117}
5118
5121{
5122 return Point(texture->w, texture->h);
5123}
5124
5125inline void Texture::GetSize(float* w, float* h) const
5126{
5127 SDL::GetTextureSize(m_resource, w, h);
5128}
5129
5131{
5132 return SDL::GetTextureSize(m_resource);
5133}
5134
5137{
5138 FPoint p;
5139 GetTextureSize(texture, &p.x, &p.y);
5140 return p;
5141}
5142
5144{
5145 return SDL::GetTextureSizeFloat(m_resource);
5146}
5147
5149inline int GetTextureWidth(TextureConstParam texture) { return texture->w; }
5150
5151inline int Texture::GetWidth() const
5152{
5153 return SDL::GetTextureWidth(m_resource);
5154}
5155
5157inline int GetTextureHeight(TextureConstParam texture) { return texture->h; }
5158
5159inline int Texture::GetHeight() const
5160{
5161 return SDL::GetTextureHeight(m_resource);
5162}
5163
5166{
5167 return texture->format;
5168}
5169
5171{
5172 return SDL::GetTextureFormat(m_resource);
5173}
5174
5175#if SDL_VERSION_ATLEAST(3, 4, 0)
5176
5196inline void SetTexturePalette(TextureParam texture, PaletteParam palette)
5197{
5198 CheckError(SDL_SetTexturePalette(texture, palette));
5199}
5200
5202{
5203 SDL::SetTexturePalette(m_resource, palette);
5204}
5205
5220{
5221 return Palette::Borrow(SDL_GetTexturePalette(texture));
5222}
5223
5225{
5226 return SDL::GetTexturePalette(m_resource);
5227}
5228
5229#endif // SDL_VERSION_ATLEAST(3, 4, 0)
5230
5257inline void SetTextureColorMod(TextureParam texture, Uint8 r, Uint8 g, Uint8 b)
5258{
5259 CheckError(SDL_SetTextureColorMod(texture, r, g, b));
5260}
5261
5263{
5264 SDL::SetTextureColorMod(m_resource, r, g, b);
5265}
5266
5294 float r,
5295 float g,
5296 float b)
5297{
5298 CheckError(SDL_SetTextureColorModFloat(texture, r, g, b));
5299}
5300
5301inline void Texture::SetColorModFloat(float r, float g, float b)
5302{
5303 SDL::SetTextureColorModFloat(m_resource, r, g, b);
5304}
5305
5324 Uint8* r,
5325 Uint8* g,
5326 Uint8* b)
5327{
5328 CheckError(SDL_GetTextureColorMod(texture, r, g, b));
5329}
5330
5331inline void Texture::GetColorMod(Uint8* r, Uint8* g, Uint8* b) const
5332{
5333 SDL::GetTextureColorMod(m_resource, r, g, b);
5334}
5335
5354 float* r,
5355 float* g,
5356 float* b)
5357{
5358 CheckError(SDL_GetTextureColorModFloat(texture, r, g, b));
5359}
5360
5361inline void Texture::GetColorModFloat(float* r, float* g, float* b) const
5362{
5363 SDL::GetTextureColorModFloat(m_resource, r, g, b);
5364}
5365
5389inline void SetTextureAlphaMod(TextureParam texture, Uint8 alpha)
5390{
5391 CheckError(SDL_SetTextureAlphaMod(texture, alpha));
5392}
5393
5394inline void Texture::SetAlphaMod(Uint8 alpha)
5395{
5396 SDL::SetTextureAlphaMod(m_resource, alpha);
5397}
5398
5422inline void SetTextureAlphaModFloat(TextureParam texture, float alpha)
5423{
5424 CheckError(SDL_SetTextureAlphaModFloat(texture, alpha));
5425}
5426
5427inline void Texture::SetAlphaModFloat(float alpha)
5428{
5429 SDL::SetTextureAlphaModFloat(m_resource, alpha);
5430}
5431
5448{
5449 Uint8 alpha;
5450 CheckError(SDL_GetTextureAlphaMod(texture, &alpha));
5451 return alpha;
5452}
5453
5455{
5456 return SDL::GetTextureAlphaMod(m_resource);
5457}
5458
5475{
5476 float alpha;
5477 CheckError(SDL_GetTextureAlphaModFloat(texture, &alpha));
5478 return alpha;
5479}
5480
5481inline float Texture::GetAlphaModFloat() const
5482{
5483 return SDL::GetTextureAlphaModFloat(m_resource);
5484}
5485
5509inline void SetTextureMod(TextureParam texture, Color c)
5510{
5511 SetTextureColorMod(texture, c.r, c.g, c.b);
5512 SetTextureAlphaMod(texture, c.a);
5513}
5514
5515inline void Texture::SetMod(Color c) { SDL::SetTextureMod(m_resource, c); }
5516
5541{
5542 SetTextureColorModFloat(texture, c.r, c.g, c.b);
5543 SetTextureAlphaModFloat(texture, c.a);
5544}
5545
5547{
5548 SDL::SetTextureModFloat(m_resource, c);
5549}
5550
5566{
5567 Color c;
5568 GetTextureColorMod(texture, &c.r, &c.g, &c.b);
5569 c.a = GetTextureAlphaMod(texture);
5570 return c;
5571}
5572
5573inline Color Texture::GetMod() const { return SDL::GetTextureMod(m_resource); }
5574
5590{
5591 FColor c;
5592 GetTextureColorModFloat(texture, &c.r, &c.g, &c.b);
5593 c.a = GetTextureAlphaModFloat(texture);
5594 return c;
5595}
5596
5598{
5599 return SDL::GetTextureModFloat(m_resource);
5600}
5601
5618inline void SetTextureBlendMode(TextureParam texture, BlendMode blendMode)
5619{
5620 CheckError(SDL_SetTextureBlendMode(texture, blendMode));
5621}
5622
5623inline void Texture::SetBlendMode(BlendMode blendMode)
5624{
5625 SDL::SetTextureBlendMode(m_resource, blendMode);
5626}
5627
5642{
5643 BlendMode blendMode;
5644 CheckError(SDL_GetTextureBlendMode(texture, &blendMode));
5645 return blendMode;
5646}
5647
5649{
5650 return SDL::GetTextureBlendMode(m_resource);
5651}
5652
5670inline void SetTextureScaleMode(TextureParam texture, ScaleMode scaleMode)
5671{
5672 CheckError(SDL_SetTextureScaleMode(texture, scaleMode));
5673}
5674
5675inline void Texture::SetScaleMode(ScaleMode scaleMode)
5676{
5677 SDL::SetTextureScaleMode(m_resource, scaleMode);
5678}
5679
5694{
5695 ScaleMode scaleMode;
5696 CheckError(SDL_GetTextureScaleMode(texture, &scaleMode));
5697 return scaleMode;
5698}
5699
5701{
5702 return SDL::GetTextureScaleMode(m_resource);
5703}
5704
5736inline void UpdateTexture(TextureParam texture,
5738 const void* pixels,
5739 int pitch)
5740{
5741 CheckError(SDL_UpdateTexture(texture, rect, pixels, pitch));
5742}
5743
5774inline void UpdateTexture(TextureParam texture,
5775 SurfaceConstParam surface,
5776 OptionalRef<const RectRaw> rect = std::nullopt)
5777{
5778 UpdateTexture(texture, rect, surface->pixels, surface->pitch);
5779}
5780
5782 const void* pixels,
5783 int pitch)
5784{
5785 SDL::UpdateTexture(m_resource, rect, pixels, pitch);
5786}
5787
5790{
5791 SDL::UpdateTexture(m_resource, surface, rect);
5792}
5793
5819inline void UpdateYUVTexture(TextureParam texture,
5821 const Uint8* Yplane,
5822 int Ypitch,
5823 const Uint8* Uplane,
5824 int Upitch,
5825 const Uint8* Vplane,
5826 int Vpitch)
5827{
5828 CheckError(SDL_UpdateYUVTexture(
5829 texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch));
5830}
5831
5833 const Uint8* Yplane,
5834 int Ypitch,
5835 const Uint8* Uplane,
5836 int Upitch,
5837 const Uint8* Vplane,
5838 int Vpitch)
5839{
5841 m_resource, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
5842}
5843
5868inline void UpdateNVTexture(TextureParam texture,
5870 const Uint8* Yplane,
5871 int Ypitch,
5872 const Uint8* UVplane,
5873 int UVpitch)
5874{
5875 CheckError(
5876 SDL_UpdateNVTexture(texture, rect, Yplane, Ypitch, UVplane, UVpitch));
5877}
5878
5880 const Uint8* Yplane,
5881 int Ypitch,
5882 const Uint8* UVplane,
5883 int UVpitch)
5884{
5885 SDL::UpdateNVTexture(m_resource, rect, Yplane, Ypitch, UVplane, UVpitch);
5886}
5887
5915inline void LockTexture(TextureParam texture,
5917 void** pixels,
5918 int* pitch)
5919{
5920 CheckError(SDL_LockTexture(texture, rect, pixels, pitch));
5921}
5922
5924 void** pixels,
5925 int* pitch)
5926{
5927 return {TextureRef(*this), rect, pixels, pitch};
5928}
5929
5932 void** pixels,
5933 int* pitch)
5934 : m_lock(std::move(resource))
5935{
5936 LockTexture(m_lock, rect, pixels, pitch);
5937}
5938
5971 TextureParam texture,
5972 OptionalRef<const RectRaw> rect = std::nullopt)
5973{
5974 SurfaceRaw surface = nullptr;
5975 CheckError(SDL_LockTextureToSurface(texture, rect, &surface));
5976 return Surface::Borrow(surface);
5977}
5978
5981{
5982 return {TextureRef(*this), rect};
5983}
5984
5987 : Surface(LockTextureToSurface(resource, rect))
5988 , m_lock(std::move(resource))
5989{
5990}
5991
6011inline void UnlockTexture(TextureParam texture) { SDL_UnlockTexture(texture); }
6012
6013inline void Texture::Unlock(TextureLock&& lock)
6014{
6015 SDL_assert_paranoid(lock.get() == *this);
6016 lock.reset();
6017}
6018
6020{
6021 SDL_assert_paranoid(lock.get() == *this);
6022 lock.reset();
6023}
6024
6026{
6027 if (!m_lock) return;
6028 UnlockTexture(m_lock);
6029 m_lock = {};
6031}
6032
6034{
6035 if (!m_lock) return;
6036 UnlockTexture(m_lock);
6037 m_lock = {};
6038}
6039
6064inline void SetRenderTarget(RendererParam renderer, TextureParam texture)
6065{
6066 CheckError(SDL_SetRenderTarget(renderer, texture));
6067}
6068
6070{
6071 SDL::SetRenderTarget(m_resource, texture);
6072}
6073
6090{
6091 SetRenderTarget(renderer, nullptr);
6092}
6093
6094inline void Renderer::ResetTarget() { SDL::ResetRenderTarget(m_resource); }
6095
6112{
6113 if (auto texture = SDL_GetRenderTarget(renderer))
6114 return Texture::Borrow(texture);
6115 return {};
6116}
6117
6119{
6120 return SDL::GetRenderTarget(m_resource);
6121}
6122
6167 const PointRaw& size,
6169{
6170 CheckError(SDL_SetRenderLogicalPresentation(renderer, size.x, size.y, mode));
6171}
6172
6175{
6176 SDL::SetRenderLogicalPresentation(m_resource, size, mode);
6177}
6178
6201 int* w,
6202 int* h,
6204{
6205 CheckError(SDL_GetRenderLogicalPresentation(renderer, w, h, mode));
6206}
6207
6230 PointRaw* size,
6232{
6233 if (size) {
6234 return GetRenderLogicalPresentation(renderer, &size->x, &size->y, mode);
6235 }
6236 return GetRenderLogicalPresentation(renderer, nullptr, nullptr, mode);
6237}
6238
6240 int* w,
6241 int* h,
6242 RendererLogicalPresentation* mode) const
6243{
6244 SDL::GetRenderLogicalPresentation(m_resource, w, h, mode);
6245}
6246
6249{
6250 SDL::GetRenderLogicalPresentation(m_resource, size, mode);
6251}
6252
6274{
6275 FRect rect;
6276 CheckError(SDL_GetRenderLogicalPresentationRect(renderer, &rect));
6277 return rect;
6278}
6279
6281{
6282 return SDL::GetRenderLogicalPresentationRect(m_resource);
6283}
6284
6308 const FPointRaw& window_coord)
6309{
6310 FPoint p;
6311 CheckError(SDL_RenderCoordinatesFromWindow(
6312 renderer, window_coord.x, window_coord.y, &p.x, &p.y));
6313 return p;
6314}
6315
6317 const FPointRaw& window_coord) const
6318{
6319 return SDL::RenderCoordinatesFromWindow(m_resource, window_coord);
6320}
6321
6346 const FPointRaw& coord)
6347{
6348 FPoint p;
6349 CheckError(
6350 SDL_RenderCoordinatesToWindow(renderer, coord.x, coord.y, &p.x, &p.y));
6351 return p;
6352}
6353
6355{
6356 return SDL::RenderCoordinatesToWindow(m_resource, coord);
6357}
6358
6392 Event* event)
6393{
6394 CheckError(SDL_ConvertEventToRenderCoordinates(renderer, event));
6395}
6396
6398{
6399 SDL::ConvertEventToRenderCoordinates(m_resource, event);
6400}
6401
6428{
6429 CheckError(SDL_SetRenderViewport(renderer, rect));
6430}
6431
6433{
6434 SDL::SetRenderViewport(m_resource, rect);
6435}
6436
6454{
6455 SetRenderViewport(renderer, std::nullopt);
6456}
6457
6459
6478{
6479 Rect rect;
6480 CheckError(SDL_GetRenderViewport(renderer, &rect));
6481 return rect;
6482}
6483
6485{
6486 return SDL::GetRenderViewport(m_resource);
6487}
6488
6510{
6511 return SDL_RenderViewportSet(renderer);
6512}
6513
6514inline bool Renderer::ViewportSet() const
6515{
6516 return SDL::RenderViewportSet(m_resource);
6517}
6518
6538{
6539 Rect rect;
6540 CheckError(SDL_GetRenderSafeArea(renderer, &rect));
6541 return rect;
6542}
6543
6545{
6546 return SDL::GetRenderSafeArea(m_resource);
6547}
6548
6569{
6570 CheckError(SDL_SetRenderClipRect(renderer, rect));
6571}
6572
6574{
6575 SDL::SetRenderClipRect(m_resource, rect);
6576}
6577
6595{
6596 SetRenderClipRect(renderer, std::nullopt);
6597}
6598
6600
6620{
6621 Rect rect;
6622 CheckError(SDL_GetRenderClipRect(renderer, &rect));
6623 return rect;
6624}
6625
6627{
6628 return SDL::GetRenderClipRect(m_resource);
6629}
6630
6649{
6650 return SDL_RenderClipEnabled(renderer);
6651}
6652
6653inline bool Renderer::IsClipEnabled() const
6654{
6655 return SDL::RenderClipEnabled(m_resource);
6656}
6657
6682inline void SetRenderScale(RendererParam renderer, const FPointRaw& scale)
6683{
6684 CheckError(SDL_SetRenderScale(renderer, scale.x, scale.y));
6685}
6686
6687inline void Renderer::SetScale(const FPointRaw& scale)
6688{
6689 SDL::SetRenderScale(m_resource, scale);
6690}
6691
6709inline void GetRenderScale(RendererParam renderer, float* scaleX, float* scaleY)
6710{
6711 CheckError(SDL_GetRenderScale(renderer, scaleX, scaleY));
6712}
6713
6730{
6731 FPoint p;
6732 GetRenderScale(renderer, &p.x, &p.y);
6733 return p;
6734}
6735
6736inline void Renderer::GetScale(float* scaleX, float* scaleY) const
6737{
6738 SDL::GetRenderScale(m_resource, scaleX, scaleY);
6739}
6740
6742{
6743 return SDL::GetRenderScale(m_resource);
6744}
6745
6764{
6765 CheckError(SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, c.a));
6766}
6767
6769{
6770 SDL::SetRenderDrawColor(m_resource, c);
6771}
6772
6790inline void SetRenderDrawColorFloat(RendererParam renderer, const FColorRaw& c)
6791{
6792 CheckError(SDL_SetRenderDrawColorFloat(renderer, c.r, c.g, c.b, c.a));
6793}
6794
6796{
6797 SDL::SetRenderDrawColorFloat(m_resource, c);
6798}
6799
6822 Uint8* r,
6823 Uint8* g,
6824 Uint8* b,
6825 Uint8* a)
6826{
6827 CheckError(SDL_GetRenderDrawColor(renderer, r, g, b, a));
6828}
6829
6845{
6846 Color c;
6847 GetRenderDrawColor(renderer, &c.r, &c.g, &c.b, &c.a);
6848 return c;
6849}
6850
6851inline void Renderer::GetDrawColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const
6852{
6853 SDL::GetRenderDrawColor(m_resource, r, g, b, a);
6854}
6855
6857{
6858 return SDL::GetRenderDrawColor(m_resource);
6859}
6860
6883 float* r,
6884 float* g,
6885 float* b,
6886 float* a)
6887{
6888 CheckError(SDL_GetRenderDrawColorFloat(renderer, r, g, b, a));
6889}
6890
6906{
6907 FColor c;
6908 GetRenderDrawColorFloat(renderer, &c.r, &c.g, &c.b, &c.a);
6909 return c;
6910}
6911
6912inline void Renderer::GetDrawColorFloat(float* r,
6913 float* g,
6914 float* b,
6915 float* a) const
6916{
6917 SDL::GetRenderDrawColorFloat(m_resource, r, g, b, a);
6918}
6919
6921{
6922 return SDL::GetRenderDrawColorFloat(m_resource);
6923}
6924
6945inline void SetRenderColorScale(RendererParam renderer, float scale)
6946{
6947 CheckError(SDL_SetRenderColorScale(renderer, scale));
6948}
6949
6950inline void Renderer::SetColorScale(float scale)
6951{
6952 SDL::SetRenderColorScale(m_resource, scale);
6953}
6954
6969{
6970 float scale;
6971 CheckError(SDL_GetRenderColorScale(renderer, &scale));
6972 return scale;
6973}
6974
6975inline float Renderer::GetColorScale() const
6976{
6977 return SDL::GetRenderColorScale(m_resource);
6978}
6979
6995inline void SetRenderDrawBlendMode(RendererParam renderer, BlendMode blendMode)
6996{
6997 CheckError(SDL_SetRenderDrawBlendMode(renderer, blendMode));
6998}
6999
7001{
7002 SDL::SetRenderDrawBlendMode(m_resource, blendMode);
7003}
7004
7019{
7020 BlendMode blendMode;
7021 CheckError(SDL_GetRenderDrawBlendMode(renderer, &blendMode));
7022 return blendMode;
7023}
7024
7026{
7027 return SDL::GetRenderDrawBlendMode(m_resource);
7028}
7029
7047inline void RenderClear(RendererParam renderer)
7048{
7049 CheckError(SDL_RenderClear(renderer));
7050}
7051
7052inline void Renderer::RenderClear() { SDL::RenderClear(m_resource); }
7053
7067inline void RenderPoint(RendererParam renderer, const FPointRaw& p)
7068{
7069 CheckError(SDL_RenderPoint(renderer, p.x, p.y));
7070}
7071
7073{
7074 SDL::RenderPoint(m_resource, p);
7075}
7076
7090inline void RenderPoints(RendererParam renderer,
7092{
7093 CheckError(SDL_RenderPoints(renderer, points.data(), points.size()));
7094}
7095
7097{
7098 SDL::RenderPoints(m_resource, points);
7099}
7100
7115inline void RenderLine(RendererParam renderer,
7116 const FPointRaw& p1,
7117 const FPointRaw& p2)
7118{
7119 CheckError(SDL_RenderLine(renderer, p1.x, p1.y, p2.x, p2.y));
7120}
7121
7122inline void Renderer::RenderLine(const FPointRaw& p1, const FPointRaw& p2)
7123{
7124 SDL::RenderLine(m_resource, p1, p2);
7125}
7126
7142{
7143 CheckError(SDL_RenderLines(renderer, points.data(), points.size()));
7144}
7145
7147{
7148 SDL::RenderLines(m_resource, points);
7149}
7150
7166{
7167 CheckError(SDL_RenderRect(renderer, rect));
7168}
7169
7171{
7172 SDL::RenderRect(m_resource, rect);
7173}
7174
7190{
7191 CheckError(SDL_RenderRects(renderer, rects.data(), rects.size()));
7192}
7193
7195{
7196 SDL::RenderRects(m_resource, rects);
7197}
7198
7214inline void RenderFillRect(RendererParam renderer,
7216{
7217 CheckError(SDL_RenderFillRect(renderer, rect));
7218}
7219
7221{
7222 SDL::RenderFillRect(m_resource, rect);
7223}
7224
7239inline void RenderFillRects(RendererParam renderer,
7241{
7242 CheckError(SDL_RenderFillRects(renderer, rects.data(), rects.size()));
7243}
7244
7246{
7247 SDL::RenderFillRects(m_resource, rects);
7248}
7249
7269inline void RenderTexture(RendererParam renderer,
7270 TextureParam texture,
7273{
7274 CheckError(SDL_RenderTexture(renderer, texture, srcrect, dstrect));
7275}
7276
7280{
7281 SDL::RenderTexture(m_resource, texture, srcrect, dstrect);
7282}
7283
7310 TextureParam texture,
7313 double angle,
7315 FlipMode flip = FlipMode::SDL_FLIP_NONE)
7316{
7317 CheckError(SDL_RenderTextureRotated(
7318 renderer, texture, srcrect, dstrect, angle, center, flip));
7319}
7320
7324 double angle,
7326 FlipMode flip)
7327{
7329 m_resource, texture, srcrect, dstrect, angle, center, flip);
7330}
7331
7358 TextureParam texture,
7363{
7364 CheckError(
7365 SDL_RenderTextureAffine(renderer, texture, srcrect, origin, right, down));
7366}
7367
7373{
7374 SDL::RenderTextureAffine(m_resource, texture, srcrect, origin, right, down);
7375}
7376
7402 TextureParam texture,
7404 float scale,
7406{
7407 CheckError(
7408 SDL_RenderTextureTiled(renderer, texture, srcrect, scale, dstrect));
7409}
7410
7413 float scale,
7415{
7416 SDL::RenderTextureTiled(m_resource, texture, srcrect, scale, dstrect);
7417}
7418
7452 TextureParam texture,
7454 float left_width,
7455 float right_width,
7456 float top_height,
7457 float bottom_height,
7458 float scale,
7460{
7461 CheckError(SDL_RenderTexture9Grid(renderer,
7462 texture,
7463 srcrect,
7464 left_width,
7465 right_width,
7466 top_height,
7467 bottom_height,
7468 scale,
7469 dstrect));
7470}
7471
7474 float left_width,
7475 float right_width,
7476 float top_height,
7477 float bottom_height,
7478 float scale,
7480{
7481 SDL::RenderTexture9Grid(m_resource,
7482 texture,
7483 srcrect,
7484 left_width,
7485 right_width,
7486 top_height,
7487 bottom_height,
7488 scale,
7489 dstrect);
7490}
7491
7492#if SDL_VERSION_ATLEAST(3, 4, 0)
7493
7530 TextureParam texture,
7531 const FRectRaw& srcrect,
7532 float left_width,
7533 float right_width,
7534 float top_height,
7535 float bottom_height,
7536 float scale,
7537 const FRectRaw& dstrect,
7538 float tileScale)
7539{
7540 CheckError(SDL_RenderTexture9GridTiled(renderer,
7541 texture,
7542 &srcrect,
7543 left_width,
7544 right_width,
7545 top_height,
7546 bottom_height,
7547 scale,
7548 &dstrect,
7549 tileScale));
7550}
7551
7553 const FRectRaw& srcrect,
7554 float left_width,
7555 float right_width,
7556 float top_height,
7557 float bottom_height,
7558 float scale,
7559 const FRectRaw& dstrect,
7560 float tileScale)
7561{
7563 texture,
7564 srcrect,
7565 left_width,
7566 right_width,
7567 top_height,
7568 bottom_height,
7569 scale,
7570 dstrect,
7571 tileScale);
7572}
7573
7574#endif // SDL_VERSION_ATLEAST(3, 4, 0)
7575
7596inline void RenderGeometry(RendererParam renderer,
7597 TextureParam texture,
7598 std::span<const Vertex> vertices,
7599 std::span<const int> indices = {})
7600{
7601 CheckError(SDL_RenderGeometry(renderer,
7602 texture,
7603 vertices.data(),
7604 vertices.size(),
7605 indices.data(),
7606 indices.size()));
7607}
7608
7610 std::span<const Vertex> vertices,
7611 std::span<const int> indices)
7612{
7613 SDL::RenderGeometry(m_resource, texture, vertices, indices);
7614}
7615
7644 TextureParam texture,
7645 const float* xy,
7646 int xy_stride,
7647 const FColor* color,
7648 int color_stride,
7649 const float* uv,
7650 int uv_stride,
7651 int num_vertices,
7652 const void* indices,
7653 int num_indices,
7654 int size_indices)
7655{
7656 CheckError(SDL_RenderGeometryRaw(renderer,
7657 texture,
7658 xy,
7659 xy_stride,
7660 color,
7661 color_stride,
7662 uv,
7663 uv_stride,
7664 num_vertices,
7665 indices,
7666 num_indices,
7667 size_indices));
7668}
7669
7671 const float* xy,
7672 int xy_stride,
7673 const FColor* color,
7674 int color_stride,
7675 const float* uv,
7676 int uv_stride,
7677 int num_vertices,
7678 const void* indices,
7679 int num_indices,
7680 int size_indices)
7681{
7682 SDL::RenderGeometryRaw(m_resource,
7683 texture,
7684 xy,
7685 xy_stride,
7686 color,
7687 color_stride,
7688 uv,
7689 uv_stride,
7690 num_vertices,
7691 indices,
7692 num_indices,
7693 size_indices);
7694}
7695
7696#if SDL_VERSION_ATLEAST(3, 4, 0)
7697
7715 TextureAddressMode u_mode,
7716 TextureAddressMode v_mode)
7717{
7718 CheckError(SDL_SetRenderTextureAddressMode(renderer, u_mode, v_mode));
7719}
7720
7722 TextureAddressMode v_mode)
7723{
7724 SDL::SetRenderTextureAddressMode(m_resource, u_mode, v_mode);
7725}
7726
7744 TextureAddressMode* u_mode,
7745 TextureAddressMode* v_mode)
7746{
7747 CheckError(SDL_GetRenderTextureAddressMode(renderer, u_mode, v_mode));
7748}
7749
7751 TextureAddressMode* v_mode)
7752{
7753 SDL::GetRenderTextureAddressMode(m_resource, u_mode, v_mode);
7754}
7755
7756#endif // SDL_VERSION_ATLEAST(3, 4, 0)
7757
7785{
7786 return Surface{CheckError(SDL_RenderReadPixels(renderer, rect))};
7787}
7788
7790{
7791 return SDL::RenderReadPixels(m_resource, rect);
7792}
7793
7839inline void RenderPresent(RendererParam renderer)
7840{
7841 CheckError(SDL_RenderPresent(renderer));
7842}
7843
7844inline void Renderer::Present() { SDL::RenderPresent(m_resource); }
7845
7861inline void DestroyTexture(TextureRaw texture) { SDL_DestroyTexture(texture); }
7862
7864
7878inline void DestroyRenderer(RendererRaw renderer)
7879{
7880 SDL_DestroyRenderer(renderer);
7881}
7882
7884
7915inline void FlushRenderer(RendererParam renderer)
7916{
7917 CheckError(SDL_FlushRenderer(renderer));
7918}
7919
7920inline void Renderer::Flush() { SDL::FlushRenderer(m_resource); }
7921
7939{
7940 return CheckError(SDL_GetRenderMetalLayer(renderer));
7941}
7942
7944{
7945 return SDL::GetRenderMetalLayer(m_resource);
7946}
7947
7970{
7971 return CheckError(SDL_GetRenderMetalCommandEncoder(renderer));
7972}
7973
7975{
7976 return SDL::GetRenderMetalCommandEncoder(m_resource);
7977}
7978
8006 Uint32 wait_stage_mask,
8007 Sint64 wait_semaphore,
8008 Sint64 signal_semaphore)
8009{
8010 CheckError(SDL_AddVulkanRenderSemaphores(
8011 renderer, wait_stage_mask, wait_semaphore, signal_semaphore));
8012}
8013
8015 Sint64 wait_semaphore,
8016 Sint64 signal_semaphore)
8017{
8019 m_resource, wait_stage_mask, wait_semaphore, signal_semaphore);
8020}
8021
8044inline void SetRenderVSync(RendererParam renderer, int vsync)
8045{
8046 CheckError(SDL_SetRenderVSync(renderer, vsync));
8047}
8048
8049inline void Renderer::SetVSync(int vsync)
8050{
8051 SDL::SetRenderVSync(m_resource, vsync);
8052}
8053
8055constexpr int RENDERER_VSYNC_DISABLED = SDL_RENDERER_VSYNC_DISABLED;
8056
8058constexpr int RENDERER_VSYNC_ADAPTIVE = SDL_RENDERER_VSYNC_ADAPTIVE;
8059
8074inline int GetRenderVSync(RendererParam renderer)
8075{
8076 int vsync;
8077 CheckError(SDL_GetRenderVSync(renderer, &vsync));
8078 return vsync;
8079}
8080
8081inline int Renderer::GetVSync() const
8082{
8083 return SDL::GetRenderVSync(m_resource);
8084}
8085
8096 SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE;
8097
8135inline void RenderDebugText(RendererParam renderer,
8136 const FPointRaw& p,
8137 StringParam str)
8138{
8139 CheckError(SDL_RenderDebugText(renderer, p.x, p.y, str));
8140}
8141
8143{
8144 SDL::RenderDebugText(m_resource, p, std::move(str));
8145}
8146
8171template<class... ARGS>
8173 const FPointRaw& p,
8174 std::string_view fmt,
8175 ARGS... args)
8176{
8178 renderer, p, std::vformat(fmt, std::make_format_args(args...)));
8179}
8180
8181template<class... ARGS>
8183 std::string_view fmt,
8184 ARGS... args)
8185{
8186 SDL::RenderDebugTextFormat(m_resource, p, fmt, args...);
8187}
8188
8189#if SDL_VERSION_ATLEAST(3, 4, 0)
8190
8207 ScaleMode scale_mode)
8208{
8209 CheckError(SDL_SetDefaultTextureScaleMode(renderer, scale_mode));
8210}
8211
8213{
8214 SDL::SetDefaultTextureScaleMode(m_resource, scale_mode);
8215}
8216
8233 ScaleMode* scale_mode)
8234{
8235 CheckError(SDL_GetDefaultTextureScaleMode(renderer, scale_mode));
8236}
8237
8239{
8240 SDL::GetDefaultTextureScaleMode(m_resource, scale_mode);
8241}
8242
8256{
8257 GPURenderStateRaw m_resource = nullptr;
8258
8259public:
8261 constexpr GPURenderState() = default;
8262
8270 constexpr explicit GPURenderState(const GPURenderStateRaw resource)
8271 : m_resource(resource)
8272 {
8273 }
8274
8275protected:
8277 constexpr GPURenderState(const GPURenderState& other) noexcept = default;
8278
8279public:
8282 : GPURenderState(other.release())
8283 {
8284 }
8285
8286 constexpr GPURenderState(const GPURenderStateRef& other) = delete;
8287
8288 constexpr GPURenderState(GPURenderStateRef&& other) = delete;
8289
8308 : m_resource(SDL_CreateGPURenderState(renderer, createinfo))
8309 {
8310 }
8311
8313 ~GPURenderState() { SDL_DestroyGPURenderState(m_resource); }
8314
8317 {
8318 std::swap(m_resource, other.m_resource);
8319 return *this;
8320 }
8321
8323 constexpr GPURenderStateRaw get() const { return m_resource; }
8324
8327 {
8328 auto r = m_resource;
8329 m_resource = nullptr;
8330 return r;
8331 }
8332
8334 constexpr auto operator<=>(const GPURenderState& other) const = default;
8335
8337 constexpr bool operator==(std::nullptr_t _) const { return !m_resource; }
8338
8340 constexpr explicit operator bool() const { return !!m_resource; }
8341
8343 constexpr operator GPURenderStateParam() const noexcept
8344 {
8345 return {m_resource};
8346 }
8347
8359 void Destroy();
8360
8377 void SetFragmentUniforms(Uint32 slot_index, const void* data, Uint32 length);
8378};
8379
8382{
8391 : GPURenderState(resource.value)
8392 {
8393 }
8394
8396 constexpr GPURenderStateRef(const GPURenderStateRef& other) noexcept =
8397 default;
8398
8401};
8402
8421 GPURenderStateCreateInfo* createinfo)
8422{
8423 return GPURenderState(renderer, createinfo);
8424}
8425
8427 GPURenderStateCreateInfo* createinfo)
8428{
8429 return GPURenderState(m_resource, createinfo);
8430}
8431
8450 Uint32 slot_index,
8451 const void* data,
8452 Uint32 length)
8453{
8454 CheckError(
8455 SDL_SetGPURenderStateFragmentUniforms(state, slot_index, data, length));
8456}
8457
8459 const void* data,
8460 Uint32 length)
8461{
8462 SDL::SetGPURenderStateFragmentUniforms(m_resource, slot_index, data, length);
8463}
8464
8482{
8483 CheckError(SDL_SetGPURenderState(renderer, state));
8484}
8485
8487{
8488 SDL::SetGPURenderState(m_resource, state);
8489}
8490
8504{
8505 SDL_DestroyGPURenderState(state);
8506}
8507
8509
8510#endif // SDL_VERSION_ATLEAST(3, 4, 0)
8511
8513
8514} // namespace SDL
8515
8516#endif /* SDL3PP_RENDER_H_ */
A custom GPU render state.
Definition: SDL3pp_render.h:8256
constexpr GPURenderState(GPURenderState &&other)
Move constructor.
Definition: SDL3pp_render.h:8281
constexpr GPURenderStateRaw release()
Retrieves underlying GPURenderStateRaw and clear this.
Definition: SDL3pp_render.h:8326
GPURenderState(RendererParam renderer, GPURenderStateCreateInfo *createinfo)
Create custom GPU render state.
Definition: SDL3pp_render.h:8307
constexpr GPURenderState(const GPURenderState &other) noexcept=default
Copy constructor.
constexpr GPURenderStateRaw get() const
Retrieves underlying GPURenderStateRaw.
Definition: SDL3pp_render.h:8323
constexpr bool operator==(std::nullptr_t _) const
Comparison.
Definition: SDL3pp_render.h:8337
constexpr GPURenderState(const GPURenderStateRaw resource)
Constructs from GPURenderStateParam.
Definition: SDL3pp_render.h:8270
constexpr auto operator<=>(const GPURenderState &other) const =default
Comparison.
~GPURenderState()
Destructor.
Definition: SDL3pp_render.h:8313
constexpr GPURenderState()=default
Default ctor.
GPURenderState & operator=(GPURenderState other)
Assignment operator.
Definition: SDL3pp_render.h:8316
Optional-like shim for references.
Definition: SDL3pp_optionalRef.h:20
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
A structure representing rendering state.
Definition: SDL3pp_render.h:329
constexpr Renderer(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_render.h:334
Renderer(WindowParam window)
Create a 2D rendering context for a window.
Definition: SDL3pp_render.h:397
constexpr Renderer(Renderer &&other) noexcept
Move constructor.
Definition: SDL3pp_render.h:357
Renderer(WindowParam window, StringParam name)
Create a 2D rendering context for a window.
Definition: SDL3pp_render.h:434
constexpr RendererRaw release() noexcept
Retrieves underlying RendererRaw and clear this.
Definition: SDL3pp_render.h:547
constexpr Renderer(const Renderer &other) noexcept=default
Copy constructor.
constexpr RendererRaw get() const noexcept
Retrieves underlying RendererRaw.
Definition: SDL3pp_render.h:544
constexpr Renderer & operator=(const Renderer &other) noexcept=default
Assignment operator.
Renderer(SurfaceParam surface)
Create a 2D software rendering context for a surface.
Definition: SDL3pp_render.h:523
constexpr Renderer(const RendererRaw resource) noexcept
Constructs from RendererParam.
Definition: SDL3pp_render.h:346
constexpr Renderer & operator=(Renderer &&other) noexcept
Assignment operator.
Definition: SDL3pp_render.h:532
Renderer(PropertiesParam props)
Create a 2D rendering context for a window, with the specified properties.
Definition: SDL3pp_render.h:500
constexpr auto operator<=>(const Renderer &other) const noexcept=default
Comparison.
~Renderer()
Destructor.
Definition: SDL3pp_render.h:529
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
A collection of pixels used in software blitting.
Definition: SDL3pp_surface.h:227
constexpr SurfaceRaw release() noexcept
Retrieves underlying SurfaceRaw and clear this.
Definition: SDL3pp_surface.h:534
constexpr Surface & operator=(Surface &&other) noexcept
Assignment operator.
Definition: SDL3pp_surface.h:521
static constexpr Surface Borrow(SurfaceParam resource)
Safely borrows the from SurfaceParam.
Definition: SDL3pp_surface.h:409
Lock a portion of the texture for write-only pixel access.
Definition: SDL3pp_render.h:3603
TextureRef get()
Get the reference to locked resource.
Definition: SDL3pp_render.h:3702
~TextureLock()
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL3pp_render.h:3668
TextureLock & operator=(TextureLock &&other) noexcept
Assignment operator.
Definition: SDL3pp_render.h:3673
TextureLock(const TextureLock &other)=delete
Copy constructor.
constexpr TextureLock(TextureLock &&other) noexcept
Move constructor.
Definition: SDL3pp_render.h:3645
void release()
Releases the lock without unlocking.
Definition: SDL3pp_render.h:3705
Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.
Definition: SDL3pp_render.h:3731
~TextureSurfaceLock()
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL3pp_render.h:3798
void release()
Releases the lock without unlocking.
Definition: SDL3pp_render.h:3836
TextureSurfaceLock(const TextureSurfaceLock &other)=delete
Copy constructor.
constexpr TextureSurfaceLock(TextureSurfaceLock &&other) noexcept
Move constructor.
Definition: SDL3pp_render.h:3774
TextureSurfaceLock & operator=(TextureSurfaceLock &&other) noexcept
Assignment operator.
Definition: SDL3pp_render.h:3803
TextureRef get()
Get the reference to locked resource.
Definition: SDL3pp_render.h:3833
An efficient driver-specific representation of pixel data.
Definition: SDL3pp_render.h:2466
constexpr Texture & operator=(Texture &&other) noexcept
Assignment operator.
Definition: SDL3pp_render.h:2787
constexpr Texture & operator=(const Texture &other) noexcept=default
Assignment operator.
constexpr TextureRaw operator->() noexcept
member access to underlying TextureRaw.
Definition: SDL3pp_render.h:2781
constexpr Texture(const TextureRaw resource) noexcept
Constructs from TextureParam.
Definition: SDL3pp_render.h:2483
constexpr Texture(const Texture &other)
Copy constructor.
Definition: SDL3pp_render.h:2489
Texture(RendererParam renderer, SurfaceParam surface)
Create a texture from an existing surface.
Definition: SDL3pp_render.h:2554
constexpr auto operator<=>(const Texture &other) const noexcept=default
Comparison.
static constexpr Texture Borrow(TextureParam resource)
Safely borrows the from TextureParam.
Definition: SDL3pp_render.h:2768
constexpr TextureRaw get() const noexcept
Retrieves underlying TextureRaw.
Definition: SDL3pp_render.h:2797
constexpr TextureRaw release() noexcept
Retrieves underlying TextureRaw and clear this.
Definition: SDL3pp_render.h:2800
~Texture()
Destructor.
Definition: SDL3pp_render.h:2784
constexpr const TextureRaw operator->() const noexcept
member access to underlying TextureRaw.
Definition: SDL3pp_render.h:2778
Texture(RendererParam renderer, PropertiesParam props)
Create a texture for a rendering context with the specified properties.
Definition: SDL3pp_render.h:2683
Texture(RendererParam renderer, PixelFormat format, TextureAccess access, const PointRaw &size)
Create a texture for a rendering context.
Definition: SDL3pp_render.h:2522
constexpr Texture(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_render.h:2471
constexpr Texture(Texture &&other) noexcept
Move constructor.
Definition: SDL3pp_render.h:2496
The struct used as an opaque handle to a window.
Definition: SDL3pp_video.h:789
constexpr Window(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_video.h:794
#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_Event Event
The structure for all events in SDL.
Definition: SDL3pp_events.h:844
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_FPoint FPointRaw
Alias to raw representation for FPoint.
Definition: SDL3pp_rect.h:28
SDL_FRect FRectRaw
Alias to raw representation for FRect.
Definition: SDL3pp_rect.h:40
SDL_Point PointRaw
Alias to raw representation for Point.
Definition: SDL3pp_rect.h:22
Rect GetRenderSafeArea(RendererParam renderer)
Get the safe area for rendering within the current viewport.
Definition: SDL3pp_render.h:6537
void reset()
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL3pp_render.h:6033
constexpr TextureAddressMode TEXTURE_ADDRESS_AUTO
Wrapping is enabled if texture coordinates are outside [0, 1], this is the default.
Definition: SDL3pp_render.h:263
FColor GetTextureModFloat(TextureConstParam texture)
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:5589
Renderer CreateRendererWithProperties(PropertiesParam props)
Create a 2D rendering context for a window, with the specified properties.
Definition: SDL3pp_render.h:4117
void SetDrawColorFloat(const FColorRaw &c)
Set the color used for drawing operations (Rect, Line and Clear).
Definition: SDL3pp_render.h:6795
constexpr int RENDERER_VSYNC_DISABLED
Constant for disabling renderer vsync.
Definition: SDL3pp_render.h:8055
void RenderPoints(RendererParam renderer, SpanRef< const FPointRaw > points)
Draw multiple points on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7090
void SetDrawColor(ColorRaw c)
Set the color used for drawing operations.
Definition: SDL3pp_render.h:6768
Texture GetTarget() const
Get the current render target.
Definition: SDL3pp_render.h:6118
void Destroy()
Destroy the rendering context for a window and free all associated textures.
Definition: SDL3pp_render.h:7883
const char * GetName() const
Get the name of a renderer.
Definition: SDL3pp_render.h:4370
SDL_GPURenderState * GPURenderStateRaw
Alias to raw representation for GPURenderState.
Definition: SDL3pp_render.h:160
void SetRenderViewport(RendererParam renderer, OptionalRef< const RectRaw > rect)
Set the drawing area for rendering on the current target.
Definition: SDL3pp_render.h:6426
void SetFragmentUniforms(Uint32 slot_index, const void *data, Uint32 length)
Set fragment shader uniform variables in a custom GPU render state.
Definition: SDL3pp_render.h:8458
void SetRenderScale(RendererParam renderer, const FPointRaw &scale)
Set the drawing scale for rendering on the current target.
Definition: SDL3pp_render.h:6682
bool RenderViewportSet(RendererParam renderer)
Return whether an explicit rectangle was set as the viewport.
Definition: SDL3pp_render.h:6509
void SetTexturePalette(TextureParam texture, PaletteParam palette)
Set the palette used by a texture.
Definition: SDL3pp_render.h:5196
void UpdateTexture(TextureParam texture, OptionalRef< const RectRaw > rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition: SDL3pp_render.h:5736
Point GetCurrentOutputSize() const
Get the current output size in pixels of a rendering context.
Definition: SDL3pp_render.h:4587
void GetTextureSize(TextureConstParam texture, float *w, float *h)
Get the size of a texture, as floating point values.
Definition: SDL3pp_render.h:5114
void SetColorModFloat(float r, float g, float b)
Set an additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:5301
void ResetRenderClipRect(RendererParam renderer)
Reset the clip rectangle for rendering to the entire render target.
Definition: SDL3pp_render.h:6594
void ResetRenderTarget(RendererParam renderer)
Set target texture back to window.
Definition: SDL3pp_render.h:6089
void RenderPoint(const FPointRaw &p)
Draw a point on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7072
GPURenderState CreateGPURenderState(GPURenderStateCreateInfo *createinfo)
Create custom GPU render state.
Definition: SDL3pp_render.h:8426
void GetTextureColorMod(TextureConstParam texture, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:5323
void CreateWindowAndRenderer(StringParam title, const PointRaw &size, WindowFlags window_flags, Window *window, Renderer *renderer)
Create a window and default renderer.
Definition: SDL3pp_render.h:3936
void SetRenderDrawColor(RendererParam renderer, ColorRaw c)
Set the color used for drawing operations.
Definition: SDL3pp_render.h:6763
void SetTextureMod(TextureParam texture, Color c)
Set an additional color and alpha values multiplied into render copy operations.
Definition: SDL3pp_render.h:5509
void SetTextureBlendMode(TextureParam texture, BlendMode blendMode)
Set the blend mode for a texture, used by Renderer.RenderTexture().
Definition: SDL3pp_render.h:5618
void GetCurrentRenderOutputSize(RendererParam renderer, int *w, int *h)
Get the current output size in pixels of a rendering context.
Definition: SDL3pp_render.h:4551
void CreateWindowAndRendererRaw(StringParam title, const PointRaw &size, WindowFlags window_flags, WindowRaw *window, RendererRaw *renderer)
Create a window and default renderer.
Definition: SDL3pp_render.h:3908
void GetRenderTextureAddressMode(TextureAddressMode *u_mode, TextureAddressMode *v_mode)
Get the texture addressing mode used in Renderer.RenderGeometry().
Definition: SDL3pp_render.h:7750
void SetBlendMode(BlendMode blendMode)
Set the blend mode for a texture, used by Renderer.RenderTexture().
Definition: SDL3pp_render.h:5623
Palette GetPalette()
Get the palette used by a texture.
Definition: SDL3pp_render.h:5224
Rect GetViewport() const
Get the drawing area for the current target.
Definition: SDL3pp_render.h:6484
Point GetSize() const
Get the size of a texture.
Definition: SDL3pp_render.h:5130
bool ViewportSet() const
Return whether an explicit rectangle was set as the viewport.
Definition: SDL3pp_render.h:6514
void RenderFillRect(RendererParam renderer, OptionalRef< const FRectRaw > rect)
Fill a rectangle on the current rendering target with the drawing color at subpixel precision.
Definition: SDL3pp_render.h:7214
void SetDrawBlendMode(BlendMode blendMode)
Set the blend mode used for drawing operations (Fill and Line).
Definition: SDL3pp_render.h:7000
FPoint GetSizeFloat() const
Get the size of a texture, as floating point values.
Definition: SDL3pp_render.h:5143
void SetDefaultTextureScaleMode(ScaleMode scale_mode)
Set default scale mode for new textures for given renderer.
Definition: SDL3pp_render.h:8212
RendererRef CreateGPURenderer(GPUDeviceParam device, WindowParam window)
Create a 2D GPU rendering context.
Definition: SDL3pp_render.h:4273
void SetAlphaMod(Uint8 alpha)
Set an additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:5394
constexpr TextureAddressMode TEXTURE_ADDRESS_WRAP
The texture is repeated (tiled)
Definition: SDL3pp_render.h:268
void RenderTextureRotated(RendererParam renderer, TextureParam texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FRectRaw > dstrect, double angle, OptionalRef< const FPointRaw > center, FlipMode flip=FlipMode::SDL_FLIP_NONE)
Copy a portion of the source texture to the current rendering target, with rotation and flipping,...
Definition: SDL3pp_render.h:7309
void SetTextureColorModFloat(TextureParam texture, float r, float g, float b)
Set an additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:5293
void RenderTexture9Grid(TextureParam texture, OptionalRef< const FRectRaw > srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, OptionalRef< const FRectRaw > dstrect)
Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precisio...
Definition: SDL3pp_render.h:7472
int GetTextureWidth(TextureConstParam texture)
Get the width in pixels.
Definition: SDL3pp_render.h:5149
Uint8 GetTextureAlphaMod(TextureConstParam texture)
Get the additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:5447
FPoint GetScale() const
Get the drawing scale for the current target.
Definition: SDL3pp_render.h:6741
SDL_Renderer * RendererRaw
Alias to raw representation for Renderer.
Definition: SDL3pp_render.h:47
PixelFormat GetFormat() const
Get the pixel format.
Definition: SDL3pp_render.h:5170
void Destroy()
Destroy the specified texture.
Definition: SDL3pp_render.h:7863
int GetTextureHeight(TextureConstParam texture)
Get the height in pixels.
Definition: SDL3pp_render.h:5157
bool IsClipEnabled() const
Get whether clipping is enabled on the given render target.
Definition: SDL3pp_render.h:6653
constexpr int RENDERER_VSYNC_ADAPTIVE
Constant for enabling asaptive renderer vsync.
Definition: SDL3pp_render.h:8058
GPUDeviceRef GetGPURendererDevice(RendererParam renderer)
Return the GPU device used by a renderer.
Definition: SDL3pp_render.h:4289
FPoint RenderCoordinatesToWindow(const FPointRaw &coord) const
Get a point in window coordinates when given a point in render coordinates.
Definition: SDL3pp_render.h:6354
void SetRenderVSync(RendererParam renderer, int vsync)
Toggle VSync of the given renderer.
Definition: SDL3pp_render.h:8044
void LockTexture(TextureParam texture, OptionalRef< const RectRaw > rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition: SDL3pp_render.h:5915
void RenderPresent(RendererParam renderer)
Update the screen with any rendering performed since the previous call.
Definition: SDL3pp_render.h:7839
constexpr auto SOFTWARE_RENDERER
The name of the software renderer.
Definition: SDL3pp_render.h:205
void RenderDebugText(RendererParam renderer, const FPointRaw &p, StringParam str)
Draw debug text to an Renderer.
Definition: SDL3pp_render.h:8135
void SetRenderClipRect(RendererParam renderer, OptionalRef< const RectRaw > rect)
Set the clip rectangle for rendering on the specified target.
Definition: SDL3pp_render.h:6567
void GetTextureColorModFloat(TextureConstParam texture, float *r, float *g, float *b)
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:5353
FPoint RenderCoordinatesToWindow(RendererParam renderer, const FPointRaw &coord)
Get a point in window coordinates when given a point in render coordinates.
Definition: SDL3pp_render.h:6345
float GetTextureAlphaModFloat(TextureConstParam texture)
Get the additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:5474
Texture GetRenderTarget(RendererParam renderer)
Get the current render target.
Definition: SDL3pp_render.h:6111
void RenderPoints(SpanRef< const FPointRaw > points)
Draw multiple points on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7096
void GetRenderTextureAddressMode(RendererParam renderer, TextureAddressMode *u_mode, TextureAddressMode *v_mode)
Get the texture addressing mode used in Renderer.RenderGeometry().
Definition: SDL3pp_render.h:7743
void ResetTarget()
Set target texture back to window.
Definition: SDL3pp_render.h:6094
void RenderTextureAffine(RendererParam renderer, TextureParam texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FPointRaw > origin, OptionalRef< const FPointRaw > right, OptionalRef< const FPointRaw > down)
Copy a portion of the source texture to the current rendering target, with affine transform,...
Definition: SDL3pp_render.h:7357
void GetDefaultTextureScaleMode(RendererParam renderer, ScaleMode *scale_mode)
Get default texture scale mode of the given renderer.
Definition: SDL3pp_render.h:8232
void RenderGeometryRaw(TextureParam texture, const float *xy, int xy_stride, const FColor *color, int color_stride, const float *uv, int uv_stride, int num_vertices, const void *indices, int num_indices, int size_indices)
Render a list of triangles, optionally using a texture and indices into the vertex arrays Color and a...
Definition: SDL3pp_render.h:7670
TextureSurfaceLock LockToSurface(OptionalRef< const RectRaw > rect=std::nullopt)
Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.
Definition: SDL3pp_render.h:5979
SDL_Vertex Vertex
Vertex structure.
Definition: SDL3pp_render.h:223
void RenderGeometryRaw(RendererParam renderer, TextureParam texture, const float *xy, int xy_stride, const FColor *color, int color_stride, const float *uv, int uv_stride, int num_vertices, const void *indices, int num_indices, int size_indices)
Render a list of triangles, optionally using a texture and indices into the vertex arrays Color and a...
Definition: SDL3pp_render.h:7643
void RenderLine(RendererParam renderer, const FPointRaw &p1, const FPointRaw &p2)
Draw a line on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7115
int GetHeight() const
Get the height in pixels.
Definition: SDL3pp_render.h:5159
GPURenderState CreateGPURenderState(RendererParam renderer, GPURenderStateCreateInfo *createinfo)
Create custom GPU render state.
Definition: SDL3pp_render.h:8420
PixelFormat GetTextureFormat(TextureConstParam texture)
Get the pixel format.
Definition: SDL3pp_render.h:5165
Texture CreateTextureFromSurface(RendererParam renderer, SurfaceParam surface)
Create a texture from an existing surface.
Definition: SDL3pp_render.h:4654
BlendMode GetTextureBlendMode(TextureConstParam texture)
Get the blend mode used for texture copy operations.
Definition: SDL3pp_render.h:5641
FPoint RenderCoordinatesFromWindow(RendererParam renderer, const FPointRaw &window_coord)
Get a point in render coordinates when given a point in window coordinates.
Definition: SDL3pp_render.h:6307
FColor GetDrawColorFloat() const
Get the color used for drawing operations (Rect, Line and Clear).
Definition: SDL3pp_render.h:6920
Uint8 GetAlphaMod() const
Get the additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:5454
constexpr TextureAddressMode TEXTURE_ADDRESS_INVALID
TEXTURE_ADDRESS_INVALID.
Definition: SDL3pp_render.h:256
FPoint GetTextureSizeFloat(TextureConstParam texture)
Get the size of a texture, as floating point values.
Definition: SDL3pp_render.h:5136
void RenderLines(RendererParam renderer, SpanRef< const FPointRaw > points)
Draw a series of connected lines on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7141
void SetModFloat(FColor c)
Set an additional color and alpha values multiplied into render copy operations.
Definition: SDL3pp_render.h:5546
void DestroyRenderer(RendererRaw renderer)
Destroy the rendering context for a window and free all associated textures.
Definition: SDL3pp_render.h:7878
void Destroy()
Destroy custom GPU render state.
Definition: SDL3pp_render.h:8508
void UnlockTexture(TextureParam texture)
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL3pp_render.h:6011
Palette GetTexturePalette(TextureParam texture)
Get the palette used by a texture.
Definition: SDL3pp_render.h:5219
void SetColorScale(float scale)
Set the color scale used for render operations.
Definition: SDL3pp_render.h:6950
int GetVSync() const
Get VSync of the given renderer.
Definition: SDL3pp_render.h:8081
void ResetRenderViewport(RendererParam renderer)
Reset the drawing area for rendering to the entire target.
Definition: SDL3pp_render.h:6453
Surface RenderReadPixels(RendererParam renderer, OptionalRef< const RectRaw > rect={})
Read pixels from the current rendering target.
Definition: SDL3pp_render.h:7783
BlendMode GetRenderDrawBlendMode(RendererParam renderer)
Get the blend mode used for drawing operations.
Definition: SDL3pp_render.h:7018
TextureSurfaceLock(TextureRef resource, OptionalRef< const RectRaw > rect=std::nullopt)
Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.
Definition: SDL3pp_render.h:5985
Point GetOutputSize() const
Get the output size in pixels of a rendering context.
Definition: SDL3pp_render.h:4526
void GetColorModFloat(float *r, float *g, float *b) const
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:5361
void SetColorMod(Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:5262
void RenderGeometry(RendererParam renderer, TextureParam texture, std::span< const Vertex > vertices, std::span< const int > indices={})
Render a list of triangles, optionally using a texture and indices into the vertex array Color and al...
Definition: SDL3pp_render.h:7596
void Update(OptionalRef< const RectRaw > rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition: SDL3pp_render.h:5781
void RenderRect(OptionalRef< const FRectRaw > rect)
Draw a rectangle on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7170
RendererRef GetRenderer() const
Get the renderer associated with a window.
Definition: SDL3pp_render.h:4325
void SetRenderTarget(RendererParam renderer, TextureParam texture)
Set a texture as the current rendering target.
Definition: SDL3pp_render.h:6064
void SetRenderDrawColorFloat(RendererParam renderer, const FColorRaw &c)
Set the color used for drawing operations (Rect, Line and Clear).
Definition: SDL3pp_render.h:6790
void SetGPURenderState(RendererParam renderer, GPURenderStateParam state)
Set custom GPU render state.
Definition: SDL3pp_render.h:8481
void Present()
Update the screen with any rendering performed since the previous call.
Definition: SDL3pp_render.h:7844
void ResetViewport()
Reset the drawing area for rendering to the entire target.
Definition: SDL3pp_render.h:6458
BlendMode GetDrawBlendMode() const
Get the blend mode used for drawing operations.
Definition: SDL3pp_render.h:7025
void RenderClear()
Clear the current rendering target with the drawing color.
Definition: SDL3pp_render.h:7052
SDL_TextureAccess TextureAccess
The access pattern allowed for a texture.
Definition: SDL3pp_render.h:230
SDL_GPURenderStateCreateInfo GPURenderStateCreateInfo
A structure specifying the parameters of a GPU render state.
Definition: SDL3pp_render.h:317
void RenderTexture(TextureParam texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FRectRaw > dstrect)
Copy a portion of the texture to the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7277
Renderer CreateSoftwareRenderer(SurfaceParam surface)
Create a 2D software rendering context for a surface.
Definition: SDL3pp_render.h:4320
void SetMod(Color c)
Set an additional color and alpha values multiplied into render copy operations.
Definition: SDL3pp_render.h:5515
void SetTextureModFloat(TextureParam texture, FColor c)
Set an additional color and alpha values multiplied into render copy operations.
Definition: SDL3pp_render.h:5540
void RenderLine(const FPointRaw &p1, const FPointRaw &p2)
Draw a line on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7122
Color GetMod() const
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:5573
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_OVERSCAN
The rendered content is fit to the smallest dimension and the other dimension extends beyond the outp...
Definition: SDL3pp_render.h:298
constexpr auto GPU_RENDERER
The name of the GPU renderer.
Definition: SDL3pp_render.h:214
PropertiesRef GetProperties() const
Get the properties associated with a texture.
Definition: SDL3pp_render.h:5074
void RenderDebugText(const FPointRaw &p, StringParam str)
Draw debug text to an Renderer.
Definition: SDL3pp_render.h:8142
Color GetTextureMod(TextureConstParam texture)
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:5565
void SetAlphaModFloat(float alpha)
Set an additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:5427
RendererRef GetRendererFromTexture(TextureConstParam texture)
Get the renderer that created an Texture.
Definition: SDL3pp_render.h:5090
SDL_TextureAddressMode TextureAddressMode
The addressing mode for a texture when used in Renderer.RenderGeometry().
Definition: SDL3pp_render.h:254
PropertiesRef GetRendererProperties(RendererParam renderer)
Get the properties associated with a renderer.
Definition: SDL3pp_render.h:4460
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_DISABLED
There is no logical size in effect.
Definition: SDL3pp_render.h:280
void GetRenderDrawColorFloat(RendererParam renderer, float *r, float *g, float *b, float *a)
Get the color used for drawing operations (Rect, Line and Clear).
Definition: SDL3pp_render.h:6882
void UpdateYUVTexture(TextureParam texture, OptionalRef< const RectRaw > rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
Update a rectangle within a planar YV12 or IYUV texture with new pixel data.
Definition: SDL3pp_render.h:5819
void RenderRects(RendererParam renderer, SpanRef< const FRectRaw > rects)
Draw some number of rectangles on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7189
ScaleMode GetTextureScaleMode(TextureConstParam texture)
Get the scale mode used for texture scale operations.
Definition: SDL3pp_render.h:5693
void * GetRenderMetalCommandEncoder(RendererParam renderer)
Get the Metal command encoder for the current frame.
Definition: SDL3pp_render.h:7969
Rect GetClipRect() const
Get the clip rectangle for the current target.
Definition: SDL3pp_render.h:6626
void * GetRenderMetalLayer()
Get the CAMetalLayer associated with the given Metal renderer.
Definition: SDL3pp_render.h:7943
void GetRenderScale(RendererParam renderer, float *scaleX, float *scaleY)
Get the drawing scale for the current target.
Definition: SDL3pp_render.h:6709
void SetRenderColorScale(RendererParam renderer, float scale)
Set the color scale used for render operations.
Definition: SDL3pp_render.h:6945
SDL_RendererLogicalPresentation RendererLogicalPresentation
How the logical size is mapped to the output.
Definition: SDL3pp_render.h:278
constexpr TextureAccess TEXTUREACCESS_TARGET
Texture can be used as a render target.
Definition: SDL3pp_render.h:238
void SetGPURenderState(GPURenderStateParam state)
Set custom GPU render state.
Definition: SDL3pp_render.h:8486
void GetRenderOutputSize(RendererParam renderer, int *w, int *h)
Get the output size in pixels of a rendering context.
Definition: SDL3pp_render.h:4490
FPoint RenderCoordinatesFromWindow(const FPointRaw &window_coord) const
Get a point in render coordinates when given a point in window coordinates.
Definition: SDL3pp_render.h:6316
void DestroyTexture(TextureRaw texture)
Destroy the specified texture.
Definition: SDL3pp_render.h:7861
void SetTextureAlphaModFloat(TextureParam texture, float alpha)
Set an additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:5422
Rect GetSafeArea() const
Get the safe area for rendering within the current viewport.
Definition: SDL3pp_render.h:6544
Rect GetRenderViewport(RendererParam renderer)
Get the drawing area for the current target.
Definition: SDL3pp_render.h:6477
PropertiesRef GetTextureProperties(TextureConstParam texture)
Get the properties associated with a texture.
Definition: SDL3pp_render.h:5069
void ConvertEventToRenderCoordinates(RendererParam renderer, Event *event)
Convert the coordinates in an event to render coordinates.
Definition: SDL3pp_render.h:6391
void RenderFillRects(RendererParam renderer, SpanRef< const FRectRaw > rects)
Fill some number of rectangles on the current rendering target with the drawing color at subpixel pre...
Definition: SDL3pp_render.h:7239
void DestroyGPURenderState(GPURenderStateRaw state)
Destroy custom GPU render state.
Definition: SDL3pp_render.h:8503
int GetWidth() const
Get the width in pixels.
Definition: SDL3pp_render.h:5151
void RenderTexture(RendererParam renderer, TextureParam texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FRectRaw > dstrect)
Copy a portion of the texture to the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7269
FColor GetModFloat() const
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:5597
void SetPalette(PaletteParam palette)
Set the palette used by a texture.
Definition: SDL3pp_render.h:5201
void RenderTextureAffine(TextureParam texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FPointRaw > origin, OptionalRef< const FPointRaw > right, OptionalRef< const FPointRaw > down)
Copy a portion of the source texture to the current rendering target, with affine transform,...
Definition: SDL3pp_render.h:7368
constexpr TextureAccess TEXTUREACCESS_STATIC
Changes rarely, not lockable.
Definition: SDL3pp_render.h:232
SDL_Texture * TextureRaw
Alias to raw representation for Texture.
Definition: SDL3pp_render.h:83
bool RenderClipEnabled(RendererParam renderer)
Get whether clipping is enabled on the given render target.
Definition: SDL3pp_render.h:6648
void AddVulkanRenderSemaphores(RendererParam renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore)
Add a set of synchronization semaphores for the current frame.
Definition: SDL3pp_render.h:8005
void * GetRenderMetalCommandEncoder()
Get the Metal command encoder for the current frame.
Definition: SDL3pp_render.h:7974
void SetViewport(OptionalRef< const RectRaw > rect)
Set the drawing area for rendering on the current target.
Definition: SDL3pp_render.h:6432
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_INTEGER_SCALE
The rendered content is scaled up by integer multiples to fit the output resolution.
Definition: SDL3pp_render.h:305
WindowRef GetWindow()
Get the window associated with a renderer.
Definition: SDL3pp_render.h:4346
constexpr TextureAccess TEXTUREACCESS_STREAMING
Changes frequently, lockable.
Definition: SDL3pp_render.h:235
BlendMode GetBlendMode() const
Get the blend mode used for texture copy operations.
Definition: SDL3pp_render.h:5648
void UpdateYUV(OptionalRef< const RectRaw > rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
Update a rectangle within a planar YV12 or IYUV texture with new pixel data.
Definition: SDL3pp_render.h:5832
PropertiesRef GetProperties() const
Get the properties associated with a renderer.
Definition: SDL3pp_render.h:4465
void RenderTextureTiled(RendererParam renderer, TextureParam texture, OptionalRef< const FRectRaw > srcrect, float scale, OptionalRef< const FRectRaw > dstrect)
Tile a portion of the texture to the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7401
void Flush()
Force the rendering context to flush any pending commands and state.
Definition: SDL3pp_render.h:7920
Texture CreateTextureWithProperties(PropertiesParam props)
Create a texture for a rendering context with the specified properties.
Definition: SDL3pp_render.h:4794
GPUDeviceRef GetGPUDevice()
Return the GPU device used by a renderer.
Definition: SDL3pp_render.h:4294
void reset()
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL3pp_render.h:6025
void RenderTextureTiled(TextureParam texture, OptionalRef< const FRectRaw > srcrect, float scale, OptionalRef< const FRectRaw > dstrect)
Tile a portion of the texture to the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7411
Surface LockTextureToSurface(TextureParam texture, OptionalRef< const RectRaw > rect=std::nullopt)
Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.
Definition: SDL3pp_render.h:5970
void SetGPURenderStateFragmentUniforms(GPURenderStateParam state, Uint32 slot_index, const void *data, Uint32 length)
Set fragment shader uniform variables in a custom GPU render state.
Definition: SDL3pp_render.h:8449
FRect GetLogicalPresentationRect() const
Get the final presentation rectangle for rendering.
Definition: SDL3pp_render.h:6280
void SetTextureColorMod(TextureParam texture, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:5257
void SetClipRect(OptionalRef< const RectRaw > rect)
Set the clip rectangle for rendering on the specified target.
Definition: SDL3pp_render.h:6573
constexpr int DEBUG_TEXT_FONT_CHARACTER_SIZE
The size, in pixels, of a single Renderer.RenderDebugText() character.
Definition: SDL3pp_render.h:8095
Renderer CreateRenderer(WindowParam window, StringParam name)
Create a 2D rendering context for a window.
Definition: SDL3pp_render.h:4050
constexpr TextureAddressMode TEXTURE_ADDRESS_CLAMP
Texture coordinates are clamped to the [0, 1] range.
Definition: SDL3pp_render.h:266
void ConvertEventToRenderCoordinates(Event *event) const
Convert the coordinates in an event to render coordinates.
Definition: SDL3pp_render.h:6397
TextureLock(TextureRef resource, OptionalRef< const RectRaw > rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition: SDL3pp_render.h:5930
void SetDefaultTextureScaleMode(RendererParam renderer, ScaleMode scale_mode)
Set default scale mode for new textures for given renderer.
Definition: SDL3pp_render.h:8206
Surface ReadPixels(OptionalRef< const RectRaw > rect={}) const
Read pixels from the current rendering target.
Definition: SDL3pp_render.h:7789
float GetRenderColorScale(RendererParam renderer)
Get the color scale used for render operations.
Definition: SDL3pp_render.h:6968
void SetScale(const FPointRaw &scale)
Set the drawing scale for rendering on the current target.
Definition: SDL3pp_render.h:6687
Texture CreateTextureFromSurface(SurfaceParam surface)
Create a texture from an existing surface.
Definition: SDL3pp_render.h:4660
Texture CreateTexture(RendererParam renderer, PixelFormat format, TextureAccess access, const PointRaw &size)
Create a texture for a rendering context.
Definition: SDL3pp_render.h:4614
float GetColorScale() const
Get the color scale used for render operations.
Definition: SDL3pp_render.h:6975
Rect GetRenderClipRect(RendererParam renderer)
Get the clip rectangle for the current target.
Definition: SDL3pp_render.h:6619
void UpdateNV(OptionalRef< const RectRaw > rect, const Uint8 *Yplane, int Ypitch, const Uint8 *UVplane, int UVpitch)
Update a rectangle within a planar NV12 or NV21 texture with new pixels.
Definition: SDL3pp_render.h:5879
void RenderFillRects(SpanRef< const FRectRaw > rects)
Fill some number of rectangles on the current rendering target with the drawing color at subpixel pre...
Definition: SDL3pp_render.h:7245
const char * GetRendererName(RendererParam renderer)
Get the name of a renderer.
Definition: SDL3pp_render.h:4365
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_LETTERBOX
The rendered content is fit to the largest dimension and the other dimension is letterboxed with the ...
Definition: SDL3pp_render.h:291
void RenderLines(SpanRef< const FPointRaw > points)
Draw a series of connected lines on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7146
void RenderTexture9Grid(RendererParam renderer, TextureParam texture, OptionalRef< const FRectRaw > srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, OptionalRef< const FRectRaw > dstrect)
Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precisio...
Definition: SDL3pp_render.h:7451
void SetLogicalPresentation(const PointRaw &size, RendererLogicalPresentation mode)
Set a device-independent resolution and presentation mode for rendering.
Definition: SDL3pp_render.h:6173
void GetLogicalPresentation(int *w, int *h, RendererLogicalPresentation *mode) const
Get device independent resolution and presentation mode for rendering.
Definition: SDL3pp_render.h:6239
void SetTarget(TextureParam texture)
Set a texture as the current rendering target.
Definition: SDL3pp_render.h:6069
ScaleMode GetScaleMode() const
Get the scale mode used for texture scale operations.
Definition: SDL3pp_render.h:5700
void SetTextureAlphaMod(TextureParam texture, Uint8 alpha)
Set an additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:5389
void * GetRenderMetalLayer(RendererParam renderer)
Get the CAMetalLayer associated with the given Metal renderer.
Definition: SDL3pp_render.h:7938
void RenderRects(SpanRef< const FRectRaw > rects)
Draw some number of rectangles on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7194
void RenderDebugTextFormat(const FPointRaw &p, std::string_view fmt, ARGS... args)
Draw debug text to an Renderer.
Definition: SDL3pp_render.h:8182
void GetRenderDrawColor(RendererParam renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Get the color used for drawing operations (Rect, Line and Clear).
Definition: SDL3pp_render.h:6821
TextureLock Lock(OptionalRef< const RectRaw > rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition: SDL3pp_render.h:5923
void RenderTexture9GridTiled(RendererParam renderer, TextureParam texture, const FRectRaw &srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const FRectRaw &dstrect, float tileScale)
Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precisio...
Definition: SDL3pp_render.h:7529
Texture CreateTextureWithProperties(RendererParam renderer, PropertiesParam props)
Create a texture for a rendering context with the specified properties.
Definition: SDL3pp_render.h:4788
void RenderDebugTextFormat(RendererParam renderer, const FPointRaw &p, std::string_view fmt, ARGS... args)
Draw debug text to an Renderer.
Definition: SDL3pp_render.h:8172
void SetRenderTextureAddressMode(RendererParam renderer, TextureAddressMode u_mode, TextureAddressMode v_mode)
Set the texture addressing mode used in Renderer.RenderGeometry().
Definition: SDL3pp_render.h:7714
FRect GetRenderLogicalPresentationRect(RendererParam renderer)
Get the final presentation rectangle for rendering.
Definition: SDL3pp_render.h:6273
void SetRenderTextureAddressMode(TextureAddressMode u_mode, TextureAddressMode v_mode)
Set the texture addressing mode used in Renderer.RenderGeometry().
Definition: SDL3pp_render.h:7721
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_STRETCH
The rendered content is stretched to the output resolution.
Definition: SDL3pp_render.h:284
void GetRenderLogicalPresentation(RendererParam renderer, int *w, int *h, RendererLogicalPresentation *mode)
Get device independent resolution and presentation mode for rendering.
Definition: SDL3pp_render.h:6200
void RenderPoint(RendererParam renderer, const FPointRaw &p)
Draw a point on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7067
void GetDefaultTextureScaleMode(ScaleMode *scale_mode)
Get default texture scale mode of the given renderer.
Definition: SDL3pp_render.h:8238
void RenderRect(RendererParam renderer, OptionalRef< const FRectRaw > rect)
Draw a rectangle on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:7165
void UpdateNVTexture(TextureParam texture, OptionalRef< const RectRaw > rect, const Uint8 *Yplane, int Ypitch, const Uint8 *UVplane, int UVpitch)
Update a rectangle within a planar NV12 or NV21 texture with new pixels.
Definition: SDL3pp_render.h:5868
void RenderFillRect(OptionalRef< const FRectRaw > rect)
Fill a rectangle on the current rendering target with the drawing color at subpixel precision.
Definition: SDL3pp_render.h:7220
int GetNumRenderDrivers()
Get the number of 2D rendering drivers available for the current display.
Definition: SDL3pp_render.h:3861
const char * GetRenderDriver(int index)
Use this function to get the name of a built in 2D rendering driver.
Definition: SDL3pp_render.h:3885
void SetRenderLogicalPresentation(RendererParam renderer, const PointRaw &size, RendererLogicalPresentation mode)
Set a device-independent resolution and presentation mode for rendering.
Definition: SDL3pp_render.h:6166
void Unlock(TextureLock &&lock)
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL3pp_render.h:6013
RendererRef GetRenderer() const
Get the renderer that created an Texture.
Definition: SDL3pp_render.h:5095
void SetVSync(int vsync)
Toggle VSync of the given renderer.
Definition: SDL3pp_render.h:8049
void ResetClipRect()
Reset the clip rectangle for rendering to the entire render target.
Definition: SDL3pp_render.h:6599
float GetAlphaModFloat() const
Get the additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:5481
void RenderTexture9GridTiled(TextureParam texture, const FRectRaw &srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const FRectRaw &dstrect, float tileScale)
Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precisio...
Definition: SDL3pp_render.h:7552
void AddVulkanRenderSemaphores(Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore)
Add a set of synchronization semaphores for the current frame.
Definition: SDL3pp_render.h:8014
void FlushRenderer(RendererParam renderer)
Force the rendering context to flush any pending commands and state.
Definition: SDL3pp_render.h:7915
void GetColorMod(Uint8 *r, Uint8 *g, Uint8 *b) const
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:5331
void RenderClear(RendererParam renderer)
Clear the current rendering target with the drawing color.
Definition: SDL3pp_render.h:7047
void SetRenderDrawBlendMode(RendererParam renderer, BlendMode blendMode)
Set the blend mode used for drawing operations (Fill and Line).
Definition: SDL3pp_render.h:6995
Texture CreateTexture(PixelFormat format, TextureAccess access, const PointRaw &size)
Create a texture for a rendering context.
Definition: SDL3pp_render.h:4622
WindowRef GetRenderWindow(RendererParam renderer)
Get the window associated with a renderer.
Definition: SDL3pp_render.h:4341
int GetRenderVSync(RendererParam renderer)
Get VSync of the given renderer.
Definition: SDL3pp_render.h:8074
void RenderGeometry(TextureParam texture, std::span< const Vertex > vertices, std::span< const int > indices={})
Render a list of triangles, optionally using a texture and indices into the vertex array Color and al...
Definition: SDL3pp_render.h:7609
Color GetDrawColor() const
Get the color used for drawing operations (Rect, Line and Clear).
Definition: SDL3pp_render.h:6856
void RenderTextureRotated(TextureParam texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FRectRaw > dstrect, double angle, OptionalRef< const FPointRaw > center, FlipMode flip=FlipMode::SDL_FLIP_NONE)
Copy a portion of the source texture to the current rendering target, with rotation and flipping,...
Definition: SDL3pp_render.h:7321
void SetTextureScaleMode(TextureParam texture, ScaleMode scaleMode)
Set the scale mode used for texture scale operations.
Definition: SDL3pp_render.h:5670
void SetScaleMode(ScaleMode scaleMode)
Set the scale mode used for texture scale operations.
Definition: SDL3pp_render.h:5675
::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
::Sint64 Sint64
A signed 64-bit integer type.
Definition: SDL3pp_stdinc.h:356
SDL_Surface * SurfaceRaw
Alias to raw representation for Surface.
Definition: SDL3pp_surface.h:46
SDL_FlipMode FlipMode
The flip mode.
Definition: SDL3pp_surface.h:182
SDL_ScaleMode ScaleMode
The scaling mode.
Definition: SDL3pp_surface.h:153
Uint64 WindowFlags
The flags on a window.
Definition: SDL3pp_video.h:556
SDL_Window * WindowRaw
Alias to raw representation for Window.
Definition: SDL3pp_video.h:47
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
The structure that defines a point (using floating point values).
Definition: SDL3pp_rect.h:512
A rectangle stored using floating point values.
Definition: SDL3pp_rect.h:1441
Safely wrap GPUDevice for non owning parameters.
Definition: SDL3pp_gpu.h:387
Semi-safe reference for GPUDevice.
Definition: SDL3pp_gpu.h:4160
Safely wrap GPURenderState for non owning parameters.
Definition: SDL3pp_render.h:167
GPURenderStateRaw value
parameter's GPURenderStateRaw
Definition: SDL3pp_render.h:168
constexpr auto operator<=>(const GPURenderStateParam &other) const =default
Comparison.
constexpr GPURenderStateParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_render.h:177
constexpr GPURenderStateParam(GPURenderStateRaw value)
Constructs from GPURenderStateRaw.
Definition: SDL3pp_render.h:171
Semi-safe reference for GPURenderState.
Definition: SDL3pp_render.h:8382
constexpr GPURenderStateRef(const GPURenderStateRef &other) noexcept=default
Copy constructor.
~GPURenderStateRef()
Destructor.
Definition: SDL3pp_render.h:8400
GPURenderStateRef(GPURenderStateParam resource)
Constructs from GPURenderStateParam.
Definition: SDL3pp_render.h:8390
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 Renderer for non owning parameters.
Definition: SDL3pp_render.h:54
constexpr RendererParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_render.h:64
constexpr auto operator<=>(const RendererParam &other) const =default
Comparison.
RendererRaw value
parameter's RendererRaw
Definition: SDL3pp_render.h:55
constexpr RendererParam(RendererRaw value)
Constructs from RendererRaw.
Definition: SDL3pp_render.h:58
Semi-safe reference for Renderer.
Definition: SDL3pp_render.h:2419
RendererRef(RendererRaw resource) noexcept
Constructs from RendererParam.
Definition: SDL3pp_render.h:2441
constexpr RendererRef(const RendererRef &other) noexcept=default
Copy constructor.
~RendererRef()
Destructor.
Definition: SDL3pp_render.h:2450
RendererRef(RendererParam resource) noexcept
Constructs from RendererParam.
Definition: SDL3pp_render.h:2429
Safely wrap Surface for non owning const parameters.
Definition: SDL3pp_surface.h:83
Safely wrap Surface for non owning parameters.
Definition: SDL3pp_surface.h:53
Safely wrap Texture for non owning const parameters.
Definition: SDL3pp_render.h:120
constexpr TextureConstParam(TextureParam value)
Constructs from TextureParam.
Definition: SDL3pp_render.h:130
const TextureRaw value
parameter's const TextureRaw
Definition: SDL3pp_render.h:121
constexpr TextureConstParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_render.h:136
constexpr auto operator->()
member access to underlying TextureRaw.
Definition: SDL3pp_render.h:151
constexpr auto operator<=>(const TextureConstParam &other) const =default
Comparison.
constexpr TextureConstParam(const TextureRaw value)
Constructs from const TextureRaw.
Definition: SDL3pp_render.h:124
Safely wrap Texture for non owning parameters.
Definition: SDL3pp_render.h:90
constexpr auto operator->()
member access to underlying TextureRaw.
Definition: SDL3pp_render.h:115
constexpr auto operator<=>(const TextureParam &other) const =default
Comparison.
constexpr TextureParam(TextureRaw value)
Constructs from TextureRaw.
Definition: SDL3pp_render.h:94
constexpr TextureParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_render.h:100
TextureRaw value
parameter's TextureRaw
Definition: SDL3pp_render.h:91
Safe reference for Texture.
Definition: SDL3pp_render.h:3551
TextureRef(Texture resource) noexcept
Constructs from Texture.
Definition: SDL3pp_render.h:3567
TextureRef(TextureRaw resource) noexcept
Constructs from TextureRaw.
Definition: SDL3pp_render.h:3561
Safely wrap Window for non owning parameters.
Definition: SDL3pp_video.h:54
Semi-safe reference for Window.
Definition: SDL3pp_video.h:3169