1#ifndef SDL3PP_RENDER_H_
2#define SDL3PP_RENDER_H_
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"
108#define SDL_SOFTWARE_RENDERER "software"
127 SDL_TEXTUREACCESS_STATIC;
130 SDL_TEXTUREACCESS_STREAMING;
133 SDL_TEXTUREACCESS_TARGET;
143 SDL_LOGICAL_PRESENTATION_DISABLED;
149 SDL_LOGICAL_PRESENTATION_STRETCH;
156 SDL_LOGICAL_PRESENTATION_LETTERBOX;
163 SDL_LOGICAL_PRESENTATION_OVERSCAN;
170 SDL_LOGICAL_PRESENTATION_INTEGER_SCALE;
498 CheckError(SDL_SetRenderLogicalPresentation(
get(), size.x, size.y, mode));
548 CheckError(SDL_GetRenderLogicalPresentation(
get(), w, h, mode));
574 CheckError(SDL_GetRenderLogicalPresentationRect(
get(), &rect));
603 get(), window_coord.x, window_coord.y, &p.x, &p.y));
633 SDL_RenderCoordinatesToWindow(
get(), coord.x, coord.y, &p.x, &p.y));
671 CheckError(SDL_ConvertEventToRenderCoordinates(
get(), event));
957 CheckError(SDL_SetRenderDrawColor(
get(), c.r, c.g, c.b, c.a));
977 CheckError(SDL_SetRenderDrawColorFloat(
get(), c.r, c.g, c.b, c.a));
1218 CheckError(SDL_RenderPoints(
get(), points.data(), points.size()));
1255 CheckError(SDL_RenderLines(
get(), points.data(), points.size()));
1292 CheckError(SDL_RenderRects(
get(), rects.data(), rects.size()));
1330 CheckError(SDL_RenderFillRects(
get(), rects.data(), rects.size()));
1411 OptionalRef<const SDL_FRect> srcrect,
1412 OptionalRef<const SDL_FPoint> origin,
1413 OptionalRef<const SDL_FPoint> right,
1414 OptionalRef<const SDL_FPoint> down);
1440 OptionalRef<const SDL_FRect> srcrect,
1442 OptionalRef<const SDL_FRect> dstrect);
1475 OptionalRef<const SDL_FRect> srcrect,
1479 float bottom_height,
1481 OptionalRef<const SDL_FRect> dstrect);
1502 std::span<const Vertex> vertices,
1503 std::span<const int> indices = {});
1534 const FColor* color,
1539 const void* indices,
1761 template<
class... ARGS>
1764 RenderDebugText(p, std::vformat(fmt, std::make_format_args(args...)));
1781 static void reset(SDL_Renderer* resource) { SDL_DestroyRenderer(resource); }
2570 const Uint8* Yplane,
2572 const Uint8* Uplane,
2574 const Uint8* Vplane,
2578 get(), rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch));
2606 const Uint8* Yplane,
2608 const Uint8* UVplane,
2612 SDL_UpdateNVTexture(
get(), rect, Yplane, Ypitch, UVplane, UVpitch));
2674 static void reset(SDL_Texture* resource) { SDL_DestroyTexture(resource); }
2734 Surface surface{SDL_LoadBMP(file)};
2778 const SDL_Point& size)
2781 CheckError(SDL_CreateTexture(renderer, format, access, size.x, size.y)));
2928 CheckError(SDL_CreateTextureWithProperties(renderer, props)));
3025 , texture(std::move(texture))
3057 SDL_UnlockTexture(texture);
3072 SDL_Surface* surface =
nullptr;
3073 CheckError(SDL_LockTextureToSurface(texture, rect, &surface));
3122 return SDL_GetRenderDriver(index);
3144 const SDL_Point& size,
3148 SDL_Renderer* renderer;
3150 title, size.x, size.y, window_flags, &window, &renderer));
3154namespace prop::Renderer {
3156constexpr auto CREATE_NAME_STRING = SDL_PROP_RENDERER_CREATE_NAME_STRING;
3158constexpr auto CREATE_WINDOW_POINTER = SDL_PROP_RENDERER_CREATE_WINDOW_POINTER;
3160constexpr auto CREATE_SURFACE_POINTER =
3161 SDL_PROP_RENDERER_CREATE_SURFACE_POINTER;
3163constexpr auto CREATE_OUTPUT_COLORSPACE_NUMBER =
3164 SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER;
3166constexpr auto CREATE_PRESENT_VSYNC_NUMBER =
3167 SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER;
3169constexpr auto CREATE_VULKAN_INSTANCE_POINTER =
3170 SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER;
3172constexpr auto CREATE_VULKAN_SURFACE_NUMBER =
3173 SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER;
3175constexpr auto CREATE_VULKAN_PHYSICAL_DEVICE_POINTER =
3176 SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER;
3178constexpr auto CREATE_VULKAN_DEVICE_POINTER =
3179 SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER;
3181constexpr auto CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER =
3182 SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER;
3184constexpr auto CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER =
3185 SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER;
3187constexpr auto NAME_STRING = SDL_PROP_RENDERER_NAME_STRING;
3189constexpr auto WINDOW_POINTER = SDL_PROP_RENDERER_WINDOW_POINTER;
3191constexpr auto SURFACE_POINTER = SDL_PROP_RENDERER_SURFACE_POINTER;
3193constexpr auto VSYNC_NUMBER = SDL_PROP_RENDERER_VSYNC_NUMBER;
3195constexpr auto MAX_TEXTURE_SIZE_NUMBER =
3196 SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER;
3198constexpr auto TEXTURE_FORMATS_POINTER =
3199 SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER;
3201constexpr auto OUTPUT_COLORSPACE_NUMBER =
3202 SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER;
3204constexpr auto HDR_ENABLED_BOOLEAN = SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN;
3206constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT;
3208constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT;
3210constexpr auto D3D9_DEVICE_POINTER = SDL_PROP_RENDERER_D3D9_DEVICE_POINTER;
3212constexpr auto D3D11_DEVICE_POINTER = SDL_PROP_RENDERER_D3D11_DEVICE_POINTER;
3214constexpr auto D3D11_SWAPCHAIN_POINTER =
3215 SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER;
3217constexpr auto D3D12_DEVICE_POINTER = SDL_PROP_RENDERER_D3D12_DEVICE_POINTER;
3219constexpr auto D3D12_SWAPCHAIN_POINTER =
3220 SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER;
3222constexpr auto D3D12_COMMAND_QUEUE_POINTER =
3223 SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER;
3225constexpr auto VULKAN_INSTANCE_POINTER =
3226 SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER;
3228constexpr auto VULKAN_SURFACE_NUMBER = SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER;
3230constexpr auto VULKAN_PHYSICAL_DEVICE_POINTER =
3231 SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER;
3233constexpr auto VULKAN_DEVICE_POINTER = SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER;
3235constexpr auto VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER =
3236 SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER;
3238constexpr auto VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER =
3239 SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER;
3241constexpr auto VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER =
3242 SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER;
3244constexpr auto GPU_DEVICE_POINTER = SDL_PROP_RENDERER_GPU_DEVICE_POINTER;
3263namespace prop::Texture {
3265constexpr auto CREATE_COLORSPACE_NUMBER =
3266 SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER;
3268constexpr auto CREATE_FORMAT_NUMBER = SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER;
3270constexpr auto CREATE_ACCESS_NUMBER = SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER;
3272constexpr auto CREATE_WIDTH_NUMBER = SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER;
3274constexpr auto CREATE_HEIGHT_NUMBER = SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER;
3276constexpr auto CREATE_SDR_WHITE_POINT_FLOAT =
3277 SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT;
3279constexpr auto CREATE_HDR_HEADROOM_FLOAT =
3280 SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT;
3282constexpr auto CREATE_D3D11_TEXTURE_POINTER =
3283 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER;
3285constexpr auto CREATE_D3D11_TEXTURE_U_POINTER =
3286 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER;
3288constexpr auto CREATE_D3D11_TEXTURE_V_POINTER =
3289 SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER;
3291constexpr auto CREATE_D3D12_TEXTURE_POINTER =
3292 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER;
3294constexpr auto CREATE_D3D12_TEXTURE_U_POINTER =
3295 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER;
3297constexpr auto CREATE_D3D12_TEXTURE_V_POINTER =
3298 SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER;
3300constexpr auto CREATE_METAL_PIXELBUFFER_POINTER =
3301 SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER;
3303constexpr auto CREATE_OPENGL_TEXTURE_NUMBER =
3304 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER;
3306constexpr auto CREATE_OPENGL_TEXTURE_UV_NUMBER =
3307 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER;
3309constexpr auto CREATE_OPENGL_TEXTURE_U_NUMBER =
3310 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER;
3312constexpr auto CREATE_OPENGL_TEXTURE_V_NUMBER =
3313 SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER;
3315constexpr auto CREATE_OPENGLES2_TEXTURE_NUMBER =
3316 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER;
3318constexpr auto CREATE_OPENGLES2_TEXTURE_UV_NUMBER =
3319 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER;
3321constexpr auto CREATE_OPENGLES2_TEXTURE_U_NUMBER =
3322 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER;
3324constexpr auto CREATE_OPENGLES2_TEXTURE_V_NUMBER =
3325 SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER;
3327constexpr auto CREATE_VULKAN_TEXTURE_NUMBER =
3328 SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER;
3330constexpr auto COLORSPACE_NUMBER = SDL_PROP_TEXTURE_COLORSPACE_NUMBER;
3332constexpr auto FORMAT_NUMBER = SDL_PROP_TEXTURE_FORMAT_NUMBER;
3334constexpr auto ACCESS_NUMBER = SDL_PROP_TEXTURE_ACCESS_NUMBER;
3336constexpr auto WIDTH_NUMBER = SDL_PROP_TEXTURE_WIDTH_NUMBER;
3338constexpr auto HEIGHT_NUMBER = SDL_PROP_TEXTURE_HEIGHT_NUMBER;
3340constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT;
3342constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT;
3344constexpr auto D3D11_TEXTURE_POINTER = SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER;
3346constexpr auto D3D11_TEXTURE_U_POINTER =
3347 SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER;
3349constexpr auto D3D11_TEXTURE_V_POINTER =
3350 SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER;
3352constexpr auto D3D12_TEXTURE_POINTER = SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER;
3354constexpr auto D3D12_TEXTURE_U_POINTER =
3355 SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER;
3357constexpr auto D3D12_TEXTURE_V_POINTER =
3358 SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER;
3360constexpr auto OPENGL_TEXTURE_NUMBER = SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER;
3362constexpr auto OPENGL_TEXTURE_UV_NUMBER =
3363 SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER;
3365constexpr auto OPENGL_TEXTURE_U_NUMBER =
3366 SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER;
3368constexpr auto OPENGL_TEXTURE_V_NUMBER =
3369 SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER;
3371constexpr auto OPENGL_TEXTURE_TARGET_NUMBER =
3372 SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER;
3374constexpr auto OPENGL_TEX_W_FLOAT = SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT;
3376constexpr auto OPENGL_TEX_H_FLOAT = SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT;
3378constexpr auto OPENGLES2_TEXTURE_NUMBER =
3379 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER;
3381constexpr auto OPENGLES2_TEXTURE_UV_NUMBER =
3382 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER;
3384constexpr auto OPENGLES2_TEXTURE_U_NUMBER =
3385 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER;
3387constexpr auto OPENGLES2_TEXTURE_V_NUMBER =
3388 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER;
3390constexpr auto OPENGLES2_TEXTURE_TARGET_NUMBER =
3391 SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER;
3393constexpr auto VULKAN_TEXTURE_NUMBER = SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER;
3409 return SDL_GetRenderTarget(
get());
3428 get(), texture.
get(), srcrect, dstrect, angle, center, flip));
3439 get(), texture.
get(), srcrect, origin, right, down));
3449 SDL_RenderTextureTiled(
get(), texture.
get(), srcrect, scale, dstrect));
3458 float bottom_height,
3474 std::span<const Vertex> vertices,
3475 std::span<const int> indices)
3493 const void* indices,
3555 return CheckError(SDL_GetRenderMetalCommandEncoder(renderer.
get()));
3586 Uint32 wait_stage_mask,
3587 Sint64 wait_semaphore,
3588 Sint64 signal_semaphore)
3591 renderer.
get(), wait_stage_mask, wait_semaphore, signal_semaphore));
3597#define SDL_RENDERER_VSYNC_DISABLED 0
3600#define SDL_RENDERER_VSYNC_ADAPTIVE (-1)
3611#define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE 8
3648 Surface surface{SDL_LoadBMP(file)};
3652#pragma endregion impl
Base class for locks.
Definition SDL3pp_resource.h:408
Optional-like shim for references.
Definition SDL3pp_optionalRef.h:20
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