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_properties.h"
9#include "SDL3pp_rect.h"
10#include "SDL3pp_stdinc.h"
11#include "SDL3pp_surface.h"
12#include "SDL3pp_video.h"
13
14namespace SDL {
15
46// Forward decl
47struct RendererRef;
48
49// Forward decl
50struct Renderer;
51
61
71
72// Forward decl
73struct TextureRef;
74
75// Forward decl
76struct Texture;
77
87
97
98// Forward decl
99struct TextureLock;
100
101#ifdef SDL3PP_DOC
102
108#define SDL_SOFTWARE_RENDERER "software"
109
110#endif // SDL3PP_DOC
111
117using Vertex = SDL_Vertex;
118
124using TextureAccess = SDL_TextureAccess;
125
127 SDL_TEXTUREACCESS_STATIC;
128
130 SDL_TEXTUREACCESS_STREAMING;
131
133 SDL_TEXTUREACCESS_TARGET;
134
140using RendererLogicalPresentation = SDL_RendererLogicalPresentation;
141
143 SDL_LOGICAL_PRESENTATION_DISABLED;
144
149 SDL_LOGICAL_PRESENTATION_STRETCH;
150
156 SDL_LOGICAL_PRESENTATION_LETTERBOX;
157
163 SDL_LOGICAL_PRESENTATION_OVERSCAN;
164
170 SDL_LOGICAL_PRESENTATION_INTEGER_SCALE;
171
181struct RendererRef : Resource<SDL_Renderer*>
182{
183 using Resource::Resource;
184
195 WindowRef GetWindow() { return CheckError(SDL_GetRenderWindow(get())); }
196
209 const char* GetName() const { return CheckError(SDL_GetRendererName(get())); }
210
221 {
222 Point p;
223 GetOutputSize(&p.x, &p.y);
224 return p;
225 }
226
246 void GetOutputSize(int* w, int* h) const
247 {
248 CheckError(SDL_GetRenderOutputSize(get(), w, h));
249 }
250
268 {
269 Point p;
270 GetCurrentOutputSize(&p.x, &p.y);
271 return p;
272 }
273
294 void GetCurrentOutputSize(int* w, int* h) const
295 {
296 CheckError(SDL_GetCurrentRenderOutputSize(get(), w, h));
297 }
298
383 {
384 return CheckError(SDL_GetRendererProperties(get()));
385 }
386
401 void ResetTarget();
402
426 void SetTarget(TextureRef texture);
427
443 TextureRef GetTarget() const;
444
495 void SetLogicalPresentation(const SDL_Point& size,
497 {
498 CheckError(SDL_SetRenderLogicalPresentation(get(), size.x, size.y, mode));
499 }
500
517 void GetLogicalPresentation(SDL_Point* size,
519 {
520 if (!size) return GetLogicalPresentation(nullptr, nullptr, mode);
521 return GetLogicalPresentation(&size->x, &size->y, mode);
522 }
523
545 int* h,
546 RendererLogicalPresentation* mode) const
547 {
548 CheckError(SDL_GetRenderLogicalPresentation(get(), w, h, mode));
549 }
550
572 {
573 FRect rect;
574 CheckError(SDL_GetRenderLogicalPresentationRect(get(), &rect));
575 return rect;
576 }
577
599 FPoint RenderCoordinatesFromWindow(const SDL_FPoint& window_coord) const
600 {
601 FPoint p;
602 CheckError(SDL_RenderCoordinatesFromWindow(
603 get(), window_coord.x, window_coord.y, &p.x, &p.y));
604 return p;
605 }
606
629 FPoint RenderCoordinatesToWindow(const SDL_FPoint& coord) const
630 {
631 FPoint p;
633 SDL_RenderCoordinatesToWindow(get(), coord.x, coord.y, &p.x, &p.y));
634 return p;
635 }
636
670 {
671 CheckError(SDL_ConvertEventToRenderCoordinates(get(), event));
672 }
673
689 void ResetViewport() { SetViewport(std::nullopt); }
690
715 {
716 CheckError(SDL_SetRenderViewport(get(), rect));
717 }
718
736 {
737 Rect rect;
738 CheckError(SDL_GetRenderViewport(get(), &rect));
739 return rect;
740 }
741
761 bool IsViewportSet() const { return SDL_RenderViewportSet(get()); }
762
781 {
782 Rect rect;
783 CheckError(SDL_GetRenderSafeArea(get(), &rect));
784 return rect;
785 }
786
803
823 {
824 CheckError(SDL_SetRenderClipRect(get(), rect));
825 }
826
845 {
846 Rect rect;
847 CheckError(SDL_GetRenderClipRect(get(), &rect));
848 return rect;
849 }
850
867 bool IsClipEnabled() const { return SDL_RenderClipEnabled(get()); }
868
892 void SetScale(const SDL_FPoint& scale)
893 {
894 CheckError(SDL_SetRenderScale(get(), scale.x, scale.y));
895 }
896
913 {
914 FPoint p;
915 GetScale(&p.x, &p.y);
916 return p;
917 }
918
935 void GetScale(float* scaleX, float* scaleY) const
936 {
937 CheckError(SDL_GetRenderScale(get(), scaleX, scaleY));
938 }
939
955 void SetDrawColor(SDL_Color c)
956 {
957 CheckError(SDL_SetRenderDrawColor(get(), c.r, c.g, c.b, c.a));
958 }
959
975 void SetDrawColor(SDL_FColor c)
976 {
977 CheckError(SDL_SetRenderDrawColorFloat(get(), c.r, c.g, c.b, c.a));
978 }
979
994 {
995 FColor color;
996 GetDrawColor(&color);
997 return color;
998 }
999
1014 void GetDrawColor(SDL_Color* c) const
1015 {
1016 GetDrawColor(&c->r, &c->g, &c->b, &c->a);
1017 }
1018
1033 void GetDrawColor(SDL_FColor* c) const
1034 {
1035 GetDrawColor(&c->r, &c->g, &c->b, &c->a);
1036 }
1037
1057 void GetDrawColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const
1058 {
1059 CheckError(SDL_GetRenderDrawColor(get(), r, g, b, a));
1060 }
1061
1081 void GetDrawColor(float* r, float* g, float* b, float* a) const
1082 {
1083 CheckError(SDL_GetRenderDrawColorFloat(get(), r, g, b, a));
1084 }
1085
1106 void SetColorScale(float scale)
1107 {
1108 CheckError(SDL_SetRenderColorScale(get(), scale));
1109 }
1110
1123 float GetColorScale() const
1124 {
1125 float scale;
1126 CheckError(SDL_GetRenderColorScale(get(), &scale));
1127 return scale;
1128 }
1129
1145 {
1146 CheckError(SDL_SetRenderDrawBlendMode(get(), blendMode));
1147 }
1148
1162 {
1163 BlendMode blendMode;
1164 CheckError(SDL_GetRenderDrawBlendMode(get(), &blendMode));
1165 return blendMode;
1166 }
1167
1184 void RenderClear() { CheckError(SDL_RenderClear(get())); }
1185
1198 void RenderPoint(const SDL_FPoint& p)
1199 {
1200 CheckError(SDL_RenderPoint(get(), p.x, p.y));
1201 }
1202
1216 {
1217 SDL_assert_paranoid(points.size() < SDL_MAX_SINT32);
1218 CheckError(SDL_RenderPoints(get(), points.data(), points.size()));
1219 }
1220
1234 void RenderLine(const SDL_FPoint& p1, const SDL_FPoint& p2)
1235 {
1236 CheckError(SDL_RenderLine(get(), p1.x, p1.y, p2.x, p2.y));
1237 }
1238
1253 {
1254 SDL_assert_paranoid(points.size() < SDL_MAX_SINT32);
1255 CheckError(SDL_RenderLines(get(), points.data(), points.size()));
1256 }
1257
1272 {
1273 CheckError(SDL_RenderRect(get(), rect));
1274 }
1275
1290 {
1291 SDL_assert_paranoid(rects.size() < SDL_MAX_SINT32);
1292 CheckError(SDL_RenderRects(get(), rects.data(), rects.size()));
1293 }
1294
1310 {
1311 CheckError(SDL_RenderFillRect(get(), rect));
1312 }
1313
1328 {
1329 SDL_assert_paranoid(rects.size() < SDL_MAX_SINT32);
1330 CheckError(SDL_RenderFillRects(get(), rects.data(), rects.size()));
1331 }
1332
1351 void RenderTexture(TextureRef texture,
1354
1379 void RenderTextureRotated(TextureRef texture,
1382 double angle,
1384 FlipMode flip = SDL_FLIP_NONE);
1385
1410 void RenderTextureAffine(TextureRef texture,
1411 OptionalRef<const SDL_FRect> srcrect,
1412 OptionalRef<const SDL_FPoint> origin,
1413 OptionalRef<const SDL_FPoint> right,
1414 OptionalRef<const SDL_FPoint> down);
1415
1439 void RenderTextureTiled(TextureRef texture,
1440 OptionalRef<const SDL_FRect> srcrect,
1441 float scale,
1442 OptionalRef<const SDL_FRect> dstrect);
1443
1474 void RenderTexture9Grid(TextureRef texture,
1475 OptionalRef<const SDL_FRect> srcrect,
1476 float left_width,
1477 float right_width,
1478 float top_height,
1479 float bottom_height,
1480 float scale,
1481 OptionalRef<const SDL_FRect> dstrect);
1482
1501 void RenderGeometry(TextureRef texture,
1502 std::span<const Vertex> vertices,
1503 std::span<const int> indices = {});
1504
1531 void RenderGeometryRaw(TextureRef texture,
1532 const float* xy,
1533 int xy_stride,
1534 const FColor* color,
1535 int color_stride,
1536 const float* uv,
1537 int uv_stride,
1538 int num_vertices,
1539 const void* indices,
1540 int num_indices,
1541 int size_indices);
1542
1569 {
1570 return Surface(CheckError(SDL_RenderReadPixels(get(), rect)));
1571 }
1572
1620 void Present() { CheckError(SDL_RenderPresent(get())); }
1621
1651 void Flush() { CheckError(SDL_FlushRenderer(get())); }
1652
1674 void SetVSync(int vsync) { CheckError(SDL_SetRenderVSync(get(), vsync)); }
1675
1688 int GetVSync() const
1689 {
1690 int vsync;
1691 CheckError(SDL_GetRenderVSync(get(), &vsync));
1692 return vsync;
1693 }
1694
1732 {
1733 CheckError(SDL_RenderDebugText(get(), p.x, p.y, str));
1734 }
1735
1761 template<class... ARGS>
1762 void RenderDebugTextFormat(FPoint p, std::string_view fmt, ARGS... args)
1763 {
1764 RenderDebugText(p, std::vformat(fmt, std::make_format_args(args...)));
1765 }
1766
1781 static void reset(SDL_Renderer* resource) { SDL_DestroyRenderer(resource); }
1782};
1783
1791struct Renderer : ResourceUnique<RendererRef>
1792{
1794
1819 {
1820 return Renderer(CheckError(SDL_CreateRenderer(window, nullptr)));
1821 }
1822
1858 {
1859 return Renderer(CheckError(SDL_CreateRenderer(window, name)));
1860 }
1861
1914 {
1915 return Renderer(CheckError(SDL_CreateRendererWithProperties(props)));
1916 }
1917
1938 {
1939 return Renderer(CheckError(SDL_CreateSoftwareRenderer(surface)));
1940 }
1941
1954 void Destroy() { reset(); }
1959
1960};
1961
1962
1964{
1965 return RendererShared(std::move(*this));
1966}
1967
1977struct RendererUnsafe : ResourceUnsafe<RendererRef>
1978{
1980
1984 constexpr explicit RendererUnsafe(Renderer&& other)
1985 : RendererUnsafe(other.release())
1986 {
1987 }
1988};
1989
2004struct TextureRef : Resource<SDL_Texture*>
2005{
2006 using Resource::Resource;
2007
2094 {
2095 return CheckError(SDL_GetTextureProperties(get()));
2096 }
2097
2108 RendererRef GetRenderer() const { return SDL_GetRendererFromTexture(get()); }
2109
2133 {
2134 SetColorMod(c.r, c.g, c.b);
2135 SetAlphaMod(c.a);
2136 }
2137
2161 {
2162 SetColorMod(c.r, c.g, c.b);
2163 SetAlphaMod(c.a);
2164 }
2165
2180 {
2181 FColor color;
2182 GetMod(&color);
2183 return color;
2184 }
2185
2199 void GetMod(Color* c) const
2200 {
2201 SDL_assert_paranoid(c != nullptr);
2202 GetColorMod(&c->r, &c->g, &c->b);
2203 GetAlphaMod(&c->a);
2204 }
2205
2219 void GetMod(FColor* c) const
2220 {
2221 SDL_assert_paranoid(c != nullptr);
2222 GetColorMod(&c->r, &c->g, &c->b);
2223 GetAlphaMod(&c->a);
2224 }
2225
2250 void SetColorMod(Uint8 r, Uint8 g, Uint8 b)
2251 {
2252 CheckError(SDL_SetTextureColorMod(get(), r, g, b));
2253 }
2254
2279 void SetColorMod(float r, float g, float b)
2280 {
2281 CheckError(SDL_SetTextureColorModFloat(get(), r, g, b));
2282 }
2283
2299 void GetColorMod(Uint8* r, Uint8* g, Uint8* b) const
2300 {
2301 CheckError(SDL_GetTextureColorMod(get(), r, g, b));
2302 }
2303
2319 void GetColorMod(float* r, float* g, float* b) const
2320 {
2321 CheckError(SDL_GetTextureColorModFloat(get(), r, g, b));
2322 }
2323
2345 void SetAlphaMod(Uint8 alpha)
2346 {
2347 CheckError(SDL_SetTextureAlphaMod(get(), alpha));
2348 }
2349
2371 void SetAlphaMod(float alpha)
2372 {
2373 CheckError(SDL_SetTextureAlphaModFloat(get(), alpha));
2374 }
2375
2384 float GetAlphaMod() const
2385 {
2386 float alpha;
2387 GetAlphaMod(&alpha);
2388 return alpha;
2389 }
2390
2404 void GetAlphaMod(Uint8* alpha) const
2405 {
2406 CheckError(SDL_GetTextureAlphaMod(get(), alpha));
2407 }
2408
2422 void GetAlphaMod(float* alpha) const
2423 {
2424 CheckError(SDL_GetTextureAlphaModFloat(get(), alpha));
2425 }
2426
2442 void SetBlendMode(BlendMode blendMode)
2443 {
2444 CheckError(SDL_SetTextureBlendMode(get(), blendMode));
2445 }
2446
2460 {
2461 BlendMode blendMode;
2462 CheckError(SDL_GetTextureBlendMode(get(), &blendMode));
2463 return blendMode;
2464 }
2465
2482 void SetScaleMode(ScaleMode scaleMode)
2483 {
2484 CheckError(SDL_SetTextureScaleMode(get(), scaleMode));
2485 }
2486
2500 {
2501 ScaleMode scaleMode;
2502 CheckError(SDL_GetTextureScaleMode(get(), &scaleMode));
2503 return scaleMode;
2504 }
2505
2536 void Update(OptionalRef<const SDL_Rect> rect, const void* pixels, int pitch)
2537 {
2538 CheckError(SDL_UpdateTexture(get(), rect, pixels, pitch));
2539 }
2540
2570 const Uint8* Yplane,
2571 int Ypitch,
2572 const Uint8* Uplane,
2573 int Upitch,
2574 const Uint8* Vplane,
2575 int Vpitch)
2576 {
2577 CheckError(SDL_UpdateYUVTexture(
2578 get(), rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch));
2579 }
2580
2606 const Uint8* Yplane,
2607 int Ypitch,
2608 const Uint8* UVplane,
2609 int UVpitch)
2610 {
2611 CheckError(
2612 SDL_UpdateNVTexture(get(), rect, Yplane, Ypitch, UVplane, UVpitch));
2613 }
2614
2638
2642 int GetWidth() const { return get()->w; }
2643
2647 int GetHeight() const { return get()->h; }
2648
2652 Point GetSize() const { return Point(GetWidth(), GetHeight()); }
2653
2657 PixelFormat GetFormat() const { return get()->format; }
2658
2674 static void reset(SDL_Texture* resource) { SDL_DestroyTexture(resource); }
2675};
2676
2684struct Texture : ResourceUnique<TextureRef>
2685{
2687
2703 static Texture Load(RendererRef renderer, StringParam file);
2704
2720 static Texture Load(RendererRef renderer, IOStreamRef src);
2721
2733 {
2734 Surface surface{SDL_LoadBMP(file)};
2735 return Texture::CreateFromSurface(renderer, surface);
2736 }
2737
2749 {
2750 auto surface{Surface::LoadBMP(src)};
2751 return Texture::CreateFromSurface(renderer, surface);
2752 }
2753
2775 static Texture Create(RendererRef renderer,
2776 PixelFormat format,
2777 TextureAccess access,
2778 const SDL_Point& size)
2779 {
2780 return Texture(
2781 CheckError(SDL_CreateTexture(renderer, format, access, size.x, size.y)));
2782 }
2783
2811 {
2812 return Texture(CheckError(SDL_CreateTextureFromSurface(renderer, surface)));
2813 }
2814
2926 {
2927 return Texture(
2928 CheckError(SDL_CreateTextureWithProperties(renderer, props)));
2929 }
2930
2945 void Destroy() { reset(); }
2950
2951};
2952
2953
2955{
2956 return TextureShared(std::move(*this));
2957}
2958
2968struct TextureUnsafe : ResourceUnsafe<TextureRef>
2969{
2971
2975 constexpr explicit TextureUnsafe(Texture&& other)
2976 : TextureUnsafe(other.release())
2977 {
2978 }
2979};
2980
2984class TextureLock : public LockBase<SurfaceRef>
2985{
2986public:
2990 constexpr TextureLock() = default;
2991
2995 constexpr TextureLock(TextureLock&& other)
2996 : LockBase(other.release())
2997 {
2998 }
2999
3024 : LockBase<SurfaceRef>(doLock(texture, rect))
3025 , texture(std::move(texture))
3026 {
3027 }
3028
3035
3053 void Unlock()
3054 {
3055 if (texture) {
3056 release();
3057 SDL_UnlockTexture(texture);
3058 texture = nullptr;
3059 }
3060 }
3061
3065 void reset() { Unlock(); }
3066
3067private:
3068 TextureRef texture;
3069
3071 {
3072 SDL_Surface* surface = nullptr;
3073 CheckError(SDL_LockTextureToSurface(texture, rect, &surface));
3074 return surface;
3075 }
3076};
3077
3096inline int GetNumRenderDrivers() { return SDL_GetNumRenderDrivers(); }
3097
3120inline const char* GetRenderDriver(int index)
3121{
3122 return SDL_GetRenderDriver(index);
3123}
3124
3142inline std::pair<Window, Renderer> CreateWindowAndRenderer(
3143 StringParam title,
3144 const SDL_Point& size,
3145 WindowFlags window_flags = 0)
3146{
3147 SDL_Window* window;
3148 SDL_Renderer* renderer;
3149 CheckError(SDL_CreateWindowAndRenderer(
3150 title, size.x, size.y, window_flags, &window, &renderer));
3151 return {Window{window}, Renderer{renderer}};
3152}
3153
3154namespace prop::Renderer {
3155
3156constexpr auto CREATE_NAME_STRING = SDL_PROP_RENDERER_CREATE_NAME_STRING;
3157
3158constexpr auto CREATE_WINDOW_POINTER = SDL_PROP_RENDERER_CREATE_WINDOW_POINTER;
3159
3160constexpr auto CREATE_SURFACE_POINTER =
3161 SDL_PROP_RENDERER_CREATE_SURFACE_POINTER;
3162
3163constexpr auto CREATE_OUTPUT_COLORSPACE_NUMBER =
3164 SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER;
3165
3166constexpr auto CREATE_PRESENT_VSYNC_NUMBER =
3167 SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER;
3168
3169constexpr auto CREATE_VULKAN_INSTANCE_POINTER =
3170 SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER;
3171
3172constexpr auto CREATE_VULKAN_SURFACE_NUMBER =
3173 SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER;
3174
3175constexpr auto CREATE_VULKAN_PHYSICAL_DEVICE_POINTER =
3176 SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER;
3177
3178constexpr auto CREATE_VULKAN_DEVICE_POINTER =
3179 SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER;
3180
3181constexpr auto CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER =
3182 SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER;
3183
3184constexpr auto CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER =
3185 SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER;
3186
3187constexpr auto NAME_STRING = SDL_PROP_RENDERER_NAME_STRING;
3188
3189constexpr auto WINDOW_POINTER = SDL_PROP_RENDERER_WINDOW_POINTER;
3190
3191constexpr auto SURFACE_POINTER = SDL_PROP_RENDERER_SURFACE_POINTER;
3192
3193constexpr auto VSYNC_NUMBER = SDL_PROP_RENDERER_VSYNC_NUMBER;
3194
3195constexpr auto MAX_TEXTURE_SIZE_NUMBER =
3196 SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER;
3197
3198constexpr auto TEXTURE_FORMATS_POINTER =
3199 SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER;
3200
3201constexpr auto OUTPUT_COLORSPACE_NUMBER =
3202 SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER;
3203
3204constexpr auto HDR_ENABLED_BOOLEAN = SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN;
3205
3206constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT;
3207
3208constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT;
3209
3210constexpr auto D3D9_DEVICE_POINTER = SDL_PROP_RENDERER_D3D9_DEVICE_POINTER;
3211
3212constexpr auto D3D11_DEVICE_POINTER = SDL_PROP_RENDERER_D3D11_DEVICE_POINTER;
3213
3214constexpr auto D3D11_SWAPCHAIN_POINTER =
3215 SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER;
3216
3217constexpr auto D3D12_DEVICE_POINTER = SDL_PROP_RENDERER_D3D12_DEVICE_POINTER;
3218
3219constexpr auto D3D12_SWAPCHAIN_POINTER =
3220 SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER;
3221
3222constexpr auto D3D12_COMMAND_QUEUE_POINTER =
3223 SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER;
3224
3225constexpr auto VULKAN_INSTANCE_POINTER =
3226 SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER;
3227
3228constexpr auto VULKAN_SURFACE_NUMBER = SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER;
3229
3230constexpr auto VULKAN_PHYSICAL_DEVICE_POINTER =
3231 SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER;
3232
3233constexpr auto VULKAN_DEVICE_POINTER = SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER;
3234
3235constexpr auto VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER =
3236 SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER;
3237
3238constexpr auto VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER =
3239 SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER;
3240
3241constexpr auto VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER =
3242 SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER;
3243
3244constexpr auto GPU_DEVICE_POINTER = SDL_PROP_RENDERER_GPU_DEVICE_POINTER;
3245
3246} // namespace prop::Renderer
3247
3259{
3260 return CheckError(SDL_GetRenderer(get()));
3261}
3262
3263namespace prop::Texture {
3264
3265constexpr auto CREATE_COLORSPACE_NUMBER =
3266 SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER;
3267
3268constexpr auto CREATE_FORMAT_NUMBER = SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER;
3269
3270constexpr auto CREATE_ACCESS_NUMBER = SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER;
3271
3272constexpr auto CREATE_WIDTH_NUMBER = SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER;
3273
3274constexpr auto CREATE_HEIGHT_NUMBER = SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER;
3275
3276constexpr auto CREATE_SDR_WHITE_POINT_FLOAT =
3277 SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT;
3278
3279constexpr auto CREATE_HDR_HEADROOM_FLOAT =
3280 SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT;
3281
3282constexpr auto CREATE_D3D11_TEXTURE_POINTER =
3283 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER;
3284
3285constexpr auto CREATE_D3D11_TEXTURE_U_POINTER =
3286 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER;
3287
3288constexpr auto CREATE_D3D11_TEXTURE_V_POINTER =
3289 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER;
3290
3291constexpr auto CREATE_D3D12_TEXTURE_POINTER =
3292 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER;
3293
3294constexpr auto CREATE_D3D12_TEXTURE_U_POINTER =
3295 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER;
3296
3297constexpr auto CREATE_D3D12_TEXTURE_V_POINTER =
3298 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER;
3299
3300constexpr auto CREATE_METAL_PIXELBUFFER_POINTER =
3301 SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER;
3302
3303constexpr auto CREATE_OPENGL_TEXTURE_NUMBER =
3304 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER;
3305
3306constexpr auto CREATE_OPENGL_TEXTURE_UV_NUMBER =
3307 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER;
3308
3309constexpr auto CREATE_OPENGL_TEXTURE_U_NUMBER =
3310 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER;
3311
3312constexpr auto CREATE_OPENGL_TEXTURE_V_NUMBER =
3313 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER;
3314
3315constexpr auto CREATE_OPENGLES2_TEXTURE_NUMBER =
3316 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER;
3317
3318constexpr auto CREATE_OPENGLES2_TEXTURE_UV_NUMBER =
3319 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER;
3320
3321constexpr auto CREATE_OPENGLES2_TEXTURE_U_NUMBER =
3322 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER;
3323
3324constexpr auto CREATE_OPENGLES2_TEXTURE_V_NUMBER =
3325 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER;
3326
3327constexpr auto CREATE_VULKAN_TEXTURE_NUMBER =
3328 SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER;
3329
3330constexpr auto COLORSPACE_NUMBER = SDL_PROP_TEXTURE_COLORSPACE_NUMBER;
3331
3332constexpr auto FORMAT_NUMBER = SDL_PROP_TEXTURE_FORMAT_NUMBER;
3333
3334constexpr auto ACCESS_NUMBER = SDL_PROP_TEXTURE_ACCESS_NUMBER;
3335
3336constexpr auto WIDTH_NUMBER = SDL_PROP_TEXTURE_WIDTH_NUMBER;
3337
3338constexpr auto HEIGHT_NUMBER = SDL_PROP_TEXTURE_HEIGHT_NUMBER;
3339
3340constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT;
3341
3342constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT;
3343
3344constexpr auto D3D11_TEXTURE_POINTER = SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER;
3345
3346constexpr auto D3D11_TEXTURE_U_POINTER =
3347 SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER;
3348
3349constexpr auto D3D11_TEXTURE_V_POINTER =
3350 SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER;
3351
3352constexpr auto D3D12_TEXTURE_POINTER = SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER;
3353
3354constexpr auto D3D12_TEXTURE_U_POINTER =
3355 SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER;
3356
3357constexpr auto D3D12_TEXTURE_V_POINTER =
3358 SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER;
3359
3360constexpr auto OPENGL_TEXTURE_NUMBER = SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER;
3361
3362constexpr auto OPENGL_TEXTURE_UV_NUMBER =
3363 SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER;
3364
3365constexpr auto OPENGL_TEXTURE_U_NUMBER =
3366 SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER;
3367
3368constexpr auto OPENGL_TEXTURE_V_NUMBER =
3369 SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER;
3370
3371constexpr auto OPENGL_TEXTURE_TARGET_NUMBER =
3372 SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER;
3373
3374constexpr auto OPENGL_TEX_W_FLOAT = SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT;
3375
3376constexpr auto OPENGL_TEX_H_FLOAT = SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT;
3377
3378constexpr auto OPENGLES2_TEXTURE_NUMBER =
3379 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER;
3380
3381constexpr auto OPENGLES2_TEXTURE_UV_NUMBER =
3382 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER;
3383
3384constexpr auto OPENGLES2_TEXTURE_U_NUMBER =
3385 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER;
3386
3387constexpr auto OPENGLES2_TEXTURE_V_NUMBER =
3388 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER;
3389
3390constexpr auto OPENGLES2_TEXTURE_TARGET_NUMBER =
3391 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER;
3392
3393constexpr auto VULKAN_TEXTURE_NUMBER = SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER;
3394
3395} // namespace prop::Texture
3396
3398{
3399 return TextureLock(get(), rect);
3400}
3401
3403{
3404 CheckError(SDL_SetRenderTarget(get(), texture.get()));
3405}
3406
3408{
3409 return SDL_GetRenderTarget(get());
3410}
3411
3415{
3416 CheckError(SDL_RenderTexture(get(), texture.get(), srcrect, dstrect));
3417}
3418
3420 TextureRef texture,
3423 double angle,
3425 FlipMode flip)
3426{
3427 CheckError(SDL_RenderTextureRotated(
3428 get(), texture.get(), srcrect, dstrect, angle, center, flip));
3429}
3430
3432 TextureRef texture,
3437{
3438 CheckError(SDL_RenderTextureAffine(
3439 get(), texture.get(), srcrect, origin, right, down));
3440}
3441
3443 TextureRef texture,
3445 float scale,
3447{
3448 CheckError(
3449 SDL_RenderTextureTiled(get(), texture.get(), srcrect, scale, dstrect));
3450}
3451
3453 TextureRef texture,
3455 float left_width,
3456 float right_width,
3457 float top_height,
3458 float bottom_height,
3459 float scale,
3461{
3462 CheckError(SDL_RenderTexture9Grid(get(),
3463 texture.get(),
3464 srcrect,
3465 left_width,
3466 right_width,
3467 top_height,
3468 bottom_height,
3469 scale,
3470 dstrect));
3471}
3472
3474 std::span<const Vertex> vertices,
3475 std::span<const int> indices)
3476{
3477 CheckError(SDL_RenderGeometry(get(),
3478 texture.get(),
3479 vertices.data(),
3480 vertices.size(),
3481 indices.data(),
3482 indices.size()));
3483}
3484
3486 const float* xy,
3487 int xy_stride,
3488 const FColor* color,
3489 int color_stride,
3490 const float* uv,
3491 int uv_stride,
3492 int num_vertices,
3493 const void* indices,
3494 int num_indices,
3495 int size_indices)
3496{
3497 CheckError(SDL_RenderGeometryRaw(get(),
3498 texture.get(),
3499 xy,
3500 xy_stride,
3501 color,
3502 color_stride,
3503 uv,
3504 uv_stride,
3505 num_vertices,
3506 indices,
3507 num_indices,
3508 size_indices));
3509}
3510
3527inline void* GetRenderMetalLayer(RendererRef renderer)
3528{
3529 return CheckError(SDL_GetRenderMetalLayer(renderer.get()));
3530}
3531
3554{
3555 return CheckError(SDL_GetRenderMetalCommandEncoder(renderer.get()));
3556}
3557
3586 Uint32 wait_stage_mask,
3587 Sint64 wait_semaphore,
3588 Sint64 signal_semaphore)
3589{
3590 CheckError(SDL_AddVulkanRenderSemaphores(
3591 renderer.get(), wait_stage_mask, wait_semaphore, signal_semaphore));
3592}
3593
3594#ifdef SDL3PP_DOC
3595
3597#define SDL_RENDERER_VSYNC_DISABLED 0
3598
3600#define SDL_RENDERER_VSYNC_ADAPTIVE (-1)
3601
3611#define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE 8
3612
3613#endif // SDL3PP_DOC
3614
3615#pragma region impl
3616
3617inline void RendererRef::ResetTarget() { return SetTarget(nullptr); }
3618
3631{
3632 auto surface{Surface::LoadBMP(src)};
3633 return Texture::CreateFromSurface(renderer, surface);
3634}
3635
3647{
3648 Surface surface{SDL_LoadBMP(file)};
3649 return Texture::CreateFromSurface(renderer, surface);
3650}
3651
3652#pragma endregion impl
3653
3655
3656} // namespace SDL
3657
3658#endif /* SDL3PP_RENDER_H_ */
Base class for locks.
Definition SDL3pp_resource.h:408
Optional-like shim for references.
Definition SDL3pp_optionalRef.h:20
Pixel format.
Definition SDL3pp_pixels.h:391
RESOURCE release()
Returns reference and reset this.
Definition SDL3pp_resource.h:178
Implement shared ownership for a resource.
Definition SDL3pp_resource.h:283
Implement unique ownership for a resource.
Definition SDL3pp_resource.h:226
constexpr ResourceUnique(std::nullptr_t=nullptr)
Default constructor.
Definition SDL3pp_resource.h:231
void reset()
Resets the value, destroying the resource if not nullptr.
Definition SDL3pp_resource.h:265
A dumb pointer to resource.
Definition SDL3pp_resource.h:197
constexpr ResourceUnsafe()=default
Default constructor.
Implement weak ownership for a resource.
Definition SDL3pp_resource.h:328
A SDL managed resource.
Definition SDL3pp_resource.h:29
constexpr Resource(T resource={})
Constructs from the underlying resource.
Definition SDL3pp_resource.h:37
constexpr SDL_Renderer * get() const
Return contained resource;.
Definition SDL3pp_resource.h:76
span-like for empty-derived structs
Definition SDL3pp_spanRef.h:24
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
Locks a Texture for access to its pixels.
Definition SDL3pp_render.h:2985
void reset()
Same as Unlock(), just for uniformity.
Definition SDL3pp_render.h:3065
constexpr TextureLock()=default
Creates an empty lock.
~TextureLock()
Destructor.
Definition SDL3pp_render.h:3034
void Unlock()
Unlock a texture, uploading the changes to video memory, if needed.
Definition SDL3pp_render.h:3053
TextureLock(TextureRef texture, OptionalRef< const SDL_Rect > rect)
Lock a portion of the texture for write-only pixel access.
Definition SDL3pp_render.h:3023
constexpr TextureLock(TextureLock &&other)
Move constructor.
Definition SDL3pp_render.h:2995
#define SDL_assert_paranoid(condition)
An assertion test that is performed only when built with paranoid settings.
Definition SDL3pp_assert.h:364
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:206
SDL_Event Event
The structure for all events in SDL.
Definition SDL3pp_events.h:832
void RenderTextureAffine(TextureRef texture, OptionalRef< const SDL_FRect > srcrect, OptionalRef< const SDL_FPoint > origin, OptionalRef< const SDL_FPoint > right, OptionalRef< const SDL_FPoint > down)
Copy a portion of the source texture to the current rendering target, with affine transform,...
Definition SDL3pp_render.h:3431
void * GetRenderMetalLayer(RendererRef renderer)
Get the CAMetalLayer associated with the given Metal renderer.
Definition SDL3pp_render.h:3527
TextureLock Lock(OptionalRef< const SDL_Rect > rect={}) &
Lock a portion of the texture for write-only pixel access.
Definition SDL3pp_render.h:3397
void RenderTexture9Grid(TextureRef texture, OptionalRef< const SDL_FRect > srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, OptionalRef< const SDL_FRect > dstrect)
Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precisio...
Definition SDL3pp_render.h:3452
TextureRef GetTarget() const
Get the current render target.
Definition SDL3pp_render.h:3407
SDL_Vertex Vertex
Vertex structure.
Definition SDL3pp_render.h:117
RendererShared share()
Move this renderer into a RendererShared.
Definition SDL3pp_render.h:1963
RendererRef GetRenderer() const
Get the renderer associated with a window.
Definition SDL3pp_render.h:3258
void ResetTarget()
Set target texture back to window.
Definition SDL3pp_render.h:3617
std::pair< Window, Renderer > CreateWindowAndRenderer(StringParam title, const SDL_Point &size, WindowFlags window_flags=0)
Create a window and default renderer.
Definition SDL3pp_render.h:3142
SDL_TextureAccess TextureAccess
The access pattern allowed for a texture.
Definition SDL3pp_render.h:124
void SetTarget(TextureRef texture)
Set a texture as the current rendering target.
Definition SDL3pp_render.h:3402
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:3485
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:162
void * GetRenderMetalCommandEncoder(RendererRef renderer)
Get the Metal command encoder for the current frame.
Definition SDL3pp_render.h:3553
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_DISABLED
There is no logical size in effect.
Definition SDL3pp_render.h:142
SDL_RendererLogicalPresentation RendererLogicalPresentation
How the logical size is mapped to the output.
Definition SDL3pp_render.h:140
constexpr TextureAccess TEXTUREACCESS_TARGET
Texture can be used as a render target.
Definition SDL3pp_render.h:132
void RenderTextureTiled(TextureRef texture, OptionalRef< const SDL_FRect > srcrect, float scale, OptionalRef< const SDL_FRect > dstrect)
Tile a portion of the texture to the current rendering target at subpixel precision.
Definition SDL3pp_render.h:3442
void RenderTexture(TextureRef texture, OptionalRef< const SDL_FRect > srcrect, OptionalRef< const SDL_FRect > dstrect)
Copy a portion of the texture to the current rendering target at subpixel precision.
Definition SDL3pp_render.h:3412
constexpr TextureAccess TEXTUREACCESS_STATIC
Changes rarely, not lockable.
Definition SDL3pp_render.h:126
ResourceShared< Renderer > RendererShared
Handle to a shared renderer.
Definition SDL3pp_render.h:60
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_INTEGER_SCALE
The rendered content is scaled up by integer multiples to fit the output resolution.
Definition SDL3pp_render.h:169
constexpr TextureAccess TEXTUREACCESS_STREAMING
Changes frequently, lockable.
Definition SDL3pp_render.h:129
Texture LoadTextureBMP(RendererRef &renderer, IOStreamRef &src)
Load a BMP texture from a seekable SDL data stream.
Definition SDL3pp_render.h:3630
TextureShared share()
Move this texture into a TextureShared.
Definition SDL3pp_render.h:2954
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:155
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:3473
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:3585
ResourceShared< Texture > TextureShared
Handle to a shared texture.
Definition SDL3pp_render.h:86
void RenderTextureRotated(TextureRef texture, OptionalRef< const SDL_FRect > srcrect, OptionalRef< const SDL_FRect > dstrect, double angle, OptionalRef< const SDL_FPoint > center={}, FlipMode flip=SDL_FLIP_NONE)
Copy a portion of the source texture to the current rendering target, with rotation and flipping,...
Definition SDL3pp_render.h:3419
constexpr RendererLogicalPresentation LOGICAL_PRESENTATION_STRETCH
The rendered content is stretched to the output resolution.
Definition SDL3pp_render.h:148
int GetNumRenderDrivers()
Get the number of 2D rendering drivers available for the current display.
Definition SDL3pp_render.h:3096
const char * GetRenderDriver(int index)
Use this function to get the name of a built in 2D rendering driver.
Definition SDL3pp_render.h:3120
SDL_FlipMode FlipMode
The flip mode.
Definition SDL3pp_surface.h:111
SDL_ScaleMode ScaleMode
The scaling mode.
Definition SDL3pp_surface.h:92
SDL_WindowFlags WindowFlags
The flags on a window.
Definition SDL3pp_video.h:133
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
A structure that represents a color as RGBA components.
Definition SDL3pp_pixels.h:1638
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition SDL3pp_pixels.h:1833
The structure that defines a point (using floating point values).
Definition SDL3pp_rect.h:487
A rectangle, with the origin at the upper left (using floating point values).
Definition SDL3pp_rect.h:1469
The read/write operation structure.
Definition SDL3pp_iostream.h:123
The structure that defines a point (using integers).
Definition SDL3pp_rect.h:46
SDL properties ID.
Definition SDL3pp_properties.h:209
A rectangle, with the origin at the upper left (using integers).
Definition SDL3pp_rect.h:833
A structure representing rendering state.
Definition SDL3pp_render.h:182
Point GetOutputSize() const
Get the output size in pixels of a rendering context.
Definition SDL3pp_render.h:220
Rect GetSafeArea() const
Get the safe area for rendering within the current viewport.
Definition SDL3pp_render.h:780
void SetClipRect(OptionalRef< const SDL_Rect > rect)
Set the clip rectangle for rendering on the specified target.
Definition SDL3pp_render.h:822
void SetLogicalPresentation(const SDL_Point &size, RendererLogicalPresentation mode)
Set a device-independent resolution and presentation mode for rendering.
Definition SDL3pp_render.h:495
bool IsClipEnabled() const
Get whether clipping is enabled on the given render target.
Definition SDL3pp_render.h:867
int GetVSync() const
Get VSync of the given renderer.
Definition SDL3pp_render.h:1688
float GetColorScale() const
Get the color scale used for render operations.
Definition SDL3pp_render.h:1123
PropertiesRef GetProperties() const
Get the properties associated with a renderer.
Definition SDL3pp_render.h:382
bool IsViewportSet() const
Return whether an explicit rectangle was set as the viewport.
Definition SDL3pp_render.h:761
FPoint RenderCoordinatesToWindow(const SDL_FPoint &coord) const
Get a point in window coordinates when given a point in render coordinates.
Definition SDL3pp_render.h:629
void Present()
Update the screen with any rendering performed since the previous call.
Definition SDL3pp_render.h:1620
void RenderPoints(SpanRef< const SDL_FPoint > points)
Draw multiple points on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:1215
Rect GetViewport() const
Get the drawing area for the current target.
Definition SDL3pp_render.h:735
void SetViewport(OptionalRef< const SDL_Rect > rect)
Set the drawing area for rendering on the current target.
Definition SDL3pp_render.h:714
void SetDrawColor(SDL_Color c)
Set the color used for drawing operations.
Definition SDL3pp_render.h:955
void GetDrawColor(SDL_FColor *c) const
Get the color used for drawing operations (Rect, Line and Clear).
Definition SDL3pp_render.h:1033
Point GetCurrentOutputSize() const
Get the current output size in pixels of a rendering context.
Definition SDL3pp_render.h:267
const char * GetName() const
Get the name of a renderer.
Definition SDL3pp_render.h:209
void GetDrawColor(SDL_Color *c) const
Get the color used for drawing operations (Rect, Line and Clear).
Definition SDL3pp_render.h:1014
Rect GetClipRect() const
Get the clip rectangle for the current target.
Definition SDL3pp_render.h:844
void RenderFillRect(OptionalRef< const SDL_FRect > rect)
Fill a rectangle on the current rendering target with the drawing color at subpixel precision.
Definition SDL3pp_render.h:1309
FRect GetLogicalPresentationRect() const
Get the final presentation rectangle for rendering.
Definition SDL3pp_render.h:571
void GetLogicalPresentation(SDL_Point *size, RendererLogicalPresentation *mode)
Get device independent resolution and presentation mode for rendering.
Definition SDL3pp_render.h:517
void ConvertEventToRenderCoordinates(Event *event) const
Convert the coordinates in an event to render coordinates.
Definition SDL3pp_render.h:669
static void reset(SDL_Renderer *resource)
Destroy the rendering context for a window and free all associated textures.
Definition SDL3pp_render.h:1781
BlendMode GetDrawBlendMode() const
Get the blend mode used for drawing operations.
Definition SDL3pp_render.h:1161
void RenderDebugTextFormat(FPoint p, std::string_view fmt, ARGS... args)
Draw debug text to an SDL_Renderer.
Definition SDL3pp_render.h:1762
void GetDrawColor(Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const
Get the color used for drawing operations (Rect, Line and Clear).
Definition SDL3pp_render.h:1057
void RenderLines(SpanRef< const SDL_FPoint > points)
Draw a series of connected lines on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:1252
FPoint RenderCoordinatesFromWindow(const SDL_FPoint &window_coord) const
Get a point in render coordinates when given a point in window coordinates.
Definition SDL3pp_render.h:599
void GetLogicalPresentation(int *w, int *h, RendererLogicalPresentation *mode) const
Get device independent resolution and presentation mode for rendering.
Definition SDL3pp_render.h:544
void RenderRects(SpanRef< const SDL_FRect > rects)
Draw some number of rectangles on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:1289
void GetDrawColor(float *r, float *g, float *b, float *a) const
Get the color used for drawing operations (Rect, Line and Clear).
Definition SDL3pp_render.h:1081
void RenderPoint(const SDL_FPoint &p)
Draw a point on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:1198
void SetColorScale(float scale)
Set the color scale used for render operations.
Definition SDL3pp_render.h:1106
void RenderFillRects(SpanRef< const SDL_FRect > rects)
Fill some number of rectangles on the current rendering target with the drawing color at subpixel pre...
Definition SDL3pp_render.h:1327
FColor GetDrawColor() const
Get the color used for drawing operations (Rect, Line and Clear).
Definition SDL3pp_render.h:993
void GetOutputSize(int *w, int *h) const
Get the output size in pixels of a rendering context.
Definition SDL3pp_render.h:246
void RenderClear()
Clear the current rendering target with the drawing color.
Definition SDL3pp_render.h:1184
void SetDrawColor(SDL_FColor c)
Set the color used for drawing operations (Rect, Line and Clear).
Definition SDL3pp_render.h:975
void GetScale(float *scaleX, float *scaleY) const
Get the drawing scale for the current target.
Definition SDL3pp_render.h:935
void ResetClipRect()
Reset the clip rectangle for rendering to the entire render target.
Definition SDL3pp_render.h:802
void RenderRect(OptionalRef< const SDL_FRect > rect)
Draw a rectangle on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:1271
void SetVSync(int vsync)
Toggle VSync of the given renderer.
Definition SDL3pp_render.h:1674
void ResetViewport()
Reset the drawing area for rendering to the entire target.
Definition SDL3pp_render.h:689
void Flush()
Force the rendering context to flush any pending commands and state.
Definition SDL3pp_render.h:1651
void RenderDebugText(FPoint p, StringParam str)
Draw debug text to an RendererRef.
Definition SDL3pp_render.h:1731
void SetDrawBlendMode(BlendMode blendMode)
Set the blend mode used for drawing operations (Fill and Line).
Definition SDL3pp_render.h:1144
void RenderLine(const SDL_FPoint &p1, const SDL_FPoint &p2)
Draw a line on the current rendering target at subpixel precision.
Definition SDL3pp_render.h:1234
FPoint GetScale() const
Get the drawing scale for the current target.
Definition SDL3pp_render.h:912
WindowRef GetWindow()
Get the window associated with a renderer.
Definition SDL3pp_render.h:195
void GetCurrentOutputSize(int *w, int *h) const
Get the current output size in pixels of a rendering context.
Definition SDL3pp_render.h:294
Surface ReadPixels(OptionalRef< const SDL_Rect > rect={}) const
Read pixels from the current rendering target.
Definition SDL3pp_render.h:1568
void SetScale(const SDL_FPoint &scale)
Set the drawing scale for rendering on the current target.
Definition SDL3pp_render.h:892
Unsafe Handle to renderer.
Definition SDL3pp_render.h:1978
constexpr RendererUnsafe(Renderer &&other)
Constructs RendererUnsafe from Renderer.
Definition SDL3pp_render.h:1984
Handle to an owned renderer.
Definition SDL3pp_render.h:1792
void Destroy()
Destroy the rendering context for a window and free all associated textures.
Definition SDL3pp_render.h:1954
static Renderer Create(WindowRef window)
Create a 2D rendering context for a window.
Definition SDL3pp_render.h:1818
static Renderer CreateWithProperties(PropertiesRef props)
Create a 2D rendering context for a window, with the specified properties.
Definition SDL3pp_render.h:1913
static Renderer Create(WindowRef window, StringParam name)
Create a 2D rendering context for a window.
Definition SDL3pp_render.h:1857
static Renderer CreateSoftware(SurfaceRef surface)
Create a 2D software rendering context for a surface.
Definition SDL3pp_render.h:1937
A collection of pixels used in software blitting.
Definition SDL3pp_surface.h:153
Handle to an owned surface.
Definition SDL3pp_surface.h:1824
static Surface LoadBMP(IOStreamRef src)
Load a BMP image from a seekable SDL data stream.
Definition SDL3pp_surface.h:1875
An efficient driver-specific representation of pixel data.
Definition SDL3pp_render.h:2005
ScaleMode GetScaleMode() const
Get the scale mode used for texture scale operations.
Definition SDL3pp_render.h:2499
FColor GetMod() const
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:2179
void SetBlendMode(BlendMode blendMode)
Set the blend mode for a texture, used by RendererRef.RenderTexture().
Definition SDL3pp_render.h:2442
void SetColorMod(float r, float g, float b)
Set an additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:2279
void UpdateNV(OptionalRef< const SDL_Rect > 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:2605
BlendMode GetBlendMode() const
Get the blend mode used for texture copy operations.
Definition SDL3pp_render.h:2459
void SetMod(Color c)
Set an additional color and alpha values multiplied into render copy operations.
Definition SDL3pp_render.h:2132
void GetColorMod(Uint8 *r, Uint8 *g, Uint8 *b) const
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:2299
void SetColorMod(Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:2250
PropertiesRef GetProperties() const
Get the properties associated with a texture.
Definition SDL3pp_render.h:2093
void GetColorMod(float *r, float *g, float *b) const
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:2319
Point GetSize() const
Get the size in pixels.
Definition SDL3pp_render.h:2652
void SetMod(FColor c)
Set an additional color and alpha values multiplied into render copy operations.
Definition SDL3pp_render.h:2160
void Update(OptionalRef< const SDL_Rect > rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition SDL3pp_render.h:2536
void SetScaleMode(ScaleMode scaleMode)
Set the scale mode used for texture scale operations.
Definition SDL3pp_render.h:2482
static void reset(SDL_Texture *resource)
Destroy the specified texture.
Definition SDL3pp_render.h:2674
void GetAlphaMod(Uint8 *alpha) const
Get the additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:2404
void SetAlphaMod(float alpha)
Set an additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:2371
void UpdateYUV(OptionalRef< const SDL_Rect > 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:2569
RendererRef GetRenderer() const
Get the renderer that created an TextureRef.
Definition SDL3pp_render.h:2108
PixelFormat GetFormat() const
Get the pixel format.
Definition SDL3pp_render.h:2657
int GetWidth() const
Get the width in pixels.
Definition SDL3pp_render.h:2642
void SetAlphaMod(Uint8 alpha)
Set an additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:2345
int GetHeight() const
Get the height in pixels.
Definition SDL3pp_render.h:2647
void GetMod(Color *c) const
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:2199
void GetAlphaMod(float *alpha) const
Get the additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:2422
void GetMod(FColor *c) const
Get the additional color value multiplied into render copy operations.
Definition SDL3pp_render.h:2219
float GetAlphaMod() const
Get the additional alpha value multiplied into render copy operations.
Definition SDL3pp_render.h:2384
Unsafe Handle to texture.
Definition SDL3pp_render.h:2969
constexpr TextureUnsafe(Texture &&other)
Constructs TextureUnsafe from Texture.
Definition SDL3pp_render.h:2975
Handle to an owned texture.
Definition SDL3pp_render.h:2685
static Texture LoadBMP(RendererRef renderer, StringParam file)
Load a BMP texture from a file.
Definition SDL3pp_render.h:2732
void Destroy()
Destroy the specified texture.
Definition SDL3pp_render.h:2945
static Texture CreateFromSurface(RendererRef renderer, SurfaceRef surface)
Create a texture from an existing surface.
Definition SDL3pp_render.h:2810
static Texture LoadBMP(RendererRef renderer, IOStreamRef src)
Load a BMP texture from a seekable SDL data stream.
Definition SDL3pp_render.h:2748
static Texture Load(RendererRef renderer, StringParam file)
Load an image from a filesystem path into a software surface.
Definition SDL3pp_image.h:2227
static Texture CreateWithProperties(RendererRef renderer, PropertiesRef props)
Create a texture for a rendering context with the specified properties.
Definition SDL3pp_render.h:2925
static Texture Create(RendererRef renderer, PixelFormat format, TextureAccess access, const SDL_Point &size)
Create a texture for a rendering context.
Definition SDL3pp_render.h:2775
Represents a handle to a window.
Definition SDL3pp_video.h:860
Handle to an owned window.
Definition SDL3pp_video.h:2572