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_pixels.h"
8#include "SDL3pp_video.h"
9
10namespace SDL {
11
42// Forward decl
43struct Renderer;
44
46using RendererRaw = SDL_Renderer*;
47
48// Forward decl
49struct RendererRef;
50
53{
55
58 : value(value)
59 {
60 }
61
63 constexpr RendererParam(std::nullptr_t _ = nullptr)
64 : value(nullptr)
65 {
66 }
67
69 constexpr explicit operator bool() const { return !!value; }
70
72 constexpr auto operator<=>(const RendererParam& other) const = default;
73
75 constexpr operator RendererRaw() const { return value; }
76};
77
78// Forward decl
79struct Texture;
80
82using TextureRaw = SDL_Texture*;
83
86{
88
91 : value(value)
92 {
93 }
94
96 constexpr TextureParam(std::nullptr_t _ = nullptr)
97 : value(nullptr)
98 {
99 }
100
102 constexpr explicit operator bool() const { return !!value; }
103
105 constexpr auto operator<=>(const TextureParam& other) const = default;
106
108 constexpr operator TextureRaw() const { return value; }
109};
110
111#ifdef SDL3PP_DOC
112
118#define SDL_SOFTWARE_RENDERER "software"
119
120#endif // SDL3PP_DOC
121
127using Vertex = SDL_Vertex;
128
134using TextureAccess = SDL_TextureAccess;
135
137 SDL_TEXTUREACCESS_STATIC;
138
140 SDL_TEXTUREACCESS_STREAMING;
141
143 SDL_TEXTUREACCESS_TARGET;
144
150using RendererLogicalPresentation = SDL_RendererLogicalPresentation;
151
153 SDL_LOGICAL_PRESENTATION_DISABLED;
154
157 SDL_LOGICAL_PRESENTATION_STRETCH;
158
164 SDL_LOGICAL_PRESENTATION_LETTERBOX;
165
171 SDL_LOGICAL_PRESENTATION_OVERSCAN;
172
178 SDL_LOGICAL_PRESENTATION_INTEGER_SCALE;
179
188{
189 RendererRaw m_resource = nullptr;
190
191public:
193 constexpr Renderer() = default;
194
202 constexpr explicit Renderer(const RendererRaw resource)
203 : m_resource(resource)
204 {
205 }
206
208 constexpr Renderer(const Renderer& other) = delete;
209
211 constexpr Renderer(Renderer&& other)
212 : Renderer(other.release())
213 {
214 }
215
216 constexpr Renderer(const RendererRef& other) = delete;
217
218 constexpr Renderer(RendererRef&& other) = delete;
219
252 : m_resource(CheckError(SDL_CreateRenderer(window, nullptr)))
253 {
254 }
255
290 : m_resource(CheckError(SDL_CreateRenderer(window, name)))
291 {
292 }
293
345 : m_resource(CheckError(SDL_CreateRendererWithProperties(props)))
346 {
347 }
348
368 : m_resource(CheckError(SDL_CreateSoftwareRenderer(surface)))
369 {
370 }
371
373 ~Renderer() { SDL_DestroyRenderer(m_resource); }
374
377 {
378 std::swap(m_resource, other.m_resource);
379 return *this;
380 }
381
383 constexpr RendererRaw get() const { return m_resource; }
384
387 {
388 auto r = m_resource;
389 m_resource = nullptr;
390 return r;
391 }
392
394 constexpr auto operator<=>(const Renderer& other) const = default;
395
397 constexpr bool operator==(std::nullptr_t _) const { return !m_resource; }
398
400 constexpr explicit operator bool() const { return !!m_resource; }
401
403 constexpr operator RendererParam() const { return {m_resource}; }
404
418 void Destroy();
419
431
444 const char* GetName() const;
445
456 {
457 Point p;
458 GetOutputSize(&p.x, &p.y);
459 return p;
460 }
461
481 void GetOutputSize(int* w, int* h) const;
482
500 {
501 Point p;
502 GetCurrentOutputSize(&p.x, &p.y);
503 return p;
504 }
505
525 void GetCurrentOutputSize(int* w, int* h) const;
526
611
626 void ResetTarget() { SetTarget(nullptr); }
627
651 void SetTarget(TextureParam texture);
652
668 Texture GetTarget() const;
669
720 void SetLogicalPresentation(const PointRaw& size,
722
740 {
741 if (!size) return GetLogicalPresentation(nullptr, nullptr, mode);
742 return GetLogicalPresentation(&size->x, &size->y, mode);
743 }
744
765 void GetLogicalPresentation(int* w,
766 int* h,
767 RendererLogicalPresentation* mode) const;
768
790
812 FPoint RenderCoordinatesFromWindow(const FPointRaw& window_coord) const;
813
836 FPoint RenderCoordinatesToWindow(const FPointRaw& coord) const;
837
870 void ConvertEventToRenderCoordinates(Event* event) const;
871
887 void ResetViewport() { SetViewport(std::nullopt); }
888
913
930 Rect GetViewport() const;
931
951 bool IsViewportSet() const;
952
970 Rect GetSafeArea() const;
971
988
1008
1026 Rect GetClipRect() const;
1027
1044 bool IsClipEnabled() const;
1045
1069 void SetScale(const FPointRaw& scale);
1070
1087 {
1088 FPoint p;
1089 GetScale(&p.x, &p.y);
1090 return p;
1091 }
1092
1109 void GetScale(float* scaleX, float* scaleY) const;
1110
1127 void SetDrawColor(ColorRaw c);
1128
1145 void SetDrawColorFloat(const FColorRaw& c);
1146
1161 {
1162 Color c;
1163 GetDrawColor(&c.r, &c.g, &c.b, &c.a);
1164 return c;
1165 }
1166
1187 void GetDrawColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const;
1188
1203 {
1204 FColor c;
1205 GetDrawColorFloat(&c.r, &c.g, &c.b, &c.a);
1206 return c;
1207 }
1208
1229 void GetDrawColorFloat(float* r, float* g, float* b, float* a) const;
1230
1251 void SetColorScale(float scale);
1252
1265 float GetColorScale() const;
1266
1281 void SetDrawBlendMode(BlendMode blendMode);
1282
1296
1313 void RenderClear();
1314
1327 void RenderPoint(const FPointRaw& p);
1328
1342
1356 void RenderLine(const FPointRaw& p1, const FPointRaw& p2);
1357
1372
1387
1402
1418
1433
1452 void RenderTexture(TextureParam texture,
1455
1483 double angle,
1485 FlipMode flip = FlipMode::SDL_FLIP_NONE);
1486
1511 void RenderTextureAffine(TextureParam texture,
1516
1540 void RenderTextureTiled(TextureParam texture,
1542 float scale,
1544
1575 void RenderTexture9Grid(TextureParam texture,
1577 float left_width,
1578 float right_width,
1579 float top_height,
1580 float bottom_height,
1581 float scale,
1583
1602 void RenderGeometry(TextureParam texture,
1603 std::span<const Vertex> vertices,
1604 std::span<const int> indices = {});
1605
1632 void RenderGeometryRaw(TextureParam texture,
1633 const float* xy,
1634 int xy_stride,
1635 const FColor* color,
1636 int color_stride,
1637 const float* uv,
1638 int uv_stride,
1639 int num_vertices,
1640 const void* indices,
1641 int num_indices,
1642 int size_indices);
1643
1668 Surface ReadPixels(OptionalRef<const RectRaw> rect = {}) const;
1669
1716 void Present();
1717
1747 void Flush();
1748
1770 void SetVSync(int vsync);
1771
1784 int GetVSync() const;
1785
1823 void RenderDebugText(const FPointRaw& p, StringParam str);
1824
1850 template<class... ARGS>
1851 void RenderDebugTextFormat(const FPointRaw& p,
1852 std::string_view fmt,
1853 ARGS... args);
1854
1876 Texture CreateTexture(PixelFormat format,
1877 TextureAccess access,
1878 const PointRaw& size);
1879
1905 Texture CreateTextureFromSurface(SurfaceParam surface);
1906
2016 Texture CreateTextureWithProperties(PropertiesParam props);
2017
2033 void* GetRenderMetalLayer();
2034
2056
2083 void AddVulkanRenderSemaphores(Uint32 wait_stage_mask,
2084 Sint64 wait_semaphore,
2085 Sint64 signal_semaphore);
2086};
2087
2090{
2099 : Renderer(resource.value)
2100 {
2101 }
2102
2105 : Renderer(other.get())
2106 {
2107 }
2108
2111};
2112
2126{
2127 TextureRaw m_resource = nullptr;
2128
2129public:
2131 constexpr Texture() = default;
2132
2140 constexpr explicit Texture(const TextureRaw resource)
2141 : m_resource(resource)
2142 {
2143 }
2144
2146 constexpr Texture(const Texture& other) { ++m_resource->refcount; }
2147
2149 constexpr Texture(Texture&& other)
2150 : Texture(other.release())
2151 {
2152 }
2153
2176 PixelFormat format,
2177 TextureAccess access,
2178 const PointRaw& size)
2179 : m_resource(
2180 CheckError(SDL_CreateTexture(renderer, format, access, size.x, size.y)))
2181 {
2182 }
2183
2209 : m_resource(CheckError(SDL_CreateTextureFromSurface(renderer, surface)))
2210 {
2211 }
2212
2323 : m_resource(CheckError(SDL_CreateTextureWithProperties(renderer, props)))
2324 {
2325 }
2326
2357 Texture(RendererParam renderer, StringParam file);
2358
2401 Texture(RendererParam renderer, IOStreamParam src, bool closeio = false);
2402
2410 static constexpr Texture Borrow(TextureParam resource)
2411 {
2412 if (resource) {
2413 ++resource.value->refcount;
2414 return Texture(resource.value);
2415 }
2416 return {};
2417 }
2418
2420 ~Texture() { SDL_DestroyTexture(m_resource); }
2421
2424 {
2425 std::swap(m_resource, other.m_resource);
2426 return *this;
2427 }
2428
2430 constexpr TextureRaw get() const { return m_resource; }
2431
2434 {
2435 auto r = m_resource;
2436 m_resource = nullptr;
2437 return r;
2438 }
2439
2441 constexpr auto operator<=>(const Texture& other) const = default;
2442
2444 constexpr bool operator==(std::nullptr_t _) const { return !m_resource; }
2445
2447 constexpr explicit operator bool() const { return !!m_resource; }
2448
2450 constexpr operator TextureParam() const { return {m_resource}; }
2451
2466 void Destroy();
2467
2554
2565 RendererRef GetRenderer() const;
2566
2590 {
2591 SetColorMod(c.r, c.g, c.b);
2592 SetAlphaMod(c.a);
2593 }
2594
2618 {
2619 SetColorMod(c.r, c.g, c.b);
2620 SetAlphaMod(c.a);
2621 }
2622
2637 {
2638 Color c;
2639 GetColorMod(&c.r, &c.g, &c.b);
2640 c.a = GetAlphaMod();
2641 return c;
2642 }
2643
2658 {
2659 FColor c;
2660 GetColorModFloat(&c.r, &c.g, &c.b);
2661 c.a = GetAlphaModFloat();
2662 return c;
2663 }
2664
2690 void SetColorMod(Uint8 r, Uint8 g, Uint8 b);
2691
2717 void SetColorModFloat(float r, float g, float b);
2718
2735 void GetColorMod(Uint8* r, Uint8* g, Uint8* b) const;
2736
2753 void GetColorModFloat(float* r, float* g, float* b) const;
2754
2777 void SetAlphaMod(Uint8 alpha);
2778
2801 void SetAlphaModFloat(float alpha);
2802
2817 Uint8 GetAlphaMod() const;
2818
2833 float GetAlphaModFloat() const;
2834
2850 void SetBlendMode(BlendMode blendMode);
2851
2864 BlendMode GetBlendMode() const;
2865
2882 void SetScaleMode(ScaleMode scaleMode);
2883
2896 ScaleMode GetScaleMode() const;
2897
2928 void Update(OptionalRef<const RectRaw> rect, const void* pixels, int pitch);
2929
2959 const Uint8* Yplane,
2960 int Ypitch,
2961 const Uint8* Uplane,
2962 int Upitch,
2963 const Uint8* Vplane,
2964 int Vpitch);
2965
2991 const Uint8* Yplane,
2992 int Ypitch,
2993 const Uint8* UVplane,
2994 int UVpitch);
2995
3023 void Lock(OptionalRef<const SDL_Rect> rect, void** pixels, int* pitch);
3024
3058
3077 void Unlock();
3078
3082 int GetWidth() const { return m_resource->w; }
3083
3087 int GetHeight() const { return m_resource->h; }
3088
3092 Point GetSize() const { return Point(GetWidth(), GetHeight()); }
3093
3107 void GetSize(float* w, float* h) const;
3108
3113 {
3114 FPoint p;
3115 GetSize(&p.x, &p.y);
3116 return p;
3117 }
3118
3122 PixelFormat GetFormat() const { return m_resource->format; }
3123};
3124
3143inline int GetNumRenderDrivers() { return SDL_GetNumRenderDrivers(); }
3144
3167inline const char* GetRenderDriver(int index)
3168{
3169 return SDL_GetRenderDriver(index);
3170}
3171
3189inline std::pair<Window, Renderer> CreateWindowAndRenderer(
3190 StringParam title,
3191 const PointRaw& size,
3192 WindowFlags window_flags = 0)
3193{
3194 SDL_Window* window = nullptr;
3195 SDL_Renderer* renderer = nullptr;
3196 CheckError(SDL_CreateWindowAndRenderer(
3197 title, size.x, size.y, window_flags, &window, &renderer));
3198 return {Window{window}, Renderer(renderer)};
3199}
3200
3236{
3237 return Renderer(window, std::move(name));
3238}
3239
3292{
3293 return Renderer(props);
3294}
3295
3296namespace prop::Renderer {
3297
3298constexpr auto CREATE_NAME_STRING = SDL_PROP_RENDERER_CREATE_NAME_STRING;
3299
3300constexpr auto CREATE_WINDOW_POINTER = SDL_PROP_RENDERER_CREATE_WINDOW_POINTER;
3301
3302constexpr auto CREATE_SURFACE_POINTER =
3303 SDL_PROP_RENDERER_CREATE_SURFACE_POINTER;
3304
3305constexpr auto CREATE_OUTPUT_COLORSPACE_NUMBER =
3306 SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER;
3307
3308constexpr auto CREATE_PRESENT_VSYNC_NUMBER =
3309 SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER;
3310
3311constexpr auto CREATE_VULKAN_INSTANCE_POINTER =
3312 SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER;
3313
3314constexpr auto CREATE_VULKAN_SURFACE_NUMBER =
3315 SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER;
3316
3317constexpr auto CREATE_VULKAN_PHYSICAL_DEVICE_POINTER =
3318 SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER;
3319
3320constexpr auto CREATE_VULKAN_DEVICE_POINTER =
3321 SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER;
3322
3323constexpr auto CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER =
3324 SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER;
3325
3326constexpr auto CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER =
3327 SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER;
3328
3329constexpr auto NAME_STRING = SDL_PROP_RENDERER_NAME_STRING;
3330
3331constexpr auto WINDOW_POINTER = SDL_PROP_RENDERER_WINDOW_POINTER;
3332
3333constexpr auto SURFACE_POINTER = SDL_PROP_RENDERER_SURFACE_POINTER;
3334
3335constexpr auto VSYNC_NUMBER = SDL_PROP_RENDERER_VSYNC_NUMBER;
3336
3337constexpr auto MAX_TEXTURE_SIZE_NUMBER =
3338 SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER;
3339
3340constexpr auto TEXTURE_FORMATS_POINTER =
3341 SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER;
3342
3343constexpr auto OUTPUT_COLORSPACE_NUMBER =
3344 SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER;
3345
3346constexpr auto HDR_ENABLED_BOOLEAN = SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN;
3347
3348constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT;
3349
3350constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT;
3351
3352constexpr auto D3D9_DEVICE_POINTER = SDL_PROP_RENDERER_D3D9_DEVICE_POINTER;
3353
3354constexpr auto D3D11_DEVICE_POINTER = SDL_PROP_RENDERER_D3D11_DEVICE_POINTER;
3355
3356constexpr auto D3D11_SWAPCHAIN_POINTER =
3357 SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER;
3358
3359constexpr auto D3D12_DEVICE_POINTER = SDL_PROP_RENDERER_D3D12_DEVICE_POINTER;
3360
3361constexpr auto D3D12_SWAPCHAIN_POINTER =
3362 SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER;
3363
3364constexpr auto D3D12_COMMAND_QUEUE_POINTER =
3365 SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER;
3366
3367constexpr auto VULKAN_INSTANCE_POINTER =
3368 SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER;
3369
3370constexpr auto VULKAN_SURFACE_NUMBER = SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER;
3371
3372constexpr auto VULKAN_PHYSICAL_DEVICE_POINTER =
3373 SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER;
3374
3375constexpr auto VULKAN_DEVICE_POINTER = SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER;
3376
3377constexpr auto VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER =
3378 SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER;
3379
3380constexpr auto VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER =
3381 SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER;
3382
3383constexpr auto VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER =
3384 SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER;
3385
3386constexpr auto GPU_DEVICE_POINTER = SDL_PROP_RENDERER_GPU_DEVICE_POINTER;
3387
3388} // namespace prop::Renderer
3389
3410{
3411 return Renderer(surface);
3412}
3413
3415{
3416 return {CheckError(SDL_GetRenderer(m_resource))};
3417}
3418
3431{
3432 return {CheckError(SDL_GetRenderWindow(renderer))};
3433}
3434
3436{
3437 return SDL::GetRenderWindow(m_resource);
3438}
3439
3454inline const char* GetRendererName(RendererParam renderer)
3455{
3456 return SDL_GetRendererName(renderer);
3457}
3458
3459inline const char* Renderer::GetName() const
3460{
3461 return SDL::GetRendererName(m_resource);
3462}
3463
3549{
3550 return {CheckError(SDL_GetRendererProperties(renderer))};
3551}
3552
3554{
3555 return SDL::GetRendererProperties(m_resource);
3556}
3557
3578inline void GetRenderOutputSize(RendererParam renderer, int* w, int* h)
3579{
3580 CheckError(SDL_GetRenderOutputSize(renderer, w, h));
3581}
3582
3583inline void Renderer::GetOutputSize(int* w, int* h) const
3584{
3585 SDL::GetRenderOutputSize(m_resource, w, h);
3586}
3587
3608inline void GetCurrentRenderOutputSize(RendererParam renderer, int* w, int* h)
3609{
3610 CheckError(SDL_GetCurrentRenderOutputSize(renderer, w, h));
3611}
3612
3613inline void Renderer::GetCurrentOutputSize(int* w, int* h) const
3614{
3615 SDL::GetCurrentRenderOutputSize(m_resource, w, h);
3616}
3617
3641 PixelFormat format,
3642 TextureAccess access,
3643 const PointRaw& size)
3644{
3645 return Texture(renderer, format, access, size);
3646}
3647
3649 TextureAccess access,
3650 const PointRaw& size)
3651{
3652 return Texture(m_resource, format, access, size);
3653}
3654
3682 SurfaceParam surface)
3683{
3684 return Texture(renderer, surface);
3685}
3686
3688{
3689 return Texture(m_resource, surface);
3690}
3691
3803 PropertiesParam props)
3804{
3805 return Texture(renderer, props);
3806}
3807
3809{
3810 return Texture(m_resource, props);
3811}
3812
3813namespace prop::Texture {
3814
3815constexpr auto CREATE_COLORSPACE_NUMBER =
3816 SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER;
3817
3818constexpr auto CREATE_FORMAT_NUMBER = SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER;
3819
3820constexpr auto CREATE_ACCESS_NUMBER = SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER;
3821
3822constexpr auto CREATE_WIDTH_NUMBER = SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER;
3823
3824constexpr auto CREATE_HEIGHT_NUMBER = SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER;
3825
3826constexpr auto CREATE_SDR_WHITE_POINT_FLOAT =
3827 SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT;
3828
3829constexpr auto CREATE_HDR_HEADROOM_FLOAT =
3830 SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT;
3831
3832constexpr auto CREATE_D3D11_TEXTURE_POINTER =
3833 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER;
3834
3835constexpr auto CREATE_D3D11_TEXTURE_U_POINTER =
3836 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER;
3837
3838constexpr auto CREATE_D3D11_TEXTURE_V_POINTER =
3839 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER;
3840
3841constexpr auto CREATE_D3D12_TEXTURE_POINTER =
3842 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER;
3843
3844constexpr auto CREATE_D3D12_TEXTURE_U_POINTER =
3845 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER;
3846
3847constexpr auto CREATE_D3D12_TEXTURE_V_POINTER =
3848 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER;
3849
3850constexpr auto CREATE_METAL_PIXELBUFFER_POINTER =
3851 SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER;
3852
3853constexpr auto CREATE_OPENGL_TEXTURE_NUMBER =
3854 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER;
3855
3856constexpr auto CREATE_OPENGL_TEXTURE_UV_NUMBER =
3857 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER;
3858
3859constexpr auto CREATE_OPENGL_TEXTURE_U_NUMBER =
3860 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER;
3861
3862constexpr auto CREATE_OPENGL_TEXTURE_V_NUMBER =
3863 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER;
3864
3865constexpr auto CREATE_OPENGLES2_TEXTURE_NUMBER =
3866 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER;
3867
3868constexpr auto CREATE_OPENGLES2_TEXTURE_UV_NUMBER =
3869 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER;
3870
3871constexpr auto CREATE_OPENGLES2_TEXTURE_U_NUMBER =
3872 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER;
3873
3874constexpr auto CREATE_OPENGLES2_TEXTURE_V_NUMBER =
3875 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER;
3876
3877constexpr auto CREATE_VULKAN_TEXTURE_NUMBER =
3878 SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER;
3879
3880constexpr auto COLORSPACE_NUMBER = SDL_PROP_TEXTURE_COLORSPACE_NUMBER;
3881
3882constexpr auto FORMAT_NUMBER = SDL_PROP_TEXTURE_FORMAT_NUMBER;
3883
3884constexpr auto ACCESS_NUMBER = SDL_PROP_TEXTURE_ACCESS_NUMBER;
3885
3886constexpr auto WIDTH_NUMBER = SDL_PROP_TEXTURE_WIDTH_NUMBER;
3887
3888constexpr auto HEIGHT_NUMBER = SDL_PROP_TEXTURE_HEIGHT_NUMBER;
3889
3890constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT;
3891
3892constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT;
3893
3894constexpr auto D3D11_TEXTURE_POINTER = SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER;
3895
3896constexpr auto D3D11_TEXTURE_U_POINTER =
3897 SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER;
3898
3899constexpr auto D3D11_TEXTURE_V_POINTER =
3900 SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER;
3901
3902constexpr auto D3D12_TEXTURE_POINTER = SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER;
3903
3904constexpr auto D3D12_TEXTURE_U_POINTER =
3905 SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER;
3906
3907constexpr auto D3D12_TEXTURE_V_POINTER =
3908 SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER;
3909
3910constexpr auto OPENGL_TEXTURE_NUMBER = SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER;
3911
3912constexpr auto OPENGL_TEXTURE_UV_NUMBER =
3913 SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER;
3914
3915constexpr auto OPENGL_TEXTURE_U_NUMBER =
3916 SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER;
3917
3918constexpr auto OPENGL_TEXTURE_V_NUMBER =
3919 SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER;
3920
3921constexpr auto OPENGL_TEXTURE_TARGET_NUMBER =
3922 SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER;
3923
3924constexpr auto OPENGL_TEX_W_FLOAT = SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT;
3925
3926constexpr auto OPENGL_TEX_H_FLOAT = SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT;
3927
3928constexpr auto OPENGLES2_TEXTURE_NUMBER =
3929 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER;
3930
3931constexpr auto OPENGLES2_TEXTURE_UV_NUMBER =
3932 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER;
3933
3934constexpr auto OPENGLES2_TEXTURE_U_NUMBER =
3935 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER;
3936
3937constexpr auto OPENGLES2_TEXTURE_V_NUMBER =
3938 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER;
3939
3940constexpr auto OPENGLES2_TEXTURE_TARGET_NUMBER =
3941 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER;
3942
3943constexpr auto VULKAN_TEXTURE_NUMBER = SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER;
3944
3945} // namespace prop::Texture
3946
4034{
4035 return {CheckError(SDL_GetTextureProperties(texture))};
4036}
4037
4039{
4040 return SDL::GetTextureProperties(m_resource);
4041}
4042
4055{
4056 return {SDL_GetRendererFromTexture(texture)};
4057}
4058
4060{
4061 return SDL::GetRendererFromTexture(m_resource);
4062}
4063
4078inline void GetTextureSize(TextureParam texture, float* w, float* h)
4079{
4080 CheckError(SDL_GetTextureSize(texture, w, h));
4081}
4082
4083inline void Texture::GetSize(float* w, float* h) const
4084{
4085 SDL::GetTextureSize(m_resource, w, h);
4086}
4087
4114inline void SetTextureColorMod(TextureParam texture, Uint8 r, Uint8 g, Uint8 b)
4115{
4116 CheckError(SDL_SetTextureColorMod(texture, r, g, b));
4117}
4118
4120{
4121 SDL::SetTextureColorMod(m_resource, r, g, b);
4122}
4123
4151 float r,
4152 float g,
4153 float b)
4154{
4155 CheckError(SDL_SetTextureColorModFloat(texture, r, g, b));
4156}
4157
4158inline void Texture::SetColorModFloat(float r, float g, float b)
4159{
4160 SDL::SetTextureColorModFloat(m_resource, r, g, b);
4161}
4162
4181 Uint8* r,
4182 Uint8* g,
4183 Uint8* b)
4184{
4185 CheckError(SDL_GetTextureColorMod(texture, r, g, b));
4186}
4187
4188inline void Texture::GetColorMod(Uint8* r, Uint8* g, Uint8* b) const
4189{
4190 SDL::GetTextureColorMod(m_resource, r, g, b);
4191}
4192
4211 float* r,
4212 float* g,
4213 float* b)
4214{
4215 CheckError(SDL_GetTextureColorModFloat(texture, r, g, b));
4216}
4217
4218inline void Texture::GetColorModFloat(float* r, float* g, float* b) const
4219{
4220 SDL::GetTextureColorModFloat(m_resource, r, g, b);
4221}
4222
4246inline void SetTextureAlphaMod(TextureParam texture, Uint8 alpha)
4247{
4248 CheckError(SDL_SetTextureAlphaMod(texture, alpha));
4249}
4250
4251inline void Texture::SetAlphaMod(Uint8 alpha)
4252{
4253 SDL::SetTextureAlphaMod(m_resource, alpha);
4254}
4255
4279inline void SetTextureAlphaModFloat(TextureParam texture, float alpha)
4280{
4281 CheckError(SDL_SetTextureAlphaModFloat(texture, alpha));
4282}
4283
4284inline void Texture::SetAlphaModFloat(float alpha)
4285{
4286 SDL::SetTextureAlphaModFloat(m_resource, alpha);
4287}
4288
4305{
4306 Uint8 alpha;
4307 CheckError(SDL_GetTextureAlphaMod(texture, &alpha));
4308 return alpha;
4309}
4310
4312{
4313 return SDL::GetTextureAlphaMod(m_resource);
4314}
4315
4332{
4333 float alpha;
4334 CheckError(SDL_GetTextureAlphaModFloat(texture, &alpha));
4335 return alpha;
4336}
4337
4338inline float Texture::GetAlphaModFloat() const
4339{
4340 return SDL::GetTextureAlphaModFloat(m_resource);
4341}
4342
4359inline void SetTextureBlendMode(TextureParam texture, BlendMode blendMode)
4360{
4361 CheckError(SDL_SetTextureBlendMode(texture, blendMode));
4362}
4363
4364inline void Texture::SetBlendMode(BlendMode blendMode)
4365{
4366 SDL::SetTextureBlendMode(m_resource, blendMode);
4367}
4368
4383{
4384 BlendMode blendMode;
4385 CheckError(SDL_GetTextureBlendMode(texture, &blendMode));
4386 return blendMode;
4387}
4388
4390{
4391 return SDL::GetTextureBlendMode(m_resource);
4392}
4393
4411inline void SetTextureScaleMode(TextureParam texture, ScaleMode scaleMode)
4412{
4413 CheckError(SDL_SetTextureScaleMode(texture, scaleMode));
4414}
4415
4416inline void Texture::SetScaleMode(ScaleMode scaleMode)
4417{
4418 SDL::SetTextureScaleMode(m_resource, scaleMode);
4419}
4420
4435{
4436 ScaleMode scaleMode;
4437 CheckError(SDL_GetTextureScaleMode(texture, &scaleMode));
4438 return scaleMode;
4439}
4440
4442{
4443 return SDL::GetTextureScaleMode(m_resource);
4444}
4445
4477inline void UpdateTexture(TextureParam texture,
4479 const void* pixels,
4480 int pitch)
4481{
4482 CheckError(SDL_UpdateTexture(texture, rect, pixels, pitch));
4483}
4484
4486 const void* pixels,
4487 int pitch)
4488{
4489 SDL::UpdateTexture(m_resource, rect, pixels, pitch);
4490}
4491
4521inline void UpdateYUVTexture(TextureParam texture,
4523 const Uint8* Yplane,
4524 int Ypitch,
4525 const Uint8* Uplane,
4526 int Upitch,
4527 const Uint8* Vplane,
4528 int Vpitch)
4529{
4530 CheckError(SDL_UpdateYUVTexture(
4531 texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch));
4532}
4533
4535 const Uint8* Yplane,
4536 int Ypitch,
4537 const Uint8* Uplane,
4538 int Upitch,
4539 const Uint8* Vplane,
4540 int Vpitch)
4541{
4543 m_resource, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
4544}
4545
4571inline void UpdateNVTexture(TextureParam texture,
4573 const Uint8* Yplane,
4574 int Ypitch,
4575 const Uint8* UVplane,
4576 int UVpitch)
4577{
4578 CheckError(
4579 SDL_UpdateNVTexture(texture, rect, Yplane, Ypitch, UVplane, UVpitch));
4580}
4581
4583 const Uint8* Yplane,
4584 int Ypitch,
4585 const Uint8* UVplane,
4586 int UVpitch)
4587{
4588 SDL::UpdateNVTexture(m_resource, rect, Yplane, Ypitch, UVplane, UVpitch);
4589}
4590
4619inline void LockTexture(TextureParam texture,
4621 void** pixels,
4622 int* pitch)
4623{
4624 CheckError(SDL_LockTexture(texture, rect, pixels, pitch));
4625}
4626
4628 void** pixels,
4629 int* pitch)
4630{
4631 SDL::LockTexture(m_resource, rect, pixels, pitch);
4632}
4633
4667 TextureParam texture,
4668 OptionalRef<const SDL_Rect> rect = std::nullopt)
4669{
4670 SurfaceRaw surface = nullptr;
4671 CheckError(SDL_LockTextureToSurface(texture, rect, &surface));
4672 return Surface::Borrow(surface);
4673}
4674
4676{
4677 return SDL::LockTextureToSurface(m_resource, rect);
4678}
4679
4699inline void UnlockTexture(TextureParam texture) { SDL_UnlockTexture(texture); }
4700
4701inline void Texture::Unlock() { SDL::UnlockTexture(m_resource); }
4702
4727inline void SetRenderTarget(RendererParam renderer, TextureParam texture)
4728{
4729 CheckError(SDL_SetRenderTarget(renderer, texture));
4730}
4731
4733{
4734 SDL::SetRenderTarget(m_resource, texture);
4735}
4736
4753{
4754 TextureRaw texture = SDL_GetRenderTarget(renderer);
4755 if (texture) return Texture::Borrow(texture);
4756 return {};
4757}
4758
4760{
4761 return SDL::GetRenderTarget(m_resource);
4762}
4763
4816 const PointRaw& size,
4818{
4819 CheckError(SDL_SetRenderLogicalPresentation(renderer, size.x, size.y, mode));
4820}
4821
4824{
4825 SDL::SetRenderLogicalPresentation(m_resource, size, mode);
4826}
4827
4850 int* w,
4851 int* h,
4853{
4854 CheckError(SDL_GetRenderLogicalPresentation(renderer, w, h, mode));
4855}
4856
4858 int* w,
4859 int* h,
4860 RendererLogicalPresentation* mode) const
4861{
4862 SDL::GetRenderLogicalPresentation(m_resource, w, h, mode);
4863}
4864
4887{
4888 FRect rect;
4889 CheckError(SDL_GetRenderLogicalPresentationRect(renderer, &rect));
4890 return rect;
4891}
4892
4894{
4895 return SDL::GetRenderLogicalPresentationRect(m_resource);
4896}
4897
4921 const FPointRaw& window_coord)
4922{
4923 FPoint p;
4924 CheckError(SDL_RenderCoordinatesFromWindow(
4925 renderer, window_coord.x, window_coord.y, &p.x, &p.y));
4926 return p;
4927}
4928
4930 const FPointRaw& window_coord) const
4931{
4932 return SDL::RenderCoordinatesFromWindow(m_resource, window_coord);
4933}
4934
4959 const FPointRaw& coord)
4960{
4961 FPoint p;
4962 CheckError(
4963 SDL_RenderCoordinatesToWindow(renderer, coord.x, coord.y, &p.x, &p.y));
4964 return p;
4965}
4966
4968{
4969 return SDL::RenderCoordinatesToWindow(m_resource, coord);
4970}
4971
5006 Event* event)
5007{
5008 CheckError(SDL_ConvertEventToRenderCoordinates(renderer, event));
5009}
5010
5012{
5013 SDL::ConvertEventToRenderCoordinates(m_resource, event);
5014}
5015
5042{
5043 CheckError(SDL_SetRenderViewport(renderer, rect));
5044}
5045
5047{
5048 SDL::SetRenderViewport(m_resource, rect);
5049}
5050
5069{
5070 Rect rect;
5071 CheckError(SDL_GetRenderViewport(renderer, &rect));
5072 return rect;
5073}
5074
5076{
5077 return SDL::GetRenderViewport(m_resource);
5078}
5079
5101{
5102 return SDL_RenderViewportSet(renderer);
5103}
5104
5105inline bool Renderer::IsViewportSet() const
5106{
5107 return SDL::RenderViewportSet(m_resource);
5108}
5109
5129{
5130 Rect rect;
5131 CheckError(SDL_GetRenderSafeArea(renderer, &rect));
5132 return rect;
5133}
5134
5136{
5137 return SDL::GetRenderSafeArea(m_resource);
5138}
5139
5160{
5161 CheckError(SDL_SetRenderClipRect(renderer, rect));
5162}
5163
5165{
5166 SDL::SetRenderClipRect(m_resource, rect);
5167}
5168
5188{
5189 Rect rect;
5190 CheckError(SDL_GetRenderClipRect(renderer, &rect));
5191 return rect;
5192}
5193
5195{
5196 return SDL::GetRenderClipRect(m_resource);
5197}
5198
5217{
5218 return SDL_RenderClipEnabled(renderer);
5219}
5220
5221inline bool Renderer::IsClipEnabled() const
5222{
5223 return SDL::RenderClipEnabled(m_resource);
5224}
5225
5250inline void SetRenderScale(RendererParam renderer, const FPointRaw& scale)
5251{
5252 CheckError(SDL_SetRenderScale(renderer, scale.x, scale.y));
5253}
5254
5255inline void Renderer::SetScale(const FPointRaw& scale)
5256{
5257 SDL::SetRenderScale(m_resource, scale);
5258}
5259
5277inline void GetRenderScale(RendererParam renderer, float* scaleX, float* scaleY)
5278{
5279 CheckError(SDL_GetRenderScale(renderer, scaleX, scaleY));
5280}
5281
5282inline void Renderer::GetScale(float* scaleX, float* scaleY) const
5283{
5284 SDL::GetRenderScale(m_resource, scaleX, scaleY);
5285}
5286
5305{
5306 CheckError(SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, c.a));
5307}
5308
5310{
5311 SDL::SetRenderDrawColor(m_resource, c);
5312}
5313
5331inline void SetRenderDrawColorFloat(RendererParam renderer, const FColorRaw& c)
5332{
5333 CheckError(SDL_SetRenderDrawColorFloat(renderer, c.r, c.g, c.b, c.a));
5334}
5335
5337{
5338 SDL::SetRenderDrawColorFloat(m_resource, c);
5339}
5340
5363 Uint8* r,
5364 Uint8* g,
5365 Uint8* b,
5366 Uint8* a)
5367{
5368 CheckError(SDL_GetRenderDrawColor(renderer, r, g, b, a));
5369}
5370
5371inline void Renderer::GetDrawColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const
5372{
5373 SDL::GetRenderDrawColor(m_resource, r, g, b, a);
5374}
5375
5398 float* r,
5399 float* g,
5400 float* b,
5401 float* a)
5402{
5403 CheckError(SDL_GetRenderDrawColorFloat(renderer, r, g, b, a));
5404}
5405
5406inline void Renderer::GetDrawColorFloat(float* r,
5407 float* g,
5408 float* b,
5409 float* a) const
5410{
5411 SDL::GetRenderDrawColorFloat(m_resource, r, g, b, a);
5412}
5413
5435inline void SetRenderColorScale(RendererParam renderer, float scale)
5436{
5437 CheckError(SDL_SetRenderColorScale(renderer, scale));
5438}
5439
5440inline void Renderer::SetColorScale(float scale)
5441{
5442 SDL::SetRenderColorScale(m_resource, scale);
5443}
5444
5459{
5460 float scale;
5461 CheckError(SDL_GetRenderColorScale(renderer, &scale));
5462 return scale;
5463}
5464
5465inline float Renderer::GetColorScale() const
5466{
5467 return SDL::GetRenderColorScale(m_resource);
5468}
5469
5485inline void SetRenderDrawBlendMode(RendererParam renderer, BlendMode blendMode)
5486{
5487 CheckError(SDL_SetRenderDrawBlendMode(renderer, blendMode));
5488}
5489
5491{
5492 SDL::SetRenderDrawBlendMode(m_resource, blendMode);
5493}
5494
5509{
5510 BlendMode blendMode;
5511 CheckError(SDL_GetRenderDrawBlendMode(renderer, &blendMode));
5512 return blendMode;
5513}
5514
5516{
5517 return SDL::GetRenderDrawBlendMode(m_resource);
5518}
5519
5537inline void RenderClear(RendererParam renderer)
5538{
5539 CheckError(SDL_RenderClear(renderer));
5540}
5541
5542inline void Renderer::RenderClear() { SDL::RenderClear(m_resource); }
5543
5557inline void RenderPoint(RendererParam renderer, const FPointRaw& p)
5558{
5559 CheckError(SDL_RenderPoint(renderer, p.x, p.y));
5560}
5561
5563{
5564 SDL::RenderPoint(m_resource, p);
5565}
5566
5580inline void RenderPoints(RendererParam renderer,
5582{
5583 CheckError(SDL_RenderPoints(renderer, points.data(), points.size()));
5584}
5585
5587{
5588 SDL::RenderPoints(m_resource, points);
5589}
5590
5605inline void RenderLine(RendererParam renderer,
5606 const FPointRaw& p1,
5607 const FPointRaw& p2)
5608{
5609 CheckError(SDL_RenderLine(renderer, p1.x, p1.y, p2.x, p2.y));
5610}
5611
5612inline void Renderer::RenderLine(const FPointRaw& p1, const FPointRaw& p2)
5613{
5614 SDL::RenderLine(m_resource, p1, p2);
5615}
5616
5632{
5633 CheckError(SDL_RenderLines(renderer, points.data(), points.size()));
5634}
5635
5637{
5638 SDL::RenderLines(m_resource, points);
5639}
5640
5656{
5657 CheckError(SDL_RenderRect(renderer, rect));
5658}
5659
5661{
5662 SDL::RenderRect(m_resource, rect);
5663}
5664
5680{
5681 CheckError(SDL_RenderRects(renderer, rects.data(), rects.size()));
5682}
5683
5685{
5686 SDL::RenderRects(m_resource, rects);
5687}
5688
5704inline void RenderFillRect(RendererParam renderer,
5706{
5707 CheckError(SDL_RenderFillRect(renderer, rect));
5708}
5709
5711{
5712 SDL::RenderFillRect(m_resource, rect);
5713}
5714
5729inline void RenderFillRects(RendererParam renderer,
5731{
5732 CheckError(SDL_RenderFillRects(renderer, rects.data(), rects.size()));
5733}
5734
5736{
5737 SDL::RenderFillRects(m_resource, rects);
5738}
5739
5759inline void RenderTexture(RendererParam renderer,
5760 TextureParam texture,
5763{
5764 CheckError(SDL_RenderTexture(renderer, texture, srcrect, dstrect));
5765}
5766
5770{
5771 SDL::RenderTexture(m_resource, texture, srcrect, dstrect);
5772}
5773
5800 TextureParam texture,
5803 double angle,
5805 FlipMode flip = FlipMode::SDL_FLIP_NONE)
5806{
5807 CheckError(SDL_RenderTextureRotated(
5808 renderer, texture, srcrect, dstrect, angle, center, flip));
5809}
5810
5814 double angle,
5816 FlipMode flip)
5817{
5819 m_resource, texture, srcrect, dstrect, angle, center, flip);
5820}
5821
5848 TextureParam texture,
5853{
5854 CheckError(
5855 SDL_RenderTextureAffine(renderer, texture, srcrect, origin, right, down));
5856}
5857
5863{
5864 SDL::RenderTextureAffine(m_resource, texture, srcrect, origin, right, down);
5865}
5866
5892 TextureParam texture,
5894 float scale,
5896{
5897 CheckError(
5898 SDL_RenderTextureTiled(renderer, texture, srcrect, scale, dstrect));
5899}
5900
5903 float scale,
5905{
5906 SDL::RenderTextureTiled(m_resource, texture, srcrect, scale, dstrect);
5907}
5908
5941 TextureParam texture,
5943 float left_width,
5944 float right_width,
5945 float top_height,
5946 float bottom_height,
5947 float scale,
5949{
5950 CheckError(SDL_RenderTexture9Grid(renderer,
5951 texture,
5952 srcrect,
5953 left_width,
5954 right_width,
5955 top_height,
5956 bottom_height,
5957 scale,
5958 dstrect));
5959}
5960
5963 float left_width,
5964 float right_width,
5965 float top_height,
5966 float bottom_height,
5967 float scale,
5969{
5970 SDL::RenderTexture9Grid(m_resource,
5971 texture,
5972 srcrect,
5973 left_width,
5974 right_width,
5975 top_height,
5976 bottom_height,
5977 scale,
5978 dstrect);
5979}
5980
6000inline void RenderGeometry(RendererParam renderer,
6001 TextureParam texture,
6002 std::span<const Vertex> vertices,
6003 std::span<const int> indices = {})
6004{
6005 CheckError(SDL_RenderGeometry(renderer,
6006 texture,
6007 vertices.data(),
6008 vertices.size(),
6009 indices.data(),
6010 indices.size()));
6011}
6012
6014 std::span<const Vertex> vertices,
6015 std::span<const int> indices)
6016{
6017 SDL::RenderGeometry(m_resource, texture, vertices, indices);
6018}
6019
6047 TextureParam texture,
6048 const float* xy,
6049 int xy_stride,
6050 const FColor* color,
6051 int color_stride,
6052 const float* uv,
6053 int uv_stride,
6054 int num_vertices,
6055 const void* indices,
6056 int num_indices,
6057 int size_indices)
6058{
6059 CheckError(SDL_RenderGeometryRaw(renderer,
6060 texture,
6061 xy,
6062 xy_stride,
6063 color,
6064 color_stride,
6065 uv,
6066 uv_stride,
6067 num_vertices,
6068 indices,
6069 num_indices,
6070 size_indices));
6071}
6072
6074 const float* xy,
6075 int xy_stride,
6076 const FColor* color,
6077 int color_stride,
6078 const float* uv,
6079 int uv_stride,
6080 int num_vertices,
6081 const void* indices,
6082 int num_indices,
6083 int size_indices)
6084{
6085 SDL::RenderGeometryRaw(m_resource,
6086 texture,
6087 xy,
6088 xy_stride,
6089 color,
6090 color_stride,
6091 uv,
6092 uv_stride,
6093 num_vertices,
6094 indices,
6095 num_indices,
6096 size_indices);
6097}
6098
6126{
6127 return Surface{CheckError(SDL_RenderReadPixels(renderer, rect))};
6128}
6129
6131{
6132 return SDL::RenderReadPixels(m_resource, rect);
6133}
6134
6182inline void RenderPresent(RendererParam renderer)
6183{
6184 CheckError(SDL_RenderPresent(renderer));
6185}
6186
6187inline void Renderer::Present() { SDL::RenderPresent(m_resource); }
6188
6204inline void DestroyTexture(TextureRaw texture) { SDL_DestroyTexture(texture); }
6205
6207
6222inline void DestroyRenderer(RendererRaw renderer)
6223{
6224 SDL_DestroyRenderer(renderer);
6225}
6226
6228
6259inline void FlushRenderer(RendererParam renderer)
6260{
6261 CheckError(SDL_FlushRenderer(renderer));
6262}
6263
6264inline void Renderer::Flush() { SDL::FlushRenderer(m_resource); }
6265
6283{
6284 return CheckError(SDL_GetRenderMetalLayer(renderer));
6285}
6286
6288{
6289 return SDL::GetRenderMetalLayer(m_resource);
6290}
6291
6314{
6315 return CheckError(SDL_GetRenderMetalCommandEncoder(renderer));
6316}
6317
6319{
6320 return SDL::GetRenderMetalCommandEncoder(m_resource);
6321}
6322
6351 Uint32 wait_stage_mask,
6352 Sint64 wait_semaphore,
6353 Sint64 signal_semaphore)
6354{
6355 CheckError(SDL_AddVulkanRenderSemaphores(
6356 renderer, wait_stage_mask, wait_semaphore, signal_semaphore));
6357}
6358
6360 Sint64 wait_semaphore,
6361 Sint64 signal_semaphore)
6362{
6364 m_resource, wait_stage_mask, wait_semaphore, signal_semaphore);
6365}
6366
6389inline void SetRenderVSync(RendererParam renderer, int vsync)
6390{
6391 CheckError(SDL_SetRenderVSync(renderer, vsync));
6392}
6393
6394inline void Renderer::SetVSync(int vsync)
6395{
6396 SDL::SetRenderVSync(m_resource, vsync);
6397}
6398
6400#define SDL_RENDERER_VSYNC_DISABLED 0
6401
6403#define SDL_RENDERER_VSYNC_ADAPTIVE (-1)
6404
6419inline int GetRenderVSync(RendererParam renderer)
6420{
6421 int vsync;
6422 CheckError(SDL_GetRenderVSync(renderer, &vsync));
6423 return vsync;
6424}
6425
6426inline int Renderer::GetVSync() const
6427{
6428 return SDL::GetRenderVSync(m_resource);
6429}
6430
6440#define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE 8
6441
6479inline void RenderDebugText(RendererParam renderer,
6480 const FPointRaw& p,
6481 StringParam str)
6482{
6483 CheckError(SDL_RenderDebugText(renderer, p.x, p.y, str));
6484}
6485
6487{
6488 SDL::RenderDebugText(m_resource, p, std::move(str));
6489}
6490
6515template<class... ARGS>
6517 const FPointRaw& p,
6518 std::string_view fmt,
6519 ARGS... args)
6520{
6522 renderer, p, std::vformat(fmt, std::make_format_args(args...)));
6523}
6524
6525template<class... ARGS>
6527 std::string_view fmt,
6528 ARGS... args)
6529{
6530 SDL::RenderDebugTextFormat(m_resource, p, fmt, args...);
6531}
6532
6534
6535} // namespace SDL
6536
6537#endif /* SDL3PP_RENDER_H_ */
Optional-like shim for references.
Definition: SDL3pp_optionalRef.h:20
Pixel format.
Definition: SDL3pp_pixels.h:408
A structure representing rendering state.
Definition: SDL3pp_render.h:188
Point GetCurrentOutputSize() const
Get the current output size in pixels of a rendering context.
Definition: SDL3pp_render.h:499
constexpr bool operator==(std::nullptr_t _) const
Comparison.
Definition: SDL3pp_render.h:397
constexpr RendererRaw get() const
Retrieves underlying RendererRaw.
Definition: SDL3pp_render.h:383
FPoint GetScale() const
Get the drawing scale for the current target.
Definition: SDL3pp_render.h:1086
constexpr RendererRaw release()
Retrieves underlying RendererRaw and clear this.
Definition: SDL3pp_render.h:386
void ResetTarget()
Set target texture back to window.
Definition: SDL3pp_render.h:626
Renderer(WindowParam window)
Create a 2D rendering context for a window.
Definition: SDL3pp_render.h:251
constexpr Renderer(const RendererRaw resource)
Constructs from RendererParam.
Definition: SDL3pp_render.h:202
FColor GetDrawColorFloat() const
Get the color used for drawing operations (Rect, Line and Clear).
Definition: SDL3pp_render.h:1202
Renderer(WindowParam window, StringParam name)
Create a 2D rendering context for a window.
Definition: SDL3pp_render.h:289
constexpr Renderer()=default
Default ctor.
Point GetOutputSize() const
Get the output size in pixels of a rendering context.
Definition: SDL3pp_render.h:455
void ResetViewport()
Reset the drawing area for rendering to the entire target.
Definition: SDL3pp_render.h:887
Renderer(SurfaceParam surface)
Create a 2D software rendering context for a surface.
Definition: SDL3pp_render.h:367
constexpr auto operator<=>(const Renderer &other) const =default
Comparison.
Renderer & operator=(Renderer other)
Assignment operator.
Definition: SDL3pp_render.h:376
Renderer(PropertiesParam props)
Create a 2D rendering context for a window, with the specified properties.
Definition: SDL3pp_render.h:344
~Renderer()
Destructor.
Definition: SDL3pp_render.h:373
void GetLogicalPresentation(PointRaw *size, RendererLogicalPresentation *mode)
Get device independent resolution and presentation mode for rendering.
Definition: SDL3pp_render.h:739
constexpr Renderer(Renderer &&other)
Move constructor.
Definition: SDL3pp_render.h:211
void ResetClipRect()
Reset the clip rectangle for rendering to the entire render target.
Definition: SDL3pp_render.h:987
constexpr Renderer(const Renderer &other)=delete
Copy constructor.
Color GetDrawColor() const
Get the color used for drawing operations (Rect, Line and Clear).
Definition: SDL3pp_render.h:1160
span-like for empty-derived structs
Definition: SDL3pp_spanRef.h:24
constexpr T * data() const
Retrieves contained data.
Definition: SDL3pp_spanRef.h:75
constexpr size_t size() const
Retrieves contained size.
Definition: SDL3pp_spanRef.h:69
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
A collection of pixels used in software blitting.
Definition: SDL3pp_surface.h:195
static constexpr Surface Borrow(SurfaceParam resource)
Safely borrows the from SurfaceParam.
Definition: SDL3pp_surface.h:374
An efficient driver-specific representation of pixel data.
Definition: SDL3pp_render.h:2126
constexpr auto operator<=>(const Texture &other) const =default
Comparison.
constexpr TextureRaw release()
Retrieves underlying TextureRaw and clear this.
Definition: SDL3pp_render.h:2433
constexpr TextureRaw get() const
Retrieves underlying TextureRaw.
Definition: SDL3pp_render.h:2430
constexpr Texture(const TextureRaw resource)
Constructs from TextureParam.
Definition: SDL3pp_render.h:2140
Point GetSize() const
Get the size in pixels.
Definition: SDL3pp_render.h:3092
FPoint GetSizeFloat() const
Get the size in pixels.
Definition: SDL3pp_render.h:3112
Texture & operator=(Texture other)
Assignment operator.
Definition: SDL3pp_render.h:2423
PixelFormat GetFormat() const
Get the pixel format.
Definition: SDL3pp_render.h:3122
int GetHeight() const
Get the height in pixels.
Definition: SDL3pp_render.h:3087
void SetModFloat(FColor c)
Set an additional color and alpha values multiplied into render copy operations.
Definition: SDL3pp_render.h:2617
constexpr Texture(const Texture &other)
Copy constructor.
Definition: SDL3pp_render.h:2146
void SetMod(Color c)
Set an additional color and alpha values multiplied into render copy operations.
Definition: SDL3pp_render.h:2589
Color GetMod() const
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:2636
Texture(RendererParam renderer, SurfaceParam surface)
Create a texture from an existing surface.
Definition: SDL3pp_render.h:2208
constexpr Texture()=default
Default ctor.
int GetWidth() const
Get the width in pixels.
Definition: SDL3pp_render.h:3082
FColor GetModFloat() const
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:2657
static constexpr Texture Borrow(TextureParam resource)
Safely borrows the from TextureParam.
Definition: SDL3pp_render.h:2410
constexpr Texture(Texture &&other)
Move constructor.
Definition: SDL3pp_render.h:2149
~Texture()
Destructor.
Definition: SDL3pp_render.h:2420
Texture(RendererParam renderer, PropertiesParam props)
Create a texture for a rendering context with the specified properties.
Definition: SDL3pp_render.h:2322
Texture(RendererParam renderer, PixelFormat format, TextureAccess access, const PointRaw &size)
Create a texture for a rendering context.
Definition: SDL3pp_render.h:2175
constexpr bool operator==(std::nullptr_t _) const
Comparison.
Definition: SDL3pp_render.h:2444
The struct used as an opaque handle to a window.
Definition: SDL3pp_video.h:737
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:198
SDL_Event Event
The structure for all events in SDL.
Definition: SDL3pp_events.h:804
SDL_FColor FColorRaw
Alias to raw representation for FColor.
Definition: SDL3pp_pixels.h:90
SDL_Color ColorRaw
Alias to raw representation for Color.
Definition: SDL3pp_pixels.h:84
SDL_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
Rect GetRenderSafeArea(RendererParam renderer)
Get the safe area for rendering within the current viewport.
Definition: SDL3pp_render.h:5128
Surface LockToSurface(OptionalRef< const SDL_Rect > 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:4675
Renderer CreateRendererWithProperties(PropertiesParam props)
Create a 2D rendering context for a window, with the specified properties.
Definition: SDL3pp_render.h:3291
void SetDrawColorFloat(const FColorRaw &c)
Set the color used for drawing operations (Rect, Line and Clear).
Definition: SDL3pp_render.h:5336
void RenderPoints(RendererParam renderer, SpanRef< const FPointRaw > points)
Draw multiple points on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5580
void SetDrawColor(ColorRaw c)
Set the color used for drawing operations.
Definition: SDL3pp_render.h:5309
Texture GetTarget() const
Get the current render target.
Definition: SDL3pp_render.h:4759
void Destroy()
Destroy the rendering context for a window and free all associated textures.
Definition: SDL3pp_render.h:6227
const char * GetName() const
Get the name of a renderer.
Definition: SDL3pp_render.h:3459
void SetRenderViewport(RendererParam renderer, OptionalRef< const RectRaw > rect)
Set the drawing area for rendering on the current target.
Definition: SDL3pp_render.h:5040
void SetRenderScale(RendererParam renderer, const FPointRaw &scale)
Set the drawing scale for rendering on the current target.
Definition: SDL3pp_render.h:5250
bool RenderViewportSet(RendererParam renderer)
Return whether an explicit rectangle was set as the viewport.
Definition: SDL3pp_render.h:5100
void UpdateTexture(TextureParam texture, OptionalRef< const RectRaw > rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition: SDL3pp_render.h:4477
void SetColorModFloat(float r, float g, float b)
Set an additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:4158
void RenderPoint(const FPointRaw &p)
Draw a point on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5562
void SetRenderDrawColor(RendererParam renderer, ColorRaw c)
Set the color used for drawing operations.
Definition: SDL3pp_render.h:5304
std::pair< Window, Renderer > CreateWindowAndRenderer(StringParam title, const PointRaw &size, WindowFlags window_flags=0)
Create a window and default renderer.
Definition: SDL3pp_render.h:3189
void SetTextureBlendMode(TextureParam texture, BlendMode blendMode)
Set the blend mode for a texture, used by Renderer.RenderTexture().
Definition: SDL3pp_render.h:4359
void GetCurrentRenderOutputSize(RendererParam renderer, int *w, int *h)
Get the current output size in pixels of a rendering context.
Definition: SDL3pp_render.h:3608
void SetBlendMode(BlendMode blendMode)
Set the blend mode for a texture, used by Renderer.RenderTexture().
Definition: SDL3pp_render.h:4364
Rect GetViewport() const
Get the drawing area for the current target.
Definition: SDL3pp_render.h:5075
void RenderFillRect(RendererParam renderer, OptionalRef< const FRectRaw > rect)
Fill a rectangle on the current rendering target with the drawing color at subpixel precision.
Definition: SDL3pp_render.h:5704
void SetDrawBlendMode(BlendMode blendMode)
Set the blend mode used for drawing operations (Fill and Line).
Definition: SDL3pp_render.h:5490
void SetAlphaMod(Uint8 alpha)
Set an additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:4251
void RenderTextureRotated(RendererParam renderer, TextureParam texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FRectRaw > dstrect, double angle, OptionalRef< const FPointRaw > center, FlipMode flip=FlipMode::SDL_FLIP_NONE)
Copy a portion of the source texture to the current rendering target, with rotation and flipping,...
Definition: SDL3pp_render.h:5799
void SetTextureColorModFloat(TextureParam texture, float r, float g, float b)
Set an additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:4150
void RenderTexture9Grid(TextureParam texture, OptionalRef< const FRectRaw > srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, OptionalRef< const FRectRaw > dstrect)
Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precisio...
Definition: SDL3pp_render.h:5961
SDL_Renderer * RendererRaw
Alias to raw representation for Renderer.
Definition: SDL3pp_render.h:46
void Destroy()
Destroy the specified texture.
Definition: SDL3pp_render.h:6206
bool IsClipEnabled() const
Get whether clipping is enabled on the given render target.
Definition: SDL3pp_render.h:5221
FPoint RenderCoordinatesToWindow(const FPointRaw &coord) const
Get a point in window coordinates when given a point in render coordinates.
Definition: SDL3pp_render.h:4967
void SetRenderVSync(RendererParam renderer, int vsync)
Toggle VSync of the given renderer.
Definition: SDL3pp_render.h:6389
void RenderPresent(RendererParam renderer)
Update the screen with any rendering performed since the previous call.
Definition: SDL3pp_render.h:6182
void RenderDebugText(RendererParam renderer, const FPointRaw &p, StringParam str)
Draw debug text to an Renderer.
Definition: SDL3pp_render.h:6479
void SetRenderClipRect(RendererParam renderer, OptionalRef< const RectRaw > rect)
Set the clip rectangle for rendering on the specified target.
Definition: SDL3pp_render.h:5158
FPoint RenderCoordinatesToWindow(RendererParam renderer, const FPointRaw &coord)
Get a point in window coordinates when given a point in render coordinates.
Definition: SDL3pp_render.h:4958
Texture GetRenderTarget(RendererParam renderer)
Get the current render target.
Definition: SDL3pp_render.h:4752
void RenderPoints(SpanRef< const FPointRaw > points)
Draw multiple points on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5586
void RenderTextureAffine(RendererParam renderer, TextureParam texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FPointRaw > origin, OptionalRef< const FPointRaw > right, OptionalRef< const FPointRaw > down)
Copy a portion of the source texture to the current rendering target, with affine transform,...
Definition: SDL3pp_render.h:5847
void RenderGeometryRaw(TextureParam texture, const float *xy, int xy_stride, const FColor *color, int color_stride, const float *uv, int uv_stride, int num_vertices, const void *indices, int num_indices, int size_indices)
Render a list of triangles, optionally using a texture and indices into the vertex arrays Color and a...
Definition: SDL3pp_render.h:6073
BlendMode GetTextureBlendMode(TextureParam texture)
Get the blend mode used for texture copy operations.
Definition: SDL3pp_render.h:4382
SDL_Vertex Vertex
Vertex structure.
Definition: SDL3pp_render.h:127
void RenderGeometryRaw(RendererParam renderer, TextureParam texture, const float *xy, int xy_stride, const FColor *color, int color_stride, const float *uv, int uv_stride, int num_vertices, const void *indices, int num_indices, int size_indices)
Render a list of triangles, optionally using a texture and indices into the vertex arrays Color and a...
Definition: SDL3pp_render.h:6046
float GetTextureAlphaModFloat(TextureParam texture)
Get the additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:4331
Uint8 GetTextureAlphaMod(TextureParam texture)
Get the additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:4304
void RenderLine(RendererParam renderer, const FPointRaw &p1, const FPointRaw &p2)
Draw a line on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5605
Texture CreateTextureFromSurface(RendererParam renderer, SurfaceParam surface)
Create a texture from an existing surface.
Definition: SDL3pp_render.h:3681
PropertiesRef GetTextureProperties(TextureParam texture)
Get the properties associated with a texture.
Definition: SDL3pp_render.h:4033
FPoint RenderCoordinatesFromWindow(RendererParam renderer, const FPointRaw &window_coord)
Get a point in render coordinates when given a point in window coordinates.
Definition: SDL3pp_render.h:4920
Uint8 GetAlphaMod() const
Get the additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:4311
void RenderLines(RendererParam renderer, SpanRef< const FPointRaw > points)
Draw a series of connected lines on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5631
void DestroyRenderer(RendererRaw renderer)
Destroy the rendering context for a window and free all associated textures.
Definition: SDL3pp_render.h:6222
void UnlockTexture(TextureParam texture)
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL3pp_render.h:4699
void SetColorScale(float scale)
Set the color scale used for render operations.
Definition: SDL3pp_render.h:5440
int GetVSync() const
Get VSync of the given renderer.
Definition: SDL3pp_render.h:6426
Surface RenderReadPixels(RendererParam renderer, OptionalRef< const RectRaw > rect={})
Read pixels from the current rendering target.
Definition: SDL3pp_render.h:6124
BlendMode GetRenderDrawBlendMode(RendererParam renderer)
Get the blend mode used for drawing operations.
Definition: SDL3pp_render.h:5508
void GetColorModFloat(float *r, float *g, float *b) const
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:4218
void SetColorMod(Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:4119
void RenderGeometry(RendererParam renderer, TextureParam texture, std::span< const Vertex > vertices, std::span< const int > indices={})
Render a list of triangles, optionally using a texture and indices into the vertex array Color and al...
Definition: SDL3pp_render.h:6000
void Update(OptionalRef< const RectRaw > rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition: SDL3pp_render.h:4485
void RenderRect(OptionalRef< const FRectRaw > rect)
Draw a rectangle on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5660
RendererRef GetRenderer() const
Get the renderer associated with a window.
Definition: SDL3pp_render.h:3414
void SetRenderTarget(RendererParam renderer, TextureParam texture)
Set a texture as the current rendering target.
Definition: SDL3pp_render.h:4727
void SetRenderDrawColorFloat(RendererParam renderer, const FColorRaw &c)
Set the color used for drawing operations (Rect, Line and Clear).
Definition: SDL3pp_render.h:5331
void Present()
Update the screen with any rendering performed since the previous call.
Definition: SDL3pp_render.h:6187
BlendMode GetDrawBlendMode() const
Get the blend mode used for drawing operations.
Definition: SDL3pp_render.h:5515
void RenderClear()
Clear the current rendering target with the drawing color.
Definition: SDL3pp_render.h:5542
SDL_TextureAccess TextureAccess
The access pattern allowed for a texture.
Definition: SDL3pp_render.h:134
void RenderTexture(TextureParam texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FRectRaw > dstrect)
Copy a portion of the texture to the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5767
Renderer CreateSoftwareRenderer(SurfaceParam surface)
Create a 2D software rendering context for a surface.
Definition: SDL3pp_render.h:3409
Surface LockTextureToSurface(TextureParam texture, OptionalRef< const SDL_Rect > 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:4666
void GetTextureColorModFloat(TextureParam texture, float *r, float *g, float *b)
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:4210
void RenderLine(const FPointRaw &p1, const FPointRaw &p2)
Draw a line on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5612
RendererRef GetRendererFromTexture(TextureParam texture)
Get the renderer that created an Texture.
Definition: SDL3pp_render.h:4054
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:170
PropertiesRef GetProperties() const
Get the properties associated with a texture.
Definition: SDL3pp_render.h:4038
void RenderDebugText(const FPointRaw &p, StringParam str)
Draw debug text to an Renderer.
Definition: SDL3pp_render.h:6486
void SetAlphaModFloat(float alpha)
Set an additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:4284
PropertiesRef GetRendererProperties(RendererParam renderer)
Get the properties associated with a renderer.
Definition: SDL3pp_render.h:3548
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_DISABLED
There is no logical size in effect.
Definition: SDL3pp_render.h:152
void GetRenderDrawColorFloat(RendererParam renderer, float *r, float *g, float *b, float *a)
Get the color used for drawing operations (Rect, Line and Clear).
Definition: SDL3pp_render.h:5397
void UpdateYUVTexture(TextureParam texture, OptionalRef< const RectRaw > rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
Update a rectangle within a planar YV12 or IYUV texture with new pixel data.
Definition: SDL3pp_render.h:4521
void RenderRects(RendererParam renderer, SpanRef< const FRectRaw > rects)
Draw some number of rectangles on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5679
void * GetRenderMetalCommandEncoder(RendererParam renderer)
Get the Metal command encoder for the current frame.
Definition: SDL3pp_render.h:6313
Rect GetClipRect() const
Get the clip rectangle for the current target.
Definition: SDL3pp_render.h:5194
void * GetRenderMetalLayer()
Get the CAMetalLayer associated with the given Metal renderer.
Definition: SDL3pp_render.h:6287
void GetRenderScale(RendererParam renderer, float *scaleX, float *scaleY)
Get the drawing scale for the current target.
Definition: SDL3pp_render.h:5277
void SetRenderColorScale(RendererParam renderer, float scale)
Set the color scale used for render operations.
Definition: SDL3pp_render.h:5435
SDL_RendererLogicalPresentation RendererLogicalPresentation
How the logical size is mapped to the output.
Definition: SDL3pp_render.h:150
constexpr TextureAccess TEXTUREACCESS_TARGET
Texture can be used as a render target.
Definition: SDL3pp_render.h:142
void GetRenderOutputSize(RendererParam renderer, int *w, int *h)
Get the output size in pixels of a rendering context.
Definition: SDL3pp_render.h:3578
FPoint RenderCoordinatesFromWindow(const FPointRaw &window_coord) const
Get a point in render coordinates when given a point in window coordinates.
Definition: SDL3pp_render.h:4929
void DestroyTexture(TextureRaw texture)
Destroy the specified texture.
Definition: SDL3pp_render.h:6204
void SetTextureAlphaModFloat(TextureParam texture, float alpha)
Set an additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:4279
Rect GetSafeArea() const
Get the safe area for rendering within the current viewport.
Definition: SDL3pp_render.h:5135
Rect GetRenderViewport(RendererParam renderer)
Get the drawing area for the current target.
Definition: SDL3pp_render.h:5068
void ConvertEventToRenderCoordinates(RendererParam renderer, Event *event)
Convert the coordinates in an event to render coordinates.
Definition: SDL3pp_render.h:5005
void RenderFillRects(RendererParam renderer, SpanRef< const FRectRaw > rects)
Fill some number of rectangles on the current rendering target with the drawing color at subpixel pre...
Definition: SDL3pp_render.h:5729
bool IsViewportSet() const
Return whether an explicit rectangle was set as the viewport.
Definition: SDL3pp_render.h:5105
void RenderTexture(RendererParam renderer, TextureParam texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FRectRaw > dstrect)
Copy a portion of the texture to the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5759
ScaleMode GetTextureScaleMode(TextureParam texture)
Get the scale mode used for texture scale operations.
Definition: SDL3pp_render.h:4434
void RenderTextureAffine(TextureParam texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FPointRaw > origin, OptionalRef< const FPointRaw > right, OptionalRef< const FPointRaw > down)
Copy a portion of the source texture to the current rendering target, with affine transform,...
Definition: SDL3pp_render.h:5858
constexpr TextureAccess TEXTUREACCESS_STATIC
Changes rarely, not lockable.
Definition: SDL3pp_render.h:136
SDL_Texture * TextureRaw
Alias to raw representation for Texture.
Definition: SDL3pp_render.h:82
bool RenderClipEnabled(RendererParam renderer)
Get whether clipping is enabled on the given render target.
Definition: SDL3pp_render.h:5216
void AddVulkanRenderSemaphores(RendererParam renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore)
Add a set of synchronization semaphores for the current frame.
Definition: SDL3pp_render.h:6350
void * GetRenderMetalCommandEncoder()
Get the Metal command encoder for the current frame.
Definition: SDL3pp_render.h:6318
void SetViewport(OptionalRef< const RectRaw > rect)
Set the drawing area for rendering on the current target.
Definition: SDL3pp_render.h:5046
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_INTEGER_SCALE
The rendered content is scaled up by integer multiples to fit the output resolution.
Definition: SDL3pp_render.h:177
WindowRef GetWindow()
Get the window associated with a renderer.
Definition: SDL3pp_render.h:3435
constexpr TextureAccess TEXTUREACCESS_STREAMING
Changes frequently, lockable.
Definition: SDL3pp_render.h:139
BlendMode GetBlendMode() const
Get the blend mode used for texture copy operations.
Definition: SDL3pp_render.h:4389
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:4534
PropertiesRef GetProperties() const
Get the properties associated with a renderer.
Definition: SDL3pp_render.h:3553
void RenderTextureTiled(RendererParam renderer, TextureParam texture, OptionalRef< const FRectRaw > srcrect, float scale, OptionalRef< const FRectRaw > dstrect)
Tile a portion of the texture to the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5891
void Flush()
Force the rendering context to flush any pending commands and state.
Definition: SDL3pp_render.h:6264
Texture CreateTextureWithProperties(PropertiesParam props)
Create a texture for a rendering context with the specified properties.
Definition: SDL3pp_render.h:3808
void RenderTextureTiled(TextureParam texture, OptionalRef< const FRectRaw > srcrect, float scale, OptionalRef< const FRectRaw > dstrect)
Tile a portion of the texture to the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5901
void Lock(OptionalRef< const SDL_Rect > rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition: SDL3pp_render.h:4627
FRect GetLogicalPresentationRect() const
Get the final presentation rectangle for rendering.
Definition: SDL3pp_render.h:4893
void SetTextureColorMod(TextureParam texture, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:4114
void SetClipRect(OptionalRef< const RectRaw > rect)
Set the clip rectangle for rendering on the specified target.
Definition: SDL3pp_render.h:5164
Renderer CreateRenderer(WindowParam window, StringParam name)
Create a 2D rendering context for a window.
Definition: SDL3pp_render.h:3235
void ConvertEventToRenderCoordinates(Event *event) const
Convert the coordinates in an event to render coordinates.
Definition: SDL3pp_render.h:5011
Surface ReadPixels(OptionalRef< const RectRaw > rect={}) const
Read pixels from the current rendering target.
Definition: SDL3pp_render.h:6130
float GetRenderColorScale(RendererParam renderer)
Get the color scale used for render operations.
Definition: SDL3pp_render.h:5458
void SetScale(const FPointRaw &scale)
Set the drawing scale for rendering on the current target.
Definition: SDL3pp_render.h:5255
Texture CreateTextureFromSurface(SurfaceParam surface)
Create a texture from an existing surface.
Definition: SDL3pp_render.h:3687
Texture CreateTexture(RendererParam renderer, PixelFormat format, TextureAccess access, const PointRaw &size)
Create a texture for a rendering context.
Definition: SDL3pp_render.h:3640
float GetColorScale() const
Get the color scale used for render operations.
Definition: SDL3pp_render.h:5465
Rect GetRenderClipRect(RendererParam renderer)
Get the clip rectangle for the current target.
Definition: SDL3pp_render.h:5187
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:4582
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:5735
const char * GetRendererName(RendererParam renderer)
Get the name of a renderer.
Definition: SDL3pp_render.h:3454
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_LETTERBOX
The rendered content is fit to the largest dimension and the other dimension is letterboxed with blac...
Definition: SDL3pp_render.h:163
void RenderLines(SpanRef< const FPointRaw > points)
Draw a series of connected lines on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5636
void RenderTexture9Grid(RendererParam renderer, TextureParam texture, OptionalRef< const FRectRaw > srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, OptionalRef< const FRectRaw > dstrect)
Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precisio...
Definition: SDL3pp_render.h:5940
void SetLogicalPresentation(const PointRaw &size, RendererLogicalPresentation mode)
Set a device-independent resolution and presentation mode for rendering.
Definition: SDL3pp_render.h:4822
void SetTarget(TextureParam texture)
Set a texture as the current rendering target.
Definition: SDL3pp_render.h:4732
ScaleMode GetScaleMode() const
Get the scale mode used for texture scale operations.
Definition: SDL3pp_render.h:4441
void SetTextureAlphaMod(TextureParam texture, Uint8 alpha)
Set an additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:4246
void LockTexture(TextureParam texture, OptionalRef< const SDL_Rect > rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition: SDL3pp_render.h:4619
void * GetRenderMetalLayer(RendererParam renderer)
Get the CAMetalLayer associated with the given Metal renderer.
Definition: SDL3pp_render.h:6282
void RenderRects(SpanRef< const FRectRaw > rects)
Draw some number of rectangles on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5684
void RenderDebugTextFormat(const FPointRaw &p, std::string_view fmt, ARGS... args)
Draw debug text to an Renderer.
Definition: SDL3pp_render.h:6526
void GetRenderDrawColor(RendererParam renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Get the color used for drawing operations (Rect, Line and Clear).
Definition: SDL3pp_render.h:5362
Texture CreateTextureWithProperties(RendererParam renderer, PropertiesParam props)
Create a texture for a rendering context with the specified properties.
Definition: SDL3pp_render.h:3802
void RenderDebugTextFormat(RendererParam renderer, const FPointRaw &p, std::string_view fmt, ARGS... args)
Draw debug text to an Renderer.
Definition: SDL3pp_render.h:6516
FRect GetRenderLogicalPresentationRect(RendererParam renderer)
Get the final presentation rectangle for rendering.
Definition: SDL3pp_render.h:4886
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_STRETCH
The rendered content is stretched to the output resolution.
Definition: SDL3pp_render.h:156
void GetRenderLogicalPresentation(RendererParam renderer, int *w, int *h, RendererLogicalPresentation *mode)
Get device independent resolution and presentation mode for rendering.
Definition: SDL3pp_render.h:4849
void RenderPoint(RendererParam renderer, const FPointRaw &p)
Draw a point on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5557
void RenderRect(RendererParam renderer, OptionalRef< const FRectRaw > rect)
Draw a rectangle on the current rendering target at subpixel precision.
Definition: SDL3pp_render.h:5655
void UpdateNVTexture(TextureParam texture, OptionalRef< const RectRaw > rect, const Uint8 *Yplane, int Ypitch, const Uint8 *UVplane, int UVpitch)
Update a rectangle within a planar NV12 or NV21 texture with new pixels.
Definition: SDL3pp_render.h:4571
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:5710
int GetNumRenderDrivers()
Get the number of 2D rendering drivers available for the current display.
Definition: SDL3pp_render.h:3143
const char * GetRenderDriver(int index)
Use this function to get the name of a built in 2D rendering driver.
Definition: SDL3pp_render.h:3167
void SetRenderLogicalPresentation(RendererParam renderer, const PointRaw &size, RendererLogicalPresentation mode)
Set a device-independent resolution and presentation mode for rendering.
Definition: SDL3pp_render.h:4815
void Unlock()
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL3pp_render.h:4701
RendererRef GetRenderer() const
Get the renderer that created an Texture.
Definition: SDL3pp_render.h:4059
void SetVSync(int vsync)
Toggle VSync of the given renderer.
Definition: SDL3pp_render.h:6394
float GetAlphaModFloat() const
Get the additional alpha value multiplied into render copy operations.
Definition: SDL3pp_render.h:4338
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:6359
void FlushRenderer(RendererParam renderer)
Force the rendering context to flush any pending commands and state.
Definition: SDL3pp_render.h:6259
void GetColorMod(Uint8 *r, Uint8 *g, Uint8 *b) const
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:4188
void RenderClear(RendererParam renderer)
Clear the current rendering target with the drawing color.
Definition: SDL3pp_render.h:5537
void SetRenderDrawBlendMode(RendererParam renderer, BlendMode blendMode)
Set the blend mode used for drawing operations (Fill and Line).
Definition: SDL3pp_render.h:5485
Texture CreateTexture(PixelFormat format, TextureAccess access, const PointRaw &size)
Create a texture for a rendering context.
Definition: SDL3pp_render.h:3648
WindowRef GetRenderWindow(RendererParam renderer)
Get the window associated with a renderer.
Definition: SDL3pp_render.h:3430
int GetRenderVSync(RendererParam renderer)
Get VSync of the given renderer.
Definition: SDL3pp_render.h:6419
void GetTextureSize(TextureParam texture, float *w, float *h)
Get the size of a texture, as floating point values.
Definition: SDL3pp_render.h:4078
void RenderGeometry(TextureParam texture, std::span< const Vertex > vertices, std::span< const int > indices={})
Render a list of triangles, optionally using a texture and indices into the vertex array Color and al...
Definition: SDL3pp_render.h:6013
void RenderTextureRotated(TextureParam texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FRectRaw > dstrect, double angle, OptionalRef< const FPointRaw > center, FlipMode flip=FlipMode::SDL_FLIP_NONE)
Copy a portion of the source texture to the current rendering target, with rotation and flipping,...
Definition: SDL3pp_render.h:5811
void SetTextureScaleMode(TextureParam texture, ScaleMode scaleMode)
Set the scale mode used for texture scale operations.
Definition: SDL3pp_render.h:4411
void GetTextureColorMod(TextureParam texture, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value multiplied into render copy operations.
Definition: SDL3pp_render.h:4180
void SetScaleMode(ScaleMode scaleMode)
Set the scale mode used for texture scale operations.
Definition: SDL3pp_render.h:4416
Sint64 Sint64
A signed 64-bit integer type.
Definition: SDL3pp_stdinc.h:347
Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:328
Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:260
SDL_Surface * SurfaceRaw
Alias to raw representation for Surface.
Definition: SDL3pp_surface.h:42
SDL_FlipMode FlipMode
The flip mode.
Definition: SDL3pp_surface.h:156
SDL_ScaleMode ScaleMode
The scaling mode.
Definition: SDL3pp_surface.h:137
Uint64 WindowFlags
The flags on a window.
Definition: SDL3pp_video.h:553
Main include header for the SDL3pp library.
A structure that represents a color as RGBA components.
Definition: SDL3pp_pixels.h:2191
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition: SDL3pp_pixels.h:2364
The structure that defines a point (using floating point values).
Definition: SDL3pp_rect.h:509
A rectangle, with the origin at the upper left (using floating point values).
Definition: SDL3pp_rect.h:1432
Safely wrap IOStream for non owning parameters.
Definition: SDL3pp_iostream.h:34
The structure that defines a point (using integers).
Definition: SDL3pp_rect.h:83
Safely wrap Properties for non owning parameters.
Definition: SDL3pp_properties.h:52
Semi-safe reference for Properties.
Definition: SDL3pp_properties.h:701
A rectangle, with the origin at the upper left (using integers).
Definition: SDL3pp_rect.h:839
Safely wrap Renderer for non owning parameters.
Definition: SDL3pp_render.h:53
constexpr RendererParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_render.h:63
constexpr auto operator<=>(const RendererParam &other) const =default
Comparison.
RendererRaw value
parameter's RendererRaw
Definition: SDL3pp_render.h:54
constexpr RendererParam(RendererRaw value)
Constructs from RendererRaw.
Definition: SDL3pp_render.h:57
Semi-safe reference for Renderer.
Definition: SDL3pp_render.h:2090
~RendererRef()
Destructor.
Definition: SDL3pp_render.h:2110
RendererRef(const RendererRef &other)
Copy constructor.
Definition: SDL3pp_render.h:2104
RendererRef(RendererParam resource)
Constructs from RendererParam.
Definition: SDL3pp_render.h:2098
Safely wrap Surface for non owning parameters.
Definition: SDL3pp_surface.h:46
Safely wrap Texture for non owning parameters.
Definition: SDL3pp_render.h:86
constexpr TextureParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_render.h:96
constexpr auto operator<=>(const TextureParam &other) const =default
Comparison.
constexpr TextureParam(TextureRaw value)
Constructs from TextureRaw.
Definition: SDL3pp_render.h:90
TextureRaw value
parameter's TextureRaw
Definition: SDL3pp_render.h:87
Safely wrap Window for non owning parameters.
Definition: SDL3pp_video.h:57
Semi-safe reference for Window.
Definition: SDL3pp_video.h:2925