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
42
43// Forward decl
44struct Renderer;
45
47using RendererRaw = SDL_Renderer*;
48
49// Forward decl
50struct Texture;
51
53using TextureRaw = SDL_Texture*;
54
56using TextureRawConst = const SDL_Texture*;
57
64
67
68#if SDL_VERSION_ATLEAST(3, 3, 6)
69
70// Forward decl
71struct GPURenderState;
72
74using GPURenderStateRaw = SDL_GPURenderState*;
75
82
83#endif // SDL_VERSION_ATLEAST(3, 3, 6)
84
85// Forward decl
87
88// Forward decl
89struct TextureLock;
90
96constexpr auto SOFTWARE_RENDERER = SDL_SOFTWARE_RENDERER;
97
98#if SDL_VERSION_ATLEAST(3, 4, 0)
99
105constexpr auto GPU_RENDERER = SDL_GPU_RENDERER;
106
107#endif // SDL_VERSION_ATLEAST(3, 4, 0)
108
114using Vertex = SDL_Vertex;
115
121using TextureAccess = SDL_TextureAccess;
122
124 SDL_TEXTUREACCESS_STATIC;
125
127 SDL_TEXTUREACCESS_STREAMING;
128
130 SDL_TEXTUREACCESS_TARGET;
131
132#if SDL_VERSION_ATLEAST(3, 4, 0)
133
145using TextureAddressMode = SDL_TextureAddressMode;
146
148 SDL_TEXTURE_ADDRESS_INVALID;
149
154constexpr TextureAddressMode TEXTURE_ADDRESS_AUTO = SDL_TEXTURE_ADDRESS_AUTO;
155
157constexpr TextureAddressMode TEXTURE_ADDRESS_CLAMP = SDL_TEXTURE_ADDRESS_CLAMP;
158
160 SDL_TEXTURE_ADDRESS_WRAP;
161
162#endif // SDL_VERSION_ATLEAST(3, 4, 0)
163
169using RendererLogicalPresentation = SDL_RendererLogicalPresentation;
170
172 SDL_LOGICAL_PRESENTATION_DISABLED;
173
176 SDL_LOGICAL_PRESENTATION_STRETCH;
177
183 SDL_LOGICAL_PRESENTATION_LETTERBOX;
184
190 SDL_LOGICAL_PRESENTATION_OVERSCAN;
191
197 SDL_LOGICAL_PRESENTATION_INTEGER_SCALE;
198
199#if SDL_VERSION_ATLEAST(3, 4, 0)
200
208using GPURenderStateCreateInfo = SDL_GPURenderStateCreateInfo;
209
210#endif // SDL_VERSION_ATLEAST(3, 4, 0)
211
219struct Renderer : ResourceBase<RendererRaw>
220{
222
230 constexpr explicit Renderer(RendererRaw resource) noexcept
231 : ResourceBase(resource)
232 {
233 }
234
236 constexpr Renderer(const Renderer& other) = delete;
237
239 constexpr Renderer(Renderer&& other) noexcept
240 : Renderer(other.release())
241 {
242 }
243
244 constexpr Renderer(const RendererRef& other) = delete;
245
246 constexpr Renderer(RendererRef&& other) = delete;
247
280 Renderer(WindowRef window, StringParam name = nullptr);
281
343 Renderer(PropertiesRef props);
344
363 Renderer(SurfaceRef surface);
364
366 ~Renderer() { SDL_DestroyRenderer(get()); }
367
369 constexpr Renderer& operator=(Renderer&& other) noexcept
370 {
371 swap(*this, other);
372 return *this;
373 }
374
376 Renderer& operator=(const Renderer& other) = delete;
377
390 void Destroy();
391
392#if SDL_VERSION_ATLEAST(3, 4, 0)
393
405
406#endif // SDL_VERSION_ATLEAST(3, 4, 0)
407
419
433 const char* GetName() const;
434
520
540 void GetOutputSize(int* w, int* h) const;
541
560 Point GetOutputSize() const;
561
581 void GetCurrentOutputSize(int* w, int* h) const;
582
602
625 TextureAccess access,
626 const PointRaw& size);
627
653
777
801 void SetTarget(TextureRef texture);
802
817 void ResetTarget();
818
834 Texture GetTarget() const;
835
878 void SetLogicalPresentation(const PointRaw& size,
880
902 void GetLogicalPresentation(int* w,
903 int* h,
904 RendererLogicalPresentation* mode) const;
905
928
950
972 FPoint RenderCoordinatesFromWindow(const FPointRaw& window_coord) const;
973
996 FPoint RenderCoordinatesToWindow(const FPointRaw& coord) const;
997
1030 void ConvertEventToRenderCoordinates(Event* event) const;
1031
1056
1072 void ResetViewport();
1073
1090 Rect GetViewport() const;
1091
1111 bool ViewportSet() const;
1112
1130 Rect GetSafeArea() const;
1131
1151
1167 void ResetClipRect();
1168
1186 Rect GetClipRect() const;
1187
1204 bool IsClipEnabled() const;
1205
1229 void SetScale(const FPointRaw& scale);
1230
1247 void GetScale(float* scaleX, float* scaleY) const;
1248
1264 FPoint GetScale() const;
1265
1282 void SetDrawColor(ColorRaw c);
1283
1300 void SetDrawColorFloat(const FColorRaw& c);
1301
1322 void GetDrawColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const;
1323
1337 Color GetDrawColor() const;
1338
1359 void GetDrawColorFloat(float* r, float* g, float* b, float* a) const;
1360
1374 FColor GetDrawColorFloat() const;
1375
1396 void SetColorScale(float scale);
1397
1410 float GetColorScale() const;
1411
1426 void SetDrawBlendMode(BlendMode blendMode);
1427
1441
1458 void RenderClear();
1459
1472 void RenderPoint(const FPointRaw& p);
1473
1487
1501 void RenderLine(const FPointRaw& p1, const FPointRaw& p2);
1502
1517
1532
1547
1563
1578
1597 void RenderTexture(TextureRef texture,
1600
1625 void RenderTextureRotated(TextureRef texture,
1628 double angle,
1630 FlipMode flip = FlipMode::SDL_FLIP_NONE);
1631
1656 void RenderTextureAffine(TextureRef texture,
1661
1685 void RenderTextureTiled(TextureRef texture,
1687 float scale,
1689
1721 void RenderTexture9Grid(TextureRef texture,
1723 float left_width,
1724 float right_width,
1725 float top_height,
1726 float bottom_height,
1727 float scale,
1729
1730#if SDL_VERSION_ATLEAST(3, 4, 0)
1731
1767 const FRectRaw& srcrect,
1768 float left_width,
1769 float right_width,
1770 float top_height,
1771 float bottom_height,
1772 float scale,
1773 const FRectRaw& dstrect,
1774 float tileScale);
1775
1776#endif // SDL_VERSION_ATLEAST(3, 4, 0)
1777
1797 void RenderGeometry(TextureRef texture,
1798 std::span<const Vertex> vertices,
1799 std::span<const int> indices = {});
1800
1828 void RenderGeometryRaw(TextureRef texture,
1829 const float* xy,
1830 int xy_stride,
1831 const FColor* color,
1832 int color_stride,
1833 const float* uv,
1834 int uv_stride,
1835 int num_vertices,
1836 const void* indices,
1837 int num_indices,
1838 int size_indices);
1839
1840#if SDL_VERSION_ATLEAST(3, 4, 0)
1841
1860 TextureAddressMode v_mode);
1861
1880 TextureAddressMode* v_mode);
1881
1882#endif // SDL_VERSION_ATLEAST(3, 4, 0)
1883
1909
1955 void Present();
1956
1986 void Flush();
1987
2003 void* GetRenderMetalLayer();
2004
2026
2053 void AddVulkanRenderSemaphores(Uint32 wait_stage_mask,
2054 Sint64 wait_semaphore,
2055 Sint64 signal_semaphore);
2056
2078 void SetVSync(int vsync);
2079
2092 int GetVSync() const;
2093
2131 void RenderDebugText(const FPointRaw& p, StringParam str);
2132
2158 template<class... ARGS>
2159 void RenderDebugTextFormat(const FPointRaw& p,
2160 std::string_view fmt,
2161 ARGS... args);
2162
2163#if SDL_VERSION_ATLEAST(3, 4, 0)
2164
2179 void SetDefaultTextureScaleMode(ScaleMode scale_mode);
2180
2195 void GetDefaultTextureScaleMode(ScaleMode* scale_mode);
2196
2213 GPURenderState CreateGPURenderState(
2214 const GPURenderStateCreateInfo& createinfo);
2215
2232
2233#endif // SDL_VERSION_ATLEAST(3, 4, 0)
2234};
2235
2248struct Texture : ResourceBase<TextureRaw, TextureRawConst>
2249{
2251
2259 constexpr explicit Texture(TextureRaw resource) noexcept
2260 : ResourceBase(resource)
2261 {
2262 }
2263
2265 constexpr Texture(const Texture& other)
2266 : Texture(other.get())
2267 {
2268 if (auto res = get()) ++res->refcount;
2269 }
2270
2272 constexpr Texture(Texture&& other) noexcept
2273 : Texture(other.release())
2274 {
2275 }
2276
2298 Texture(RendererRef renderer,
2299 PixelFormat format,
2300 TextureAccess access,
2301 const PointRaw& size);
2302
2327 Texture(RendererRef renderer, SurfaceRef surface);
2328
2451 Texture(RendererRef renderer, PropertiesRef props);
2452
2482 Texture(RendererRef renderer, StringParam file);
2483
2524 Texture(RendererRef renderer, IOStreamRef src, bool closeio = false);
2525
2533 static Texture Borrow(TextureRaw resource)
2534 {
2535 if (resource) {
2536 ++resource->refcount;
2537 return Texture(resource);
2538 }
2539 return {};
2540 }
2541
2543 constexpr operator TextureConstRef() const noexcept { return get(); }
2544
2546 ~Texture() { SDL_DestroyTexture(get()); }
2547
2549 constexpr Texture& operator=(Texture&& other) noexcept
2550 {
2551 swap(*this, other);
2552 return *this;
2553 }
2554
2557 {
2558 if (get() != other.get()) {
2559 Texture tmp(other);
2560 swap(*this, tmp);
2561 }
2562 return *this;
2563 }
2564
2578 void Destroy();
2579
2677
2688 RendererRef GetRenderer() const;
2689
2703 void GetSize(float* w, float* h) const;
2704
2706 Point GetSize() const;
2707
2709 FPoint GetSizeFloat() const;
2710
2712 int GetWidth() const;
2713
2715 int GetHeight() const;
2716
2718 PixelFormat GetFormat() const;
2719
2720#if SDL_VERSION_ATLEAST(3, 4, 0)
2721
2740 void SetPalette(PaletteRef palette);
2741
2755
2756#endif // SDL_VERSION_ATLEAST(3, 4, 0)
2757
2783 void SetColorMod(Uint8 r, Uint8 g, Uint8 b);
2784
2810 void SetColorModFloat(float r, float g, float b);
2811
2828 void GetColorMod(Uint8* r, Uint8* g, Uint8* b) const;
2829
2846 void GetColorModFloat(float* r, float* g, float* b) const;
2847
2870 void SetAlphaMod(Uint8 alpha);
2871
2894 void SetAlphaModFloat(float alpha);
2895
2910 Uint8 GetAlphaMod() const;
2911
2926 float GetAlphaModFloat() const;
2927
2950 void SetMod(Color c);
2951
2974 void SetModFloat(FColor c);
2975
2989 Color GetMod() const;
2990
3004 FColor GetModFloat() const;
3005
3021 void SetBlendMode(BlendMode blendMode);
3022
3035 BlendMode GetBlendMode() const;
3036
3053 void SetScaleMode(ScaleMode scaleMode);
3054
3067 ScaleMode GetScaleMode() const;
3068
3099 void Update(OptionalRef<const RectRaw> rect, const void* pixels, int pitch);
3100
3130 void Update(SurfaceConstRef surface,
3131 OptionalRef<const RectRaw> rect = std::nullopt);
3132
3162 const Uint8* Yplane,
3163 int Ypitch,
3164 const Uint8* Uplane,
3165 int Upitch,
3166 const Uint8* Vplane,
3167 int Vpitch);
3168
3194 const Uint8* Yplane,
3195 int Ypitch,
3196 const Uint8* UVplane,
3197 int UVpitch);
3198
3224 TextureLock Lock(OptionalRef<const RectRaw> rect, void** pixels, int* pitch);
3225
3257 OptionalRef<const RectRaw> rect = std::nullopt);
3258
3276 void Unlock(TextureLock&& lock);
3277
3295 void Unlock(TextureSurfaceLock&& lock);
3296};
3297
3328{
3329 TextureRef m_lock;
3330
3331public:
3363 void** pixels,
3364 int* pitch);
3365
3367 TextureLock(const TextureLock& other) = delete;
3368
3370 TextureLock(TextureLock&& other) noexcept
3371 : m_lock(std::move(other.m_lock))
3372 {
3373 }
3374
3393
3394 TextureLock& operator=(const TextureLock& other) = delete;
3395
3398 {
3399 std::swap(m_lock, other.m_lock);
3400 return *this;
3401 }
3402
3404 constexpr operator bool() const { return bool(m_lock); }
3405
3423 void reset();
3424
3426 TextureRef resource() const { return m_lock; }
3427
3429 void release() { m_lock.release(); }
3430};
3431
3455{
3456 TextureRef m_lock;
3457
3458public:
3492 OptionalRef<const RectRaw> rect = std::nullopt);
3493
3496
3499 : Surface(std::move(other))
3500 , m_lock(std::move(other.m_lock))
3501 {
3502 }
3503
3522
3523 TextureSurfaceLock& operator=(const TextureSurfaceLock& other) = delete;
3524
3527 {
3528 std::swap(m_lock, other.m_lock);
3529 Surface::operator=(std::move(other));
3530 return *this;
3531 }
3532
3550 void reset();
3551
3553 TextureRef resource() const { return m_lock; }
3554};
3555
3574inline int GetNumRenderDrivers() { return SDL_GetNumRenderDrivers(); }
3575
3598inline const char* GetRenderDriver(int index)
3599{
3600 return SDL_GetRenderDriver(index);
3601}
3602
3622 const PointRaw& size,
3623 WindowFlags window_flags,
3624 WindowRaw* window,
3625 RendererRaw* renderer)
3626{
3627 CheckError(SDL_CreateWindowAndRenderer(
3628 title, size.x, size.y, window_flags, window, renderer));
3629}
3630
3649 const PointRaw& size,
3650 WindowFlags window_flags,
3651 Window* window,
3652 Renderer* renderer)
3653{
3654 SDL_Window* windowRaw = nullptr;
3655 SDL_Renderer* rendererRaw = nullptr;
3657 std::move(title), size, window_flags, &windowRaw, &rendererRaw);
3658 if (window) *window = Window{windowRaw};
3659 if (renderer) *renderer = Renderer{rendererRaw};
3660}
3661
3678inline std::pair<Window, Renderer> CreateWindowAndRenderer(
3679 StringParam title,
3680 const PointRaw& size,
3681 WindowFlags window_flags = 0)
3682{
3683 SDL_Window* window = nullptr;
3684 SDL_Renderer* renderer = nullptr;
3686 std::move(title), size, window_flags, &window, &renderer);
3687 return {Window{window}, Renderer(renderer)};
3688}
3689
3708 const PointRaw& size,
3709 WindowFlags window_flags,
3710 Renderer* renderer)
3711{
3712 Window window;
3714 std::move(title), size, window_flags, &window, renderer);
3715 return window;
3716}
3717
3719 const PointRaw& size,
3720 WindowFlags window_flags,
3721 RendererRef* renderer)
3722 : Window(
3723 CreateWindowAndRenderer(std::move(title), size, window_flags, renderer))
3724{
3725}
3726
3760inline Renderer CreateRenderer(WindowRef window, StringParam name = nullptr)
3761{
3762 return Renderer(window, std::move(name));
3763}
3764
3766 : Renderer(SDL_CreateRenderer(window, name))
3767{
3768}
3769
3771 : Renderer(SDL_CreateRendererWithProperties(props))
3772{
3773}
3774
3776 : Renderer(SDL_CreateSoftwareRenderer(surface))
3777{
3778}
3779
3843{
3844 return Renderer(props);
3845}
3846
3858
3859constexpr auto CREATE_NAME_STRING = SDL_PROP_RENDERER_CREATE_NAME_STRING;
3860
3861constexpr auto CREATE_WINDOW_POINTER = SDL_PROP_RENDERER_CREATE_WINDOW_POINTER;
3862
3863constexpr auto CREATE_SURFACE_POINTER =
3864 SDL_PROP_RENDERER_CREATE_SURFACE_POINTER;
3865
3866constexpr auto CREATE_OUTPUT_COLORSPACE_NUMBER =
3867 SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER;
3868
3869constexpr auto CREATE_PRESENT_VSYNC_NUMBER =
3870 SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER;
3871
3872#if SDL_VERSION_ATLEAST(3, 4, 0)
3873
3874constexpr auto CREATE_GPU_DEVICE_POINTER =
3875 SDL_PROP_RENDERER_CREATE_GPU_DEVICE_POINTER;
3876
3877constexpr auto CREATE_GPU_SHADERS_SPIRV_BOOLEAN =
3878 SDL_PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN;
3879
3880constexpr auto CREATE_GPU_SHADERS_DXIL_BOOLEAN =
3881 SDL_PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN;
3882
3883constexpr auto CREATE_GPU_SHADERS_MSL_BOOLEAN =
3884 SDL_PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN;
3885
3886#endif // SDL_VERSION_ATLEAST(3, 4, 0)
3887
3888constexpr auto CREATE_VULKAN_INSTANCE_POINTER =
3889 SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER;
3890
3891constexpr auto CREATE_VULKAN_SURFACE_NUMBER =
3892 SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER;
3893
3894constexpr auto CREATE_VULKAN_PHYSICAL_DEVICE_POINTER =
3895 SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER;
3896
3897constexpr auto CREATE_VULKAN_DEVICE_POINTER =
3898 SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER;
3899
3900constexpr auto CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER =
3901 SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER;
3902
3903constexpr auto CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER =
3904 SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER;
3905
3906constexpr auto NAME_STRING = SDL_PROP_RENDERER_NAME_STRING;
3907
3908constexpr auto WINDOW_POINTER = SDL_PROP_RENDERER_WINDOW_POINTER;
3909
3910constexpr auto SURFACE_POINTER = SDL_PROP_RENDERER_SURFACE_POINTER;
3911
3912constexpr auto VSYNC_NUMBER = SDL_PROP_RENDERER_VSYNC_NUMBER;
3913
3914constexpr auto MAX_TEXTURE_SIZE_NUMBER =
3915 SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER;
3916
3917constexpr auto TEXTURE_FORMATS_POINTER =
3918 SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER;
3919
3920#if SDL_VERSION_ATLEAST(3, 4, 0)
3921
3922constexpr auto TEXTURE_WRAPPING_BOOLEAN =
3923 SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN;
3924
3925#endif // SDL_VERSION_ATLEAST(3, 4, 0)
3926
3927constexpr auto OUTPUT_COLORSPACE_NUMBER =
3928 SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER;
3929
3930constexpr auto HDR_ENABLED_BOOLEAN = SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN;
3931
3932constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT;
3933
3934constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT;
3935
3936constexpr auto D3D9_DEVICE_POINTER = SDL_PROP_RENDERER_D3D9_DEVICE_POINTER;
3937
3938constexpr auto D3D11_DEVICE_POINTER = SDL_PROP_RENDERER_D3D11_DEVICE_POINTER;
3939
3940constexpr auto D3D11_SWAPCHAIN_POINTER =
3941 SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER;
3942
3943constexpr auto D3D12_DEVICE_POINTER = SDL_PROP_RENDERER_D3D12_DEVICE_POINTER;
3944
3945constexpr auto D3D12_SWAPCHAIN_POINTER =
3946 SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER;
3947
3948constexpr auto D3D12_COMMAND_QUEUE_POINTER =
3949 SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER;
3950
3951constexpr auto VULKAN_INSTANCE_POINTER =
3952 SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER;
3953
3954constexpr auto VULKAN_SURFACE_NUMBER = SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER;
3955
3956constexpr auto VULKAN_PHYSICAL_DEVICE_POINTER =
3957 SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER;
3958
3959constexpr auto VULKAN_DEVICE_POINTER = SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER;
3960
3961constexpr auto VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER =
3962 SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER;
3963
3964constexpr auto VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER =
3965 SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER;
3966
3967constexpr auto VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER =
3968 SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER;
3969
3970constexpr auto GPU_DEVICE_POINTER = SDL_PROP_RENDERER_GPU_DEVICE_POINTER;
3971
3972} // namespace prop::Renderer
3973
3974#if SDL_VERSION_ATLEAST(3, 4, 0)
3975
4009{
4010 return SDL_CreateGPURenderer(device, window);
4011}
4012
4025{
4026 return SDL_GetGPURendererDevice(renderer);
4027}
4028
4033
4034#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4035
4056{
4057 return Renderer(surface);
4058}
4059
4061{
4062 return CheckError(SDL_GetRenderer(get()));
4063}
4064
4077{
4078 return CheckError(SDL_GetRenderWindow(renderer));
4079}
4080
4082
4097inline const char* GetRendererName(RendererRef renderer)
4098{
4099 return CheckError(SDL_GetRendererName(renderer));
4100}
4101
4102inline const char* Renderer::GetName() const
4103{
4104 return SDL::GetRendererName(get());
4105}
4106
4193{
4194 return CheckError(SDL_GetRendererProperties(renderer));
4195}
4196
4198{
4200}
4201
4222inline void GetRenderOutputSize(RendererRef renderer, int* w, int* h)
4223{
4224 CheckError(SDL_GetRenderOutputSize(renderer, w, h));
4225}
4226
4247{
4248 Point p;
4249 GetRenderOutputSize(renderer, &p.x, &p.y);
4250 return p;
4251}
4252
4253inline void Renderer::GetOutputSize(int* w, int* h) const
4254{
4256}
4257
4259{
4260 return SDL::GetRenderOutputSize(get());
4261}
4262
4283inline void GetCurrentRenderOutputSize(RendererRef renderer, int* w, int* h)
4284{
4285 CheckError(SDL_GetCurrentRenderOutputSize(renderer, w, h));
4286}
4287
4308{
4309 Point p;
4310 GetCurrentRenderOutputSize(renderer, &p.x, &p.y);
4311 return p;
4312}
4313
4314inline void Renderer::GetCurrentOutputSize(int* w, int* h) const
4315{
4317}
4318
4323
4347 PixelFormat format,
4348 TextureAccess access,
4349 const PointRaw& size)
4350{
4351 return Texture(renderer, format, access, size);
4352}
4353
4355 TextureAccess access,
4356 const PointRaw& size)
4357{
4358 return Texture(get(), format, access, size);
4359}
4360
4362 PixelFormat format,
4363 TextureAccess access,
4364 const PointRaw& size)
4365 : Texture(SDL_CreateTexture(renderer, format, access, size.x, size.y))
4366{
4367}
4368
4369inline Texture::Texture(RendererRef renderer, SurfaceRef surface)
4370 : Texture(SDL_CreateTextureFromSurface(renderer, surface))
4371{
4372}
4373
4375 : Texture(SDL_CreateTextureWithProperties(renderer, props))
4376{
4377}
4378
4405 SurfaceRef surface)
4406{
4407 return Texture(renderer, surface);
4408}
4409
4411{
4412 return Texture(get(), surface);
4413}
4414
4537 PropertiesRef props)
4538{
4539 return Texture(renderer, props);
4540}
4541
4543{
4544 return Texture(get(), props);
4545}
4546
4557namespace prop::Texture {
4558
4559constexpr auto CREATE_COLORSPACE_NUMBER =
4560 SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER;
4561
4562constexpr auto CREATE_FORMAT_NUMBER = SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER;
4563
4564constexpr auto CREATE_ACCESS_NUMBER = SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER;
4565
4566constexpr auto CREATE_WIDTH_NUMBER = SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER;
4567
4568constexpr auto CREATE_HEIGHT_NUMBER = SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER;
4569
4570#if SDL_VERSION_ATLEAST(3, 4, 0)
4571
4572constexpr auto CREATE_PALETTE_POINTER = SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER;
4573
4574#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4575
4576constexpr auto CREATE_SDR_WHITE_POINT_FLOAT =
4577 SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT;
4578
4579constexpr auto CREATE_HDR_HEADROOM_FLOAT =
4580 SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT;
4581
4582constexpr auto CREATE_D3D11_TEXTURE_POINTER =
4583 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER;
4584
4585constexpr auto CREATE_D3D11_TEXTURE_U_POINTER =
4586 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER;
4587
4588constexpr auto CREATE_D3D11_TEXTURE_V_POINTER =
4589 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER;
4590
4591constexpr auto CREATE_D3D12_TEXTURE_POINTER =
4592 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER;
4593
4594constexpr auto CREATE_D3D12_TEXTURE_U_POINTER =
4595 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER;
4596
4597constexpr auto CREATE_D3D12_TEXTURE_V_POINTER =
4598 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER;
4599
4600constexpr auto CREATE_METAL_PIXELBUFFER_POINTER =
4601 SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER;
4602
4603constexpr auto CREATE_OPENGL_TEXTURE_NUMBER =
4604 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER;
4605
4606constexpr auto CREATE_OPENGL_TEXTURE_UV_NUMBER =
4607 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER;
4608
4609constexpr auto CREATE_OPENGL_TEXTURE_U_NUMBER =
4610 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER;
4611
4612constexpr auto CREATE_OPENGL_TEXTURE_V_NUMBER =
4613 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER;
4614
4615constexpr auto CREATE_OPENGLES2_TEXTURE_NUMBER =
4616 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER;
4617
4618constexpr auto CREATE_OPENGLES2_TEXTURE_UV_NUMBER =
4619 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER;
4620
4621constexpr auto CREATE_OPENGLES2_TEXTURE_U_NUMBER =
4622 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER;
4623
4624constexpr auto CREATE_OPENGLES2_TEXTURE_V_NUMBER =
4625 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER;
4626
4627constexpr auto CREATE_VULKAN_TEXTURE_NUMBER =
4628 SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER;
4629
4630#if SDL_VERSION_ATLEAST(3, 4, 0)
4631
4632constexpr auto CREATE_VULKAN_LAYOUT_NUMBER =
4633 SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER;
4634
4635constexpr auto CREATE_GPU_TEXTURE_POINTER =
4636 SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER;
4637
4638constexpr auto CREATE_GPU_TEXTURE_UV_POINTER =
4639 SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_POINTER;
4640
4641constexpr auto CREATE_GPU_TEXTURE_U_POINTER =
4642 SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_POINTER;
4643
4644constexpr auto CREATE_GPU_TEXTURE_V_POINTER =
4645 SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_POINTER;
4646
4647#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4648
4649constexpr auto COLORSPACE_NUMBER = SDL_PROP_TEXTURE_COLORSPACE_NUMBER;
4650
4651constexpr auto FORMAT_NUMBER = SDL_PROP_TEXTURE_FORMAT_NUMBER;
4652
4653constexpr auto ACCESS_NUMBER = SDL_PROP_TEXTURE_ACCESS_NUMBER;
4654
4655constexpr auto WIDTH_NUMBER = SDL_PROP_TEXTURE_WIDTH_NUMBER;
4656
4657constexpr auto HEIGHT_NUMBER = SDL_PROP_TEXTURE_HEIGHT_NUMBER;
4658
4659constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT;
4660
4661constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT;
4662
4663constexpr auto D3D11_TEXTURE_POINTER = SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER;
4664
4665constexpr auto D3D11_TEXTURE_U_POINTER =
4666 SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER;
4667
4668constexpr auto D3D11_TEXTURE_V_POINTER =
4669 SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER;
4670
4671constexpr auto D3D12_TEXTURE_POINTER = SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER;
4672
4673constexpr auto D3D12_TEXTURE_U_POINTER =
4674 SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER;
4675
4676constexpr auto D3D12_TEXTURE_V_POINTER =
4677 SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER;
4678
4679constexpr auto OPENGL_TEXTURE_NUMBER = SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER;
4680
4681constexpr auto OPENGL_TEXTURE_UV_NUMBER =
4682 SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER;
4683
4684constexpr auto OPENGL_TEXTURE_U_NUMBER =
4685 SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER;
4686
4687constexpr auto OPENGL_TEXTURE_V_NUMBER =
4688 SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER;
4689
4690constexpr auto OPENGL_TEXTURE_TARGET_NUMBER =
4691 SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER;
4692
4693constexpr auto OPENGL_TEX_W_FLOAT = SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT;
4694
4695constexpr auto OPENGL_TEX_H_FLOAT = SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT;
4696
4697constexpr auto OPENGLES2_TEXTURE_NUMBER =
4698 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER;
4699
4700constexpr auto OPENGLES2_TEXTURE_UV_NUMBER =
4701 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER;
4702
4703constexpr auto OPENGLES2_TEXTURE_U_NUMBER =
4704 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER;
4705
4706constexpr auto OPENGLES2_TEXTURE_V_NUMBER =
4707 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER;
4708
4709constexpr auto OPENGLES2_TEXTURE_TARGET_NUMBER =
4710 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER;
4711
4712constexpr auto VULKAN_TEXTURE_NUMBER = SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER;
4713
4714#if SDL_VERSION_ATLEAST(3, 4, 0)
4715
4716constexpr auto GPU_TEXTURE_POINTER = SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER;
4717
4718constexpr auto GPU_TEXTURE_UV_POINTER = SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER;
4719
4720constexpr auto GPU_TEXTURE_U_POINTER = SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER;
4721
4722constexpr auto GPU_TEXTURE_V_POINTER = SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER;
4723
4724#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4725
4726} // namespace prop::Texture
4727
4824{
4825 return CheckError(SDL_GetTextureProperties(texture));
4826}
4827
4829{
4831}
4832
4845{
4846 return CheckError(SDL_GetRendererFromTexture(texture));
4847}
4848
4850{
4852}
4853
4868inline void GetTextureSize(TextureConstRef texture, float* w, float* h)
4869{
4870 CheckError(SDL_GetTextureSize(texture, w, h));
4871}
4872
4875{
4876 return Point(texture->w, texture->h);
4877}
4878
4879inline void Texture::GetSize(float* w, float* h) const
4880{
4881 SDL::GetTextureSize(get(), w, h);
4882}
4883
4884inline Point Texture::GetSize() const { return SDL::GetTextureSize(get()); }
4885
4888{
4889 FPoint p;
4890 GetTextureSize(texture, &p.x, &p.y);
4891 return p;
4892}
4893
4895{
4896 return SDL::GetTextureSizeFloat(get());
4897}
4898
4900inline int GetTextureWidth(TextureConstRef texture) { return texture->w; }
4901
4902inline int Texture::GetWidth() const { return SDL::GetTextureWidth(get()); }
4903
4905inline int GetTextureHeight(TextureConstRef texture) { return texture->h; }
4906
4907inline int Texture::GetHeight() const { return SDL::GetTextureHeight(get()); }
4908
4911{
4912 return texture->format;
4913}
4914
4916{
4917 return SDL::GetTextureFormat(get());
4918}
4919
4920#if SDL_VERSION_ATLEAST(3, 4, 0)
4921
4941inline void SetTexturePalette(TextureRef texture, PaletteRef palette)
4942{
4943 CheckError(SDL_SetTexturePalette(texture, palette));
4944}
4945
4947{
4948 SDL::SetTexturePalette(get(), palette);
4949}
4950
4965{
4966 return Palette::Borrow(SDL_GetTexturePalette(texture));
4967}
4968
4970
4971#endif // SDL_VERSION_ATLEAST(3, 4, 0)
4972
4999inline void SetTextureColorMod(TextureRef texture, Uint8 r, Uint8 g, Uint8 b)
5000{
5001 CheckError(SDL_SetTextureColorMod(texture, r, g, b));
5002}
5003
5005{
5006 SDL::SetTextureColorMod(get(), r, g, b);
5007}
5008
5036 float r,
5037 float g,
5038 float b)
5039{
5040 CheckError(SDL_SetTextureColorModFloat(texture, r, g, b));
5041}
5042
5043inline void Texture::SetColorModFloat(float r, float g, float b)
5044{
5046}
5047
5066 Uint8* r,
5067 Uint8* g,
5068 Uint8* b)
5069{
5070 CheckError(SDL_GetTextureColorMod(texture, r, g, b));
5071}
5072
5073inline void Texture::GetColorMod(Uint8* r, Uint8* g, Uint8* b) const
5074{
5075 SDL::GetTextureColorMod(get(), r, g, b);
5076}
5077
5096 float* r,
5097 float* g,
5098 float* b)
5099{
5100 CheckError(SDL_GetTextureColorModFloat(texture, r, g, b));
5101}
5102
5103inline void Texture::GetColorModFloat(float* r, float* g, float* b) const
5104{
5106}
5107
5131inline void SetTextureAlphaMod(TextureRef texture, Uint8 alpha)
5132{
5133 CheckError(SDL_SetTextureAlphaMod(texture, alpha));
5134}
5135
5136inline void Texture::SetAlphaMod(Uint8 alpha)
5137{
5138 SDL::SetTextureAlphaMod(get(), alpha);
5139}
5140
5164inline void SetTextureAlphaModFloat(TextureRef texture, float alpha)
5165{
5166 CheckError(SDL_SetTextureAlphaModFloat(texture, alpha));
5167}
5168
5169inline void Texture::SetAlphaModFloat(float alpha)
5170{
5172}
5173
5190{
5191 Uint8 alpha;
5192 CheckError(SDL_GetTextureAlphaMod(texture, &alpha));
5193 return alpha;
5194}
5195
5197{
5198 return SDL::GetTextureAlphaMod(get());
5199}
5200
5217{
5218 float alpha;
5219 CheckError(SDL_GetTextureAlphaModFloat(texture, &alpha));
5220 return alpha;
5221}
5222
5223inline float Texture::GetAlphaModFloat() const
5224{
5226}
5227
5251inline void SetTextureMod(TextureRef texture, Color c)
5252{
5253 SetTextureColorMod(texture, c.r, c.g, c.b);
5254 SetTextureAlphaMod(texture, c.a);
5255}
5256
5258
5282inline void SetTextureModFloat(TextureRef texture, FColor c)
5283{
5284 SetTextureColorModFloat(texture, c.r, c.g, c.b);
5285 SetTextureAlphaModFloat(texture, c.a);
5286}
5287
5289{
5291}
5292
5308{
5309 Color c;
5310 GetTextureColorMod(texture, &c.r, &c.g, &c.b);
5311 c.a = GetTextureAlphaMod(texture);
5312 return c;
5313}
5314
5315inline Color Texture::GetMod() const { return SDL::GetTextureMod(get()); }
5316
5332{
5333 FColor c;
5334 GetTextureColorModFloat(texture, &c.r, &c.g, &c.b);
5335 c.a = GetTextureAlphaModFloat(texture);
5336 return c;
5337}
5338
5340{
5341 return SDL::GetTextureModFloat(get());
5342}
5343
5360inline void SetTextureBlendMode(TextureRef texture, BlendMode blendMode)
5361{
5362 CheckError(SDL_SetTextureBlendMode(texture, blendMode));
5363}
5364
5365inline void Texture::SetBlendMode(BlendMode blendMode)
5366{
5367 SDL::SetTextureBlendMode(get(), blendMode);
5368}
5369
5384{
5385 BlendMode blendMode;
5386 CheckError(SDL_GetTextureBlendMode(texture, &blendMode));
5387 return blendMode;
5388}
5389
5391{
5392 return SDL::GetTextureBlendMode(get());
5393}
5394
5412inline void SetTextureScaleMode(TextureRef texture, ScaleMode scaleMode)
5413{
5414 CheckError(SDL_SetTextureScaleMode(texture, scaleMode));
5415}
5416
5417inline void Texture::SetScaleMode(ScaleMode scaleMode)
5418{
5419 SDL::SetTextureScaleMode(get(), scaleMode);
5420}
5421
5436{
5437 ScaleMode scaleMode;
5438 CheckError(SDL_GetTextureScaleMode(texture, &scaleMode));
5439 return scaleMode;
5440}
5441
5443{
5444 return SDL::GetTextureScaleMode(get());
5445}
5446
5478inline void UpdateTexture(TextureRef texture,
5480 const void* pixels,
5481 int pitch)
5482{
5483 CheckError(SDL_UpdateTexture(texture, rect, pixels, pitch));
5484}
5485
5516inline void UpdateTexture(TextureRef texture,
5517 SurfaceConstRef surface,
5518 OptionalRef<const RectRaw> rect = std::nullopt)
5519{
5520 UpdateTexture(texture, rect, surface->pixels, surface->pitch);
5521}
5522
5524 const void* pixels,
5525 int pitch)
5526{
5527 SDL::UpdateTexture(get(), rect, pixels, pitch);
5528}
5529
5532{
5533 SDL::UpdateTexture(get(), surface, rect);
5534}
5535
5561inline void UpdateYUVTexture(TextureRef texture,
5563 const Uint8* Yplane,
5564 int Ypitch,
5565 const Uint8* Uplane,
5566 int Upitch,
5567 const Uint8* Vplane,
5568 int Vpitch)
5569{
5570 CheckError(SDL_UpdateYUVTexture(
5571 texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch));
5572}
5573
5575 const Uint8* Yplane,
5576 int Ypitch,
5577 const Uint8* Uplane,
5578 int Upitch,
5579 const Uint8* Vplane,
5580 int Vpitch)
5581{
5583 get(), rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
5584}
5585
5610inline void UpdateNVTexture(TextureRef texture,
5612 const Uint8* Yplane,
5613 int Ypitch,
5614 const Uint8* UVplane,
5615 int UVpitch)
5616{
5617 CheckError(
5618 SDL_UpdateNVTexture(texture, rect, Yplane, Ypitch, UVplane, UVpitch));
5619}
5620
5622 const Uint8* Yplane,
5623 int Ypitch,
5624 const Uint8* UVplane,
5625 int UVpitch)
5626{
5627 SDL::UpdateNVTexture(get(), rect, Yplane, Ypitch, UVplane, UVpitch);
5628}
5629
5657inline void LockTexture(TextureRef texture,
5659 void** pixels,
5660 int* pitch)
5661{
5662 CheckError(SDL_LockTexture(texture, rect, pixels, pitch));
5663}
5664
5666 void** pixels,
5667 int* pitch)
5668{
5669 return {TextureRef(*this), rect, pixels, pitch};
5670}
5671
5674 void** pixels,
5675 int* pitch)
5676 : m_lock(std::move(resource))
5677{
5678 LockTexture(m_lock, rect, pixels, pitch);
5679}
5680
5713 TextureRef texture,
5714 OptionalRef<const RectRaw> rect = std::nullopt)
5715{
5716 SurfaceRaw surface = nullptr;
5717 CheckError(SDL_LockTextureToSurface(texture, rect, &surface));
5718 return Surface::Borrow(surface);
5719}
5720
5723{
5724 return {TextureRef(*this), rect};
5725}
5726
5733
5753inline void UnlockTexture(TextureRef texture) { SDL_UnlockTexture(texture); }
5754
5755inline void Texture::Unlock(TextureLock&& lock)
5756{
5757 SDL_assert_paranoid(lock.resource() == *this);
5758 std::move(lock).reset();
5759}
5760
5762{
5763 SDL_assert_paranoid(lock.resource() == *this);
5764 std::move(lock).reset();
5765}
5766
5768{
5769 if (!m_lock) return;
5770 UnlockTexture(m_lock);
5771 m_lock = {};
5773}
5774
5776{
5777 if (!m_lock) return;
5778 UnlockTexture(m_lock);
5779 m_lock = {};
5780}
5781
5806inline void SetRenderTarget(RendererRef renderer, TextureRef texture)
5807{
5808 CheckError(SDL_SetRenderTarget(renderer, texture));
5809}
5810
5812{
5813 SDL::SetRenderTarget(get(), texture);
5814}
5815
5831inline void ResetRenderTarget(RendererRef renderer)
5832{
5833 SetRenderTarget(renderer, nullptr);
5834}
5835
5837
5854{
5855 if (auto texture = SDL_GetRenderTarget(renderer))
5856 return Texture::Borrow(texture);
5857 return {};
5858}
5859
5861{
5862 return SDL::GetRenderTarget(get());
5863}
5864
5909 const PointRaw& size,
5911{
5912 CheckError(SDL_SetRenderLogicalPresentation(renderer, size.x, size.y, mode));
5913}
5914
5917{
5919}
5920
5943 int* w,
5944 int* h,
5946{
5947 CheckError(SDL_GetRenderLogicalPresentation(renderer, w, h, mode));
5948}
5949
5972 PointRaw* size,
5974{
5975 if (size) {
5976 return GetRenderLogicalPresentation(renderer, &size->x, &size->y, mode);
5977 }
5978 return GetRenderLogicalPresentation(renderer, nullptr, nullptr, mode);
5979}
5980
5982 int* w,
5983 int* h,
5984 RendererLogicalPresentation* mode) const
5985{
5987}
5988
5994
6016{
6017 FRect rect;
6018 CheckError(SDL_GetRenderLogicalPresentationRect(renderer, &rect));
6019 return rect;
6020}
6021
6026
6050 const FPointRaw& window_coord)
6051{
6052 FPoint p;
6053 CheckError(SDL_RenderCoordinatesFromWindow(
6054 renderer, window_coord.x, window_coord.y, &p.x, &p.y));
6055 return p;
6056}
6057
6059 const FPointRaw& window_coord) const
6060{
6061 return SDL::RenderCoordinatesFromWindow(get(), window_coord);
6062}
6063
6088 const FPointRaw& coord)
6089{
6090 FPoint p;
6091 CheckError(
6092 SDL_RenderCoordinatesToWindow(renderer, coord.x, coord.y, &p.x, &p.y));
6093 return p;
6094}
6095
6097{
6098 return SDL::RenderCoordinatesToWindow(get(), coord);
6099}
6100
6134{
6135 CheckError(SDL_ConvertEventToRenderCoordinates(renderer, event));
6136}
6137
6142
6167inline void SetRenderViewport(RendererRef renderer,
6169{
6170 CheckError(SDL_SetRenderViewport(renderer, rect));
6171}
6172
6177
6195{
6196 SetRenderViewport(renderer, std::nullopt);
6197}
6198
6200
6219{
6220 Rect rect;
6221 CheckError(SDL_GetRenderViewport(renderer, &rect));
6222 return rect;
6223}
6224
6226{
6227 return SDL::GetRenderViewport(get());
6228}
6229
6250inline bool RenderViewportSet(RendererRef renderer)
6251{
6252 return SDL_RenderViewportSet(renderer);
6253}
6254
6255inline bool Renderer::ViewportSet() const
6256{
6257 return SDL::RenderViewportSet(get());
6258}
6259
6279{
6280 Rect rect;
6281 CheckError(SDL_GetRenderSafeArea(renderer, &rect));
6282 return rect;
6283}
6284
6286{
6287 return SDL::GetRenderSafeArea(get());
6288}
6289
6308inline void SetRenderClipRect(RendererRef renderer,
6310{
6311 CheckError(SDL_SetRenderClipRect(renderer, rect));
6312}
6313
6318
6336{
6337 SetRenderClipRect(renderer, std::nullopt);
6338}
6339
6341
6361{
6362 Rect rect;
6363 CheckError(SDL_GetRenderClipRect(renderer, &rect));
6364 return rect;
6365}
6366
6368{
6369 return SDL::GetRenderClipRect(get());
6370}
6371
6389inline bool RenderClipEnabled(RendererRef renderer)
6390{
6391 return SDL_RenderClipEnabled(renderer);
6392}
6393
6394inline bool Renderer::IsClipEnabled() const
6395{
6396 return SDL::RenderClipEnabled(get());
6397}
6398
6423inline void SetRenderScale(RendererRef renderer, const FPointRaw& scale)
6424{
6425 CheckError(SDL_SetRenderScale(renderer, scale.x, scale.y));
6426}
6427
6428inline void Renderer::SetScale(const FPointRaw& scale)
6429{
6430 SDL::SetRenderScale(get(), scale);
6431}
6432
6450inline void GetRenderScale(RendererRef renderer, float* scaleX, float* scaleY)
6451{
6452 CheckError(SDL_GetRenderScale(renderer, scaleX, scaleY));
6453}
6454
6471{
6472 FPoint p;
6473 GetRenderScale(renderer, &p.x, &p.y);
6474 return p;
6475}
6476
6477inline void Renderer::GetScale(float* scaleX, float* scaleY) const
6478{
6479 SDL::GetRenderScale(get(), scaleX, scaleY);
6480}
6481
6483
6502{
6503 CheckError(SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, c.a));
6504}
6505
6507{
6509}
6510
6528inline void SetRenderDrawColorFloat(RendererRef renderer, const FColorRaw& c)
6529{
6530 CheckError(SDL_SetRenderDrawColorFloat(renderer, c.r, c.g, c.b, c.a));
6531}
6532
6534{
6536}
6537
6559inline void GetRenderDrawColor(RendererRef renderer,
6560 Uint8* r,
6561 Uint8* g,
6562 Uint8* b,
6563 Uint8* a)
6564{
6565 CheckError(SDL_GetRenderDrawColor(renderer, r, g, b, a));
6566}
6567
6583{
6584 Color c;
6585 GetRenderDrawColor(renderer, &c.r, &c.g, &c.b, &c.a);
6586 return c;
6587}
6588
6589inline void Renderer::GetDrawColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const
6590{
6591 SDL::GetRenderDrawColor(get(), r, g, b, a);
6592}
6593
6595{
6596 return SDL::GetRenderDrawColor(get());
6597}
6598
6621 float* r,
6622 float* g,
6623 float* b,
6624 float* a)
6625{
6626 CheckError(SDL_GetRenderDrawColorFloat(renderer, r, g, b, a));
6627}
6628
6644{
6645 FColor c;
6646 GetRenderDrawColorFloat(renderer, &c.r, &c.g, &c.b, &c.a);
6647 return c;
6648}
6649
6650inline void Renderer::GetDrawColorFloat(float* r,
6651 float* g,
6652 float* b,
6653 float* a) const
6654{
6655 SDL::GetRenderDrawColorFloat(get(), r, g, b, a);
6656}
6657
6659{
6661}
6662
6683inline void SetRenderColorScale(RendererRef renderer, float scale)
6684{
6685 CheckError(SDL_SetRenderColorScale(renderer, scale));
6686}
6687
6688inline void Renderer::SetColorScale(float scale)
6689{
6690 SDL::SetRenderColorScale(get(), scale);
6691}
6692
6706inline float GetRenderColorScale(RendererRef renderer)
6707{
6708 float scale;
6709 CheckError(SDL_GetRenderColorScale(renderer, &scale));
6710 return scale;
6711}
6712
6713inline float Renderer::GetColorScale() const
6714{
6715 return SDL::GetRenderColorScale(get());
6716}
6717
6733inline void SetRenderDrawBlendMode(RendererRef renderer, BlendMode blendMode)
6734{
6735 CheckError(SDL_SetRenderDrawBlendMode(renderer, blendMode));
6736}
6737
6739{
6740 SDL::SetRenderDrawBlendMode(get(), blendMode);
6741}
6742
6757{
6758 BlendMode blendMode;
6759 CheckError(SDL_GetRenderDrawBlendMode(renderer, &blendMode));
6760 return blendMode;
6761}
6762
6764{
6766}
6767
6785inline void RenderClear(RendererRef renderer)
6786{
6787 CheckError(SDL_RenderClear(renderer));
6788}
6789
6791
6805inline void RenderPoint(RendererRef renderer, const FPointRaw& p)
6806{
6807 CheckError(SDL_RenderPoint(renderer, p.x, p.y));
6808}
6809
6811{
6812 SDL::RenderPoint(get(), p);
6813}
6814
6829{
6830 CheckError(
6831 SDL_RenderPoints(renderer, points.data(), narrowS32(points.size())));
6832}
6833
6835{
6836 SDL::RenderPoints(get(), points);
6837}
6838
6853inline void RenderLine(RendererRef renderer,
6854 const FPointRaw& p1,
6855 const FPointRaw& p2)
6856{
6857 CheckError(SDL_RenderLine(renderer, p1.x, p1.y, p2.x, p2.y));
6858}
6859
6860inline void Renderer::RenderLine(const FPointRaw& p1, const FPointRaw& p2)
6861{
6862 SDL::RenderLine(get(), p1, p2);
6863}
6864
6880{
6881 CheckError(
6882 SDL_RenderLines(renderer, points.data(), narrowS32(points.size())));
6883}
6884
6886{
6887 SDL::RenderLines(get(), points);
6888}
6889
6905{
6906 CheckError(SDL_RenderRect(renderer, rect));
6907}
6908
6910{
6911 SDL::RenderRect(get(), rect);
6912}
6913
6929{
6930 CheckError(SDL_RenderRects(renderer, rects.data(), narrowS32(rects.size())));
6931}
6932
6934{
6935 SDL::RenderRects(get(), rects);
6936}
6937
6953inline void RenderFillRect(RendererRef renderer,
6955{
6956 CheckError(SDL_RenderFillRect(renderer, rect));
6957}
6958
6963
6979{
6980 CheckError(
6981 SDL_RenderFillRects(renderer, rects.data(), narrowS32(rects.size())));
6982}
6983
6985{
6986 SDL::RenderFillRects(get(), rects);
6987}
6988
7008inline void RenderTexture(RendererRef renderer,
7009 TextureRef texture,
7012{
7013 CheckError(SDL_RenderTexture(renderer, texture, srcrect, dstrect));
7014}
7015
7019{
7020 SDL::RenderTexture(get(), texture, srcrect, dstrect);
7021}
7022
7049 TextureRef texture,
7052 double angle,
7054 FlipMode flip = FlipMode::SDL_FLIP_NONE)
7055{
7056 CheckError(SDL_RenderTextureRotated(
7057 renderer, texture, srcrect, dstrect, angle, center, flip));
7058}
7059
7063 double angle,
7065 FlipMode flip)
7066{
7068 get(), texture, srcrect, dstrect, angle, center, flip);
7069}
7070
7097 TextureRef texture,
7102{
7103 CheckError(
7104 SDL_RenderTextureAffine(renderer, texture, srcrect, origin, right, down));
7105}
7106
7112{
7113 SDL::RenderTextureAffine(get(), texture, srcrect, origin, right, down);
7114}
7115
7140inline void RenderTextureTiled(RendererRef renderer,
7141 TextureRef texture,
7143 float scale,
7145{
7146 CheckError(
7147 SDL_RenderTextureTiled(renderer, texture, srcrect, scale, dstrect));
7148}
7149
7152 float scale,
7154{
7155 SDL::RenderTextureTiled(get(), texture, srcrect, scale, dstrect);
7156}
7157
7190inline void RenderTexture9Grid(RendererRef renderer,
7191 TextureRef texture,
7193 float left_width,
7194 float right_width,
7195 float top_height,
7196 float bottom_height,
7197 float scale,
7199{
7200 CheckError(SDL_RenderTexture9Grid(renderer,
7201 texture,
7202 srcrect,
7203 left_width,
7204 right_width,
7205 top_height,
7206 bottom_height,
7207 scale,
7208 dstrect));
7209}
7210
7213 float left_width,
7214 float right_width,
7215 float top_height,
7216 float bottom_height,
7217 float scale,
7219{
7221 texture,
7222 srcrect,
7223 left_width,
7224 right_width,
7225 top_height,
7226 bottom_height,
7227 scale,
7228 dstrect);
7229}
7230
7231#if SDL_VERSION_ATLEAST(3, 4, 0)
7232
7269 TextureRef texture,
7270 const FRectRaw& srcrect,
7271 float left_width,
7272 float right_width,
7273 float top_height,
7274 float bottom_height,
7275 float scale,
7276 const FRectRaw& dstrect,
7277 float tileScale)
7278{
7279 CheckError(SDL_RenderTexture9GridTiled(renderer,
7280 texture,
7281 &srcrect,
7282 left_width,
7283 right_width,
7284 top_height,
7285 bottom_height,
7286 scale,
7287 &dstrect,
7288 tileScale));
7289}
7290
7292 const FRectRaw& srcrect,
7293 float left_width,
7294 float right_width,
7295 float top_height,
7296 float bottom_height,
7297 float scale,
7298 const FRectRaw& dstrect,
7299 float tileScale)
7300{
7302 texture,
7303 srcrect,
7304 left_width,
7305 right_width,
7306 top_height,
7307 bottom_height,
7308 scale,
7309 dstrect,
7310 tileScale);
7311}
7312
7313#endif // SDL_VERSION_ATLEAST(3, 4, 0)
7314
7335inline void RenderGeometry(RendererRef renderer,
7336 TextureRef texture,
7337 std::span<const Vertex> vertices,
7338 std::span<const int> indices = {})
7339{
7340 CheckError(SDL_RenderGeometry(renderer,
7341 texture,
7342 vertices.data(),
7343 narrowS32(vertices.size()),
7344 indices.data(),
7345 narrowS32(indices.size())));
7346}
7347
7349 std::span<const Vertex> vertices,
7350 std::span<const int> indices)
7351{
7352 SDL::RenderGeometry(get(), texture, vertices, indices);
7353}
7354
7382inline void RenderGeometryRaw(RendererRef renderer,
7383 TextureRef texture,
7384 const float* xy,
7385 int xy_stride,
7386 const FColor* color,
7387 int color_stride,
7388 const float* uv,
7389 int uv_stride,
7390 int num_vertices,
7391 const void* indices,
7392 int num_indices,
7393 int size_indices)
7394{
7395 CheckError(SDL_RenderGeometryRaw(renderer,
7396 texture,
7397 xy,
7398 xy_stride,
7399 color,
7400 color_stride,
7401 uv,
7402 uv_stride,
7403 num_vertices,
7404 indices,
7405 num_indices,
7406 size_indices));
7407}
7408
7410 const float* xy,
7411 int xy_stride,
7412 const FColor* color,
7413 int color_stride,
7414 const float* uv,
7415 int uv_stride,
7416 int num_vertices,
7417 const void* indices,
7418 int num_indices,
7419 int size_indices)
7420{
7422 texture,
7423 xy,
7424 xy_stride,
7425 color,
7426 color_stride,
7427 uv,
7428 uv_stride,
7429 num_vertices,
7430 indices,
7431 num_indices,
7432 size_indices);
7433}
7434
7435#if SDL_VERSION_ATLEAST(3, 4, 0)
7436
7456 TextureAddressMode u_mode,
7457 TextureAddressMode v_mode)
7458{
7459 CheckError(SDL_SetRenderTextureAddressMode(renderer, u_mode, v_mode));
7460}
7461
7467
7487 TextureAddressMode* u_mode,
7488 TextureAddressMode* v_mode)
7489{
7490 CheckError(SDL_GetRenderTextureAddressMode(renderer, u_mode, v_mode));
7491}
7492
7494 TextureAddressMode* v_mode)
7495{
7496 SDL::GetRenderTextureAddressMode(get(), u_mode, v_mode);
7497}
7498
7499#endif // SDL_VERSION_ATLEAST(3, 4, 0)
7500
7528{
7529 return Surface{CheckError(SDL_RenderReadPixels(renderer, rect))};
7530}
7531
7533{
7534 return SDL::RenderReadPixels(get(), rect);
7535}
7536
7582inline void RenderPresent(RendererRef renderer)
7583{
7584 CheckError(SDL_RenderPresent(renderer));
7585}
7586
7588
7604inline void DestroyTexture(TextureRaw texture) { SDL_DestroyTexture(texture); }
7605
7607
7621inline void DestroyRenderer(RendererRaw renderer)
7622{
7623 SDL_DestroyRenderer(renderer);
7624}
7625
7627
7658inline void FlushRenderer(RendererRef renderer)
7659{
7660 CheckError(SDL_FlushRenderer(renderer));
7661}
7662
7664
7681inline void* GetRenderMetalLayer(RendererRef renderer)
7682{
7683 return SDL_GetRenderMetalLayer(renderer);
7684}
7685
7687{
7688 return SDL::GetRenderMetalLayer(get());
7689}
7690
7713{
7714 return SDL_GetRenderMetalCommandEncoder(renderer);
7715}
7716
7721
7749 Uint32 wait_stage_mask,
7750 Sint64 wait_semaphore,
7751 Sint64 signal_semaphore)
7752{
7753 CheckError(SDL_AddVulkanRenderSemaphores(
7754 renderer, wait_stage_mask, wait_semaphore, signal_semaphore));
7755}
7756
7758 Sint64 wait_semaphore,
7759 Sint64 signal_semaphore)
7760{
7762 get(), wait_stage_mask, wait_semaphore, signal_semaphore);
7763}
7764
7787inline void SetRenderVSync(RendererRef renderer, int vsync)
7788{
7789 CheckError(SDL_SetRenderVSync(renderer, vsync));
7790}
7791
7792inline void Renderer::SetVSync(int vsync) { SDL::SetRenderVSync(get(), vsync); }
7793
7795constexpr int RENDERER_VSYNC_DISABLED = SDL_RENDERER_VSYNC_DISABLED;
7796
7798constexpr int RENDERER_VSYNC_ADAPTIVE = SDL_RENDERER_VSYNC_ADAPTIVE;
7799
7814inline int GetRenderVSync(RendererRef renderer)
7815{
7816 int vsync;
7817 CheckError(SDL_GetRenderVSync(renderer, &vsync));
7818 return vsync;
7819}
7820
7821inline int Renderer::GetVSync() const { return SDL::GetRenderVSync(get()); }
7822
7833 SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE;
7834
7872inline void RenderDebugText(RendererRef renderer,
7873 const FPointRaw& p,
7874 StringParam str)
7875{
7876 CheckError(SDL_RenderDebugText(renderer, p.x, p.y, str));
7877}
7878
7880{
7881 SDL::RenderDebugText(get(), p, std::move(str));
7882}
7883
7908template<class... ARGS>
7910 const FPointRaw& p,
7911 std::string_view fmt,
7912 ARGS... args)
7913{
7915 renderer, p, std::vformat(fmt, std::make_format_args(args...)));
7916}
7917
7918template<class... ARGS>
7920 std::string_view fmt,
7921 ARGS... args)
7922{
7923 SDL::RenderDebugTextFormat(get(), p, fmt, args...);
7924}
7925
7926#if SDL_VERSION_ATLEAST(3, 4, 0)
7927
7944 ScaleMode scale_mode)
7945{
7946 CheckError(SDL_SetDefaultTextureScaleMode(renderer, scale_mode));
7947}
7948
7950{
7951 SDL::SetDefaultTextureScaleMode(get(), scale_mode);
7952}
7953
7970 ScaleMode* scale_mode)
7971{
7972 CheckError(SDL_GetDefaultTextureScaleMode(renderer, scale_mode));
7973}
7974
7976{
7977 SDL::GetDefaultTextureScaleMode(get(), scale_mode);
7978}
7979
7992struct GPURenderState : ResourceBase<GPURenderStateRaw>
7993{
7995
8003 constexpr explicit GPURenderState(GPURenderStateRaw resource) noexcept
8004 : ResourceBase(resource)
8005 {
8006 }
8007
8009 constexpr GPURenderState(const GPURenderState& other) = delete;
8010
8012 constexpr GPURenderState(GPURenderState&& other) noexcept
8013 : GPURenderState(other.release())
8014 {
8015 }
8016
8017 constexpr GPURenderState(const GPURenderStateRef& other) = delete;
8018
8019 constexpr GPURenderState(GPURenderStateRef&& other) = delete;
8020
8038 GPURenderState(RendererRef renderer,
8039 const GPURenderStateCreateInfo& createinfo);
8040
8042 ~GPURenderState() { SDL_DestroyGPURenderState(get()); }
8043
8045 constexpr GPURenderState& operator=(GPURenderState&& other) noexcept
8046 {
8047 swap(*this, other);
8048 return *this;
8049 }
8050
8052 GPURenderState& operator=(const GPURenderState& other) = delete;
8053
8065 void Destroy();
8066
8083 void SetFragmentUniforms(Uint32 slot_index, const void* data, Uint32 length);
8084};
8085
8104 RendererRef renderer,
8105 const GPURenderStateCreateInfo& createinfo)
8106{
8107 return GPURenderState(renderer, createinfo);
8108}
8109
8111 const GPURenderStateCreateInfo& createinfo)
8112{
8113 return GPURenderState(get(), createinfo);
8114}
8115
8117 RendererRef renderer,
8118 const GPURenderStateCreateInfo& createinfo)
8119 : GPURenderState(SDL_CreateGPURenderState(renderer, &createinfo))
8120{
8121}
8122
8141 Uint32 slot_index,
8142 const void* data,
8143 Uint32 length)
8144{
8145 CheckError(
8146 SDL_SetGPURenderStateFragmentUniforms(state, slot_index, data, length));
8147}
8148
8150 const void* data,
8151 Uint32 length)
8152{
8153 SDL::SetGPURenderStateFragmentUniforms(get(), slot_index, data, length);
8154}
8155
8173{
8174 CheckError(SDL_SetGPURenderState(renderer, state));
8175}
8176
8178{
8179 SDL::SetGPURenderState(get(), state);
8180}
8181
8195{
8196 SDL_DestroyGPURenderState(state);
8197}
8198
8200
8201#endif // SDL_VERSION_ATLEAST(3, 4, 0)
8202
8204
8205} // namespace SDL
8206
8207#endif /* SDL3PP_RENDER_H_ */
Optional-like shim for references.
Definition SDL3pp_optionalRef.h:20
Pixel format.
Definition SDL3pp_pixels.h:358
constexpr RawPointer get() const noexcept
Definition SDL3pp_resource.h:53
constexpr RawPointer release() noexcept
Definition SDL3pp_resource.h:56
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
Const reference wrapper for a given resource,.
Definition SDL3pp_resource.h:111
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
Lock a portion of the texture for write-only pixel access.
Definition SDL3pp_render.h:3328
TextureRef resource() const
Get the reference to locked resource.
Definition SDL3pp_render.h:3426
~TextureLock()
Unlock a texture, uploading the changes to video memory, if needed.
Definition SDL3pp_render.h:3392
TextureLock & operator=(TextureLock &&other) noexcept
Assignment operator.
Definition SDL3pp_render.h:3397
TextureLock(const TextureLock &other)=delete
Copy constructor.
TextureLock(TextureLock &&other) noexcept
Move constructor.
Definition SDL3pp_render.h:3370
void release()
Releases the lock without unlocking.
Definition SDL3pp_render.h:3429
Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.
Definition SDL3pp_render.h:3455
~TextureSurfaceLock()
Unlock a texture, uploading the changes to video memory, if needed.
Definition SDL3pp_render.h:3521
TextureSurfaceLock(TextureSurfaceLock &&other) noexcept
Move constructor.
Definition SDL3pp_render.h:3498
TextureRef resource() const
Get the reference to locked resource.
Definition SDL3pp_render.h:3553
TextureSurfaceLock(const TextureSurfaceLock &other)=delete
Copy constructor.
TextureSurfaceLock & operator=(TextureSurfaceLock &&other) noexcept
Assignment operator.
Definition SDL3pp_render.h:3526
#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:199
SDL_Event Event
The structure for all events in SDL.
Definition SDL3pp_events.h:844
ResourceRef< GPUDevice > GPUDeviceRef
Reference for GPUDevice.
Definition SDL3pp_gpu.h:386
ResourceRef< IOStream > IOStreamRef
Reference for IOStream.
Definition SDL3pp_iostream.h:34
SDL_Color ColorRaw
Alias to raw representation for Color.
Definition SDL3pp_pixels.h:83
SDL_FColor FColorRaw
Alias to raw representation for FColor.
Definition SDL3pp_pixels.h:89
ResourceRef< Palette > PaletteRef
Reference for Palette.
Definition SDL3pp_pixels.h:108
ResourceRef< Properties > PropertiesRef
Reference for Properties.
Definition SDL3pp_properties.h:54
SDL_FRect FRectRaw
Alias to raw representation for FRect.
Definition SDL3pp_rect.h:40
SDL_FPoint FPointRaw
Alias to raw representation for FPoint.
Definition SDL3pp_rect.h:28
SDL_Point PointRaw
Alias to raw representation for Point.
Definition SDL3pp_rect.h:22
FPoint RenderCoordinatesFromWindow(RendererRef renderer, const FPointRaw &window_coord)
Get a point in render coordinates when given a point in window coordinates.
Definition SDL3pp_render.h:6049
void reset()
Unlock a texture, uploading the changes to video memory, if needed.
Definition SDL3pp_render.h:5775
void UpdateTexture(TextureRef texture, OptionalRef< const RectRaw > rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition SDL3pp_render.h:5478
constexpr TextureAddressMode TEXTURE_ADDRESS_AUTO
Wrapping is enabled if texture coordinates are outside [0, 1], this is the default.
Definition SDL3pp_render.h:154
void GetRenderScale(RendererRef renderer, float *scaleX, float *scaleY)
Get the drawing scale for the current target.
Definition SDL3pp_render.h:6450
void SetDrawColorFloat(const FColorRaw &c)
Set the color used for drawing operations (Rect, Line and Clear).
Definition SDL3pp_render.h:6533
constexpr int RENDERER_VSYNC_DISABLED
Constant for disabling renderer vsync.
Definition SDL3pp_render.h:7795
SDL_Vertex Vertex
Vertex structure.
Definition SDL3pp_render.h:114
void SetDrawColor(ColorRaw c)
Set the color used for drawing operations.
Definition SDL3pp_render.h:6506
void RenderTexture9Grid(RendererRef renderer, TextureRef 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:7190
Texture GetTarget() const
Get the current render target.
Definition SDL3pp_render.h:5860
void Destroy()
Destroy the rendering context for a window and free all associated textures.
Definition SDL3pp_render.h:7626
const char * GetName() const
Get the name of a renderer.
Definition SDL3pp_render.h:4102
void RenderRects(RendererRef renderer, SpanRef< const FRectRaw > rects)
Draw some number of rectangles on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:6928
void ResetRenderViewport(RendererRef renderer)
Reset the drawing area for rendering to the entire target.
Definition SDL3pp_render.h:6194
const SDL_Texture * TextureRawConst
Alias to const raw representation for Texture.
Definition SDL3pp_render.h:56
void RenderGeometryRaw(TextureRef 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:7409
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:8149
GPURenderState CreateGPURenderState(const GPURenderStateCreateInfo &createinfo)
Create custom GPU render state.
Definition SDL3pp_render.h:8110
void SetPalette(PaletteRef palette)
Set the palette used by a texture.
Definition SDL3pp_render.h:4946
Texture GetRenderTarget(RendererRef renderer)
Get the current render target.
Definition SDL3pp_render.h:5853
RendererRef CreateGPURenderer(GPUDeviceRef device, WindowRef window)
Create a 2D GPU rendering context.
Definition SDL3pp_render.h:4008
void FlushRenderer(RendererRef renderer)
Force the rendering context to flush any pending commands and state.
Definition SDL3pp_render.h:7658
Point GetCurrentOutputSize() const
Get the current output size in pixels of a rendering context.
Definition SDL3pp_render.h:4319
void SetColorModFloat(float r, float g, float b)
Set an additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:5043
GPURenderState CreateGPURenderState(RendererRef renderer, const GPURenderStateCreateInfo &createinfo)
Create custom GPU render state.
Definition SDL3pp_render.h:8103
void SetDefaultTextureScaleMode(RendererRef renderer, ScaleMode scale_mode)
Set default scale mode for new textures for given renderer.
Definition SDL3pp_render.h:7943
void RenderPoint(const FPointRaw &p)
Draw a point on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:6810
void CreateWindowAndRenderer(StringParam title, const PointRaw &size, WindowFlags window_flags, Window *window, Renderer *renderer)
Create a window and default renderer.
Definition SDL3pp_render.h:3648
ScaleMode GetTextureScaleMode(TextureConstRef texture)
Get the scale mode used for texture scale operations.
Definition SDL3pp_render.h:5435
void * GetRenderMetalLayer(RendererRef renderer)
Get the CAMetalLayer associated with the given Metal renderer.
Definition SDL3pp_render.h:7681
void GetRenderOutputSize(RendererRef renderer, int *w, int *h)
Get the output size in pixels of a rendering context.
Definition SDL3pp_render.h:4222
BlendMode GetTextureBlendMode(TextureConstRef texture)
Get the blend mode used for texture copy operations.
Definition SDL3pp_render.h:5383
void SetRenderTextureAddressMode(RendererRef renderer, TextureAddressMode u_mode, TextureAddressMode v_mode)
Set the texture addressing mode used in Renderer.RenderGeometry().
Definition SDL3pp_render.h:7455
void CreateWindowAndRendererRaw(StringParam title, const PointRaw &size, WindowFlags window_flags, WindowRaw *window, RendererRaw *renderer)
Create a window and default renderer.
Definition SDL3pp_render.h:3621
void GetRenderTextureAddressMode(TextureAddressMode *u_mode, TextureAddressMode *v_mode)
Get the texture addressing mode used in Renderer.RenderGeometry().
Definition SDL3pp_render.h:7493
void RenderDebugText(RendererRef renderer, const FPointRaw &p, StringParam str)
Draw debug text to an Renderer.
Definition SDL3pp_render.h:7872
void SetBlendMode(BlendMode blendMode)
Set the blend mode for a texture, used by Renderer.RenderTexture().
Definition SDL3pp_render.h:5365
Palette GetPalette()
Get the palette used by a texture.
Definition SDL3pp_render.h:4969
Rect GetViewport() const
Get the drawing area for the current target.
Definition SDL3pp_render.h:6225
Point GetSize() const
Get the size of a texture.
Definition SDL3pp_render.h:4884
bool ViewportSet() const
Return whether an explicit rectangle was set as the viewport.
Definition SDL3pp_render.h:6255
void RenderFillRects(RendererRef 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:6978
void SetDrawBlendMode(BlendMode blendMode)
Set the blend mode used for drawing operations (Fill and Line).
Definition SDL3pp_render.h:6738
Texture CreateTextureFromSurface(SurfaceRef surface)
Create a texture from an existing surface.
Definition SDL3pp_render.h:4410
FPoint GetSizeFloat() const
Get the size of a texture, as floating point values.
Definition SDL3pp_render.h:4894
ResourceConstRef< TextureRaw, TextureRawConst > TextureConstRef
Safely wrap Texture for non owning const parameters.
Definition SDL3pp_render.h:66
void SetDefaultTextureScaleMode(ScaleMode scale_mode)
Set default scale mode for new textures for given renderer.
Definition SDL3pp_render.h:7949
void GetRenderDrawColor(RendererRef renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Get the color used for drawing operations (Rect, Line and Clear).
Definition SDL3pp_render.h:6559
void SetGPURenderState(RendererRef renderer, GPURenderStateRef state)
Set custom GPU render state.
Definition SDL3pp_render.h:8172
void SetGPURenderState(GPURenderStateRef state)
Set custom GPU render state.
Definition SDL3pp_render.h:8177
void RenderPoint(RendererRef renderer, const FPointRaw &p)
Draw a point on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:6805
void SetAlphaMod(Uint8 alpha)
Set an additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:5136
constexpr TextureAddressMode TEXTURE_ADDRESS_WRAP
The texture is repeated (tiled).
Definition SDL3pp_render.h:159
void RenderRect(RendererRef renderer, OptionalRef< const FRectRaw > rect)
Draw a rectangle on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:6904
Palette GetTexturePalette(TextureRef texture)
Get the palette used by a texture.
Definition SDL3pp_render.h:4964
Texture CreateTextureWithProperties(RendererRef renderer, PropertiesRef props)
Create a texture for a rendering context with the specified properties.
Definition SDL3pp_render.h:4536
FPoint GetScale() const
Get the drawing scale for the current target.
Definition SDL3pp_render.h:6482
SDL_TextureAccess TextureAccess
The access pattern allowed for a texture.
Definition SDL3pp_render.h:121
PixelFormat GetFormat() const
Get the pixel format.
Definition SDL3pp_render.h:4915
void Destroy()
Destroy the specified texture.
Definition SDL3pp_render.h:7606
Rect GetRenderSafeArea(RendererRef renderer)
Get the safe area for rendering within the current viewport.
Definition SDL3pp_render.h:6278
bool IsClipEnabled() const
Get whether clipping is enabled on the given render target.
Definition SDL3pp_render.h:6394
constexpr int RENDERER_VSYNC_ADAPTIVE
Constant for enabling asaptive renderer vsync.
Definition SDL3pp_render.h:7798
ResourceRef< GPURenderState > GPURenderStateRef
Reference for GPURenderState.
Definition SDL3pp_render.h:81
int GetTextureWidth(TextureConstRef texture)
Get the width in pixels.
Definition SDL3pp_render.h:4900
FPoint RenderCoordinatesToWindow(const FPointRaw &coord) const
Get a point in window coordinates when given a point in render coordinates.
Definition SDL3pp_render.h:6096
PropertiesRef GetRendererProperties(RendererRef renderer)
Get the properties associated with a renderer.
Definition SDL3pp_render.h:4192
constexpr auto SOFTWARE_RENDERER
The name of the software renderer.
Definition SDL3pp_render.h:96
void SetRenderColorScale(RendererRef renderer, float scale)
Set the color scale used for render operations.
Definition SDL3pp_render.h:6683
void RenderTextureAffine(TextureRef 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:7107
void RenderPoints(SpanRef< const FPointRaw > points)
Draw multiple points on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:6834
void GetTextureColorMod(TextureConstRef texture, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:5065
void ResetTarget()
Set target texture back to window.
Definition SDL3pp_render.h:5836
void SetRenderVSync(RendererRef renderer, int vsync)
Toggle VSync of the given renderer.
Definition SDL3pp_render.h:7787
GPUDeviceRef GetGPURendererDevice(RendererRef renderer)
Return the GPU device used by a renderer.
Definition SDL3pp_render.h:4024
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:5721
void GetRenderLogicalPresentation(RendererRef renderer, int *w, int *h, RendererLogicalPresentation *mode)
Get device independent resolution and presentation mode for rendering.
Definition SDL3pp_render.h:5942
void SetTextureModFloat(TextureRef texture, FColor c)
Set an additional color and alpha values multiplied into render copy operations.
Definition SDL3pp_render.h:5282
int GetHeight() const
Get the height in pixels.
Definition SDL3pp_render.h:4907
FColor GetDrawColorFloat() const
Get the color used for drawing operations (Rect, Line and Clear).
Definition SDL3pp_render.h:6658
Uint8 GetAlphaMod() const
Get the additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:5196
SDL_GPURenderState * GPURenderStateRaw
Alias to raw representation for GPURenderState.
Definition SDL3pp_render.h:74
constexpr TextureAddressMode TEXTURE_ADDRESS_INVALID
TEXTURE_ADDRESS_INVALID.
Definition SDL3pp_render.h:147
void SetModFloat(FColor c)
Set an additional color and alpha values multiplied into render copy operations.
Definition SDL3pp_render.h:5288
void DestroyRenderer(RendererRaw renderer)
Destroy the rendering context for a window and free all associated textures.
Definition SDL3pp_render.h:7621
void Destroy()
Destroy custom GPU render state.
Definition SDL3pp_render.h:8199
void SetColorScale(float scale)
Set the color scale used for render operations.
Definition SDL3pp_render.h:6688
int GetVSync() const
Get VSync of the given renderer.
Definition SDL3pp_render.h:7821
void GetTextureSize(TextureConstRef texture, float *w, float *h)
Get the size of a texture, as floating point values.
Definition SDL3pp_render.h:4868
void SetTarget(TextureRef texture)
Set a texture as the current rendering target.
Definition SDL3pp_render.h:5811
Texture CreateTexture(RendererRef renderer, PixelFormat format, TextureAccess access, const PointRaw &size)
Create a texture for a rendering context.
Definition SDL3pp_render.h:4346
Texture CreateTextureWithProperties(PropertiesRef props)
Create a texture for a rendering context with the specified properties.
Definition SDL3pp_render.h:4542
Surface RenderReadPixels(RendererRef renderer, OptionalRef< const RectRaw > rect={})
Read pixels from the current rendering target.
Definition SDL3pp_render.h:7526
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:5727
void SetTextureScaleMode(TextureRef texture, ScaleMode scaleMode)
Set the scale mode used for texture scale operations.
Definition SDL3pp_render.h:5412
bool RenderClipEnabled(RendererRef renderer)
Get whether clipping is enabled on the given render target.
Definition SDL3pp_render.h:6389
void RenderTexture9Grid(TextureRef 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:7211
Point GetOutputSize() const
Get the output size in pixels of a rendering context.
Definition SDL3pp_render.h:4258
void GetColorModFloat(float *r, float *g, float *b) const
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:5103
void SetColorMod(Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:5004
void SetRenderDrawColorFloat(RendererRef renderer, const FColorRaw &c)
Set the color used for drawing operations (Rect, Line and Clear).
Definition SDL3pp_render.h:6528
void Update(OptionalRef< const RectRaw > rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition SDL3pp_render.h:5523
void RenderRect(OptionalRef< const FRectRaw > rect)
Draw a rectangle on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:6909
RendererRef GetRenderer() const
Get the renderer associated with a window.
Definition SDL3pp_render.h:4060
void Present()
Update the screen with any rendering performed since the previous call.
Definition SDL3pp_render.h:7587
void ResetViewport()
Reset the drawing area for rendering to the entire target.
Definition SDL3pp_render.h:6199
float GetRenderColorScale(RendererRef renderer)
Get the color scale used for render operations.
Definition SDL3pp_render.h:6706
BlendMode GetDrawBlendMode() const
Get the blend mode used for drawing operations.
Definition SDL3pp_render.h:6763
void RenderClear()
Clear the current rendering target with the drawing color.
Definition SDL3pp_render.h:6790
FRect GetRenderLogicalPresentationRect(RendererRef renderer)
Get the final presentation rectangle for rendering.
Definition SDL3pp_render.h:6015
FPoint GetTextureSizeFloat(TextureConstRef texture)
Get the size of a texture, as floating point values.
Definition SDL3pp_render.h:4887
RendererRef GetRendererFromTexture(TextureConstRef texture)
Get the renderer that created an Texture.
Definition SDL3pp_render.h:4844
void SetRenderDrawBlendMode(RendererRef renderer, BlendMode blendMode)
Set the blend mode used for drawing operations (Fill and Line).
Definition SDL3pp_render.h:6733
void RenderTextureRotated(RendererRef renderer, TextureRef 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:7048
void SetMod(Color c)
Set an additional color and alpha values multiplied into render copy operations.
Definition SDL3pp_render.h:5257
void RenderTextureTiled(RendererRef renderer, TextureRef 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:7140
void RenderLine(const FPointRaw &p1, const FPointRaw &p2)
Draw a line on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:6860
Color GetMod() const
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:5315
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:189
void GetRenderDrawColorFloat(RendererRef renderer, float *r, float *g, float *b, float *a)
Get the color used for drawing operations (Rect, Line and Clear).
Definition SDL3pp_render.h:6620
constexpr auto GPU_RENDERER
The name of the GPU renderer.
Definition SDL3pp_render.h:105
void ResetRenderClipRect(RendererRef renderer)
Reset the clip rectangle for rendering to the entire render target.
Definition SDL3pp_render.h:6335
PropertiesRef GetProperties() const
Get the properties associated with a texture.
Definition SDL3pp_render.h:4828
void RenderDebugText(const FPointRaw &p, StringParam str)
Draw debug text to an Renderer.
Definition SDL3pp_render.h:7879
void SetAlphaModFloat(float alpha)
Set an additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:5169
void * GetRenderMetalCommandEncoder(RendererRef renderer)
Get the Metal command encoder for the current frame.
Definition SDL3pp_render.h:7712
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_DISABLED
There is no logical size in effect.
Definition SDL3pp_render.h:171
void RenderGeometry(TextureRef 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:7348
void UpdateNVTexture(TextureRef 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:5610
Rect GetClipRect() const
Get the clip rectangle for the current target.
Definition SDL3pp_render.h:6367
void * GetRenderMetalLayer()
Get the CAMetalLayer associated with the given Metal renderer.
Definition SDL3pp_render.h:7686
void RenderDebugTextFormat(RendererRef renderer, const FPointRaw &p, std::string_view fmt, ARGS... args)
Draw debug text to an Renderer.
Definition SDL3pp_render.h:7909
constexpr TextureAccess TEXTUREACCESS_TARGET
Texture can be used as a render target.
Definition SDL3pp_render.h:129
void RenderPoints(RendererRef renderer, SpanRef< const FPointRaw > points)
Draw multiple points on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:6828
FPoint RenderCoordinatesFromWindow(const FPointRaw &window_coord) const
Get a point in render coordinates when given a point in window coordinates.
Definition SDL3pp_render.h:6058
void DestroyTexture(TextureRaw texture)
Destroy the specified texture.
Definition SDL3pp_render.h:7604
FColor GetTextureModFloat(TextureConstRef texture)
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:5331
Rect GetSafeArea() const
Get the safe area for rendering within the current viewport.
Definition SDL3pp_render.h:6285
void RenderFillRect(RendererRef renderer, OptionalRef< const FRectRaw > rect)
Fill a rectangle on the current rendering target with the drawing color at subpixel precision.
Definition SDL3pp_render.h:6953
void RenderClear(RendererRef renderer)
Clear the current rendering target with the drawing color.
Definition SDL3pp_render.h:6785
Renderer CreateRenderer(WindowRef window, StringParam name=nullptr)
Create a 2D rendering context for a window.
Definition SDL3pp_render.h:3760
void DestroyGPURenderState(GPURenderStateRaw state)
Destroy custom GPU render state.
Definition SDL3pp_render.h:8194
PixelFormat GetTextureFormat(TextureConstRef texture)
Get the pixel format.
Definition SDL3pp_render.h:4910
int GetWidth() const
Get the width in pixels.
Definition SDL3pp_render.h:4902
FColor GetModFloat() const
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:5339
ResourceRef< Texture > TextureRef
Reference for Texture.
Definition SDL3pp_render.h:63
Renderer CreateRendererWithProperties(PropertiesRef props)
Create a 2D rendering context for a window, with the specified properties.
Definition SDL3pp_render.h:3842
void UpdateYUVTexture(TextureRef 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:5561
constexpr TextureAccess TEXTUREACCESS_STATIC
Changes rarely, not lockable.
Definition SDL3pp_render.h:123
void * GetRenderMetalCommandEncoder()
Get the Metal command encoder for the current frame.
Definition SDL3pp_render.h:7717
Rect GetRenderViewport(RendererRef renderer)
Get the drawing area for the current target.
Definition SDL3pp_render.h:6218
void SetViewport(OptionalRef< const RectRaw > rect)
Set the drawing area for rendering on the current target.
Definition SDL3pp_render.h:6173
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_INTEGER_SCALE
The rendered content is scaled up by integer multiples to fit the output resolution.
Definition SDL3pp_render.h:196
WindowRef GetWindow()
Get the window associated with a renderer.
Definition SDL3pp_render.h:4081
SDL_GPURenderStateCreateInfo GPURenderStateCreateInfo
A structure specifying the parameters of a GPU render state.
Definition SDL3pp_render.h:208
constexpr TextureAccess TEXTUREACCESS_STREAMING
Changes frequently, lockable.
Definition SDL3pp_render.h:126
void RenderTexture(TextureRef 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:7016
BlendMode GetBlendMode() const
Get the blend mode used for texture copy operations.
Definition SDL3pp_render.h:5390
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:5574
PropertiesRef GetProperties() const
Get the properties associated with a renderer.
Definition SDL3pp_render.h:4197
Rect GetRenderClipRect(RendererRef renderer)
Get the clip rectangle for the current target.
Definition SDL3pp_render.h:6360
void Flush()
Force the rendering context to flush any pending commands and state.
Definition SDL3pp_render.h:7663
void RenderLine(RendererRef renderer, const FPointRaw &p1, const FPointRaw &p2)
Draw a line on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:6853
void SetRenderLogicalPresentation(RendererRef renderer, const PointRaw &size, RendererLogicalPresentation mode)
Set a device-independent resolution and presentation mode for rendering.
Definition SDL3pp_render.h:5908
GPUDeviceRef GetGPUDevice()
Return the GPU device used by a renderer.
Definition SDL3pp_render.h:4029
void reset()
Unlock a texture, uploading the changes to video memory, if needed.
Definition SDL3pp_render.h:5767
void SetTextureColorMod(TextureRef texture, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:4999
void GetDefaultTextureScaleMode(RendererRef renderer, ScaleMode *scale_mode)
Get default texture scale mode of the given renderer.
Definition SDL3pp_render.h:7969
void RenderTextureRotated(TextureRef 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:7060
SDL_RendererLogicalPresentation RendererLogicalPresentation
How the logical size is mapped to the output.
Definition SDL3pp_render.h:169
SDL_TextureAddressMode TextureAddressMode
The addressing mode for a texture when used in Renderer.RenderGeometry().
Definition SDL3pp_render.h:145
FRect GetLogicalPresentationRect() const
Get the final presentation rectangle for rendering.
Definition SDL3pp_render.h:6022
void SetRenderTarget(RendererRef renderer, TextureRef texture)
Set a texture as the current rendering target.
Definition SDL3pp_render.h:5806
int GetRenderVSync(RendererRef renderer)
Get VSync of the given renderer.
Definition SDL3pp_render.h:7814
void SetClipRect(OptionalRef< const RectRaw > rect)
Set the clip rectangle for rendering on the specified target.
Definition SDL3pp_render.h:6314
constexpr int DEBUG_TEXT_FONT_CHARACTER_SIZE
The size, in pixels, of a single Renderer.RenderDebugText() character.
Definition SDL3pp_render.h:7832
BlendMode GetRenderDrawBlendMode(RendererRef renderer)
Get the blend mode used for drawing operations.
Definition SDL3pp_render.h:6756
constexpr TextureAddressMode TEXTURE_ADDRESS_CLAMP
Texture coordinates are clamped to the [0, 1] range.
Definition SDL3pp_render.h:157
PropertiesRef GetTextureProperties(TextureConstRef texture)
Get the properties associated with a texture.
Definition SDL3pp_render.h:4823
void SetRenderDrawColor(RendererRef renderer, ColorRaw c)
Set the color used for drawing operations.
Definition SDL3pp_render.h:6501
void ConvertEventToRenderCoordinates(Event *event) const
Convert the coordinates in an event to render coordinates.
Definition SDL3pp_render.h:6138
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:5672
Surface ReadPixels(OptionalRef< const RectRaw > rect={}) const
Read pixels from the current rendering target.
Definition SDL3pp_render.h:7532
void SetScale(const FPointRaw &scale)
Set the drawing scale for rendering on the current target.
Definition SDL3pp_render.h:6428
FPoint RenderCoordinatesToWindow(RendererRef renderer, const FPointRaw &coord)
Get a point in window coordinates when given a point in render coordinates.
Definition SDL3pp_render.h:6087
void RenderGeometry(RendererRef renderer, TextureRef 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:7335
float GetColorScale() const
Get the color scale used for render operations.
Definition SDL3pp_render.h:6713
void RenderTexture9GridTiled(TextureRef 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:7291
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:5621
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:6984
SDL_Renderer * RendererRaw
Alias to raw representation for Renderer.
Definition SDL3pp_render.h:47
void SetTextureColorModFloat(TextureRef texture, float r, float g, float b)
Set an additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:5035
Texture CreateTextureFromSurface(RendererRef renderer, SurfaceRef surface)
Create a texture from an existing surface.
Definition SDL3pp_render.h:4404
SDL_Texture * TextureRaw
Alias to raw representation for Texture.
Definition SDL3pp_render.h:53
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:182
void RenderLines(SpanRef< const FPointRaw > points)
Draw a series of connected lines on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:6885
void SetLogicalPresentation(const PointRaw &size, RendererLogicalPresentation mode)
Set a device-independent resolution and presentation mode for rendering.
Definition SDL3pp_render.h:5915
void SetTextureAlphaModFloat(TextureRef texture, float alpha)
Set an additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:5164
void GetLogicalPresentation(int *w, int *h, RendererLogicalPresentation *mode) const
Get device independent resolution and presentation mode for rendering.
Definition SDL3pp_render.h:5981
void RenderTexture(RendererRef renderer, TextureRef 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:7008
void GetRenderTextureAddressMode(RendererRef renderer, TextureAddressMode *u_mode, TextureAddressMode *v_mode)
Get the texture addressing mode used in Renderer.RenderGeometry().
Definition SDL3pp_render.h:7486
Renderer CreateSoftwareRenderer(SurfaceRef surface)
Create a 2D software rendering context for a surface.
Definition SDL3pp_render.h:4055
void ConvertEventToRenderCoordinates(RendererRef renderer, Event *event)
Convert the coordinates in an event to render coordinates.
Definition SDL3pp_render.h:6133
Color GetTextureMod(TextureConstRef texture)
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:5307
void RenderGeometryRaw(RendererRef renderer, TextureRef 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:7382
ScaleMode GetScaleMode() const
Get the scale mode used for texture scale operations.
Definition SDL3pp_render.h:5442
void RenderRects(SpanRef< const FRectRaw > rects)
Draw some number of rectangles on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:6933
void RenderDebugTextFormat(const FPointRaw &p, std::string_view fmt, ARGS... args)
Draw debug text to an Renderer.
Definition SDL3pp_render.h:7919
void SetRenderScale(RendererRef renderer, const FPointRaw &scale)
Set the drawing scale for rendering on the current target.
Definition SDL3pp_render.h:6423
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:5665
void SetRenderViewport(RendererRef renderer, OptionalRef< const RectRaw > rect)
Set the drawing area for rendering on the current target.
Definition SDL3pp_render.h:6167
void RenderPresent(RendererRef renderer)
Update the screen with any rendering performed since the previous call.
Definition SDL3pp_render.h:7582
void RenderTextureAffine(RendererRef renderer, TextureRef 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:7096
void UnlockTexture(TextureRef texture)
Unlock a texture, uploading the changes to video memory, if needed.
Definition SDL3pp_render.h:5753
void AddVulkanRenderSemaphores(RendererRef 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:7748
void SetRenderTextureAddressMode(TextureAddressMode u_mode, TextureAddressMode v_mode)
Set the texture addressing mode used in Renderer.RenderGeometry().
Definition SDL3pp_render.h:7462
void RenderTextureTiled(TextureRef 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:7150
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_STRETCH
The rendered content is stretched to the output resolution.
Definition SDL3pp_render.h:175
const char * GetRendererName(RendererRef renderer)
Get the name of a renderer.
Definition SDL3pp_render.h:4097
void GetDefaultTextureScaleMode(ScaleMode *scale_mode)
Get default texture scale mode of the given renderer.
Definition SDL3pp_render.h:7975
void GetCurrentRenderOutputSize(RendererRef renderer, int *w, int *h)
Get the current output size in pixels of a rendering context.
Definition SDL3pp_render.h:4283
float GetTextureAlphaModFloat(TextureConstRef texture)
Get the additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:5216
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:6959
int GetNumRenderDrivers()
Get the number of 2D rendering drivers available for the current display.
Definition SDL3pp_render.h:3574
const char * GetRenderDriver(int index)
Use this function to get the name of a built in 2D rendering driver.
Definition SDL3pp_render.h:3598
void RenderLines(RendererRef renderer, SpanRef< const FPointRaw > points)
Draw a series of connected lines on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:6879
WindowRef GetRenderWindow(RendererRef renderer)
Get the window associated with a renderer.
Definition SDL3pp_render.h:4076
void Unlock(TextureLock &&lock)
Unlock a texture, uploading the changes to video memory, if needed.
Definition SDL3pp_render.h:5755
RendererRef GetRenderer() const
Get the renderer that created an Texture.
Definition SDL3pp_render.h:4849
void SetVSync(int vsync)
Toggle VSync of the given renderer.
Definition SDL3pp_render.h:7792
bool RenderViewportSet(RendererRef renderer)
Return whether an explicit rectangle was set as the viewport.
Definition SDL3pp_render.h:6250
void GetTextureColorModFloat(TextureConstRef texture, float *r, float *g, float *b)
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:5095
void ResetClipRect()
Reset the clip rectangle for rendering to the entire render target.
Definition SDL3pp_render.h:6340
float GetAlphaModFloat() const
Get the additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:5223
void SetTextureBlendMode(TextureRef texture, BlendMode blendMode)
Set the blend mode for a texture, used by Renderer.RenderTexture().
Definition SDL3pp_render.h:5360
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:7757
Uint8 GetTextureAlphaMod(TextureConstRef texture)
Get the additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:5189
void GetColorMod(Uint8 *r, Uint8 *g, Uint8 *b) const
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:5073
void LockTexture(TextureRef texture, OptionalRef< const RectRaw > rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition SDL3pp_render.h:5657
void RenderTexture9GridTiled(RendererRef renderer, TextureRef 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:7268
Texture CreateTexture(PixelFormat format, TextureAccess access, const PointRaw &size)
Create a texture for a rendering context.
Definition SDL3pp_render.h:4354
void SetTextureAlphaMod(TextureRef texture, Uint8 alpha)
Set an additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:5131
void SetTexturePalette(TextureRef texture, PaletteRef palette)
Set the palette used by a texture.
Definition SDL3pp_render.h:4941
Surface LockTextureToSurface(TextureRef 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:5712
void ResetRenderTarget(RendererRef renderer)
Set target texture back to window.
Definition SDL3pp_render.h:5831
void SetTextureMod(TextureRef texture, Color c)
Set an additional color and alpha values multiplied into render copy operations.
Definition SDL3pp_render.h:5251
void SetRenderClipRect(RendererRef renderer, OptionalRef< const RectRaw > rect)
Set the clip rectangle for rendering on the specified target.
Definition SDL3pp_render.h:6308
Color GetDrawColor() const
Get the color used for drawing operations (Rect, Line and Clear).
Definition SDL3pp_render.h:6594
void SetGPURenderStateFragmentUniforms(GPURenderStateRef state, Uint32 slot_index, const void *data, Uint32 length)
Set fragment shader uniform variables in a custom GPU render state.
Definition SDL3pp_render.h:8140
int GetTextureHeight(TextureConstRef texture)
Get the height in pixels.
Definition SDL3pp_render.h:4905
void SetScaleMode(ScaleMode scaleMode)
Set the scale mode used for texture scale operations.
Definition SDL3pp_render.h:5417
::Sint64 Sint64
A signed 64-bit integer type.
Definition SDL3pp_stdinc.h:305
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition SDL3pp_stdinc.h:290
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition SDL3pp_stdinc.h:238
SDL_FlipMode FlipMode
The flip mode.
Definition SDL3pp_surface.h:127
SDL_ScaleMode ScaleMode
The scaling mode.
Definition SDL3pp_surface.h:98
SDL_Surface * SurfaceRaw
Alias to raw representation for Surface.
Definition SDL3pp_surface.h:44
ResourceConstRef< SurfaceRaw, SurfaceRawConst > SurfaceConstRef
Safely wrap Surface for non owning const parameters.
Definition SDL3pp_surface.h:57
ResourceRef< Surface > SurfaceRef
Reference for Surface.
Definition SDL3pp_surface.h:54
ResourceRef< Window > WindowRef
Reference for Window.
Definition SDL3pp_video.h:54
Uint64 WindowFlags
The flags on a window.
Definition SDL3pp_video.h:515
SDL_Window * WindowRaw
Alias to raw representation for Window.
Definition SDL3pp_video.h:47
ResourceRef< Renderer > RendererRef
Reference for Renderer.
Definition SDL3pp_video.h:75
Properties for Renderer.
Definition SDL3pp_render.h:3857
Properties for Texture.
Definition SDL3pp_render.h:4557
Main include header for the SDL3pp library.
Sint32 narrowS32(T value)
Narrows to Sint32.
Definition SDL3pp_stdinc.h:6257
A structure that represents a color as RGBA components.
Definition SDL3pp_pixels.h:2145
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition SDL3pp_pixels.h:2318
The structure that defines a point (using floating point values).
Definition SDL3pp_rect.h:526
A rectangle stored using floating point values.
Definition SDL3pp_rect.h:1457
A custom GPU render state.
Definition SDL3pp_render.h:7993
constexpr GPURenderState & operator=(GPURenderState &&other) noexcept
Assignment operator.
Definition SDL3pp_render.h:8045
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
~GPURenderState()
Destructor.
Definition SDL3pp_render.h:8042
constexpr GPURenderState(const GPURenderState &other)=delete
Copy constructor.
constexpr GPURenderState(GPURenderState &&other) noexcept
Move constructor.
Definition SDL3pp_render.h:8012
constexpr GPURenderState(GPURenderStateRaw resource) noexcept
Constructs from raw GPURenderState.
Definition SDL3pp_render.h:8003
GPURenderState & operator=(const GPURenderState &other)=delete
Assignment operator.
A set of indexed colors representing a palette.
Definition SDL3pp_pixels.h:2463
static Palette Borrow(PaletteRaw resource)
Safely borrows the from PaletteRaw.
Definition SDL3pp_pixels.h:2517
The structure that defines a point (using integers).
Definition SDL3pp_rect.h:97
A rectangle, with the origin at the upper left (using integers).
Definition SDL3pp_rect.h:859
A structure representing rendering state.
Definition SDL3pp_render.h:220
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
constexpr Renderer(Renderer &&other) noexcept
Move constructor.
Definition SDL3pp_render.h:239
constexpr Renderer(RendererRaw resource) noexcept
Constructs from raw Renderer.
Definition SDL3pp_render.h:230
Renderer & operator=(const Renderer &other)=delete
Assignment operator.
constexpr Renderer & operator=(Renderer &&other) noexcept
Assignment operator.
Definition SDL3pp_render.h:369
~Renderer()
Destructor.
Definition SDL3pp_render.h:366
constexpr Renderer(const Renderer &other)=delete
Copy constructor.
A non-owning reference wrapper for a given resource.
Definition SDL3pp_resource.h:156
A collection of pixels used in software blitting.
Definition SDL3pp_surface.h:172
constexpr Surface & operator=(Surface &&other) noexcept
Assignment operator.
Definition SDL3pp_surface.h:356
constexpr Surface(SurfaceRaw resource) noexcept
Constructs from raw Surface.
Definition SDL3pp_surface.h:182
static Surface Borrow(SurfaceRaw resource)
Safely borrows the from SurfaceRaw.
Definition SDL3pp_surface.h:340
An efficient driver-specific representation of pixel data.
Definition SDL3pp_render.h:2249
constexpr Texture & operator=(Texture &&other) noexcept
Assignment operator.
Definition SDL3pp_render.h:2549
static Texture Borrow(TextureRaw resource)
Safely borrows the from TextureRaw.
Definition SDL3pp_render.h:2533
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
constexpr Texture(const Texture &other)
Copy constructor.
Definition SDL3pp_render.h:2265
Texture & operator=(const Texture &other)
Assignment operator.
Definition SDL3pp_render.h:2556
~Texture()
Destructor.
Definition SDL3pp_render.h:2546
constexpr Texture(TextureRaw resource) noexcept
Constructs from raw Texture.
Definition SDL3pp_render.h:2259
constexpr Texture(Texture &&other) noexcept
Move constructor.
Definition SDL3pp_render.h:2272
The struct used as an opaque handle to a window.
Definition SDL3pp_video.h:748
constexpr Window(WindowRaw resource) noexcept
Constructs from raw Window.
Definition SDL3pp_video.h:758