SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
2D Accelerated Rendering

Header file for SDL 2D rendering functions. More...

Namespaces

namespace  SDL::prop
 Constants for Properties keys.
namespace  SDL::prop::Renderer
 Properties for Renderer.
namespace  SDL::prop::Renderer::Create
 Properties for Renderer creation.
namespace  SDL::prop::Texture
 Properties for Texture.
namespace  SDL::prop::Texture::Create
 Properties for Texture creation.

Classes

struct  SDL::Renderer
 A structure representing rendering state. More...
struct  SDL::Texture
 An efficient driver-specific representation of pixel data. More...
class  SDL::TextureLock
 Lock a portion of the texture for write-only pixel access. More...
class  SDL::TextureSurfaceLock
 Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface. More...
struct  SDL::GPURenderState
 A custom GPU render state. More...

Typedefs

using SDL::RendererRaw = SDL_Renderer*
 Alias to raw representation for Renderer.
using SDL::TextureRaw = SDL_Texture*
 Alias to raw representation for Texture.
using SDL::TextureRawConst = const SDL_Texture*
 Alias to const raw representation for Texture.
using SDL::TextureRef = ResourceRef<Texture>
 Reference for Texture.
using SDL::TextureConstRef = ResourceConstRef<TextureRaw, TextureRawConst>
 Safely wrap Texture for non owning const parameters.
using SDL::GPURenderStateRaw = SDL_GPURenderState*
 Alias to raw representation for GPURenderState.
using SDL::GPURenderStateRef = ResourceRef<GPURenderState>
 Reference for GPURenderState.
using SDL::Vertex = SDL_Vertex
 Vertex structure.
using SDL::TextureAccess = SDL_TextureAccess
 The access pattern allowed for a texture.
using SDL::TextureAddressMode = SDL_TextureAddressMode
 The addressing mode for a texture when used in Renderer.RenderGeometry().
using SDL::RendererLogicalPresentation = SDL_RendererLogicalPresentation
 How the logical size is mapped to the output.
using SDL::GPURenderStateCreateInfo = SDL_GPURenderStateCreateInfo
 A structure specifying the parameters of a GPU render state.

Functions

int SDL::GetNumRenderDrivers ()
 Get the number of 2D rendering drivers available for the current display.
const char * SDL::GetRenderDriver (int index)
 Use this function to get the name of a built in 2D rendering driver.
void SDL::CreateWindowAndRendererRaw (StringParam title, const PointRaw &size, WindowFlags window_flags, WindowRaw *window, RendererRaw *renderer)
 Create a window and default renderer.
void SDL::CreateWindowAndRenderer (StringParam title, const PointRaw &size, WindowFlags window_flags, Window *window, Renderer *renderer)
 Create a window and default renderer.
std::pair< Window, RendererSDL::CreateWindowAndRenderer (StringParam title, const PointRaw &size, WindowFlags window_flags=0)
 Create a window and default renderer.
Window SDL::CreateWindowAndRenderer (StringParam title, const PointRaw &size, WindowFlags window_flags, Renderer *renderer)
 Create a window and default renderer.
Renderer SDL::CreateRenderer (WindowRef window, StringParam name=nullptr)
 Create a 2D rendering context for a window.
Renderer SDL::CreateRendererWithProperties (PropertiesRef props)
 Create a 2D rendering context for a window, with the specified properties.
RendererRef SDL::CreateGPURenderer (GPUDeviceRef device, WindowRef window)
 Create a 2D GPU rendering context.
GPUDeviceRef SDL::GetGPURendererDevice (RendererRef renderer)
 Return the GPU device used by a renderer.
Renderer SDL::CreateSoftwareRenderer (SurfaceRef surface)
 Create a 2D software rendering context for a surface.
WindowRef SDL::GetRenderWindow (RendererRef renderer)
 Get the window associated with a renderer.
const char * SDL::GetRendererName (RendererRef renderer)
 Get the name of a renderer.
PropertiesRef SDL::GetRendererProperties (RendererRef renderer)
 Get the properties associated with a renderer.
void SDL::GetRenderOutputSize (RendererRef renderer, int *w, int *h)
 Get the output size in pixels of a rendering context.
Point SDL::GetRenderOutputSize (RendererRef renderer)
 Get the output size in pixels of a rendering context.
void SDL::GetCurrentRenderOutputSize (RendererRef renderer, int *w, int *h)
 Get the current output size in pixels of a rendering context.
Point SDL::GetCurrentRenderOutputSize (RendererRef renderer)
 Get the current output size in pixels of a rendering context.
Texture SDL::CreateTexture (RendererRef renderer, PixelFormat format, TextureAccess access, const PointRaw &size)
 Create a texture for a rendering context.
Texture SDL::CreateTextureFromSurface (RendererRef renderer, SurfaceRef surface)
 Create a texture from an existing surface.
Texture SDL::CreateTextureWithProperties (RendererRef renderer, PropertiesRef props)
 Create a texture for a rendering context with the specified properties.
PropertiesRef SDL::GetTextureProperties (TextureConstRef texture)
 Get the properties associated with a texture.
RendererRef SDL::GetRendererFromTexture (TextureConstRef texture)
 Get the renderer that created an Texture.
void SDL::GetTextureSize (TextureConstRef texture, float *w, float *h)
 Get the size of a texture, as floating point values.
Point SDL::GetTextureSize (TextureConstRef texture)
 Get the size of a texture.
FPoint SDL::GetTextureSizeFloat (TextureConstRef texture)
 Get the size of a texture, as floating point values.
int SDL::GetTextureWidth (TextureConstRef texture)
 Get the width in pixels.
int SDL::GetTextureHeight (TextureConstRef texture)
 Get the height in pixels.
PixelFormat SDL::GetTextureFormat (TextureConstRef texture)
 Get the pixel format.
void SDL::SetTexturePalette (TextureRef texture, PaletteRef palette)
 Set the palette used by a texture.
Palette SDL::GetTexturePalette (TextureRef texture)
 Get the palette used by a texture.
void SDL::SetTextureColorMod (TextureRef texture, Uint8 r, Uint8 g, Uint8 b)
 Set an additional color value multiplied into render copy operations.
void SDL::SetTextureColorModFloat (TextureRef texture, float r, float g, float b)
 Set an additional color value multiplied into render copy operations.
void SDL::GetTextureColorMod (TextureConstRef texture, Uint8 *r, Uint8 *g, Uint8 *b)
 Get the additional color value multiplied into render copy operations.
void SDL::GetTextureColorModFloat (TextureConstRef texture, float *r, float *g, float *b)
 Get the additional color value multiplied into render copy operations.
void SDL::SetTextureAlphaMod (TextureRef texture, Uint8 alpha)
 Set an additional alpha value multiplied into render copy operations.
void SDL::SetTextureAlphaModFloat (TextureRef texture, float alpha)
 Set an additional alpha value multiplied into render copy operations.
Uint8 SDL::GetTextureAlphaMod (TextureConstRef texture)
 Get the additional alpha value multiplied into render copy operations.
float SDL::GetTextureAlphaModFloat (TextureConstRef texture)
 Get the additional alpha value multiplied into render copy operations.
void SDL::SetTextureMod (TextureRef texture, Color c)
 Set an additional color and alpha values multiplied into render copy operations.
void SDL::SetTextureModFloat (TextureRef texture, FColor c)
 Set an additional color and alpha values multiplied into render copy operations.
Color SDL::GetTextureMod (TextureConstRef texture)
 Get the additional color value multiplied into render copy operations.
FColor SDL::GetTextureModFloat (TextureConstRef texture)
 Get the additional color value multiplied into render copy operations.
void SDL::SetTextureBlendMode (TextureRef texture, BlendMode blendMode)
 Set the blend mode for a texture, used by Renderer.RenderTexture().
BlendMode SDL::GetTextureBlendMode (TextureConstRef texture)
 Get the blend mode used for texture copy operations.
void SDL::SetTextureScaleMode (TextureRef texture, ScaleMode scaleMode)
 Set the scale mode used for texture scale operations.
ScaleMode SDL::GetTextureScaleMode (TextureConstRef texture)
 Get the scale mode used for texture scale operations.
void SDL::UpdateTexture (TextureRef texture, OptionalRef< const RectRaw > rect, const void *pixels, int pitch)
 Update the given texture rectangle with new pixel data.
void SDL::UpdateTexture (TextureRef texture, SurfaceConstRef surface, OptionalRef< const RectRaw > rect=std::nullopt)
 Update the given texture rectangle with new pixel data.
void SDL::UpdateYUVTexture (TextureRef texture, OptionalRef< const RectRaw > rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
 Update a rectangle within a planar YV12 or IYUV texture with new pixel data.
void SDL::UpdateNVTexture (TextureRef texture, OptionalRef< const RectRaw > rect, const Uint8 *Yplane, int Ypitch, const Uint8 *UVplane, int UVpitch)
 Update a rectangle within a planar NV12 or NV21 texture with new pixels.
void SDL::LockTexture (TextureRef texture, OptionalRef< const RectRaw > rect, void **pixels, int *pitch)
 Lock a portion of the texture for write-only pixel access.
Surface SDL::LockTextureToSurface (TextureRef texture, OptionalRef< const RectRaw > rect=std::nullopt)
 Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.
void SDL::UnlockTexture (TextureRef texture)
 Unlock a texture, uploading the changes to video memory, if needed.
void SDL::SetRenderTarget (RendererRef renderer, TextureRef texture)
 Set a texture as the current rendering target.
void SDL::ResetRenderTarget (RendererRef renderer)
 Set target texture back to window.
Texture SDL::GetRenderTarget (RendererRef renderer)
 Get the current render target.
void SDL::SetRenderLogicalPresentation (RendererRef renderer, const PointRaw &size, RendererLogicalPresentation mode)
 Set a device-independent resolution and presentation mode for rendering.
void SDL::GetRenderLogicalPresentation (RendererRef renderer, int *w, int *h, RendererLogicalPresentation *mode)
 Get device independent resolution and presentation mode for rendering.
void SDL::GetRenderLogicalPresentation (RendererRef renderer, PointRaw *size, RendererLogicalPresentation *mode)
 Get device independent resolution and presentation mode for rendering.
FRect SDL::GetRenderLogicalPresentationRect (RendererRef renderer)
 Get the final presentation rectangle for rendering.
FPoint SDL::RenderCoordinatesFromWindow (RendererRef renderer, const FPointRaw &window_coord)
 Get a point in render coordinates when given a point in window coordinates.
FPoint SDL::RenderCoordinatesToWindow (RendererRef renderer, const FPointRaw &coord)
 Get a point in window coordinates when given a point in render coordinates.
void SDL::ConvertEventToRenderCoordinates (RendererRef renderer, Event *event)
 Convert the coordinates in an event to render coordinates.
void SDL::SetRenderViewport (RendererRef renderer, OptionalRef< const RectRaw > rect)
 Set the drawing area for rendering on the current target.
void SDL::ResetRenderViewport (RendererRef renderer)
 Reset the drawing area for rendering to the entire target.
Rect SDL::GetRenderViewport (RendererRef renderer)
 Get the drawing area for the current target.
bool SDL::RenderViewportSet (RendererRef renderer)
 Return whether an explicit rectangle was set as the viewport.
Rect SDL::GetRenderSafeArea (RendererRef renderer)
 Get the safe area for rendering within the current viewport.
void SDL::SetRenderClipRect (RendererRef renderer, OptionalRef< const RectRaw > rect)
 Set the clip rectangle for rendering on the specified target.
void SDL::ResetRenderClipRect (RendererRef renderer)
 Reset the clip rectangle for rendering to the entire render target.
Rect SDL::GetRenderClipRect (RendererRef renderer)
 Get the clip rectangle for the current target.
bool SDL::RenderClipEnabled (RendererRef renderer)
 Get whether clipping is enabled on the given render target.
void SDL::SetRenderScale (RendererRef renderer, const FPointRaw &scale)
 Set the drawing scale for rendering on the current target.
void SDL::GetRenderScale (RendererRef renderer, float *scaleX, float *scaleY)
 Get the drawing scale for the current target.
FPoint SDL::GetRenderScale (RendererRef renderer)
 Get the drawing scale for the current target.
void SDL::SetRenderDrawColor (RendererRef renderer, ColorRaw c)
 Set the color used for drawing operations.
void SDL::SetRenderDrawColorFloat (RendererRef renderer, const FColorRaw &c)
 Set the color used for drawing operations (Rect, Line and Clear).
void SDL::GetRenderDrawColor (RendererRef renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
 Get the color used for drawing operations (Rect, Line and Clear).
Color SDL::GetRenderDrawColor (RendererRef renderer)
 Get the color used for drawing operations (Rect, Line and Clear).
void SDL::GetRenderDrawColorFloat (RendererRef renderer, float *r, float *g, float *b, float *a)
 Get the color used for drawing operations (Rect, Line and Clear).
FColor SDL::GetRenderDrawColorFloat (RendererRef renderer)
 Get the color used for drawing operations (Rect, Line and Clear).
void SDL::SetRenderColorScale (RendererRef renderer, float scale)
 Set the color scale used for render operations.
float SDL::GetRenderColorScale (RendererRef renderer)
 Get the color scale used for render operations.
void SDL::SetRenderDrawBlendMode (RendererRef renderer, BlendMode blendMode)
 Set the blend mode used for drawing operations (Fill and Line).
BlendMode SDL::GetRenderDrawBlendMode (RendererRef renderer)
 Get the blend mode used for drawing operations.
void SDL::RenderClear (RendererRef renderer)
 Clear the current rendering target with the drawing color.
void SDL::RenderPoint (RendererRef renderer, const FPointRaw &p)
 Draw a point on the current rendering target at subpixel precision.
void SDL::RenderPoints (RendererRef renderer, SpanRef< const FPointRaw > points)
 Draw multiple points on the current rendering target at subpixel precision.
void SDL::RenderLine (RendererRef renderer, const FPointRaw &p1, const FPointRaw &p2)
 Draw a line on the current rendering target at subpixel precision.
void SDL::RenderLines (RendererRef renderer, SpanRef< const FPointRaw > points)
 Draw a series of connected lines on the current rendering target at subpixel precision.
void SDL::RenderRect (RendererRef renderer, OptionalRef< const FRectRaw > rect)
 Draw a rectangle on the current rendering target at subpixel precision.
void SDL::RenderRects (RendererRef renderer, SpanRef< const FRectRaw > rects)
 Draw some number of rectangles on the current rendering target at subpixel precision.
void SDL::RenderFillRect (RendererRef renderer, OptionalRef< const FRectRaw > rect)
 Fill a rectangle on the current rendering target with the drawing color at subpixel precision.
void SDL::RenderFillRects (RendererRef renderer, SpanRef< const FRectRaw > rects)
 Fill some number of rectangles on the current rendering target with the drawing color at subpixel precision.
void SDL::RenderTexture (RendererRef renderer, TextureRef texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FRectRaw > dstrect)
 Copy a portion of the texture to the current rendering target at subpixel precision.
void SDL::RenderTextureRotated (RendererRef renderer, TextureRef texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FRectRaw > dstrect, double angle, OptionalRef< const FPointRaw > center, FlipMode flip=FlipMode::SDL_FLIP_NONE)
 Copy a portion of the source texture to the current rendering target, with rotation and flipping, at subpixel precision.
void SDL::RenderTextureAffine (RendererRef renderer, TextureRef texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FPointRaw > origin, OptionalRef< const FPointRaw > right, OptionalRef< const FPointRaw > down)
 Copy a portion of the source texture to the current rendering target, with affine transform, at subpixel precision.
void SDL::RenderTextureTiled (RendererRef renderer, TextureRef texture, OptionalRef< const FRectRaw > srcrect, float scale, OptionalRef< const FRectRaw > dstrect)
 Tile a portion of the texture to the current rendering target at subpixel precision.
void SDL::RenderTexture9Grid (RendererRef renderer, TextureRef texture, OptionalRef< const FRectRaw > srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, OptionalRef< const FRectRaw > dstrect)
 Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precision.
void SDL::RenderTexture9GridTiled (RendererRef renderer, TextureRef texture, const FRectRaw &srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const FRectRaw &dstrect, float tileScale)
 Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precision.
void SDL::RenderGeometry (RendererRef renderer, TextureRef texture, std::span< const Vertex > vertices, std::span< const int > indices={})
 Render a list of triangles, optionally using a texture and indices into the vertex array Color and alpha modulation is done per vertex (Texture.SetColorMod and Texture.SetAlphaMod are ignored).
void SDL::RenderGeometryRaw (RendererRef renderer, TextureRef texture, const float *xy, int xy_stride, const FColor *color, int color_stride, const float *uv, int uv_stride, int num_vertices, const void *indices, int num_indices, int size_indices)
 Render a list of triangles, optionally using a texture and indices into the vertex arrays Color and alpha modulation is done per vertex (Texture.SetColorMod and Texture.SetAlphaMod are ignored).
void SDL::SetRenderTextureAddressMode (RendererRef renderer, TextureAddressMode u_mode, TextureAddressMode v_mode)
 Set the texture addressing mode used in Renderer.RenderGeometry().
void SDL::GetRenderTextureAddressMode (RendererRef renderer, TextureAddressMode *u_mode, TextureAddressMode *v_mode)
 Get the texture addressing mode used in Renderer.RenderGeometry().
Surface SDL::RenderReadPixels (RendererRef renderer, OptionalRef< const RectRaw > rect={})
 Read pixels from the current rendering target.
void SDL::RenderPresent (RendererRef renderer)
 Update the screen with any rendering performed since the previous call.
void SDL::DestroyTexture (TextureRaw texture)
 Destroy the specified texture.
void SDL::DestroyRenderer (RendererRaw renderer)
 Destroy the rendering context for a window and free all associated textures.
void SDL::FlushRenderer (RendererRef renderer)
 Force the rendering context to flush any pending commands and state.
void * SDL::GetRenderMetalLayer (RendererRef renderer)
 Get the CAMetalLayer associated with the given Metal renderer.
void * SDL::GetRenderMetalCommandEncoder (RendererRef renderer)
 Get the Metal command encoder for the current frame.
void SDL::AddVulkanRenderSemaphores (RendererRef renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore)
 Add a set of synchronization semaphores for the current frame.
void SDL::SetRenderVSync (RendererRef renderer, int vsync)
 Toggle VSync of the given renderer.
int SDL::GetRenderVSync (RendererRef renderer)
 Get VSync of the given renderer.
void SDL::RenderDebugText (RendererRef renderer, const FPointRaw &p, StringParam str)
 Draw debug text to an Renderer.
template<class... ARGS>
void SDL::RenderDebugTextFormat (RendererRef renderer, const FPointRaw &p, std::string_view fmt, ARGS... args)
 Draw debug text to an Renderer.
void SDL::SetDefaultTextureScaleMode (RendererRef renderer, ScaleMode scale_mode)
 Set default scale mode for new textures for given renderer.
void SDL::GetDefaultTextureScaleMode (RendererRef renderer, ScaleMode *scale_mode)
 Get default texture scale mode of the given renderer.
GPURenderState SDL::CreateGPURenderState (RendererRef renderer, const GPURenderStateCreateInfo &createinfo)
 Create custom GPU render state.
void SDL::SetGPURenderStateFragmentUniforms (GPURenderStateRef state, Uint32 slot_index, const void *data, Uint32 length)
 Set fragment shader uniform variables in a custom GPU render state.
void SDL::SetGPURenderState (RendererRef renderer, GPURenderStateRef state)
 Set custom GPU render state.
void SDL::DestroyGPURenderState (GPURenderStateRaw state)
 Destroy custom GPU render state.
 SDL::Window::Window (StringParam title, const PointRaw &size, WindowFlags window_flags, RendererRef *renderer)
 Create a window and default renderer.
 SDL::Renderer::Renderer (WindowRef window, StringParam name=nullptr)
 Create a 2D rendering context for a window.
 SDL::Renderer::Renderer (PropertiesRef props)
 Create a 2D rendering context for a window, with the specified properties.
 SDL::Renderer::Renderer (SurfaceRef surface)
 Create a 2D software rendering context for a surface.
GPUDeviceRef SDL::Renderer::GetGPUDevice ()
 Return the GPU device used by a renderer.
RendererRef SDL::Window::GetRenderer () const
 Get the renderer associated with a window.
WindowRef SDL::Renderer::GetWindow ()
 Get the window associated with a renderer.
const char * SDL::Renderer::GetName () const
 Get the name of a renderer.
PropertiesRef SDL::Renderer::GetProperties () const
 Get the properties associated with a renderer.
void SDL::Renderer::GetOutputSize (int *w, int *h) const
 Get the output size in pixels of a rendering context.
Point SDL::Renderer::GetOutputSize () const
 Get the output size in pixels of a rendering context.
void SDL::Renderer::GetCurrentOutputSize (int *w, int *h) const
 Get the current output size in pixels of a rendering context.
Point SDL::Renderer::GetCurrentOutputSize () const
 Get the current output size in pixels of a rendering context.
Texture SDL::Renderer::CreateTexture (PixelFormat format, TextureAccess access, const PointRaw &size)
 Create a texture for a rendering context.
 SDL::Texture::Texture (RendererRef renderer, PixelFormat format, TextureAccess access, const PointRaw &size)
 Create a texture for a rendering context.
 SDL::Texture::Texture (RendererRef renderer, SurfaceRef surface)
 Create a texture from an existing surface.
 SDL::Texture::Texture (RendererRef renderer, PropertiesRef props)
 Create a texture for a rendering context with the specified properties.
Texture SDL::Renderer::CreateTextureFromSurface (SurfaceRef surface)
 Create a texture from an existing surface.
Texture SDL::Renderer::CreateTextureWithProperties (PropertiesRef props)
 Create a texture for a rendering context with the specified properties.
PropertiesRef SDL::Texture::GetProperties () const
 Get the properties associated with a texture.
RendererRef SDL::Texture::GetRenderer () const
 Get the renderer that created an Texture.
void SDL::Texture::GetSize (float *w, float *h) const
 Get the size of a texture, as floating point values.
Point SDL::Texture::GetSize () const
 Get the size of a texture.
FPoint SDL::Texture::GetSizeFloat () const
 Get the size of a texture, as floating point values.
int SDL::Texture::GetWidth () const
 Get the width in pixels.
int SDL::Texture::GetHeight () const
 Get the height in pixels.
PixelFormat SDL::Texture::GetFormat () const
 Get the pixel format.
void SDL::Texture::SetPalette (PaletteRef palette)
 Set the palette used by a texture.
Palette SDL::Texture::GetPalette ()
 Get the palette used by a texture.
void SDL::Texture::SetColorMod (Uint8 r, Uint8 g, Uint8 b)
 Set an additional color value multiplied into render copy operations.
void SDL::Texture::SetColorModFloat (float r, float g, float b)
 Set an additional color value multiplied into render copy operations.
void SDL::Texture::GetColorMod (Uint8 *r, Uint8 *g, Uint8 *b) const
 Get the additional color value multiplied into render copy operations.
void SDL::Texture::GetColorModFloat (float *r, float *g, float *b) const
 Get the additional color value multiplied into render copy operations.
void SDL::Texture::SetAlphaMod (Uint8 alpha)
 Set an additional alpha value multiplied into render copy operations.
void SDL::Texture::SetAlphaModFloat (float alpha)
 Set an additional alpha value multiplied into render copy operations.
Uint8 SDL::Texture::GetAlphaMod () const
 Get the additional alpha value multiplied into render copy operations.
float SDL::Texture::GetAlphaModFloat () const
 Get the additional alpha value multiplied into render copy operations.
void SDL::Texture::SetMod (Color c)
 Set an additional color and alpha values multiplied into render copy operations.
void SDL::Texture::SetModFloat (FColor c)
 Set an additional color and alpha values multiplied into render copy operations.
Color SDL::Texture::GetMod () const
 Get the additional color value multiplied into render copy operations.
FColor SDL::Texture::GetModFloat () const
 Get the additional color value multiplied into render copy operations.
void SDL::Texture::SetBlendMode (BlendMode blendMode)
 Set the blend mode for a texture, used by Renderer.RenderTexture().
BlendMode SDL::Texture::GetBlendMode () const
 Get the blend mode used for texture copy operations.
void SDL::Texture::SetScaleMode (ScaleMode scaleMode)
 Set the scale mode used for texture scale operations.
ScaleMode SDL::Texture::GetScaleMode () const
 Get the scale mode used for texture scale operations.
void SDL::Texture::Update (OptionalRef< const RectRaw > rect, const void *pixels, int pitch)
 Update the given texture rectangle with new pixel data.
void SDL::Texture::Update (SurfaceConstRef surface, OptionalRef< const RectRaw > rect=std::nullopt)
 Update the given texture rectangle with new pixel data.
void SDL::Texture::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.
void SDL::Texture::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.
TextureLock SDL::Texture::Lock (OptionalRef< const RectRaw > rect, void **pixels, int *pitch)
 Lock a portion of the texture for write-only pixel access.
 SDL::TextureLock::TextureLock (TextureRef resource, OptionalRef< const RectRaw > rect, void **pixels, int *pitch)
 Lock a portion of the texture for write-only pixel access.
TextureSurfaceLock SDL::Texture::LockToSurface (OptionalRef< const RectRaw > rect=std::nullopt)
 Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.
 SDL::TextureSurfaceLock::TextureSurfaceLock (TextureRef resource, OptionalRef< const RectRaw > rect=std::nullopt)
 Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.
void SDL::Texture::Unlock (TextureLock &&lock)
 Unlock a texture, uploading the changes to video memory, if needed.
void SDL::Texture::Unlock (TextureSurfaceLock &&lock)
 Unlock a texture, uploading the changes to video memory, if needed.
void SDL::TextureSurfaceLock::reset ()
 Unlock a texture, uploading the changes to video memory, if needed.
void SDL::TextureLock::reset ()
 Unlock a texture, uploading the changes to video memory, if needed.
void SDL::Renderer::SetTarget (TextureRef texture)
 Set a texture as the current rendering target.
void SDL::Renderer::ResetTarget ()
 Set target texture back to window.
Texture SDL::Renderer::GetTarget () const
 Get the current render target.
void SDL::Renderer::SetLogicalPresentation (const PointRaw &size, RendererLogicalPresentation mode)
 Set a device-independent resolution and presentation mode for rendering.
void SDL::Renderer::GetLogicalPresentation (int *w, int *h, RendererLogicalPresentation *mode) const
 Get device independent resolution and presentation mode for rendering.
void SDL::Renderer::GetLogicalPresentation (PointRaw *size, RendererLogicalPresentation *mode)
 Get device independent resolution and presentation mode for rendering.
FRect SDL::Renderer::GetLogicalPresentationRect () const
 Get the final presentation rectangle for rendering.
FPoint SDL::Renderer::RenderCoordinatesFromWindow (const FPointRaw &window_coord) const
 Get a point in render coordinates when given a point in window coordinates.
FPoint SDL::Renderer::RenderCoordinatesToWindow (const FPointRaw &coord) const
 Get a point in window coordinates when given a point in render coordinates.
void SDL::Renderer::ConvertEventToRenderCoordinates (Event *event) const
 Convert the coordinates in an event to render coordinates.
void SDL::Renderer::SetViewport (OptionalRef< const RectRaw > rect)
 Set the drawing area for rendering on the current target.
void SDL::Renderer::ResetViewport ()
 Reset the drawing area for rendering to the entire target.
Rect SDL::Renderer::GetViewport () const
 Get the drawing area for the current target.
bool SDL::Renderer::ViewportSet () const
 Return whether an explicit rectangle was set as the viewport.
Rect SDL::Renderer::GetSafeArea () const
 Get the safe area for rendering within the current viewport.
void SDL::Renderer::SetClipRect (OptionalRef< const RectRaw > rect)
 Set the clip rectangle for rendering on the specified target.
void SDL::Renderer::ResetClipRect ()
 Reset the clip rectangle for rendering to the entire render target.
Rect SDL::Renderer::GetClipRect () const
 Get the clip rectangle for the current target.
bool SDL::Renderer::IsClipEnabled () const
 Get whether clipping is enabled on the given render target.
void SDL::Renderer::SetScale (const FPointRaw &scale)
 Set the drawing scale for rendering on the current target.
void SDL::Renderer::GetScale (float *scaleX, float *scaleY) const
 Get the drawing scale for the current target.
FPoint SDL::Renderer::GetScale () const
 Get the drawing scale for the current target.
void SDL::Renderer::SetDrawColor (ColorRaw c)
 Set the color used for drawing operations.
void SDL::Renderer::SetDrawColorFloat (const FColorRaw &c)
 Set the color used for drawing operations (Rect, Line and Clear).
void SDL::Renderer::GetDrawColor (Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const
 Get the color used for drawing operations (Rect, Line and Clear).
Color SDL::Renderer::GetDrawColor () const
 Get the color used for drawing operations (Rect, Line and Clear).
void SDL::Renderer::GetDrawColorFloat (float *r, float *g, float *b, float *a) const
 Get the color used for drawing operations (Rect, Line and Clear).
FColor SDL::Renderer::GetDrawColorFloat () const
 Get the color used for drawing operations (Rect, Line and Clear).
void SDL::Renderer::SetColorScale (float scale)
 Set the color scale used for render operations.
float SDL::Renderer::GetColorScale () const
 Get the color scale used for render operations.
void SDL::Renderer::SetDrawBlendMode (BlendMode blendMode)
 Set the blend mode used for drawing operations (Fill and Line).
BlendMode SDL::Renderer::GetDrawBlendMode () const
 Get the blend mode used for drawing operations.
void SDL::Renderer::RenderClear ()
 Clear the current rendering target with the drawing color.
void SDL::Renderer::RenderPoint (const FPointRaw &p)
 Draw a point on the current rendering target at subpixel precision.
void SDL::Renderer::RenderPoints (SpanRef< const FPointRaw > points)
 Draw multiple points on the current rendering target at subpixel precision.
void SDL::Renderer::RenderLine (const FPointRaw &p1, const FPointRaw &p2)
 Draw a line on the current rendering target at subpixel precision.
void SDL::Renderer::RenderLines (SpanRef< const FPointRaw > points)
 Draw a series of connected lines on the current rendering target at subpixel precision.
void SDL::Renderer::RenderRect (OptionalRef< const FRectRaw > rect)
 Draw a rectangle on the current rendering target at subpixel precision.
void SDL::Renderer::RenderRects (SpanRef< const FRectRaw > rects)
 Draw some number of rectangles on the current rendering target at subpixel precision.
void SDL::Renderer::RenderFillRect (OptionalRef< const FRectRaw > rect)
 Fill a rectangle on the current rendering target with the drawing color at subpixel precision.
void SDL::Renderer::RenderFillRects (SpanRef< const FRectRaw > rects)
 Fill some number of rectangles on the current rendering target with the drawing color at subpixel precision.
void SDL::Renderer::RenderTexture (TextureRef texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FRectRaw > dstrect)
 Copy a portion of the texture to the current rendering target at subpixel precision.
void SDL::Renderer::RenderTextureRotated (TextureRef texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FRectRaw > dstrect, double angle, OptionalRef< const FPointRaw > center, FlipMode flip=FlipMode::SDL_FLIP_NONE)
 Copy a portion of the source texture to the current rendering target, with rotation and flipping, at subpixel precision.
void SDL::Renderer::RenderTextureAffine (TextureRef texture, OptionalRef< const FRectRaw > srcrect, OptionalRef< const FPointRaw > origin, OptionalRef< const FPointRaw > right, OptionalRef< const FPointRaw > down)
 Copy a portion of the source texture to the current rendering target, with affine transform, at subpixel precision.
void SDL::Renderer::RenderTextureTiled (TextureRef texture, OptionalRef< const FRectRaw > srcrect, float scale, OptionalRef< const FRectRaw > dstrect)
 Tile a portion of the texture to the current rendering target at subpixel precision.
void SDL::Renderer::RenderTexture9Grid (TextureRef texture, OptionalRef< const FRectRaw > srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, OptionalRef< const FRectRaw > dstrect)
 Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precision.
void SDL::Renderer::RenderTexture9GridTiled (TextureRef texture, const FRectRaw &srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const FRectRaw &dstrect, float tileScale)
 Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precision.
void SDL::Renderer::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 alpha modulation is done per vertex (Texture.SetColorMod and Texture.SetAlphaMod are ignored).
void SDL::Renderer::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 alpha modulation is done per vertex (Texture.SetColorMod and Texture.SetAlphaMod are ignored).
void SDL::Renderer::SetRenderTextureAddressMode (TextureAddressMode u_mode, TextureAddressMode v_mode)
 Set the texture addressing mode used in Renderer.RenderGeometry().
void SDL::Renderer::GetRenderTextureAddressMode (TextureAddressMode *u_mode, TextureAddressMode *v_mode)
 Get the texture addressing mode used in Renderer.RenderGeometry().
Surface SDL::Renderer::ReadPixels (OptionalRef< const RectRaw > rect={}) const
 Read pixels from the current rendering target.
void SDL::Renderer::Present ()
 Update the screen with any rendering performed since the previous call.
void SDL::Texture::Destroy ()
 Destroy the specified texture.
void SDL::Renderer::Destroy ()
 Destroy the rendering context for a window and free all associated textures.
void SDL::Renderer::Flush ()
 Force the rendering context to flush any pending commands and state.
void * SDL::Renderer::GetRenderMetalLayer ()
 Get the CAMetalLayer associated with the given Metal renderer.
void * SDL::Renderer::GetRenderMetalCommandEncoder ()
 Get the Metal command encoder for the current frame.
void SDL::Renderer::AddVulkanRenderSemaphores (Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore)
 Add a set of synchronization semaphores for the current frame.
void SDL::Renderer::SetVSync (int vsync)
 Toggle VSync of the given renderer.
int SDL::Renderer::GetVSync () const
 Get VSync of the given renderer.
void SDL::Renderer::RenderDebugText (const FPointRaw &p, StringParam str)
 Draw debug text to an Renderer.
template<class... ARGS>
void SDL::Renderer::RenderDebugTextFormat (const FPointRaw &p, std::string_view fmt, ARGS... args)
 Draw debug text to an Renderer.
void SDL::Renderer::SetDefaultTextureScaleMode (ScaleMode scale_mode)
 Set default scale mode for new textures for given renderer.
void SDL::Renderer::GetDefaultTextureScaleMode (ScaleMode *scale_mode)
 Get default texture scale mode of the given renderer.
GPURenderState SDL::Renderer::CreateGPURenderState (const GPURenderStateCreateInfo &createinfo)
 Create custom GPU render state.
 SDL::GPURenderState::GPURenderState (RendererRef renderer, const GPURenderStateCreateInfo &createinfo)
 Create custom GPU render state.
void SDL::GPURenderState::SetFragmentUniforms (Uint32 slot_index, const void *data, Uint32 length)
 Set fragment shader uniform variables in a custom GPU render state.
void SDL::Renderer::SetGPURenderState (GPURenderStateRef state)
 Set custom GPU render state.
void SDL::GPURenderState::Destroy ()
 Destroy custom GPU render state.

Variables

constexpr auto SDL::SOFTWARE_RENDERER = SDL_SOFTWARE_RENDERER
 The name of the software renderer.
constexpr auto SDL::GPU_RENDERER = SDL_GPU_RENDERER
 The name of the GPU renderer.
constexpr TextureAccess SDL::TEXTUREACCESS_STATIC
 Changes rarely, not lockable.
constexpr TextureAccess SDL::TEXTUREACCESS_STREAMING
 Changes frequently, lockable.
constexpr TextureAccess SDL::TEXTUREACCESS_TARGET
 Texture can be used as a render target.
constexpr TextureAddressMode SDL::TEXTURE_ADDRESS_INVALID
 TEXTURE_ADDRESS_INVALID.
constexpr TextureAddressMode SDL::TEXTURE_ADDRESS_AUTO = SDL_TEXTURE_ADDRESS_AUTO
 Wrapping is enabled if texture coordinates are outside [0, 1], this is the default.
constexpr TextureAddressMode SDL::TEXTURE_ADDRESS_CLAMP = SDL_TEXTURE_ADDRESS_CLAMP
 Texture coordinates are clamped to the [0, 1] range.
constexpr TextureAddressMode SDL::TEXTURE_ADDRESS_WRAP
 The texture is repeated (tiled).
constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_DISABLED
 There is no logical size in effect.
constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_STRETCH
 The rendered content is stretched to the output resolution.
constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_LETTERBOX
 The rendered content is fit to the largest dimension and the other dimension is letterboxed with the clear color.
constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_OVERSCAN
 The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds.
constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_INTEGER_SCALE
 The rendered content is scaled up by integer multiples to fit the output resolution.
constexpr int SDL::RENDERER_VSYNC_DISABLED = SDL_RENDERER_VSYNC_DISABLED
 Constant for disabling renderer vsync.
constexpr int SDL::RENDERER_VSYNC_ADAPTIVE = SDL_RENDERER_VSYNC_ADAPTIVE
 Constant for enabling asaptive renderer vsync.
constexpr int SDL::DEBUG_TEXT_FONT_CHARACTER_SIZE
 The size, in pixels, of a single Renderer.RenderDebugText() character.

Detailed Description

Header file for SDL 2D rendering functions.

This API supports the following features:

  • single pixel points
  • single pixel lines
  • filled rectangles
  • texture images
  • 2D polygons

The primitives may be drawn in opaque, blended, or additive modes.

The texture images may be drawn in opaque, blended, or additive modes. They can have an additional color tint or alpha modulation applied to them, and may also be stretched with linear interpolation.

This API is designed to accelerate simple 2D operations. You may want more functionality such as 3D polygons and particle effects, and in that case you should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of the many good 3D engines.

These functions must be called from the main thread. See this bug for details: https://github.com/libsdl-org/SDL/issues/986

Typedef Documentation

◆ GPURenderStateCreateInfo

using SDL::GPURenderStateCreateInfo = SDL_GPURenderStateCreateInfo

A structure specifying the parameters of a GPU render state.

Since
This struct is available since SDL 3.4.0.
See also
Renderer.CreateGPURenderState

◆ GPURenderStateRef

Reference for GPURenderState.

This does not take ownership!

◆ RendererLogicalPresentation

using SDL::RendererLogicalPresentation = SDL_RendererLogicalPresentation

How the logical size is mapped to the output.

Since
This enum is available since SDL 3.2.0.

◆ TextureAccess

using SDL::TextureAccess = SDL_TextureAccess

The access pattern allowed for a texture.

Since
This enum is available since SDL 3.2.0.

◆ TextureAddressMode

using SDL::TextureAddressMode = SDL_TextureAddressMode

The addressing mode for a texture when used in Renderer.RenderGeometry().

This affects how texture coordinates are interpreted outside of [0, 1]

Texture wrapping is always supported for power of two texture sizes, and is supported for other texture sizes if prop.Renderer.TEXTURE_WRAPPING_BOOLEAN is set to true.

Since
This enum is available since SDL 3.4.0.

◆ TextureRef

Reference for Texture.

This does not take ownership!

◆ Vertex

using SDL::Vertex = SDL_Vertex

Vertex structure.

Since
This struct is available since SDL 3.2.0.

Function Documentation

◆ AddVulkanRenderSemaphores() [1/2]

void SDL::AddVulkanRenderSemaphores ( RendererRef renderer,
Uint32 wait_stage_mask,
Sint64 wait_semaphore,
Sint64 signal_semaphore )
inline

Add a set of synchronization semaphores for the current frame.

The Vulkan renderer will wait for wait_semaphore before submitting rendering commands and signal signal_semaphore after rendering commands are complete for this frame.

This should be called each frame that you want semaphore synchronization. The Vulkan renderer may have multiple frames in flight on the GPU, so you should have multiple semaphores that are used for synchronization. Querying prop.Renderer.VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the maximum number of semaphores you'll need.

Parameters
rendererthe rendering context.
wait_stage_maskthe VkPipelineStageFlags for the wait.
wait_semaphorea VkSempahore to wait on before rendering the current frame, or 0 if not needed.
signal_semaphorea VkSempahore that SDL will signal when rendering for the current frame is complete, or 0 if not needed.
Exceptions
Erroron failure.
Thread safety:
It is NOT safe to call this function from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ AddVulkanRenderSemaphores() [2/2]

void SDL::Renderer::AddVulkanRenderSemaphores ( Uint32 wait_stage_mask,
Sint64 wait_semaphore,
Sint64 signal_semaphore )
inline

Add a set of synchronization semaphores for the current frame.

The Vulkan renderer will wait for wait_semaphore before submitting rendering commands and signal signal_semaphore after rendering commands are complete for this frame.

This should be called each frame that you want semaphore synchronization. The Vulkan renderer may have multiple frames in flight on the GPU, so you should have multiple semaphores that are used for synchronization. Querying prop.Renderer.VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the maximum number of semaphores you'll need.

Parameters
wait_stage_maskthe VkPipelineStageFlags for the wait.
wait_semaphorea VkSempahore to wait on before rendering the current frame, or 0 if not needed.
signal_semaphorea VkSempahore that SDL will signal when rendering for the current frame is complete, or 0 if not needed.
Exceptions
Erroron failure.
Thread safety:
It is NOT safe to call this function from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ConvertEventToRenderCoordinates() [1/2]

void SDL::ConvertEventToRenderCoordinates ( RendererRef renderer,
Event * event )
inline

Convert the coordinates in an event to render coordinates.

This takes into account several states:

Various event types are converted with this function: mouse, touch, pen, etc.

Touch coordinates are converted from normalized coordinates in the window to non-normalized rendering coordinates.

Relative mouse coordinates (xrel and yrel event fields) are also converted. Applications that do not want these fields converted should use Renderer.RenderCoordinatesFromWindow() on the specific event fields instead of converting the entire event structure.

Once converted, coordinates may be outside the rendering area.

Parameters
rendererthe rendering context.
eventthe event to modify.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderCoordinatesFromWindow

◆ ConvertEventToRenderCoordinates() [2/2]

void SDL::Renderer::ConvertEventToRenderCoordinates ( Event * event) const
inline

Convert the coordinates in an event to render coordinates.

This takes into account several states:

Various event types are converted with this function: mouse, touch, pen, etc.

Touch coordinates are converted from normalized coordinates in the window to non-normalized rendering coordinates.

Relative mouse coordinates (xrel and yrel event fields) are also converted. Applications that do not want these fields converted should use Renderer.RenderCoordinatesFromWindow() on the specific event fields instead of converting the entire event structure.

Once converted, coordinates may be outside the rendering area.

Parameters
eventthe event to modify.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderCoordinatesFromWindow

◆ CreateGPURenderer()

RendererRef SDL::CreateGPURenderer ( GPUDeviceRef device,
WindowRef window )
inline

Create a 2D GPU rendering context.

The GPU device to use is passed in as a parameter. If this is nullptr, then a device will be created normally and can be retrieved using Renderer.GetGPUDevice().

The window to use is passed in as a parameter. If this is nullptr, then this will become an offscreen renderer. In that case, you should call Renderer.SetTarget() to setup rendering to a texture, and then call Renderer.Present() normally to complete drawing a frame.

Parameters
devicethe GPU device to use with the renderer, or nullptr to create a device.
windowthe window where rendering is displayed, or nullptr to create an offscreen renderer.
Returns
a valid rendering context or nullptr if there was an error; call GetError() for more information.
Thread safety:
If this function is called with a valid GPU device, it should be called on the thread that created the device. If this function is called with a valid window, it should be called on the thread that created the window.
Since
This function is available since SDL 3.4.0.
See also
CreateRendererWithProperties
Renderer.GetGPUDevice
GPUDevice.CreateShader
Renderer.CreateGPURenderState
Renderer.SetGPURenderState

◆ CreateGPURenderState() [1/2]

GPURenderState SDL::CreateGPURenderState ( RendererRef renderer,
const GPURenderStateCreateInfo & createinfo )
inline

Create custom GPU render state.

Parameters
rendererthe renderer to use.
createinfoa struct describing the GPU render state to create.
Returns
a custom GPU render state or nullptr on failure; call GetError() for more information.
Thread safety:
This function should be called on the thread that created the renderer.
Since
This function is available since SDL 3.4.0.
See also
GPURenderState.SetFragmentUniforms
Renderer.SetGPURenderState
GPURenderState.Destroy

◆ CreateGPURenderState() [2/2]

GPURenderState SDL::Renderer::CreateGPURenderState ( const GPURenderStateCreateInfo & createinfo)
inline

Create custom GPU render state.

Parameters
createinfoa struct describing the GPU render state to create.
Returns
a custom GPU render state or nullptr on failure; call GetError() for more information.
Thread safety:
This function should be called on the thread that created the renderer.
Since
This function is available since SDL 3.4.0.
See also
GPURenderState.SetFragmentUniforms
Renderer.SetGPURenderState
GPURenderState.Destroy

◆ CreateRenderer()

Renderer SDL::CreateRenderer ( WindowRef window,
StringParam name = nullptr )
inline

Create a 2D rendering context for a window.

If you want a specific renderer, you can specify its name here. A list of available renderers can be obtained by calling GetRenderDriver() multiple times, with indices from 0 to GetNumRenderDrivers()-1. If you don't need a specific renderer, specify nullptr and SDL will attempt to choose the best option for you, based on what is available on the user's system.

If name is a comma-separated list, SDL will try each name, in the order listed, until one succeeds or all of them fail.

By default the rendering size matches the window size in pixels, but you can call Renderer.SetLogicalPresentation() to change the content size and scaling options.

Parameters
windowthe window where rendering is displayed.
namethe name of the rendering driver to initialize, or nullptr to let SDL choose one.
Returns
a valid rendering context or nullptr if there was an error; call GetError() for more information.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRendererWithProperties
CreateSoftwareRenderer
Renderer.Destroy
GetNumRenderDrivers
GetRenderDriver
Renderer.GetName

◆ CreateRendererWithProperties()

Renderer SDL::CreateRendererWithProperties ( PropertiesRef props)
inline

Create a 2D rendering context for a window, with the specified properties.

These are the supported properties:

With the SDL GPU renderer (since SDL 3.4.0):

With the vulkan renderer:

Parameters
propsthe properties to use.
Returns
a valid rendering context or nullptr if there was an error; call GetError() for more information.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Properties.Create
CreateRenderer
CreateSoftwareRenderer
Renderer.Destroy
Renderer.GetName

◆ CreateSoftwareRenderer()

Renderer SDL::CreateSoftwareRenderer ( SurfaceRef surface)
inline

Create a 2D software rendering context for a surface.

Two other API which can be used to create Renderer: CreateRenderer() and CreateWindowAndRenderer(). These can also create a software renderer, but they are intended to be used with an Window as the final destination and not an Surface.

Parameters
surfacethe Surface structure representing the surface where rendering is done.
Returns
a valid rendering context or nullptr if there was an error; call GetError() for more information.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.Destroy

◆ CreateTexture() [1/2]

Texture SDL::CreateTexture ( RendererRef renderer,
PixelFormat format,
TextureAccess access,
const PointRaw & size )
inline

Create a texture for a rendering context.

The contents of a texture when first created are not defined.

Parameters
rendererthe rendering context.
formatone of the enumerated values in PixelFormat.
accessone of the enumerated values in TextureAccess.
sizethe width and height of the texture in pixels.
Returns
the created texture or nullptr on failure; call GetError() for more information.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.CreateTextureFromSurface
Renderer.CreateTextureWithProperties
Texture.Destroy
Texture.GetSize
Texture.Update

◆ CreateTexture() [2/2]

Texture SDL::Renderer::CreateTexture ( PixelFormat format,
TextureAccess access,
const PointRaw & size )
inline

Create a texture for a rendering context.

The contents of a texture when first created are not defined.

Parameters
formatone of the enumerated values in PixelFormat.
accessone of the enumerated values in TextureAccess.
sizethe width and height of the texture in pixels.
Returns
the created texture or nullptr on failure; call GetError() for more information.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.CreateTextureFromSurface
Renderer.CreateTextureWithProperties
Texture.Destroy
Texture.GetSize
Texture.Update

◆ CreateTextureFromSurface() [1/2]

Texture SDL::CreateTextureFromSurface ( RendererRef renderer,
SurfaceRef surface )
inline

Create a texture from an existing surface.

The surface is not modified or freed by this function.

The TextureAccess hint for the created texture is TEXTUREACCESS_STATIC.

The pixel format of the created texture may be different from the pixel format of the surface, and can be queried using the prop.Texture.FORMAT_NUMBER property.

Parameters
rendererthe rendering context.
surfacethe Surface structure containing pixel data used to fill the texture.
Returns
the created texture or nullptr on failure; call GetError() for more information.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.CreateTexture
Renderer.CreateTextureWithProperties
Texture.Destroy

◆ CreateTextureFromSurface() [2/2]

Texture SDL::Renderer::CreateTextureFromSurface ( SurfaceRef surface)
inline

Create a texture from an existing surface.

The surface is not modified or freed by this function.

The TextureAccess hint for the created texture is TEXTUREACCESS_STATIC.

The pixel format of the created texture may be different from the pixel format of the surface, and can be queried using the prop.Texture.FORMAT_NUMBER property.

Parameters
surfacethe Surface structure containing pixel data used to fill the texture.
Returns
the created texture or nullptr on failure; call GetError() for more information.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.CreateTexture
Renderer.CreateTextureWithProperties
Texture.Destroy

◆ CreateTextureWithProperties() [1/2]

Texture SDL::CreateTextureWithProperties ( RendererRef renderer,
PropertiesRef props )
inline

Create a texture for a rendering context with the specified properties.

These are the supported properties:

With the direct3d11 renderer:

With the direct3d12 renderer:

With the metal renderer:

With the opengl renderer:

With the opengles2 renderer:

With the vulkan renderer:

With the GPU renderer:

  • prop.Texture.Create.GPU_TEXTURE_POINTER: the GPUTexture associated with the texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_NUMBER: the GPUTexture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_NUMBER: the GPUTexture associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_NUMBER: the GPUTexture associated with the V plane of a YUV texture, if you want to wrap an existing texture.
Parameters
rendererthe rendering context.
propsthe properties to use.
Returns
the created texture or nullptr on failure; call GetError() for more information.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Properties.Create
Renderer.CreateTexture
Renderer.CreateTextureFromSurface
Texture.Destroy
Texture.GetSize
Texture.Update

◆ CreateTextureWithProperties() [2/2]

Texture SDL::Renderer::CreateTextureWithProperties ( PropertiesRef props)
inline

Create a texture for a rendering context with the specified properties.

These are the supported properties:

With the direct3d11 renderer:

With the direct3d12 renderer:

With the metal renderer:

With the opengl renderer:

With the opengles2 renderer:

With the vulkan renderer:

With the GPU renderer:

  • prop.Texture.Create.GPU_TEXTURE_POINTER: the GPUTexture associated with the texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_NUMBER: the GPUTexture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_NUMBER: the GPUTexture associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_NUMBER: the GPUTexture associated with the V plane of a YUV texture, if you want to wrap an existing texture.
Parameters
propsthe properties to use.
Returns
the created texture or nullptr on failure; call GetError() for more information.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Properties.Create
Renderer.CreateTexture
Renderer.CreateTextureFromSurface
Texture.Destroy
Texture.GetSize
Texture.Update

◆ CreateWindowAndRenderer() [1/3]

Window SDL::CreateWindowAndRenderer ( StringParam title,
const PointRaw & size,
WindowFlags window_flags,
Renderer * renderer )
inline

Create a window and default renderer.

Parameters
titlethe title of the window, in UTF-8 encoding.
sizethe width and height of the window.
window_flagsthe flags used to create the window (see CreateWindow()).
renderera pointer filled with the renderer, or nullptr on error.
Returns
the created window on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRenderer
CreateWindow

◆ CreateWindowAndRenderer() [2/3]

void SDL::CreateWindowAndRenderer ( StringParam title,
const PointRaw & size,
WindowFlags window_flags,
Window * window,
Renderer * renderer )
inline

Create a window and default renderer.

Parameters
titlethe title of the window, in UTF-8 encoding.
sizethe width and height of the window.
window_flagsthe flags used to create the window (see CreateWindow()).
windowa pointer filled with the window, or nullptr on error.
renderera pointer filled with the renderer, or nullptr on error.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRenderer
CreateWindow

◆ CreateWindowAndRenderer() [3/3]

std::pair< Window, Renderer > SDL::CreateWindowAndRenderer ( StringParam title,
const PointRaw & size,
WindowFlags window_flags = 0 )
inline

Create a window and default renderer.

Parameters
titlethe title of the window, in UTF-8 encoding.
sizethe width and height of the window.
window_flagsthe flags used to create the window (see CreateWindow()).
Returns
a pair with window and renderer.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRenderer
CreateWindow

◆ CreateWindowAndRendererRaw()

void SDL::CreateWindowAndRendererRaw ( StringParam title,
const PointRaw & size,
WindowFlags window_flags,
WindowRaw * window,
RendererRaw * renderer )
inline

Create a window and default renderer.

Parameters
titlethe title of the window, in UTF-8 encoding.
sizethe width and height of the window.
window_flagsthe flags used to create the window (see Window.Window()).
windowa pointer filled with the window, or nullptr on error.
renderera pointer filled with the renderer, or nullptr on error.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.Renderer
Window.Window

◆ Destroy() [1/3]

void SDL::GPURenderState::Destroy ( )
inline

Destroy custom GPU render state.

Thread safety:
This function should be called on the thread that created the renderer.
Since
This function is available since SDL 3.4.0.
See also
Renderer.CreateGPURenderState

◆ Destroy() [2/3]

void SDL::Renderer::Destroy ( )
inline

Destroy the rendering context for a window and free all associated textures.

This should be called before destroying the associated window.

Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRenderer

◆ Destroy() [3/3]

void SDL::Texture::Destroy ( )
inline

Destroy the specified texture.

Passing nullptr or an otherwise invalid texture will set the SDL error message to "Invalid texture".

Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.CreateTexture
Renderer.CreateTextureFromSurface

◆ DestroyGPURenderState()

void SDL::DestroyGPURenderState ( GPURenderStateRaw state)
inline

Destroy custom GPU render state.

Parameters
statethe state to destroy.
Thread safety:
This function should be called on the thread that created the renderer.
Since
This function is available since SDL 3.4.0.
See also
Renderer.CreateGPURenderState

◆ DestroyRenderer()

void SDL::DestroyRenderer ( RendererRaw renderer)
inline

Destroy the rendering context for a window and free all associated textures.

This should be called before destroying the associated window.

Parameters
rendererthe rendering context.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRenderer

◆ DestroyTexture()

void SDL::DestroyTexture ( TextureRaw texture)
inline

Destroy the specified texture.

Passing nullptr or an otherwise invalid texture will set the SDL error message to "Invalid texture".

Parameters
texturethe texture to destroy.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.CreateTexture
Renderer.CreateTextureFromSurface

◆ Flush()

void SDL::Renderer::Flush ( )
inline

Force the rendering context to flush any pending commands and state.

You do not need to (and in fact, shouldn't) call this function unless you are planning to call into OpenGL/Direct3D/Metal/whatever directly, in addition to using an Renderer.

This is for a very-specific case: if you are using SDL's render API, and you plan to make OpenGL/D3D/whatever calls in addition to SDL render API calls. If this applies, you should call this function between calls to SDL's render API and the low-level API you're using in cooperation.

In all other cases, you can ignore this function.

This call makes SDL flush any pending rendering work it was queueing up to do later in a single batch, and marks any internal cached state as invalid, so it'll prepare all its state again later, from scratch.

This means you do not need to save state in your rendering code to protect the SDL renderer. However, there lots of arbitrary pieces of Direct3D and OpenGL state that can confuse things; you should use your best judgment and be prepared to make changes if specific state needs to be protected.

Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ FlushRenderer()

void SDL::FlushRenderer ( RendererRef renderer)
inline

Force the rendering context to flush any pending commands and state.

You do not need to (and in fact, shouldn't) call this function unless you are planning to call into OpenGL/Direct3D/Metal/whatever directly, in addition to using an Renderer.

This is for a very-specific case: if you are using SDL's render API, and you plan to make OpenGL/D3D/whatever calls in addition to SDL render API calls. If this applies, you should call this function between calls to SDL's render API and the low-level API you're using in cooperation.

In all other cases, you can ignore this function.

This call makes SDL flush any pending rendering work it was queueing up to do later in a single batch, and marks any internal cached state as invalid, so it'll prepare all its state again later, from scratch.

This means you do not need to save state in your rendering code to protect the SDL renderer. However, there lots of arbitrary pieces of Direct3D and OpenGL state that can confuse things; you should use your best judgment and be prepared to make changes if specific state needs to be protected.

Parameters
rendererthe rendering context.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ GetAlphaMod()

Uint8 SDL::Texture::GetAlphaMod ( ) const
inline

Get the additional alpha value multiplied into render copy operations.

Returns
the current alpha value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetAlphaModFloat
Texture.GetColorMod
Texture.SetAlphaMod

◆ GetAlphaModFloat()

float SDL::Texture::GetAlphaModFloat ( ) const
inline

Get the additional alpha value multiplied into render copy operations.

Returns
the current alpha value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetAlphaMod
Texture.GetColorModFloat
Texture.SetAlphaModFloat

◆ GetBlendMode()

BlendMode SDL::Texture::GetBlendMode ( ) const
inline

Get the blend mode used for texture copy operations.

Returns
the current SDL_BlendMode on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.SetBlendMode

◆ GetClipRect()

Rect SDL::Renderer::GetClipRect ( ) const
inline

Get the clip rectangle for the current target.

Each render target has its own clip rectangle. This function gets the cliprect for the current render target.

Returns
a Rect structure filled in with the current clipping area or an empty rectangle if clipping is disabled.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.IsClipEnabled
Renderer.SetClipRect

◆ GetColorMod()

void SDL::Texture::GetColorMod ( Uint8 * r,
Uint8 * g,
Uint8 * b ) const
inline

Get the additional color value multiplied into render copy operations.

Parameters
ra pointer filled in with the current red color value.
ga pointer filled in with the current green color value.
ba pointer filled in with the current blue color value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetAlphaMod
Texture.GetColorModFloat
Texture.SetColorMod

◆ GetColorModFloat()

void SDL::Texture::GetColorModFloat ( float * r,
float * g,
float * b ) const
inline

Get the additional color value multiplied into render copy operations.

Parameters
ra pointer filled in with the current red color value.
ga pointer filled in with the current green color value.
ba pointer filled in with the current blue color value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetAlphaModFloat
Texture.GetColorMod
Texture.SetColorModFloat

◆ GetColorScale()

float SDL::Renderer::GetColorScale ( ) const
inline

Get the color scale used for render operations.

Returns
a float representing the current color scale on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetColorScale

◆ GetCurrentOutputSize() [1/2]

Point SDL::Renderer::GetCurrentOutputSize ( ) const
inline

Get the current output size in pixels of a rendering context.

If a rendering target is active, this will return the size of the rendering target in pixels, otherwise return the value of Renderer.GetOutputSize().

Rendering target or not, the output will be adjusted by the current logical presentation state, dictated by Renderer.SetLogicalPresentation().

Returns
the size on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetOutputSize

◆ GetCurrentOutputSize() [2/2]

void SDL::Renderer::GetCurrentOutputSize ( int * w,
int * h ) const
inline

Get the current output size in pixels of a rendering context.

If a rendering target is active, this will return the size of the rendering target in pixels, otherwise return the value of Renderer.GetOutputSize().

Rendering target or not, the output will be adjusted by the current logical presentation state, dictated by Renderer.SetLogicalPresentation().

Parameters
wa pointer filled in with the current width.
ha pointer filled in with the current height.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetOutputSize

◆ GetCurrentRenderOutputSize() [1/2]

Point SDL::GetCurrentRenderOutputSize ( RendererRef renderer)
inline

Get the current output size in pixels of a rendering context.

If a rendering target is active, this will return the size of the rendering target in pixels, otherwise return the value of Renderer.GetOutputSize().

Rendering target or not, the output will be adjusted by the current logical presentation state, dictated by Renderer.SetLogicalPresentation().

Parameters
rendererthe rendering context.
Returns
the size on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetOutputSize

◆ GetCurrentRenderOutputSize() [2/2]

void SDL::GetCurrentRenderOutputSize ( RendererRef renderer,
int * w,
int * h )
inline

Get the current output size in pixels of a rendering context.

If a rendering target is active, this will return the size of the rendering target in pixels, otherwise return the value of Renderer.GetOutputSize().

Rendering target or not, the output will be adjusted by the current logical presentation state, dictated by Renderer.SetLogicalPresentation().

Parameters
rendererthe rendering context.
wa pointer filled in with the current width.
ha pointer filled in with the current height.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetOutputSize

◆ GetDefaultTextureScaleMode() [1/2]

void SDL::GetDefaultTextureScaleMode ( RendererRef renderer,
ScaleMode * scale_mode )
inline

Get default texture scale mode of the given renderer.

Parameters
rendererthe renderer to get data from.
scale_modea ScaleMode filled with current default scale mode. See Renderer.SetDefaultTextureScaleMode() for the meaning of the value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
Renderer.SetDefaultTextureScaleMode

◆ GetDefaultTextureScaleMode() [2/2]

void SDL::Renderer::GetDefaultTextureScaleMode ( ScaleMode * scale_mode)
inline

Get default texture scale mode of the given renderer.

Parameters
scale_modea ScaleMode filled with current default scale mode. See Renderer.SetDefaultTextureScaleMode() for the meaning of the value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
Renderer.SetDefaultTextureScaleMode

◆ GetDrawBlendMode()

BlendMode SDL::Renderer::GetDrawBlendMode ( ) const
inline

Get the blend mode used for drawing operations.

Returns
the current BlendMode on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetDrawBlendMode

◆ GetDrawColor() [1/2]

Color SDL::Renderer::GetDrawColor ( ) const
inline

Get the color used for drawing operations (Rect, Line and Clear).

Returns
the color channel values used to draw on the rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
GetDrawColor(SDL_FColor*)
SetDrawColor()

◆ GetDrawColor() [2/2]

void SDL::Renderer::GetDrawColor ( Uint8 * r,
Uint8 * g,
Uint8 * b,
Uint8 * a ) const
inline

Get the color used for drawing operations (Rect, Line and Clear).

Parameters
ra pointer filled in with the red value used to draw on the rendering target.
ga pointer filled in with the green value used to draw on the rendering target.
ba pointer filled in with the blue value used to draw on the rendering target.
aa pointer filled in with the alpha value used to draw on the rendering target; usually ALPHA_OPAQUE (255).
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetDrawColorFloat
Renderer.SetDrawColor

◆ GetDrawColorFloat() [1/2]

FColor SDL::Renderer::GetDrawColorFloat ( ) const
inline

Get the color used for drawing operations (Rect, Line and Clear).

Returns
the color on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
GetDrawColor(SDL_FColor*)
SetDrawColor()

◆ GetDrawColorFloat() [2/2]

void SDL::Renderer::GetDrawColorFloat ( float * r,
float * g,
float * b,
float * a ) const
inline

Get the color used for drawing operations (Rect, Line and Clear).

Parameters
ra pointer filled in with the red value used to draw on the rendering target.
ga pointer filled in with the green value used to draw on the rendering target.
ba pointer filled in with the blue value used to draw on the rendering target.
aa pointer filled in with the alpha value used to draw on the rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetDrawColorFloat
Renderer.GetDrawColor

◆ GetGPUDevice()

GPUDeviceRef SDL::Renderer::GetGPUDevice ( )
inline

Return the GPU device used by a renderer.

Returns
the GPU device used by the renderer, or nullptr if the renderer is not a GPU renderer; call GetError() for more information.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.4.0.

◆ GetGPURendererDevice()

GPUDeviceRef SDL::GetGPURendererDevice ( RendererRef renderer)
inline

Return the GPU device used by a renderer.

Parameters
rendererthe rendering context.
Returns
the GPU device used by the renderer, or nullptr if the renderer is not a GPU renderer; call GetError() for more information.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.4.0.

◆ GetLogicalPresentation() [1/2]

void SDL::Renderer::GetLogicalPresentation ( int * w,
int * h,
RendererLogicalPresentation * mode ) const
inline

Get device independent resolution and presentation mode for rendering.

This function gets the width and height of the logical rendering output, or 0 if a logical resolution is not enabled.

Each render target has its own logical presentation state. This function gets the state for the current render target.

Parameters
wan int filled with the logical presentation width.
han int filled with the logical presentation height.
modea variable filled with the logical presentation mode being used.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetLogicalPresentation

◆ GetLogicalPresentation() [2/2]

void SDL::Renderer::GetLogicalPresentation ( PointRaw * size,
RendererLogicalPresentation * mode )
inline

Get device independent resolution and presentation mode for rendering.

This function gets the width and height of the logical rendering output, or 0 if a logical resolution is not enabled.

Each render target has its own logical presentation state. This function gets the state for the current render target.

Parameters
sizea Point to be filled with the width and height.
modea variable filled with the logical presentation mode being used.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetLogicalPresentation

◆ GetLogicalPresentationRect()

FRect SDL::Renderer::GetLogicalPresentationRect ( ) const
inline

Get the final presentation rectangle for rendering.

This function returns the calculated rectangle used for logical presentation, based on the presentation mode and output size. If logical presentation is disabled, it will fill the rectangle with the output size, in pixels.

Each render target has its own logical presentation state. This function gets the rectangle for the current render target.

Returns
the final presentation rectangle.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetLogicalPresentation

◆ GetMod()

Color SDL::Texture::GetMod ( ) const
inline

Get the additional color value multiplied into render copy operations.

Returns
the color channels (0-1) on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
GetAlphaMod()
SetColorMod()

◆ GetModFloat()

FColor SDL::Texture::GetModFloat ( ) const
inline

Get the additional color value multiplied into render copy operations.

Returns
the color channels (0-1) on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
GetAlphaMod()
SetColorMod()

◆ GetName()

const char * SDL::Renderer::GetName ( ) const
inline

Get the name of a renderer.

Returns
the name of the selected renderer on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRenderer
CreateRendererWithProperties

◆ GetNumRenderDrivers()

int SDL::GetNumRenderDrivers ( )
inline

Get the number of 2D rendering drivers available for the current display.

A render driver is a set of code that handles rendering and texture management on a particular display. Normally there is only one, but some drivers may have several available with different capabilities.

There may be none if SDL was compiled without render support.

Returns
the number of built in render drivers.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRenderer
GetRenderDriver

◆ GetOutputSize() [1/2]

Point SDL::Renderer::GetOutputSize ( ) const
inline

Get the output size in pixels of a rendering context.

This returns the true output size in pixels, ignoring any render targets or logical size and presentation.

For the output size of the current rendering target, with logical size adjustments, use Renderer.GetCurrentOutputSize() instead.

Returns
Point on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetCurrentOutputSize

◆ GetOutputSize() [2/2]

void SDL::Renderer::GetOutputSize ( int * w,
int * h ) const
inline

Get the output size in pixels of a rendering context.

This returns the true output size in pixels, ignoring any render targets or logical size and presentation.

For the output size of the current rendering target, with logical size adjustments, use Renderer.GetCurrentOutputSize() instead.

Parameters
wa pointer filled in with the width in pixels.
ha pointer filled in with the height in pixels.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetCurrentOutputSize

◆ GetPalette()

Palette SDL::Texture::GetPalette ( )
inline

Get the palette used by a texture.

Returns
a pointer to the palette used by the texture, or nullptr if there is no palette used.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
Texture.SetPalette

◆ GetProperties() [1/2]

PropertiesRef SDL::Renderer::GetProperties ( ) const
inline

Get the properties associated with a renderer.

The following read-only properties are provided by SDL:

With the direct3d renderer:

With the direct3d11 renderer:

With the direct3d12 renderer:

With the vulkan renderer:

With the gpu renderer:

Returns
a valid property ID on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ GetProperties() [2/2]

PropertiesRef SDL::Texture::GetProperties ( ) const
inline

Get the properties associated with a texture.

The following read-only properties are provided by SDL:

With the direct3d11 renderer:

With the direct3d12 renderer:

With the vulkan renderer:

With the opengl renderer:

With the opengles2 renderer:

With the gpu renderer:

Returns
a valid property ID on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ GetRenderClipRect()

Rect SDL::GetRenderClipRect ( RendererRef renderer)
inline

Get the clip rectangle for the current target.

Each render target has its own clip rectangle. This function gets the cliprect for the current render target.

Parameters
rendererthe rendering context.
Returns
an Rect structure filled in with the current clipping area or an empty rectangle if clipping is disabled.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.IsClipEnabled
Renderer.SetClipRect

◆ GetRenderColorScale()

float SDL::GetRenderColorScale ( RendererRef renderer)
inline

Get the color scale used for render operations.

Parameters
rendererthe rendering context.
Returns
the current color scale value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetColorScale

◆ GetRenderDrawBlendMode()

BlendMode SDL::GetRenderDrawBlendMode ( RendererRef renderer)
inline

Get the blend mode used for drawing operations.

Parameters
rendererthe rendering context.
Returns
the current BlendMode.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetDrawBlendMode

◆ GetRenderDrawColor() [1/2]

Color SDL::GetRenderDrawColor ( RendererRef renderer)
inline

Get the color used for drawing operations (Rect, Line and Clear).

Parameters
rendererthe rendering context.
Returns
the color channel values used to draw on the rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetDrawColorFloat
Renderer.SetDrawColor

◆ GetRenderDrawColor() [2/2]

void SDL::GetRenderDrawColor ( RendererRef renderer,
Uint8 * r,
Uint8 * g,
Uint8 * b,
Uint8 * a )
inline

Get the color used for drawing operations (Rect, Line and Clear).

Parameters
rendererthe rendering context.
ra pointer filled in with the red value used to draw on the rendering target.
ga pointer filled in with the green value used to draw on the rendering target.
ba pointer filled in with the blue value used to draw on the rendering target.
aa pointer filled in with the alpha value used to draw on the rendering target; usually ALPHA_OPAQUE (255).
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetDrawColorFloat
Renderer.SetDrawColor

◆ GetRenderDrawColorFloat() [1/2]

FColor SDL::GetRenderDrawColorFloat ( RendererRef renderer)
inline

Get the color used for drawing operations (Rect, Line and Clear).

Parameters
rendererthe rendering context.
Returns
the color on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetDrawColorFloat
Renderer.GetDrawColor

◆ GetRenderDrawColorFloat() [2/2]

void SDL::GetRenderDrawColorFloat ( RendererRef renderer,
float * r,
float * g,
float * b,
float * a )
inline

Get the color used for drawing operations (Rect, Line and Clear).

Parameters
rendererthe rendering context.
ra pointer filled in with the red value used to draw on the rendering target.
ga pointer filled in with the green value used to draw on the rendering target.
ba pointer filled in with the blue value used to draw on the rendering target.
aa pointer filled in with the alpha value used to draw on the rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetDrawColorFloat
Renderer.GetDrawColor

◆ GetRenderDriver()

const char * SDL::GetRenderDriver ( int index)
inline

Use this function to get the name of a built in 2D rendering driver.

The list of rendering drivers is given in the order that they are normally initialized by default; the drivers that seem more reasonable to choose first (as far as the SDL developers believe) are earlier in the list.

The names of drivers are all simple, low-ASCII identifiers, like "opengl", "direct3d12" or "metal". These never have Unicode characters, and are not meant to be proper names.

Parameters
indexthe index of the rendering driver; the value ranges from 0 to GetNumRenderDrivers() - 1.
Returns
the name of the rendering driver at the requested index, or nullptr if an invalid index was specified.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
GetNumRenderDrivers

◆ GetRenderer() [1/2]

RendererRef SDL::Texture::GetRenderer ( ) const
inline

Get the renderer that created an Texture.

Returns
a pointer to the Renderer that created the texture on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ GetRenderer() [2/2]

RendererRef SDL::Window::GetRenderer ( ) const
inline

Get the renderer associated with a window.

Returns
the rendering context on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ GetRendererFromTexture()

RendererRef SDL::GetRendererFromTexture ( TextureConstRef texture)
inline

Get the renderer that created an Texture.

Parameters
texturethe texture to query.
Returns
a pointer to the Renderer that created the texture on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ GetRendererName()

const char * SDL::GetRendererName ( RendererRef renderer)
inline

Get the name of a renderer.

Parameters
rendererthe rendering context.
Returns
the name of the selected renderer on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRenderer
CreateRendererWithProperties

◆ GetRendererProperties()

PropertiesRef SDL::GetRendererProperties ( RendererRef renderer)
inline

Get the properties associated with a renderer.

The following read-only properties are provided by SDL:

With the direct3d renderer:

With the direct3d11 renderer:

With the direct3d12 renderer:

With the vulkan renderer:

With the gpu renderer:

Parameters
rendererthe rendering context.
Returns
a valid property ID on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ GetRenderLogicalPresentation() [1/2]

void SDL::GetRenderLogicalPresentation ( RendererRef renderer,
int * w,
int * h,
RendererLogicalPresentation * mode )
inline

Get device independent resolution and presentation mode for rendering.

This function gets the width and height of the logical rendering output, or 0 if a logical resolution is not enabled.

Each render target has its own logical presentation state. This function gets the state for the current render target.

Parameters
rendererthe rendering context.
wan int filled with the logical presentation width.
han int filled with the logical presentation height.
modea variable filled with the logical presentation mode being used.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetLogicalPresentation

◆ GetRenderLogicalPresentation() [2/2]

void SDL::GetRenderLogicalPresentation ( RendererRef renderer,
PointRaw * size,
RendererLogicalPresentation * mode )
inline

Get device independent resolution and presentation mode for rendering.

This function gets the width and height of the logical rendering output, or 0 if a logical resolution is not enabled.

Each render target has its own logical presentation state. This function gets the state for the current render target.

Parameters
rendererthe rendering context.
sizea Point to be filled with the logical presentation width and height.
modea variable filled with the logical presentation mode being used.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetLogicalPresentation

◆ GetRenderLogicalPresentationRect()

FRect SDL::GetRenderLogicalPresentationRect ( RendererRef renderer)
inline

Get the final presentation rectangle for rendering.

This function returns the calculated rectangle used for logical presentation, based on the presentation mode and output size. If logical presentation is disabled, it will fill the rectangle with the output size, in pixels.

Each render target has its own logical presentation state. This function gets the rectangle for the current render target.

Parameters
rendererthe rendering context.
Returns
with the final presentation rectangle.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetLogicalPresentation

◆ GetRenderMetalCommandEncoder() [1/2]

void * SDL::GetRenderMetalCommandEncoder ( RendererRef renderer)
inline

Get the Metal command encoder for the current frame.

This function returns void *, so SDL doesn't have to include Metal's headers, but it can be safely cast to an id<MTLRenderCommandEncoder>.

This will return nullptr if Metal refuses to give SDL a drawable to render to, which might happen if the window is hidden/minimized/offscreen. This doesn't apply to command encoders for render targets, just the window's backbuffer. Check your return values!

Parameters
rendererthe renderer to query.
Returns
an id<MTLRenderCommandEncoder> on success, or nullptr if the renderer isn't a Metal renderer or there was an error.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetRenderMetalLayer

◆ GetRenderMetalCommandEncoder() [2/2]

void * SDL::Renderer::GetRenderMetalCommandEncoder ( )
inline

Get the Metal command encoder for the current frame.

This function returns void *, so SDL doesn't have to include Metal's headers, but it can be safely cast to an id<MTLRenderCommandEncoder>.

This will return nullptr if Metal refuses to give SDL a drawable to render to, which might happen if the window is hidden/minimized/offscreen. This doesn't apply to command encoders for render targets, just the window's backbuffer. Check your return values!

Returns
an id<MTLRenderCommandEncoder> on success, or nullptr if the renderer isn't a Metal renderer or there was an error.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetRenderMetalLayer

◆ GetRenderMetalLayer() [1/2]

void * SDL::GetRenderMetalLayer ( RendererRef renderer)
inline

Get the CAMetalLayer associated with the given Metal renderer.

This function returns void *, so SDL doesn't have to include Metal's headers, but it can be safely cast to a CAMetalLayer *.

Parameters
rendererthe renderer to query.
Returns
a CAMetalLayer * on success, or nullptr if the renderer isn't a Metal renderer.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetRenderMetalCommandEncoder

◆ GetRenderMetalLayer() [2/2]

void * SDL::Renderer::GetRenderMetalLayer ( )
inline

Get the CAMetalLayer associated with the given Metal renderer.

This function returns void *, so SDL doesn't have to include Metal's headers, but it can be safely cast to a CAMetalLayer *.

Returns
a CAMetalLayer * on success, or nullptr if the renderer isn't a Metal renderer.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetRenderMetalCommandEncoder

◆ GetRenderOutputSize() [1/2]

Point SDL::GetRenderOutputSize ( RendererRef renderer)
inline

Get the output size in pixels of a rendering context.

This returns the true output size in pixels, ignoring any render targets or logical size and presentation.

For the output size of the current rendering target, with logical size adjustments, use Renderer.GetCurrentOutputSize() instead.

Parameters
rendererthe rendering context.
Returns
the size on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetCurrentOutputSize

◆ GetRenderOutputSize() [2/2]

void SDL::GetRenderOutputSize ( RendererRef renderer,
int * w,
int * h )
inline

Get the output size in pixels of a rendering context.

This returns the true output size in pixels, ignoring any render targets or logical size and presentation.

For the output size of the current rendering target, with logical size adjustments, use Renderer.GetCurrentOutputSize() instead.

Parameters
rendererthe rendering context.
wa pointer filled in with the width in pixels.
ha pointer filled in with the height in pixels.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetCurrentOutputSize

◆ GetRenderSafeArea()

Rect SDL::GetRenderSafeArea ( RendererRef renderer)
inline

Get the safe area for rendering within the current viewport.

Some devices have portions of the screen which are partially obscured or not interactive, possibly due to on-screen controls, curved edges, camera notches, TV overscan, etc. This function provides the area of the current viewport which is safe to have interactible content. You should continue rendering into the rest of the render target, but it should not contain visually important or interactible content.

Parameters
rendererthe rendering context.
Returns
the area that is safe for interactive content.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ GetRenderScale() [1/2]

FPoint SDL::GetRenderScale ( RendererRef renderer)
inline

Get the drawing scale for the current target.

Each render target has its own scale. This function gets the scale for the current render target.

Returns
the scaling factors on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetScale

◆ GetRenderScale() [2/2]

void SDL::GetRenderScale ( RendererRef renderer,
float * scaleX,
float * scaleY )
inline

Get the drawing scale for the current target.

Each render target has its own scale. This function gets the scale for the current render target.

Parameters
rendererthe rendering context.
scaleXa pointer filled in with the horizontal scaling factor.
scaleYa pointer filled in with the vertical scaling factor.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetScale

◆ GetRenderTarget()

Texture SDL::GetRenderTarget ( RendererRef renderer)
inline

Get the current render target.

The default render target is the window for which the renderer was created, and is reported a nullptr here.

Parameters
rendererthe rendering context.
Returns
the current render target or nullptr for the default render target.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetTarget

◆ GetRenderTextureAddressMode() [1/2]

void SDL::GetRenderTextureAddressMode ( RendererRef renderer,
TextureAddressMode * u_mode,
TextureAddressMode * v_mode )
inline

Get the texture addressing mode used in Renderer.RenderGeometry().

Parameters
rendererthe rendering context.
u_modea pointer filled in with the TextureAddressMode to use for horizontal texture coordinates in Renderer.RenderGeometry(), may be nullptr.
v_modea pointer filled in with the TextureAddressMode to use for vertical texture coordinates in Renderer.RenderGeometry(), may be nullptr.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
Renderer.SetRenderTextureAddressMode

◆ GetRenderTextureAddressMode() [2/2]

void SDL::Renderer::GetRenderTextureAddressMode ( TextureAddressMode * u_mode,
TextureAddressMode * v_mode )
inline

Get the texture addressing mode used in Renderer.RenderGeometry().

Parameters
u_modea pointer filled in with the TextureAddressMode to use for horizontal texture coordinates in Renderer.RenderGeometry(), may be nullptr.
v_modea pointer filled in with the TextureAddressMode to use for vertical texture coordinates in Renderer.RenderGeometry(), may be nullptr.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
Renderer.SetRenderTextureAddressMode

◆ GetRenderViewport()

Rect SDL::GetRenderViewport ( RendererRef renderer)
inline

Get the drawing area for the current target.

Each render target has its own viewport. This function gets the viewport for the current render target.

Parameters
rendererthe rendering context.
Returns
an Rect structure filled in with the current drawing area.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.ViewportSet
Renderer.SetViewport

◆ GetRenderVSync()

int SDL::GetRenderVSync ( RendererRef renderer)
inline

Get VSync of the given renderer.

Parameters
rendererthe renderer to toggle.
Returns
the current vertical refresh sync interval. See Renderer.SetVSync() for the meaning of the value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetVSync

◆ GetRenderWindow()

WindowRef SDL::GetRenderWindow ( RendererRef renderer)
inline

Get the window associated with a renderer.

Parameters
rendererthe renderer to query.
Returns
the window on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ GetSafeArea()

Rect SDL::Renderer::GetSafeArea ( ) const
inline

Get the safe area for rendering within the current viewport.

Some devices have portions of the screen which are partially obscured or not interactive, possibly due to on-screen controls, curved edges, camera notches, TV overscan, etc. This function provides the area of the current viewport which is safe to have interactible content. You should continue rendering into the rest of the render target, but it should not contain visually important or interactible content.

Returns
the rect filled the area that is safe for interactive content.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ GetScale() [1/2]

FPoint SDL::Renderer::GetScale ( ) const
inline

Get the drawing scale for the current target.

Each render target has its own scale. This function gets the scale for the current render target.

Returns
the scaling factors on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetScale

◆ GetScale() [2/2]

void SDL::Renderer::GetScale ( float * scaleX,
float * scaleY ) const
inline

Get the drawing scale for the current target.

Each render target has its own scale. This function gets the scale for the current render target.

Parameters
scaleXa pointer filled in with the horizontal scaling factor.
scaleYa pointer filled in with the vertical scaling factor.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetScale

◆ GetScaleMode()

ScaleMode SDL::Texture::GetScaleMode ( ) const
inline

Get the scale mode used for texture scale operations.

Returns
the current scale mode on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.SetScaleMode

◆ GetSize()

void SDL::Texture::GetSize ( float * w,
float * h ) const
inline

Get the size of a texture, as floating point values.

Parameters
wa pointer filled in with the width of the texture in pixels. This argument can be nullptr if you don't need this information.
ha pointer filled in with the height of the texture in pixels. This argument can be nullptr if you don't need this information.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ GetTarget()

Texture SDL::Renderer::GetTarget ( ) const
inline

Get the current render target.

The default render target is the window for which the renderer was created, and is reported a nullptr here.

Returns
the current render target or nullptr for the default render target.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetTarget

◆ GetTextureAlphaMod()

Uint8 SDL::GetTextureAlphaMod ( TextureConstRef texture)
inline

Get the additional alpha value multiplied into render copy operations.

Parameters
texturethe texture to query.
Returns
the current alpha value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetAlphaModFloat
Texture.GetColorMod
Texture.SetAlphaMod

◆ GetTextureAlphaModFloat()

float SDL::GetTextureAlphaModFloat ( TextureConstRef texture)
inline

Get the additional alpha value multiplied into render copy operations.

Parameters
texturethe texture to query.
Returns
the current alpha value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetAlphaMod
Texture.GetColorModFloat
Texture.SetAlphaModFloat

◆ GetTextureBlendMode()

BlendMode SDL::GetTextureBlendMode ( TextureConstRef texture)
inline

Get the blend mode used for texture copy operations.

Parameters
texturethe texture to query.
Returns
the current BlendMode.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.SetBlendMode

◆ GetTextureColorMod()

void SDL::GetTextureColorMod ( TextureConstRef texture,
Uint8 * r,
Uint8 * g,
Uint8 * b )
inline

Get the additional color value multiplied into render copy operations.

Parameters
texturethe texture to query.
ra pointer filled in with the current red color value.
ga pointer filled in with the current green color value.
ba pointer filled in with the current blue color value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetAlphaMod
Texture.GetColorModFloat
Texture.SetColorMod

◆ GetTextureColorModFloat()

void SDL::GetTextureColorModFloat ( TextureConstRef texture,
float * r,
float * g,
float * b )
inline

Get the additional color value multiplied into render copy operations.

Parameters
texturethe texture to query.
ra pointer filled in with the current red color value.
ga pointer filled in with the current green color value.
ba pointer filled in with the current blue color value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetAlphaModFloat
Texture.GetColorMod
Texture.SetColorModFloat

◆ GetTextureMod()

Color SDL::GetTextureMod ( TextureConstRef texture)
inline

Get the additional color value multiplied into render copy operations.

Parameters
texturethe texture to query.
Returns
the color channels (0-1) on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
GetAlphaMod()
SetColorMod()

◆ GetTextureModFloat()

FColor SDL::GetTextureModFloat ( TextureConstRef texture)
inline

Get the additional color value multiplied into render copy operations.

Parameters
texturethe texture to query.
Returns
the color channels (0-1) on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
GetAlphaMod()
SetColorMod()

◆ GetTexturePalette()

Palette SDL::GetTexturePalette ( TextureRef texture)
inline

Get the palette used by a texture.

Parameters
texturethe texture to query.
Returns
a pointer to the palette used by the texture, or nullptr if there is no palette used.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
Texture.SetPalette

◆ GetTextureProperties()

PropertiesRef SDL::GetTextureProperties ( TextureConstRef texture)
inline

Get the properties associated with a texture.

The following read-only properties are provided by SDL:

With the direct3d11 renderer:

With the direct3d12 renderer:

With the vulkan renderer:

With the opengl renderer:

With the opengles2 renderer:

With the gpu renderer:

Parameters
texturethe texture to query.
Returns
a valid property ID on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ GetTextureScaleMode()

ScaleMode SDL::GetTextureScaleMode ( TextureConstRef texture)
inline

Get the scale mode used for texture scale operations.

Parameters
texturethe texture to query.
Returns
the current scale mode.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.SetScaleMode

◆ GetTextureSize()

void SDL::GetTextureSize ( TextureConstRef texture,
float * w,
float * h )
inline

Get the size of a texture, as floating point values.

Parameters
texturethe texture to query.
wa pointer filled in with the width of the texture in pixels. This argument can be nullptr if you don't need this information.
ha pointer filled in with the height of the texture in pixels. This argument can be nullptr if you don't need this information.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ GetViewport()

Rect SDL::Renderer::GetViewport ( ) const
inline

Get the drawing area for the current target.

Each render target has its own viewport. This function gets the viewport for the current render target.

Returns
an Rect with the current drawing area.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.ViewportSet
Renderer.SetViewport

◆ GetVSync()

int SDL::Renderer::GetVSync ( ) const
inline

Get VSync of the given renderer.

Returns
the current vertical refresh sync interval on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetVSync

◆ GetWindow()

WindowRef SDL::Renderer::GetWindow ( )
inline

Get the window associated with a renderer.

Returns
the window on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ GPURenderState()

SDL::GPURenderState::GPURenderState ( RendererRef renderer,
const GPURenderStateCreateInfo & createinfo )
inline

Create custom GPU render state.

Parameters
rendererthe renderer to use.
createinfoa struct describing the GPU render state to create.
Postcondition
a custom GPU render state or nullptr on failure; call GetError() for more information.
Thread safety:
This function should be called on the thread that created the renderer.
Since
This function is available since SDL 3.4.0.
See also
GPURenderState.SetFragmentUniforms
Renderer.SetGPURenderState
GPURenderState.Destroy

◆ IsClipEnabled()

bool SDL::Renderer::IsClipEnabled ( ) const
inline

Get whether clipping is enabled on the given render target.

Each render target has its own clip rectangle. This function checks the cliprect for the current render target.

Returns
true if clipping is enabled or false if not; call GetError() for more information.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetClipRect
Renderer.SetClipRect

◆ Lock()

TextureLock SDL::Texture::Lock ( OptionalRef< const RectRaw > rect,
void ** pixels,
int * pitch )
inline

Lock a portion of the texture for write-only pixel access.

As an optimization, the pixels made available for editing don't necessarily contain the old texture data. This is a write-only operation, and if you need to keep a copy of the texture data you should do that at the application level.

You must use Texture.Unlock() to unlock the pixels and apply any changes.

Parameters
rectan Rect structure representing the area to lock for access; nullptr to lock the entire texture.
pixelsthis is filled in with a pointer to the locked pixels, appropriately offset by the locked area.
pitchthis is filled in with the pitch of the locked pixels; the pitch is the length of one row in bytes.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.LockToSurface
Texture.Unlock

◆ LockTexture()

void SDL::LockTexture ( TextureRef texture,
OptionalRef< const RectRaw > rect,
void ** pixels,
int * pitch )
inline

Lock a portion of the texture for write-only pixel access.

As an optimization, the pixels made available for editing don't necessarily contain the old texture data. This is a write-only operation, and if you need to keep a copy of the texture data you should do that at the application level.

You must use Texture.Unlock() to unlock the pixels and apply any changes.

Parameters
texturethe texture to lock for access, which was created with TEXTUREACCESS_STREAMING.
rectan Rect structure representing the area to lock for access; nullptr to lock the entire texture.
pixelsthis is filled in with a pointer to the locked pixels, appropriately offset by the locked area.
pitchthis is filled in with the pitch of the locked pixels; the pitch is the length of one row in bytes.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.LockToSurface
Texture.Unlock

◆ LockTextureToSurface()

Surface SDL::LockTextureToSurface ( TextureRef texture,
OptionalRef< const RectRaw > rect = std::nullopt )
inline

Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.

Besides providing an Surface instead of raw pixel data, this function operates like Texture.Lock.

As an optimization, the pixels made available for editing don't necessarily contain the old texture data. This is a write-only operation, and if you need to keep a copy of the texture data you should do that at the application level.

You must use Texture.Unlock() to unlock the pixels and apply any changes.

The returned surface is freed internally after calling Texture.Unlock() or Texture.Destroy(). The caller should not free it.

Parameters
texturethe texture to lock for access, which must be created with TEXTUREACCESS_STREAMING.
recta pointer to the rectangle to lock for access. If the rect is nullptr, the entire texture will be locked.
Returns
a surface of size rect. Don't assume any specific pixel content.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Lock
Texture.Unlock

◆ LockToSurface()

TextureSurfaceLock SDL::Texture::LockToSurface ( OptionalRef< const RectRaw > rect = std::nullopt)
inline

Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.

Besides providing an Surface instead of raw pixel data, this function operates like Texture.Lock.

As an optimization, the pixels made available for editing don't necessarily contain the old texture data. This is a write-only operation, and if you need to keep a copy of the texture data you should do that at the application level.

You must use Texture.Unlock() to unlock the pixels and apply any changes.

The returned surface is freed internally after calling Texture.Unlock() or Texture.Destroy(). The caller should not free it.

Parameters
recta pointer to the rectangle to lock for access. If the rect is nullptr, the entire texture will be locked.
Returns
a surface of size rect. Don't assume any specific pixel content.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Lock
Texture.Unlock

◆ Present()

void SDL::Renderer::Present ( )
inline

Update the screen with any rendering performed since the previous call.

SDL's rendering functions operate on a backbuffer; that is, calling a rendering function such as Renderer.RenderLine() does not directly put a line on the screen, but rather updates the backbuffer. As such, you compose your entire scene and present the composed backbuffer to the screen as a complete picture.

Therefore, when using SDL's rendering API, one does all drawing intended for the frame, and then calls this function once per frame to present the final drawing to the user.

The backbuffer should be considered invalidated after each present; do not assume that previous contents will exist between frames. You are strongly encouraged to call Renderer.RenderClear() to initialize the backbuffer before starting each new frame's drawing, even if you plan to overwrite every pixel.

Please note, that in case of rendering to a texture - there is no need to call Renderer.Present after drawing needed objects to a texture, and should not be done; you are only required to change back the rendering target to default via Renderer.SetTarget(renderer, nullptr) afterwards, as textures by themselves do not have a concept of backbuffers. Calling Renderer.Present while rendering to a texture will fail.

Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRenderer
Renderer.RenderClear
Renderer.RenderFillRect
Renderer.RenderFillRects
Renderer.RenderLine
Renderer.RenderLines
Renderer.RenderPoint
Renderer.RenderPoints
Renderer.RenderRect
Renderer.RenderRects
Renderer.SetDrawBlendMode
Renderer.SetDrawColor

◆ ReadPixels()

Surface SDL::Renderer::ReadPixels ( OptionalRef< const RectRaw > rect = {}) const
inline

Read pixels from the current rendering target.

The returned surface contains pixels inside the desired area clipped to the current viewport, and should be freed with Surface.Destroy().

Note that this returns the actual pixels on the screen, so if you are using logical presentation you should use Renderer.GetLogicalPresentationRect() to get the area containing your content.

WARNING: This is a very slow operation, and should not be used frequently. If you're using this on the main rendering target, it should be called after rendering and before Renderer.Present().

Parameters
rectan Rect structure representing the area to read, which will be clipped to the current viewport, or nullptr for the entire viewport.
Returns
a new Surface on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ RenderClear() [1/2]

void SDL::RenderClear ( RendererRef renderer)
inline

Clear the current rendering target with the drawing color.

This function clears the entire rendering target, ignoring the viewport and the clip rectangle. Note, that clearing will also set/fill all pixels of the rendering target to current renderer draw color, so make sure to invoke Renderer.SetDrawColor() when needed.

Parameters
rendererthe rendering context.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetDrawColor

◆ RenderClear() [2/2]

void SDL::Renderer::RenderClear ( )
inline

Clear the current rendering target with the drawing color.

This function clears the entire rendering target, ignoring the viewport and the clip rectangle. Note, that clearing will also set/fill all pixels of the rendering target to current renderer draw color, so make sure to invoke Renderer.SetDrawColor() when needed.

Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetDrawColor

◆ RenderClipEnabled()

bool SDL::RenderClipEnabled ( RendererRef renderer)
inline

Get whether clipping is enabled on the given render target.

Each render target has its own clip rectangle. This function checks the cliprect for the current render target.

Parameters
rendererthe rendering context.
Returns
true if clipping is enabled or false if not; call GetError() for more information.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetClipRect
Renderer.SetClipRect

◆ RenderCoordinatesFromWindow() [1/2]

FPoint SDL::RenderCoordinatesFromWindow ( RendererRef renderer,
const FPointRaw & window_coord )
inline

Get a point in render coordinates when given a point in window coordinates.

This takes into account several states:

Parameters
rendererthe rendering context.
window_coordthe x, y coordinate in window coordinates.
Returns
the x, y coordinate in render coordinates.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetLogicalPresentation
Renderer.SetScale

◆ RenderCoordinatesFromWindow() [2/2]

FPoint SDL::Renderer::RenderCoordinatesFromWindow ( const FPointRaw & window_coord) const
inline

Get a point in render coordinates when given a point in window coordinates.

This takes into account several states:

Parameters
window_coordthe x, y coordinate in window coordinates.
Returns
a FPoint containing ther render coordinates on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetLogicalPresentation
Renderer.SetScale

◆ RenderCoordinatesToWindow() [1/2]

FPoint SDL::RenderCoordinatesToWindow ( RendererRef renderer,
const FPointRaw & coord )
inline

Get a point in window coordinates when given a point in render coordinates.

This takes into account several states:

Parameters
rendererthe rendering context.
coordthe x, y coordinates in render coordinates.
Returns
x, y in window coordinates.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetLogicalPresentation
Renderer.SetScale
Renderer.SetViewport

◆ RenderCoordinatesToWindow() [2/2]

FPoint SDL::Renderer::RenderCoordinatesToWindow ( const FPointRaw & coord) const
inline

Get a point in window coordinates when given a point in render coordinates.

This takes into account several states:

Parameters
coordthe x, y coordinate in render coordinates.
Returns
a FPoint filled with window coordinates on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.SetLogicalPresentation
Renderer.SetScale
Renderer.SetViewport

◆ RenderDebugText() [1/2]

void SDL::RenderDebugText ( RendererRef renderer,
const FPointRaw & p,
StringParam str )
inline

Draw debug text to an Renderer.

This function will render a string of text to an Renderer. Note that this is a convenience function for debugging, with severe limitations, and not intended to be used for production apps and games.

Among these limitations:

  • It accepts UTF-8 strings, but will only renders ASCII characters.
  • It has a single, tiny size (8x8 pixels). You can use logical presentation or Renderer.SetScale() to adjust it.
  • It uses a simple, hardcoded bitmap font. It does not allow different font selections and it does not support truetype, for proper scaling.
  • It does no word-wrapping and does not treat newline characters as a line break. If the text goes out of the window, it's gone.

For serious text rendering, there are several good options, such as SDL_ttf, stb_truetype, or other external libraries.

On first use, this will create an internal texture for rendering glyphs. This texture will live until the renderer is destroyed.

The text is drawn in the color specified by Renderer.SetDrawColor().

Parameters
rendererthe renderer which should draw a line of text.
pthe x,y coordinates where the top-left corner of the text will draw.
strthe string to render.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderDebugTextFormat
DEBUG_TEXT_FONT_CHARACTER_SIZE

◆ RenderDebugText() [2/2]

void SDL::Renderer::RenderDebugText ( const FPointRaw & p,
StringParam str )
inline

Draw debug text to an Renderer.

This function will render a string of text to an Renderer. Note that this is a convenience function for debugging, with severe limitations, and not intended to be used for production apps and games.

Among these limitations:

  • It accepts UTF-8 strings, but will only renders ASCII characters.
  • It has a single, tiny size (8x8 pixels). You can use logical presentation or Renderer.SetScale() to adjust it.
  • It uses a simple, hardcoded bitmap font. It does not allow different font selections and it does not support truetype, for proper scaling.
  • It does no word-wrapping and does not treat newline characters as a line break. If the text goes out of the window, it's gone.

For serious text rendering, there are several good options, such as SDL_ttf, stb_truetype, or other external libraries.

On first use, this will create an internal texture for rendering glyphs. This texture will live until the renderer is destroyed.

The text is drawn in the color specified by Renderer.SetDrawColor().

Parameters
pthe x, y coordinates where the top-left corner of the text will draw.
strthe string to render.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderDebugTextFormat
DEBUG_TEXT_FONT_CHARACTER_SIZE

◆ RenderDebugTextFormat() [1/2]

template<class... ARGS>
void SDL::RenderDebugTextFormat ( RendererRef renderer,
const FPointRaw & p,
std::string_view fmt,
ARGS... args )
inline

Draw debug text to an Renderer.

This function will render a printf()-style format string to a renderer. Note that this is a convenience function for debugging, with severe limitations, and is not intended to be used for production apps and games.

For the full list of limitations and other useful information, see Renderer.RenderDebugText.

Parameters
rendererthe renderer which should draw the text.
pthe x,y coordinate where the top-left corner of the text will draw.
fmtthe format string to draw.
argsadditional parameters matching % tokens in the fmt string, if any.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderDebugText
DEBUG_TEXT_FONT_CHARACTER_SIZE

◆ RenderDebugTextFormat() [2/2]

template<class... ARGS>
void SDL::Renderer::RenderDebugTextFormat ( const FPointRaw & p,
std::string_view fmt,
ARGS... args )
inline

Draw debug text to an Renderer.

This function will render a std::format()-style format string to a renderer. Note that this is a convenience function for debugging, with severe limitations, and is not intended to be used for production apps and games.

For the full list of limitations and other useful information, see Renderer.RenderDebugText.

Parameters
pthe x, y coordinates where the top-left corner of the text will draw.
fmtthe format string to draw.
argsadditional parameters matching {} tokens in the fmt string, if any.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderDebugText
DEBUG_TEXT_FONT_CHARACTER_SIZE

◆ Renderer() [1/3]

SDL::Renderer::Renderer ( PropertiesRef props)
inline

Create a 2D rendering context for a window, with the specified properties.

These are the supported properties:

With the SDL GPU renderer (since SDL 3.4.0):

With the vulkan renderer:

Parameters
propsthe properties to use.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Properties.Create
CreateRenderer
CreateSoftwareRenderer
Renderer.Destroy
Renderer.GetName

◆ Renderer() [2/3]

SDL::Renderer::Renderer ( SurfaceRef surface)
inline

Create a 2D software rendering context for a surface.

Two other API which can be used to create Renderer: CreateRenderer() and CreateWindowAndRenderer(). These can also create a software renderer, but they are intended to be used with an Window as the final destination and not an Surface.

Parameters
surfacethe Surface structure representing the surface where rendering is done.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.Destroy

◆ Renderer() [3/3]

SDL::Renderer::Renderer ( WindowRef window,
StringParam name = nullptr )
inline

Create a 2D rendering context for a window.

If you want a specific renderer, you can specify its name here. A list of available renderers can be obtained by calling GetRenderDriver() multiple times, with indices from 0 to GetNumRenderDrivers()-1. If you don't need a specific renderer, specify nullptr and SDL will attempt to choose the best option for you, based on what is available on the user's system.

If name is a comma-separated list, SDL will try each name, in the order listed, until one succeeds or all of them fail.

By default the rendering size matches the window size in pixels, but you can call Renderer.SetLogicalPresentation() to change the content size and scaling options.

Parameters
windowthe window where rendering is displayed.
namethe name of the rendering driver to initialize, or nullptr to let SDL choose one.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRendererWithProperties
CreateSoftwareRenderer
Renderer.Destroy
GetNumRenderDrivers
GetRenderDriver
Renderer.GetName

◆ RenderFillRect() [1/2]

void SDL::Renderer::RenderFillRect ( OptionalRef< const FRectRaw > rect)
inline

Fill a rectangle on the current rendering target with the drawing color at subpixel precision.

Parameters
recta pointer to the destination rectangle, or std::nullopt for the entire rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderFillRects

◆ RenderFillRect() [2/2]

void SDL::RenderFillRect ( RendererRef renderer,
OptionalRef< const FRectRaw > rect )
inline

Fill a rectangle on the current rendering target with the drawing color at subpixel precision.

Parameters
rendererthe renderer which should fill a rectangle.
recta pointer to the destination rectangle, or nullptr for the entire rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderFillRects

◆ RenderFillRects() [1/2]

void SDL::Renderer::RenderFillRects ( SpanRef< const FRectRaw > rects)
inline

Fill some number of rectangles on the current rendering target with the drawing color at subpixel precision.

Parameters
rectsa pointer to an array of destination rectangles.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderFillRect

◆ RenderFillRects() [2/2]

void SDL::RenderFillRects ( RendererRef renderer,
SpanRef< const FRectRaw > rects )
inline

Fill some number of rectangles on the current rendering target with the drawing color at subpixel precision.

Parameters
rendererthe renderer which should fill multiple rectangles.
rectsa pointer to an array of destination rectangles.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderFillRect

◆ RenderGeometry() [1/2]

void SDL::Renderer::RenderGeometry ( TextureRef texture,
std::span< const Vertex > vertices,
std::span< const int > indices = {} )
inline

Render a list of triangles, optionally using a texture and indices into the vertex array Color and alpha modulation is done per vertex (Texture.SetColorMod and Texture.SetAlphaMod are ignored).

Parameters
texture(optional) The SDL texture to use.
verticesvertices.
indices(optional) An array of integer indices into the 'vertices' array, if nullptr all vertices will be rendered in sequential order.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderGeometryRaw
Renderer.SetRenderTextureAddressMode

◆ RenderGeometry() [2/2]

void SDL::RenderGeometry ( RendererRef renderer,
TextureRef texture,
std::span< const Vertex > vertices,
std::span< const int > indices = {} )
inline

Render a list of triangles, optionally using a texture and indices into the vertex array Color and alpha modulation is done per vertex (Texture.SetColorMod and Texture.SetAlphaMod are ignored).

Parameters
rendererthe rendering context.
texture(optional) The SDL texture to use.
verticesvertices.
indices(optional) An array of integer indices into the 'vertices' array, if nullptr all vertices will be rendered in sequential order.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderGeometryRaw
Renderer.SetRenderTextureAddressMode

◆ RenderGeometryRaw() [1/2]

void SDL::Renderer::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 )
inline

Render a list of triangles, optionally using a texture and indices into the vertex arrays Color and alpha modulation is done per vertex (Texture.SetColorMod and Texture.SetAlphaMod are ignored).

Parameters
texture(optional) The SDL texture to use.
xyvertex positions.
xy_stridebyte size to move from one element to the next element.
colorvertex colors (as FColor).
color_stridebyte size to move from one element to the next element.
uvvertex normalized texture coordinates.
uv_stridebyte size to move from one element to the next element.
num_verticesnumber of vertices.
indices(optional) An array of indices into the 'vertices' arrays, if nullptr all vertices will be rendered in sequential order.
num_indicesnumber of indices.
size_indicesindex size: 1 (byte), 2 (short), 4 (int).
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderGeometry
Renderer.SetRenderTextureAddressMode

◆ RenderGeometryRaw() [2/2]

void SDL::RenderGeometryRaw ( RendererRef renderer,
TextureRef texture,
const float * xy,
int xy_stride,
const FColor * color,
int color_stride,
const float * uv,
int uv_stride,
int num_vertices,
const void * indices,
int num_indices,
int size_indices )
inline

Render a list of triangles, optionally using a texture and indices into the vertex arrays Color and alpha modulation is done per vertex (Texture.SetColorMod and Texture.SetAlphaMod are ignored).

Parameters
rendererthe rendering context.
texture(optional) The SDL texture to use.
xyvertex positions.
xy_stridebyte size to move from one element to the next element.
colorvertex colors (as FColor).
color_stridebyte size to move from one element to the next element.
uvvertex normalized texture coordinates.
uv_stridebyte size to move from one element to the next element.
num_verticesnumber of vertices.
indices(optional) An array of indices into the 'vertices' arrays, if nullptr all vertices will be rendered in sequential order.
num_indicesnumber of indices.
size_indicesindex size: 1 (byte), 2 (short), 4 (int).
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderGeometry
Renderer.SetRenderTextureAddressMode

◆ RenderLine() [1/2]

void SDL::Renderer::RenderLine ( const FPointRaw & p1,
const FPointRaw & p2 )
inline

Draw a line on the current rendering target at subpixel precision.

Parameters
p1the x,y coordinate of the start point.
p2the x,y coordinate of the end point.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderLines

◆ RenderLine() [2/2]

void SDL::RenderLine ( RendererRef renderer,
const FPointRaw & p1,
const FPointRaw & p2 )
inline

Draw a line on the current rendering target at subpixel precision.

Parameters
rendererthe renderer which should draw a line.
p1the x,y coordinates of the start point.
p2the x,y coordinates of the end point.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderLines

◆ RenderLines() [1/2]

void SDL::Renderer::RenderLines ( SpanRef< const FPointRaw > points)
inline

Draw a series of connected lines on the current rendering target at subpixel precision.

Parameters
pointsthe points along the lines.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderLine

◆ RenderLines() [2/2]

void SDL::RenderLines ( RendererRef renderer,
SpanRef< const FPointRaw > points )
inline

Draw a series of connected lines on the current rendering target at subpixel precision.

Parameters
rendererthe renderer which should draw multiple lines.
pointsthe points along the lines.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderLine

◆ RenderPoint() [1/2]

void SDL::Renderer::RenderPoint ( const FPointRaw & p)
inline

Draw a point on the current rendering target at subpixel precision.

Parameters
pthe x, y coordinates of the point.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderPoints

◆ RenderPoint() [2/2]

void SDL::RenderPoint ( RendererRef renderer,
const FPointRaw & p )
inline

Draw a point on the current rendering target at subpixel precision.

Parameters
rendererthe renderer which should draw a point.
pthe x, y coordinate of the point.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderPoints

◆ RenderPoints() [1/2]

void SDL::Renderer::RenderPoints ( SpanRef< const FPointRaw > points)
inline

Draw multiple points on the current rendering target at subpixel precision.

Parameters
pointsthe points to draw.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderPoint

◆ RenderPoints() [2/2]

void SDL::RenderPoints ( RendererRef renderer,
SpanRef< const FPointRaw > points )
inline

Draw multiple points on the current rendering target at subpixel precision.

Parameters
rendererthe renderer which should draw multiple points.
pointsthe points to draw.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderPoint

◆ RenderPresent()

void SDL::RenderPresent ( RendererRef renderer)
inline

Update the screen with any rendering performed since the previous call.

SDL's rendering functions operate on a backbuffer; that is, calling a rendering function such as Renderer.RenderLine() does not directly put a line on the screen, but rather updates the backbuffer. As such, you compose your entire scene and present the composed backbuffer to the screen as a complete picture.

Therefore, when using SDL's rendering API, one does all drawing intended for the frame, and then calls this function once per frame to present the final drawing to the user.

The backbuffer should be considered invalidated after each present; do not assume that previous contents will exist between frames. You are strongly encouraged to call Renderer.RenderClear() to initialize the backbuffer before starting each new frame's drawing, even if you plan to overwrite every pixel.

Please note, that in case of rendering to a texture - there is no need to call Renderer.Present after drawing needed objects to a texture, and should not be done; you are only required to change back the rendering target to default via Renderer.SetTarget(renderer, nullptr) afterwards, as textures by themselves do not have a concept of backbuffers. Calling Renderer.Present while rendering to a texture will fail.

Parameters
rendererthe rendering context.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRenderer
Renderer.RenderClear
Renderer.RenderFillRect
Renderer.RenderFillRects
Renderer.RenderLine
Renderer.RenderLines
Renderer.RenderPoint
Renderer.RenderPoints
Renderer.RenderRect
Renderer.RenderRects
Renderer.SetDrawBlendMode
Renderer.SetDrawColor

◆ RenderReadPixels()

Surface SDL::RenderReadPixels ( RendererRef renderer,
OptionalRef< const RectRaw > rect = {} )
inline

Read pixels from the current rendering target.

The returned surface contains pixels inside the desired area clipped to the current viewport, and should be freed with Surface.Destroy().

Note that this returns the actual pixels on the screen, so if you are using logical presentation you should use Renderer.GetLogicalPresentationRect() to get the area containing your content.

WARNING: This is a very slow operation, and should not be used frequently. If you're using this on the main rendering target, it should be called after rendering and before Renderer.Present().

Parameters
rendererthe rendering context.
rectan Rect structure representing the area to read, which will be clipped to the current viewport, or nullptr for the entire viewport.
Returns
a new Surface on success.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ RenderRect() [1/2]

void SDL::Renderer::RenderRect ( OptionalRef< const FRectRaw > rect)
inline

Draw a rectangle on the current rendering target at subpixel precision.

Parameters
recta pointer to the destination rectangle, or std::nullopt to outline the entire rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderRects

◆ RenderRect() [2/2]

void SDL::RenderRect ( RendererRef renderer,
OptionalRef< const FRectRaw > rect )
inline

Draw a rectangle on the current rendering target at subpixel precision.

Parameters
rendererthe renderer which should draw a rectangle.
recta pointer to the destination rectangle, or nullptr to outline the entire rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderRects

◆ RenderRects() [1/2]

void SDL::Renderer::RenderRects ( SpanRef< const FRectRaw > rects)
inline

Draw some number of rectangles on the current rendering target at subpixel precision.

Parameters
rectsa pointer to an array of destination rectangles.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderRect

◆ RenderRects() [2/2]

void SDL::RenderRects ( RendererRef renderer,
SpanRef< const FRectRaw > rects )
inline

Draw some number of rectangles on the current rendering target at subpixel precision.

Parameters
rendererthe renderer which should draw multiple rectangles.
rectsa pointer to an array of destination rectangles.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderRect

◆ RenderTexture() [1/2]

void SDL::Renderer::RenderTexture ( TextureRef texture,
OptionalRef< const FRectRaw > srcrect,
OptionalRef< const FRectRaw > dstrect )
inline

Copy a portion of the texture to the current rendering target at subpixel precision.

Parameters
texturethe source texture.
srcrecta pointer to the source rectangle, or nullptr for the entire texture.
dstrecta pointer to the destination rectangle, or nullptr for the entire rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderTextureRotated
Renderer.RenderTextureTiled

◆ RenderTexture() [2/2]

void SDL::RenderTexture ( RendererRef renderer,
TextureRef texture,
OptionalRef< const FRectRaw > srcrect,
OptionalRef< const FRectRaw > dstrect )
inline

Copy a portion of the texture to the current rendering target at subpixel precision.

Parameters
rendererthe renderer which should copy parts of a texture.
texturethe source texture.
srcrecta pointer to the source rectangle, or nullptr for the entire texture.
dstrecta pointer to the destination rectangle, or nullptr for the entire rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderTextureRotated
Renderer.RenderTextureTiled

◆ RenderTexture9Grid() [1/2]

void SDL::Renderer::RenderTexture9Grid ( TextureRef texture,
OptionalRef< const FRectRaw > srcrect,
float left_width,
float right_width,
float top_height,
float bottom_height,
float scale,
OptionalRef< const FRectRaw > dstrect )
inline

Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precision.

The pixels in the texture are split into a 3x3 grid, using the different corner sizes for each corner, and the sides and center making up the remaining pixels. The corners are then scaled using scale and fit into the corners of the destination rectangle. The sides and center are then stretched into place to cover the remaining destination rectangle.

Parameters
texturethe source texture.
srcrectthe Rect structure representing the rectangle to be used for the 9-grid, or nullptr to use the entire texture.
left_widththe width, in pixels, of the left corners in srcrect.
right_widththe width, in pixels, of the right corners in srcrect.
top_heightthe height, in pixels, of the top corners in srcrect.
bottom_heightthe height, in pixels, of the bottom corners in srcrect.
scalethe scale used to transform the corner of srcrect into the corner of dstrect, or 0.0f for an unscaled copy.
dstrecta pointer to the destination rectangle, or nullptr for the entire rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderTexture
Renderer.RenderTexture9GridTiled

◆ RenderTexture9Grid() [2/2]

void SDL::RenderTexture9Grid ( RendererRef renderer,
TextureRef texture,
OptionalRef< const FRectRaw > srcrect,
float left_width,
float right_width,
float top_height,
float bottom_height,
float scale,
OptionalRef< const FRectRaw > dstrect )
inline

Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precision.

The pixels in the texture are split into a 3x3 grid, using the different corner sizes for each corner, and the sides and center making up the remaining pixels. The corners are then scaled using scale and fit into the corners of the destination rectangle. The sides and center are then stretched into place to cover the remaining destination rectangle.

Parameters
rendererthe renderer which should copy parts of a texture.
texturethe source texture.
srcrectthe Rect structure representing the rectangle to be used for the 9-grid, or nullptr to use the entire texture.
left_widththe width, in pixels, of the left corners in srcrect.
right_widththe width, in pixels, of the right corners in srcrect.
top_heightthe height, in pixels, of the top corners in srcrect.
bottom_heightthe height, in pixels, of the bottom corners in srcrect.
scalethe scale used to transform the corner of srcrect into the corner of dstrect, or 0.0f for an unscaled copy.
dstrecta pointer to the destination rectangle, or nullptr for the entire rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderTexture
Renderer.RenderTexture9GridTiled

◆ RenderTexture9GridTiled() [1/2]

void SDL::Renderer::RenderTexture9GridTiled ( TextureRef texture,
const FRectRaw & srcrect,
float left_width,
float right_width,
float top_height,
float bottom_height,
float scale,
const FRectRaw & dstrect,
float tileScale )
inline

Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precision.

The pixels in the texture are split into a 3x3 grid, using the different corner sizes for each corner, and the sides and center making up the remaining pixels. The corners are then scaled using scale and fit into the corners of the destination rectangle. The sides and center are then tiled into place to cover the remaining destination rectangle.

Parameters
texturethe source texture.
srcrectthe Rect structure representing the rectangle to be used for the 9-grid, or nullptr to use the entire texture.
left_widththe width, in pixels, of the left corners in srcrect.
right_widththe width, in pixels, of the right corners in srcrect.
top_heightthe height, in pixels, of the top corners in srcrect.
bottom_heightthe height, in pixels, of the bottom corners in srcrect.
scalethe scale used to transform the corner of srcrect into the corner of dstrect, or 0.0f for an unscaled copy.
dstrecta pointer to the destination rectangle, or nullptr for the entire rendering target.
tileScalethe scale used to transform the borders and center of srcrect into the borders and middle of dstrect, or 1.0f for an unscaled copy.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
Renderer.RenderTexture
Renderer.RenderTexture9Grid

◆ RenderTexture9GridTiled() [2/2]

void SDL::RenderTexture9GridTiled ( RendererRef renderer,
TextureRef texture,
const FRectRaw & srcrect,
float left_width,
float right_width,
float top_height,
float bottom_height,
float scale,
const FRectRaw & dstrect,
float tileScale )
inline

Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precision.

The pixels in the texture are split into a 3x3 grid, using the different corner sizes for each corner, and the sides and center making up the remaining pixels. The corners are then scaled using scale and fit into the corners of the destination rectangle. The sides and center are then tiled into place to cover the remaining destination rectangle.

Parameters
rendererthe renderer which should copy parts of a texture.
texturethe source texture.
srcrectthe Rect structure representing the rectangle to be used for the 9-grid, or nullptr to use the entire texture.
left_widththe width, in pixels, of the left corners in srcrect.
right_widththe width, in pixels, of the right corners in srcrect.
top_heightthe height, in pixels, of the top corners in srcrect.
bottom_heightthe height, in pixels, of the bottom corners in srcrect.
scalethe scale used to transform the corner of srcrect into the corner of dstrect, or 0.0f for an unscaled copy.
dstrecta pointer to the destination rectangle, or nullptr for the entire rendering target.
tileScalethe scale used to transform the borders and center of srcrect into the borders and middle of dstrect, or 1.0f for an unscaled copy.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
Renderer.RenderTexture
Renderer.RenderTexture9Grid

◆ RenderTextureAffine() [1/2]

void SDL::Renderer::RenderTextureAffine ( TextureRef texture,
OptionalRef< const FRectRaw > srcrect,
OptionalRef< const FPointRaw > origin,
OptionalRef< const FPointRaw > right,
OptionalRef< const FPointRaw > down )
inline

Copy a portion of the source texture to the current rendering target, with affine transform, at subpixel precision.

Parameters
texturethe source texture.
srcrecta pointer to the source rectangle, or nullptr for the entire texture.
origina pointer to a point indicating where the top-left corner of srcrect should be mapped to, or nullptr for the rendering target's origin.
righta pointer to a point indicating where the top-right corner of srcrect should be mapped to, or nullptr for the rendering target's top-right corner.
downa pointer to a point indicating where the bottom-left corner of srcrect should be mapped to, or nullptr for the rendering target's bottom-left corner.
Exceptions
Erroron failure.
Thread safety:
You may only call this function from the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderTexture

◆ RenderTextureAffine() [2/2]

void SDL::RenderTextureAffine ( RendererRef renderer,
TextureRef texture,
OptionalRef< const FRectRaw > srcrect,
OptionalRef< const FPointRaw > origin,
OptionalRef< const FPointRaw > right,
OptionalRef< const FPointRaw > down )
inline

Copy a portion of the source texture to the current rendering target, with affine transform, at subpixel precision.

Parameters
rendererthe renderer which should copy parts of a texture.
texturethe source texture.
srcrecta pointer to the source rectangle, or nullptr for the entire texture.
origina pointer to a point indicating where the top-left corner of srcrect should be mapped to, or nullptr for the rendering target's origin.
righta pointer to a point indicating where the top-right corner of srcrect should be mapped to, or nullptr for the rendering target's top-right corner.
downa pointer to a point indicating where the bottom-left corner of srcrect should be mapped to, or nullptr for the rendering target's bottom-left corner.
Exceptions
Erroron failure.
Thread safety:
You may only call this function from the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderTexture

◆ RenderTextureRotated() [1/2]

void SDL::Renderer::RenderTextureRotated ( TextureRef texture,
OptionalRef< const FRectRaw > srcrect,
OptionalRef< const FRectRaw > dstrect,
double angle,
OptionalRef< const FPointRaw > center,
FlipMode flip = FlipMode::SDL_FLIP_NONE )
inline

Copy a portion of the source texture to the current rendering target, with rotation and flipping, at subpixel precision.

Parameters
texturethe source texture.
srcrecta pointer to the source rectangle, or nullptr for the entire texture.
dstrecta pointer to the destination rectangle, or nullptr for the entire rendering target.
anglean angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction.
centera pointer to a point indicating the point around which dstrect will be rotated (if nullptr, rotation will be done around dstrect.w/2, dstrect.h/2).
flipan FlipMode value stating which flipping actions should be performed on the texture.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderTexture

◆ RenderTextureRotated() [2/2]

void SDL::RenderTextureRotated ( RendererRef renderer,
TextureRef texture,
OptionalRef< const FRectRaw > srcrect,
OptionalRef< const FRectRaw > dstrect,
double angle,
OptionalRef< const FPointRaw > center,
FlipMode flip = FlipMode::SDL_FLIP_NONE )
inline

Copy a portion of the source texture to the current rendering target, with rotation and flipping, at subpixel precision.

Parameters
rendererthe renderer which should copy parts of a texture.
texturethe source texture.
srcrecta pointer to the source rectangle, or nullptr for the entire texture.
dstrecta pointer to the destination rectangle, or nullptr for the entire rendering target.
anglean angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction.
centera pointer to a point indicating the point around which dstrect will be rotated (if nullptr, rotation will be done around dstrect.w/2, dstrect.h/2).
flipan FlipMode value stating which flipping actions should be performed on the texture.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderTexture

◆ RenderTextureTiled() [1/2]

void SDL::Renderer::RenderTextureTiled ( TextureRef texture,
OptionalRef< const FRectRaw > srcrect,
float scale,
OptionalRef< const FRectRaw > dstrect )
inline

Tile a portion of the texture to the current rendering target at subpixel precision.

The pixels in srcrect will be repeated as many times as needed to completely fill dstrect.

Parameters
texturethe source texture.
srcrecta pointer to the source rectangle, or nullptr for the entire texture.
scalethe scale used to transform srcrect into the destination rectangle, e.g. a 32x32 texture with a scale of 2 would fill 64x64 tiles.
dstrecta pointer to the destination rectangle, or nullptr for the entire rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderTexture

◆ RenderTextureTiled() [2/2]

void SDL::RenderTextureTiled ( RendererRef renderer,
TextureRef texture,
OptionalRef< const FRectRaw > srcrect,
float scale,
OptionalRef< const FRectRaw > dstrect )
inline

Tile a portion of the texture to the current rendering target at subpixel precision.

The pixels in srcrect will be repeated as many times as needed to completely fill dstrect.

Parameters
rendererthe renderer which should copy parts of a texture.
texturethe source texture.
srcrecta pointer to the source rectangle, or nullptr for the entire texture.
scalethe scale used to transform srcrect into the destination rectangle, e.g. a 32x32 texture with a scale of 2 would fill 64x64 tiles.
dstrecta pointer to the destination rectangle, or nullptr for the entire rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.RenderTexture

◆ RenderViewportSet()

bool SDL::RenderViewportSet ( RendererRef renderer)
inline

Return whether an explicit rectangle was set as the viewport.

This is useful if you're saving and restoring the viewport and want to know whether you should restore a specific rectangle or nullptr.

Each render target has its own viewport. This function checks the viewport for the current render target.

Parameters
rendererthe rendering context.
Returns
true if the viewport was set to a specific rectangle, or false if it was set to nullptr (the entire target).
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetViewport
Renderer.SetViewport

◆ reset() [1/2]

void SDL::TextureLock::reset ( )
inline

Unlock a texture, uploading the changes to video memory, if needed.

Warning: Please note that Texture.Lock() is intended to be write-only; it will not guarantee the previous contents of the texture will be provided. You must fully initialize any area of a texture that you lock before unlocking it, as the pixels might otherwise be uninitialized memory.

Which is to say: locking and immediately unlocking a texture can result in corrupted textures, depending on the renderer in use.

Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Lock

◆ reset() [2/2]

void SDL::TextureSurfaceLock::reset ( )
inline

Unlock a texture, uploading the changes to video memory, if needed.

Warning: Please note that Texture.Lock() is intended to be write-only; it will not guarantee the previous contents of the texture will be provided. You must fully initialize any area of a texture that you lock before unlocking it, as the pixels might otherwise be uninitialized memory.

Which is to say: locking and immediately unlocking a texture can result in corrupted textures, depending on the renderer in use.

Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Lock

◆ ResetClipRect()

void SDL::Renderer::ResetClipRect ( )
inline

Reset the clip rectangle for rendering to the entire render target.

This is equivalent to SetClipRect(std::nullopt)

Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
GetClipRect()
SetClipRect()
ClipEnabled()

◆ ResetRenderClipRect()

void SDL::ResetRenderClipRect ( RendererRef renderer)
inline

Reset the clip rectangle for rendering to the entire render target.

This is equivalent to SetClipRect(std::nullopt)

Parameters
rendererthe rendering context.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
GetClipRect()
SetClipRect()
ClipEnabled()

◆ ResetRenderTarget()

void SDL::ResetRenderTarget ( RendererRef renderer)
inline

Set target texture back to window.

This is equivalent to SetTarget(nullptr)

Parameters
rendererthe rendering context.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
SetTarget(nullptr)
GetTarget()

◆ ResetRenderViewport()

void SDL::ResetRenderViewport ( RendererRef renderer)
inline

Reset the drawing area for rendering to the entire target.

This is equivalent to SetViewport(std::nullopt)

Parameters
rendererthe rendering context.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
GetViewport()
SetViewport()
ViewportSet()

◆ ResetTarget()

void SDL::Renderer::ResetTarget ( )
inline

Set target texture back to window.

This is equivalent to SetTarget(nullptr)

Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
SetTarget(nullptr)
GetTarget()

◆ ResetViewport()

void SDL::Renderer::ResetViewport ( )
inline

Reset the drawing area for rendering to the entire target.

This is equivalent to SetViewport(std::nullopt)

Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
GetViewport()
SetViewport()
ViewportSet()

◆ SetAlphaMod()

void SDL::Texture::SetAlphaMod ( Uint8 alpha)
inline

Set an additional alpha value multiplied into render copy operations.

When this texture is rendered, during the copy operation the source alpha value is modulated by this alpha value according to the following formula:

srcA = srcA * (alpha / 255)

Alpha modulation is not always supported by the renderer; it will return false if alpha modulation is not supported.

Parameters
alphathe source alpha value multiplied into copy operations.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetAlphaMod
Texture.SetAlphaModFloat
Texture.SetColorMod

◆ SetAlphaModFloat()

void SDL::Texture::SetAlphaModFloat ( float alpha)
inline

Set an additional alpha value multiplied into render copy operations.

When this texture is rendered, during the copy operation the source alpha value is modulated by this alpha value according to the following formula:

srcA = srcA * alpha

Alpha modulation is not always supported by the renderer; it will return false if alpha modulation is not supported.

Parameters
alphathe source alpha value multiplied into copy operations.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetAlphaModFloat
Texture.SetAlphaMod
Texture.SetColorModFloat

◆ SetBlendMode()

void SDL::Texture::SetBlendMode ( BlendMode blendMode)
inline

Set the blend mode for a texture, used by Renderer.RenderTexture().

If the blend mode is not supported, the closest supported mode is chosen and this function returns false.

Parameters
blendModethe BlendMode to use for texture blending.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetBlendMode

◆ SetClipRect()

void SDL::Renderer::SetClipRect ( OptionalRef< const RectRaw > rect)
inline

Set the clip rectangle for rendering on the specified target.

Each render target has its own clip rectangle. This function sets the cliprect for the current render target.

Parameters
rectan Rect structure representing the clip area, relative to the viewport, or nullptr to disable clipping.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetClipRect
Renderer.ResetClipRect()
Renderer.IsClipEnabled

◆ SetColorMod()

void SDL::Texture::SetColorMod ( Uint8 r,
Uint8 g,
Uint8 b )
inline

Set an additional color value multiplied into render copy operations.

When this texture is rendered, during the copy operation each source color channel is modulated by the appropriate color value according to the following formula:

srcC = srcC * (color / 255)

Color modulation is not always supported by the renderer; it will return false if color modulation is not supported.

Parameters
rthe red color value multiplied into copy operations.
gthe green color value multiplied into copy operations.
bthe blue color value multiplied into copy operations.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetColorMod
Texture.SetAlphaMod
Texture.SetColorModFloat

◆ SetColorModFloat()

void SDL::Texture::SetColorModFloat ( float r,
float g,
float b )
inline

Set an additional color value multiplied into render copy operations.

When this texture is rendered, during the copy operation each source color channel is modulated by the appropriate color value according to the following formula:

srcC = srcC * color

Color modulation is not always supported by the renderer; it will return false if color modulation is not supported.

Parameters
rthe red color value multiplied into copy operations.
gthe green color value multiplied into copy operations.
bthe blue color value multiplied into copy operations.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetColorModFloat
Texture.SetAlphaModFloat
Texture.SetColorMod

◆ SetColorScale()

void SDL::Renderer::SetColorScale ( float scale)
inline

Set the color scale used for render operations.

The color scale is an additional scale multiplied into the pixel color value while rendering. This can be used to adjust the brightness of colors during HDR rendering, or changing HDR video brightness when playing on an SDR display.

The color scale does not affect the alpha channel, only the color brightness.

Parameters
scalethe color scale value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetColorScale

◆ SetDefaultTextureScaleMode() [1/2]

void SDL::Renderer::SetDefaultTextureScaleMode ( ScaleMode scale_mode)
inline

Set default scale mode for new textures for given renderer.

When a renderer is created, scale_mode defaults to SCALEMODE_LINEAR.

Parameters
scale_modethe scale mode to change to for new textures.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
Renderer.GetDefaultTextureScaleMode

◆ SetDefaultTextureScaleMode() [2/2]

void SDL::SetDefaultTextureScaleMode ( RendererRef renderer,
ScaleMode scale_mode )
inline

Set default scale mode for new textures for given renderer.

When a renderer is created, scale_mode defaults to SCALEMODE_LINEAR.

Parameters
rendererthe renderer to update.
scale_modethe scale mode to change to for new textures.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
Renderer.GetDefaultTextureScaleMode

◆ SetDrawBlendMode()

void SDL::Renderer::SetDrawBlendMode ( BlendMode blendMode)
inline

Set the blend mode used for drawing operations (Fill and Line).

If the blend mode is not supported, the closest supported mode is chosen.

Parameters
blendModethe BlendMode to use for blending.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetDrawBlendMode

◆ SetDrawColor()

void SDL::Renderer::SetDrawColor ( ColorRaw c)
inline

Set the color used for drawing operations.

Set the color for drawing or filling rectangles, lines, and points, and for Renderer.RenderClear().

Parameters
cthe color value used to draw on the rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetDrawColor
Renderer.SetDrawColorFloat

◆ SetDrawColorFloat()

void SDL::Renderer::SetDrawColorFloat ( const FColorRaw & c)
inline

Set the color used for drawing operations (Rect, Line and Clear).

Set the color for drawing or filling rectangles, lines, and points, and for Renderer.RenderClear().

Parameters
cthe RGBA values used to draw on the rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetDrawColorFloat
Renderer.SetDrawColor

◆ SetFragmentUniforms()

void SDL::GPURenderState::SetFragmentUniforms ( Uint32 slot_index,
const void * data,
Uint32 length )
inline

Set fragment shader uniform variables in a custom GPU render state.

The data is copied and will be pushed using GPUCommandBuffer.PushFragmentUniformData() during draw call execution.

Parameters
slot_indexthe fragment uniform slot to push data to.
dataclient data to write.
lengththe length of the data to write.
Exceptions
Erroron failure.
Thread safety:
This function should be called on the thread that created the renderer.
Since
This function is available since SDL 3.4.0.

◆ SetGPURenderState() [1/2]

void SDL::Renderer::SetGPURenderState ( GPURenderStateRef state)
inline

Set custom GPU render state.

This function sets custom GPU render state for subsequent draw calls. This allows using custom shaders with the GPU renderer.

Parameters
statethe state to to use, or nullptr to clear custom GPU render state.
Exceptions
Erroron failure.
Thread safety:
This function should be called on the thread that created the renderer.
Since
This function is available since SDL 3.4.0.

◆ SetGPURenderState() [2/2]

void SDL::SetGPURenderState ( RendererRef renderer,
GPURenderStateRef state )
inline

Set custom GPU render state.

This function sets custom GPU render state for subsequent draw calls. This allows using custom shaders with the GPU renderer.

Parameters
rendererthe renderer to use.
statethe state to to use, or nullptr to clear custom GPU render state.
Exceptions
Erroron failure.
Thread safety:
This function should be called on the thread that created the renderer.
Since
This function is available since SDL 3.4.0.

◆ SetGPURenderStateFragmentUniforms()

void SDL::SetGPURenderStateFragmentUniforms ( GPURenderStateRef state,
Uint32 slot_index,
const void * data,
Uint32 length )
inline

Set fragment shader uniform variables in a custom GPU render state.

The data is copied and will be pushed using GPUCommandBuffer.PushFragmentUniformData() during draw call execution.

Parameters
statethe state to modify.
slot_indexthe fragment uniform slot to push data to.
dataclient data to write.
lengththe length of the data to write.
Exceptions
Erroron failure.
Thread safety:
This function should be called on the thread that created the renderer.
Since
This function is available since SDL 3.4.0.

◆ SetLogicalPresentation()

void SDL::Renderer::SetLogicalPresentation ( const PointRaw & size,
RendererLogicalPresentation mode )
inline

Set a device-independent resolution and presentation mode for rendering.

This function sets the width and height of the logical rendering output. The renderer will act as if the current render target is always the requested dimensions, scaling to the actual resolution as necessary.

This can be useful for games that expect a fixed size, but would like to scale the output to whatever is available, regardless of how a user resizes a window, or if the display is high DPI.

Logical presentation can be used with both render target textures and the renderer's window; the state is unique to each render target, and this function sets the state for the current render target. It might be useful to draw to a texture that matches the window dimensions with logical presentation enabled, and then draw that texture across the entire window with logical presentation disabled. Be careful not to render both with logical presentation enabled, however, as this could produce double-letterboxing, etc.

You can disable logical coordinates by setting the mode to LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel resolution of the render target; it is safe to toggle logical presentation during the rendering of a frame: perhaps most of the rendering is done to specific dimensions but to make fonts look sharp, the app turns off logical presentation while drawing text, for example.

You can convert coordinates in an event into rendering coordinates using Renderer.ConvertEventToRenderCoordinates().

Parameters
sizethe width and height of the logical resolution.
modethe presentation mode used.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.ConvertEventToRenderCoordinates
Renderer.GetLogicalPresentation
Renderer.GetLogicalPresentationRect

◆ SetMod()

void SDL::Texture::SetMod ( Color c)
inline

Set an additional color and alpha values multiplied into render copy operations.

When this texture is rendered, during the copy operation each source color and alpha channels are modulated by the appropriate color value according to the following formula:

 srcC = srcC * (color / 255)
 srcA = srcA * (alpha / 255)

Color and alpha modulation is not always supported by the renderer; it will return false if either modulation is not supported.

Parameters
cthe color and alpha channel values multiplied into copy operations.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ SetModFloat()

void SDL::Texture::SetModFloat ( FColor c)
inline

Set an additional color and alpha values multiplied into render copy operations.

When this texture is rendered, during the copy operation each source color and alpha channels are modulated by the appropriate color value according to the following formula:

 srcC = srcC * (color / 255)
 srcA = srcA * (alpha / 255)

Color and alpha modulation is not always supported by the renderer; it will return false if either modulation is not supported.

Parameters
cthe color and alpha channel values multiplied into copy operations.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ SetPalette()

void SDL::Texture::SetPalette ( PaletteRef palette)
inline

Set the palette used by a texture.

Setting the palette keeps an internal reference to the palette, which can be safely destroyed afterwards.

A single palette can be shared with many textures.

Parameters
palettethe Palette structure to use.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
CreatePalette
Texture.GetPalette

◆ SetRenderClipRect()

void SDL::SetRenderClipRect ( RendererRef renderer,
OptionalRef< const RectRaw > rect )
inline

Set the clip rectangle for rendering on the specified target.

Each render target has its own clip rectangle. This function sets the cliprect for the current render target.

Parameters
rendererthe rendering context.
rectan Rect structure representing the clip area, relative to the viewport, or nullptr to disable clipping.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetClipRect
Renderer.IsClipEnabled

◆ SetRenderColorScale()

void SDL::SetRenderColorScale ( RendererRef renderer,
float scale )
inline

Set the color scale used for render operations.

The color scale is an additional scale multiplied into the pixel color value while rendering. This can be used to adjust the brightness of colors during HDR rendering, or changing HDR video brightness when playing on an SDR display.

The color scale does not affect the alpha channel, only the color brightness.

Parameters
rendererthe rendering context.
scalethe color scale value.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetColorScale

◆ SetRenderDrawBlendMode()

void SDL::SetRenderDrawBlendMode ( RendererRef renderer,
BlendMode blendMode )
inline

Set the blend mode used for drawing operations (Fill and Line).

If the blend mode is not supported, the closest supported mode is chosen.

Parameters
rendererthe rendering context.
blendModethe BlendMode to use for blending.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetDrawBlendMode

◆ SetRenderDrawColor()

void SDL::SetRenderDrawColor ( RendererRef renderer,
ColorRaw c )
inline

Set the color used for drawing operations.

Set the color for drawing or filling rectangles, lines, and points, and for Renderer.RenderClear().

Parameters
rendererthe rendering context.
cthe color used to draw on the rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetDrawColor
Renderer.SetDrawColorFloat

◆ SetRenderDrawColorFloat()

void SDL::SetRenderDrawColorFloat ( RendererRef renderer,
const FColorRaw & c )
inline

Set the color used for drawing operations (Rect, Line and Clear).

Set the color for drawing or filling rectangles, lines, and points, and for Renderer.RenderClear().

Parameters
rendererthe rendering context.
cthe color used to draw on the rendering target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetDrawColorFloat
Renderer.SetDrawColor

◆ SetRenderLogicalPresentation()

void SDL::SetRenderLogicalPresentation ( RendererRef renderer,
const PointRaw & size,
RendererLogicalPresentation mode )
inline

Set a device-independent resolution and presentation mode for rendering.

This function sets the width and height of the logical rendering output. The renderer will act as if the current render target is always the requested dimensions, scaling to the actual resolution as necessary.

This can be useful for games that expect a fixed size, but would like to scale the output to whatever is available, regardless of how a user resizes a window, or if the display is high DPI.

Logical presentation can be used with both render target textures and the renderer's window; the state is unique to each render target, and this function sets the state for the current render target. It might be useful to draw to a texture that matches the window dimensions with logical presentation enabled, and then draw that texture across the entire window with logical presentation disabled. Be careful not to render both with logical presentation enabled, however, as this could produce double-letterboxing, etc.

You can disable logical coordinates by setting the mode to LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel resolution of the render target; it is safe to toggle logical presentation during the rendering of a frame: perhaps most of the rendering is done to specific dimensions but to make fonts look sharp, the app turns off logical presentation while drawing text, for example.

You can convert coordinates in an event into rendering coordinates using Renderer.ConvertEventToRenderCoordinates().

Parameters
rendererthe rendering context.
sizethe width and height of the logical resolution.
modethe presentation mode used.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.ConvertEventToRenderCoordinates
Renderer.GetLogicalPresentation
Renderer.GetLogicalPresentationRect

◆ SetRenderScale()

void SDL::SetRenderScale ( RendererRef renderer,
const FPointRaw & scale )
inline

Set the drawing scale for rendering on the current target.

The drawing coordinates are scaled by the x/y scaling factors before they are used by the renderer. This allows resolution independent drawing with a single coordinate system.

If this results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints. For best results use integer scaling factors.

Each render target has its own scale. This function sets the scale for the current render target.

Parameters
rendererthe rendering context.
scalethe horizontal and vertical scaling factors.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetScale

◆ SetRenderTarget()

void SDL::SetRenderTarget ( RendererRef renderer,
TextureRef texture )
inline

Set a texture as the current rendering target.

The default render target is the window for which the renderer was created. To stop rendering to a texture and render to the window again, call this function with a nullptr texture.

Viewport, cliprect, scale, and logical presentation are unique to each render target. Get and set functions for these states apply to the current render target set by this function, and those states persist on each target when the current render target changes.

Parameters
rendererthe rendering context.
texturethe targeted texture, which must be created with the TEXTUREACCESS_TARGET flag, or nullptr to render to the window instead of a texture.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetTarget

◆ SetRenderTextureAddressMode() [1/2]

void SDL::Renderer::SetRenderTextureAddressMode ( TextureAddressMode u_mode,
TextureAddressMode v_mode )
inline

Set the texture addressing mode used in Renderer.RenderGeometry().

Parameters
u_modethe TextureAddressMode to use for horizontal texture coordinates in Renderer.RenderGeometry().
v_modethe TextureAddressMode to use for vertical texture coordinates in Renderer.RenderGeometry().
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
Renderer.RenderGeometry
Renderer.RenderGeometryRaw
Renderer.GetRenderTextureAddressMode

◆ SetRenderTextureAddressMode() [2/2]

void SDL::SetRenderTextureAddressMode ( RendererRef renderer,
TextureAddressMode u_mode,
TextureAddressMode v_mode )
inline

Set the texture addressing mode used in Renderer.RenderGeometry().

Parameters
rendererthe rendering context.
u_modethe TextureAddressMode to use for horizontal texture coordinates in Renderer.RenderGeometry().
v_modethe TextureAddressMode to use for vertical texture coordinates in Renderer.RenderGeometry().
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
Renderer.RenderGeometry
Renderer.RenderGeometryRaw
Renderer.GetRenderTextureAddressMode

◆ SetRenderViewport()

void SDL::SetRenderViewport ( RendererRef renderer,
OptionalRef< const RectRaw > rect )
inline

Set the drawing area for rendering on the current target.

Drawing will clip to this area (separately from any clipping done with Renderer.SetClipRect), and the top left of the area will become coordinate (0, 0) for future drawing commands.

The area's width and height must be >= 0.

Each render target has its own viewport. This function sets the viewport for the current render target.

Parameters
rendererthe rendering context.
rectthe Rect structure representing the drawing area, or nullptr to set the viewport to the entire target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetViewport
Renderer.ViewportSet

◆ SetRenderVSync()

void SDL::SetRenderVSync ( RendererRef renderer,
int vsync )
inline

Toggle VSync of the given renderer.

When a renderer is created, vsync defaults to RENDERER_VSYNC_DISABLED.

The vsync parameter can be 1 to synchronize present with every vertical refresh, 2 to synchronize present with every second vertical refresh, etc., RENDERER_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or RENDERER_VSYNC_DISABLED to disable. Not every value is supported by every driver, so you should check the return value to see whether the requested setting is supported.

Parameters
rendererthe renderer to toggle.
vsyncthe vertical refresh sync interval.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetVSync

◆ SetScale()

void SDL::Renderer::SetScale ( const FPointRaw & scale)
inline

Set the drawing scale for rendering on the current target.

The drawing coordinates are scaled by the x/y scaling factors before they are used by the renderer. This allows resolution independent drawing with a single coordinate system.

If this results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints. For best results use integer scaling factors.

Each render target has its own scale. This function sets the scale for the current render target.

Parameters
scalethe x, y scaling factors.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetScale

◆ SetScaleMode()

void SDL::Texture::SetScaleMode ( ScaleMode scaleMode)
inline

Set the scale mode used for texture scale operations.

The default texture scale mode is SCALEMODE_LINEAR.

If the scale mode is not supported, the closest supported mode is chosen.

Parameters
scaleModethe ScaleMode to use for texture scaling.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetScaleMode

◆ SetTarget()

void SDL::Renderer::SetTarget ( TextureRef texture)
inline

Set a texture as the current rendering target.

The default render target is the window for which the renderer was created. To stop rendering to a texture and render to the window again, call this function with a nullptr texture.

Viewport, cliprect, scale, and logical presentation are unique to each render target. Get and set functions for these states apply to the current render target set by this function, and those states persist on each target when the current render target changes.

Parameters
texturethe targeted texture, which must be created with the TEXTUREACCESS_TARGET flag, or nullptr to render to the window instead of a texture.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetTarget

◆ SetTextureAlphaMod()

void SDL::SetTextureAlphaMod ( TextureRef texture,
Uint8 alpha )
inline

Set an additional alpha value multiplied into render copy operations.

When this texture is rendered, during the copy operation the source alpha value is modulated by this alpha value according to the following formula:

srcA = srcA * (alpha / 255)

Alpha modulation is not always supported by the renderer; it will return false if alpha modulation is not supported.

Parameters
texturethe texture to update.
alphathe source alpha value multiplied into copy operations.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetAlphaMod
Texture.SetAlphaModFloat
Texture.SetColorMod

◆ SetTextureAlphaModFloat()

void SDL::SetTextureAlphaModFloat ( TextureRef texture,
float alpha )
inline

Set an additional alpha value multiplied into render copy operations.

When this texture is rendered, during the copy operation the source alpha value is modulated by this alpha value according to the following formula:

srcA = srcA * alpha

Alpha modulation is not always supported by the renderer; it will return false if alpha modulation is not supported.

Parameters
texturethe texture to update.
alphathe source alpha value multiplied into copy operations.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetAlphaModFloat
Texture.SetAlphaMod
Texture.SetColorModFloat

◆ SetTextureBlendMode()

void SDL::SetTextureBlendMode ( TextureRef texture,
BlendMode blendMode )
inline

Set the blend mode for a texture, used by Renderer.RenderTexture().

If the blend mode is not supported, the closest supported mode is chosen and this function returns false.

Parameters
texturethe texture to update.
blendModethe BlendMode to use for texture blending.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetBlendMode

◆ SetTextureColorMod()

void SDL::SetTextureColorMod ( TextureRef texture,
Uint8 r,
Uint8 g,
Uint8 b )
inline

Set an additional color value multiplied into render copy operations.

When this texture is rendered, during the copy operation each source color channel is modulated by the appropriate color value according to the following formula:

srcC = srcC * (color / 255)

Color modulation is not always supported by the renderer; it will return false if color modulation is not supported.

Parameters
texturethe texture to update.
rthe red color value multiplied into copy operations.
gthe green color value multiplied into copy operations.
bthe blue color value multiplied into copy operations.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetColorMod
Texture.SetAlphaMod
Texture.SetColorModFloat

◆ SetTextureColorModFloat()

void SDL::SetTextureColorModFloat ( TextureRef texture,
float r,
float g,
float b )
inline

Set an additional color value multiplied into render copy operations.

When this texture is rendered, during the copy operation each source color channel is modulated by the appropriate color value according to the following formula:

srcC = srcC * color

Color modulation is not always supported by the renderer; it will return false if color modulation is not supported.

Parameters
texturethe texture to update.
rthe red color value multiplied into copy operations.
gthe green color value multiplied into copy operations.
bthe blue color value multiplied into copy operations.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetColorModFloat
Texture.SetAlphaModFloat
Texture.SetColorMod

◆ SetTextureMod()

void SDL::SetTextureMod ( TextureRef texture,
Color c )
inline

Set an additional color and alpha values multiplied into render copy operations.

When this texture is rendered, during the copy operation each source color and alpha channels are modulated by the appropriate color value according to the following formula:

 srcC = srcC * (color / 255)
 srcA = srcA * (alpha / 255)

Color and alpha modulation is not always supported by the renderer; it will return false if either modulation is not supported.

Parameters
texturethe texture to update.
cthe color and alpha channel values multiplied into copy operations.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ SetTextureModFloat()

void SDL::SetTextureModFloat ( TextureRef texture,
FColor c )
inline

Set an additional color and alpha values multiplied into render copy operations.

When this texture is rendered, during the copy operation each source color and alpha channels are modulated by the appropriate color value according to the following formula:

 srcC = srcC * (color / 255)
 srcA = srcA * (alpha / 255)

Color and alpha modulation is not always supported by the renderer; it will return false if either modulation is not supported.

Parameters
texturethe texture to update.
cthe color and alpha channel values multiplied into copy operations.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

◆ SetTexturePalette()

void SDL::SetTexturePalette ( TextureRef texture,
PaletteRef palette )
inline

Set the palette used by a texture.

Setting the palette keeps an internal reference to the palette, which can be safely destroyed afterwards.

A single palette can be shared with many textures.

Parameters
texturethe texture to update.
palettethe Palette structure to use.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.4.0.
See also
CreatePalette
Texture.GetPalette

◆ SetTextureScaleMode()

void SDL::SetTextureScaleMode ( TextureRef texture,
ScaleMode scaleMode )
inline

Set the scale mode used for texture scale operations.

The default texture scale mode is SCALEMODE_LINEAR.

If the scale mode is not supported, the closest supported mode is chosen.

Parameters
texturethe texture to update.
scaleModethe ScaleMode to use for texture scaling.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.GetScaleMode

◆ SetViewport()

void SDL::Renderer::SetViewport ( OptionalRef< const RectRaw > rect)
inline

Set the drawing area for rendering on the current target.

Drawing will clip to this area (separately from any clipping done with Renderer.SetClipRect), and the top left of the area will become coordinate (0, 0) for future drawing commands.

The area's width and height must be >= 0.

Each render target has its own viewport. This function sets the viewport for the current render target.

Parameters
rectthe Rect structure representing the drawing area, or nullptr to set the viewport to the entire target.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetViewport
Renderer.ViewportSet

◆ SetVSync()

void SDL::Renderer::SetVSync ( int vsync)
inline

Toggle VSync of the given renderer.

When a renderer is created, vsync defaults to RENDERER_VSYNC_DISABLED.

The vsync parameter can be 1 to synchronize present with every vertical refresh, 2 to synchronize present with every second vertical refresh, etc., RENDERER_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or RENDERER_VSYNC_DISABLED to disable. Not every value is supported by every driver, so you should check the return value to see whether the requested setting is supported.

Parameters
vsyncthe vertical refresh sync interval.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetVSync

◆ Texture() [1/3]

SDL::Texture::Texture ( RendererRef renderer,
PixelFormat format,
TextureAccess access,
const PointRaw & size )
inline

Create a texture for a rendering context.

The contents of a texture when first created are not defined.

Parameters
rendererthe rendering context.
formatone of the enumerated values in PixelFormat.
accessone of the enumerated values in TextureAccess.
sizethe width and height of the texture in pixels.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.CreateTextureFromSurface
Renderer.CreateTextureWithProperties
Texture.Destroy
Texture.GetSize
Texture.Update

◆ Texture() [2/3]

SDL::Texture::Texture ( RendererRef renderer,
PropertiesRef props )
inline

Create a texture for a rendering context with the specified properties.

These are the supported properties:

With the direct3d11 renderer:

With the direct3d12 renderer:

With the metal renderer:

With the opengl renderer:

With the opengles2 renderer:

With the vulkan renderer:

With the GPU renderer:

  • prop.Texture.Create.GPU_TEXTURE_POINTER: the GPUTexture associated with the texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_NUMBER: the GPUTexture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_NUMBER: the GPUTexture associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_NUMBER: the GPUTexture associated with the V plane of a YUV texture, if you want to wrap an existing texture.
Parameters
rendererthe rendering context.
propsthe properties to use.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Properties.Create
Renderer.CreateTexture
Renderer.CreateTextureFromSurface
Texture.Destroy
Texture.GetSize
Texture.Update

◆ Texture() [3/3]

SDL::Texture::Texture ( RendererRef renderer,
SurfaceRef surface )
inline

Create a texture from an existing surface.

The surface is not modified or freed by this function.

The TextureAccess hint for the created texture is TEXTUREACCESS_STATIC.

The pixel format of the created texture may be different from the pixel format of the surface, and can be queried using the prop.Texture.FORMAT_NUMBER property.

Parameters
rendererthe rendering context.
surfacethe Surface structure containing pixel data used to fill the texture.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.CreateTexture
Renderer.CreateTextureWithProperties
Texture.Destroy

◆ TextureLock()

SDL::TextureLock::TextureLock ( TextureRef resource,
OptionalRef< const RectRaw > rect,
void ** pixels,
int * pitch )
inline

Lock a portion of the texture for write-only pixel access.

As an optimization, the pixels made available for editing don't necessarily contain the old texture data. This is a write-only operation, and if you need to keep a copy of the texture data you should do that at the application level.

You must use Texture.Unlock() to unlock the pixels and apply any changes.

Parameters
resourcethe texture to lock for access, which was created with TEXTUREACCESS_STREAMING.
rectan Rect structure representing the area to lock for access; nullptr to lock the entire texture.
pixelsthis is filled in with a pointer to the locked pixels, appropriately offset by the locked area.
pitchthis is filled in with the pitch of the locked pixels; the pitch is the length of one row in bytes.
Postcondition
true on success or false if the texture is not valid or was not created with TEXTUREACCESS_STREAMING; call GetError() for more information.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.LockToSurface
Texture.Unlock

◆ TextureSurfaceLock()

SDL::TextureSurfaceLock::TextureSurfaceLock ( TextureRef resource,
OptionalRef< const RectRaw > rect = std::nullopt )
inline

Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.

Besides providing an Surface instead of raw pixel data, this function operates like Texture.Lock.

As an optimization, the pixels made available for editing don't necessarily contain the old texture data. This is a write-only operation, and if you need to keep a copy of the texture data you should do that at the application level.

You must use Texture.Unlock() to unlock the pixels and apply any changes.

The returned surface is freed internally after calling Texture.Unlock() or Texture.Destroy(). The caller should not free it.

Parameters
resourcethe texture to lock for access, which must be created with TEXTUREACCESS_STREAMING.
recta pointer to the rectangle to lock for access. If the rect is nullptr, the entire texture will be locked.
Postcondition
a surface of size rect. Don't assume any specific pixel content.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Lock
Texture.Unlock

◆ Unlock() [1/2]

void SDL::Texture::Unlock ( TextureLock && lock)
inline

Unlock a texture, uploading the changes to video memory, if needed.

Warning: Please note that Texture.Lock() is intended to be write-only; it will not guarantee the previous contents of the texture will be provided. You must fully initialize any area of a texture that you lock before unlocking it, as the pixels might otherwise be uninitialized memory.

Which is to say: locking and immediately unlocking a texture can result in corrupted textures, depending on the renderer in use.

Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Lock

◆ Unlock() [2/2]

void SDL::Texture::Unlock ( TextureSurfaceLock && lock)
inline

Unlock a texture, uploading the changes to video memory, if needed.

Warning: Please note that Texture.Lock() is intended to be write-only; it will not guarantee the previous contents of the texture will be provided. You must fully initialize any area of a texture that you lock before unlocking it, as the pixels might otherwise be uninitialized memory.

Which is to say: locking and immediately unlocking a texture can result in corrupted textures, depending on the renderer in use.

Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Lock

◆ UnlockTexture()

void SDL::UnlockTexture ( TextureRef texture)
inline

Unlock a texture, uploading the changes to video memory, if needed.

Warning: Please note that Texture.Lock() is intended to be write-only; it will not guarantee the previous contents of the texture will be provided. You must fully initialize any area of a texture that you lock before unlocking it, as the pixels might otherwise be uninitialized memory.

Which is to say: locking and immediately unlocking a texture can result in corrupted textures, depending on the renderer in use.

Parameters
texturea texture locked by Texture.Lock().
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Lock

◆ Update() [1/2]

void SDL::Texture::Update ( OptionalRef< const RectRaw > rect,
const void * pixels,
int pitch )
inline

Update the given texture rectangle with new pixel data.

The pixel data must be in the pixel format of the texture, which can be queried using the prop.Texture.FORMAT_NUMBER property.

This is a fairly slow function, intended for use with static textures that do not change often.

If the texture is intended to be updated often, it is preferred to create the texture as streaming and use the locking functions referenced below. While this function will work with streaming textures, for optimization reasons you may not get the pixels back if you lock the texture afterward.

Parameters
rectan Rect structure representing the area to update, or nullptr to update the entire texture.
pixelsthe raw pixel data in the format of the texture.
pitchthe number of bytes in a row of pixel data, including padding between lines.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Lock
Texture.Unlock
Texture.UpdateNV
Texture.UpdateYUV

◆ Update() [2/2]

void SDL::Texture::Update ( SurfaceConstRef surface,
OptionalRef< const RectRaw > rect = std::nullopt )
inline

Update the given texture rectangle with new pixel data.

The pixel data must be in the pixel format of the texture, which can be queried using the prop.Texture.FORMAT_NUMBER property.

This is a fairly slow function, intended for use with static textures that do not change often.

If the texture is intended to be updated often, it is preferred to create the texture as streaming and use the locking functions referenced below. While this function will work with streaming textures, for optimization reasons you may not get the pixels back if you lock the texture afterward.

Parameters
surfacethe surface containing pixel data in the format of the texture.
rectan Rect structure representing the area to update, or std::nullopt to update the entire texture.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Lock
Texture.Unlock
Texture.UpdateNV
Texture.UpdateYUV

◆ UpdateNV()

void SDL::Texture::UpdateNV ( OptionalRef< const RectRaw > rect,
const Uint8 * Yplane,
int Ypitch,
const Uint8 * UVplane,
int UVpitch )
inline

Update a rectangle within a planar NV12 or NV21 texture with new pixels.

You can use Texture.Update() as long as your pixel data is a contiguous block of NV12/21 planes in the proper order, but this function is available if your pixel data is not contiguous.

Parameters
recta pointer to the rectangle of pixels to update, or nullptr to update the entire texture.
Yplanethe raw pixel data for the Y plane.
Ypitchthe number of bytes between rows of pixel data for the Y plane.
UVplanethe raw pixel data for the UV plane.
UVpitchthe number of bytes between rows of pixel data for the UV plane.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Update
Texture.UpdateYUV

◆ UpdateNVTexture()

void SDL::UpdateNVTexture ( TextureRef texture,
OptionalRef< const RectRaw > rect,
const Uint8 * Yplane,
int Ypitch,
const Uint8 * UVplane,
int UVpitch )
inline

Update a rectangle within a planar NV12 or NV21 texture with new pixels.

You can use Texture.Update() as long as your pixel data is a contiguous block of NV12/21 planes in the proper order, but this function is available if your pixel data is not contiguous.

Parameters
texturethe texture to update.
recta pointer to the rectangle of pixels to update, or nullptr to update the entire texture.
Yplanethe raw pixel data for the Y plane.
Ypitchthe number of bytes between rows of pixel data for the Y plane.
UVplanethe raw pixel data for the UV plane.
UVpitchthe number of bytes between rows of pixel data for the UV plane.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Update
Texture.UpdateYUV

◆ UpdateTexture() [1/2]

void SDL::UpdateTexture ( TextureRef texture,
OptionalRef< const RectRaw > rect,
const void * pixels,
int pitch )
inline

Update the given texture rectangle with new pixel data.

The pixel data must be in the pixel format of the texture, which can be queried using the prop.Texture.FORMAT_NUMBER property.

This is a fairly slow function, intended for use with static textures that do not change often.

If the texture is intended to be updated often, it is preferred to create the texture as streaming and use the locking functions referenced below. While this function will work with streaming textures, for optimization reasons you may not get the pixels back if you lock the texture afterward.

Parameters
texturethe texture to update.
rectan Rect structure representing the area to update, or nullptr to update the entire texture.
pixelsthe raw pixel data in the format of the texture.
pitchthe number of bytes in a row of pixel data, including padding between lines.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Lock
Texture.Unlock
Texture.UpdateNV
Texture.UpdateYUV

◆ UpdateTexture() [2/2]

void SDL::UpdateTexture ( TextureRef texture,
SurfaceConstRef surface,
OptionalRef< const RectRaw > rect = std::nullopt )
inline

Update the given texture rectangle with new pixel data.

The pixel data must be in the pixel format of the texture, which can be queried using the prop.Texture.FORMAT_NUMBER property.

This is a fairly slow function, intended for use with static textures that do not change often.

If the texture is intended to be updated often, it is preferred to create the texture as streaming and use the locking functions referenced below. While this function will work with streaming textures, for optimization reasons you may not get the pixels back if you lock the texture afterward.

Parameters
texturethe texture to update.
surfacethe surface containing pixel data in the format of the texture.
rectan Rect structure representing the area to update, or std::nullopt to update the entire texture.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.Lock
Texture.Unlock
Texture.UpdateNV
Texture.UpdateYUV

◆ UpdateYUV()

void SDL::Texture::UpdateYUV ( OptionalRef< const RectRaw > rect,
const Uint8 * Yplane,
int Ypitch,
const Uint8 * Uplane,
int Upitch,
const Uint8 * Vplane,
int Vpitch )
inline

Update a rectangle within a planar YV12 or IYUV texture with new pixel data.

You can use Texture.Update() as long as your pixel data is a contiguous block of Y and U/V planes in the proper order, but this function is available if your pixel data is not contiguous.

Parameters
recta pointer to the rectangle of pixels to update, or nullptr to update the entire texture.
Yplanethe raw pixel data for the Y plane.
Ypitchthe number of bytes between rows of pixel data for the Y plane.
Uplanethe raw pixel data for the U plane.
Upitchthe number of bytes between rows of pixel data for the U plane.
Vplanethe raw pixel data for the V plane.
Vpitchthe number of bytes between rows of pixel data for the V plane.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.UpdateNV
Texture.Update

◆ UpdateYUVTexture()

void SDL::UpdateYUVTexture ( TextureRef texture,
OptionalRef< const RectRaw > rect,
const Uint8 * Yplane,
int Ypitch,
const Uint8 * Uplane,
int Upitch,
const Uint8 * Vplane,
int Vpitch )
inline

Update a rectangle within a planar YV12 or IYUV texture with new pixel data.

You can use Texture.Update() as long as your pixel data is a contiguous block of Y and U/V planes in the proper order, but this function is available if your pixel data is not contiguous.

Parameters
texturethe texture to update.
recta pointer to the rectangle of pixels to update, or nullptr to update the entire texture.
Yplanethe raw pixel data for the Y plane.
Ypitchthe number of bytes between rows of pixel data for the Y plane.
Uplanethe raw pixel data for the U plane.
Upitchthe number of bytes between rows of pixel data for the U plane.
Vplanethe raw pixel data for the V plane.
Vpitchthe number of bytes between rows of pixel data for the V plane.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Texture.UpdateNV
Texture.Update

◆ ViewportSet()

bool SDL::Renderer::ViewportSet ( ) const
inline

Return whether an explicit rectangle was set as the viewport.

This is useful if you're saving and restoring the viewport and want to know whether you should restore a specific rectangle or nullptr.

Each render target has its own viewport. This function checks the viewport for the current render target.

Returns
true if the viewport was set to a specific rectangle, or false if it was set to nullptr (the entire target).
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.GetViewport
Renderer.SetViewport

◆ Window()

SDL::Window::Window ( StringParam title,
const PointRaw & size,
WindowFlags window_flags,
RendererRef * renderer )
inline

Create a window and default renderer.

Parameters
titlethe title of the window, in UTF-8 encoding.
sizethe width and height of the window.
window_flagsthe flags used to create the window (see CreateWindow()).
renderera pointer filled with the renderer.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
CreateRenderer
CreateWindow

Variable Documentation

◆ DEBUG_TEXT_FONT_CHARACTER_SIZE

int SDL::DEBUG_TEXT_FONT_CHARACTER_SIZE
constexpr
Initial value:
=
SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE

The size, in pixels, of a single Renderer.RenderDebugText() character.

The font is monospaced and square, so this applies to all characters.

Since
This constant is available since SDL 3.2.0.
See also
Renderer.RenderDebugText

◆ GPU_RENDERER

auto SDL::GPU_RENDERER = SDL_GPU_RENDERER
constexpr

The name of the GPU renderer.

Since
This constant is available since SDL 3.4.0.

◆ LOGICAL_PRESENTATION_DISABLED

RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_DISABLED
constexpr
Initial value:
=
SDL_LOGICAL_PRESENTATION_DISABLED

There is no logical size in effect.

◆ LOGICAL_PRESENTATION_INTEGER_SCALE

RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_INTEGER_SCALE
constexpr
Initial value:
=
SDL_LOGICAL_PRESENTATION_INTEGER_SCALE

The rendered content is scaled up by integer multiples to fit the output resolution.

◆ LOGICAL_PRESENTATION_LETTERBOX

RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_LETTERBOX
constexpr
Initial value:
=
SDL_LOGICAL_PRESENTATION_LETTERBOX

The rendered content is fit to the largest dimension and the other dimension is letterboxed with the clear color.

◆ LOGICAL_PRESENTATION_OVERSCAN

RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_OVERSCAN
constexpr
Initial value:
=
SDL_LOGICAL_PRESENTATION_OVERSCAN

The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds.

◆ LOGICAL_PRESENTATION_STRETCH

RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_STRETCH
constexpr
Initial value:
=
SDL_LOGICAL_PRESENTATION_STRETCH

The rendered content is stretched to the output resolution.

◆ SOFTWARE_RENDERER

auto SDL::SOFTWARE_RENDERER = SDL_SOFTWARE_RENDERER
constexpr

The name of the software renderer.

Since
This constant is available since SDL 3.2.0.

◆ TEXTURE_ADDRESS_INVALID

TextureAddressMode SDL::TEXTURE_ADDRESS_INVALID
constexpr
Initial value:
=
SDL_TEXTURE_ADDRESS_INVALID

TEXTURE_ADDRESS_INVALID.

◆ TEXTURE_ADDRESS_WRAP

TextureAddressMode SDL::TEXTURE_ADDRESS_WRAP
constexpr
Initial value:
=
SDL_TEXTURE_ADDRESS_WRAP

The texture is repeated (tiled).

◆ TEXTUREACCESS_STATIC

TextureAccess SDL::TEXTUREACCESS_STATIC
constexpr
Initial value:
=
SDL_TEXTUREACCESS_STATIC

Changes rarely, not lockable.

◆ TEXTUREACCESS_STREAMING

TextureAccess SDL::TEXTUREACCESS_STREAMING
constexpr
Initial value:
=
SDL_TEXTUREACCESS_STREAMING

Changes frequently, lockable.

◆ TEXTUREACCESS_TARGET

TextureAccess SDL::TEXTUREACCESS_TARGET
constexpr
Initial value:
=
SDL_TEXTUREACCESS_TARGET

Texture can be used as a render target.