SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
2D Accelerated Rendering

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

Collaboration diagram for 2D Accelerated Rendering:

Classes

struct  SDL::RendererParam
 Safely wrap Renderer for non owning parameters. More...
 
struct  SDL::TextureParam
 Safely wrap Texture for non owning parameters. More...
 
class  SDL::Renderer
 A structure representing rendering state. More...
 
struct  SDL::RendererRef
 Semi-safe reference for Renderer. More...
 
class  SDL::Texture
 An efficient driver-specific representation of pixel data. More...
 

Macros

#define SDL_SOFTWARE_RENDERER   "software"
 The name of the software renderer. More...
 
#define SDL_RENDERER_VSYNC_DISABLED   0
 Constant for disabling renderer vsync.
 
#define SDL_RENDERER_VSYNC_ADAPTIVE   (-1)
 Constant for enabling asaptive renderer vsync.
 
#define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE   8
 The size, in pixels, of a single Renderer.RenderDebugText() character. 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::Vertex = SDL_Vertex
 Vertex structure. More...
 
using SDL::TextureAccess = SDL_TextureAccess
 The access pattern allowed for a texture. More...
 
using SDL::RendererLogicalPresentation = SDL_RendererLogicalPresentation
 How the logical size is mapped to the output. More...
 

Functions

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

Variables

constexpr TextureAccess SDL::TEXTUREACCESS_STATIC
 Changes rarely, not lockable. More...
 
constexpr TextureAccess SDL::TEXTUREACCESS_STREAMING
 Changes frequently, lockable. More...
 
constexpr TextureAccess SDL::TEXTUREACCESS_TARGET
 Texture can be used as a render target. More...
 
constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_DISABLED
 There is no logical size in effect. More...
 
constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_STRETCH
 The rendered content is stretched to the output resolution. More...
 
constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_LETTERBOX
 The rendered content is fit to the largest dimension and the other dimension is letterboxed with black bars. More...
 
constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_OVERSCAN
 The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds. More...
 
constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_INTEGER_SCALE
 The rendered content is scaled up by integer multiples to fit the output resolution. More...
 

Detailed Description

This API supports the following features:

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 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

Macro Definition Documentation

◆ SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE

#define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE   8

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

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

◆ SDL_SOFTWARE_RENDERER

#define SDL_SOFTWARE_RENDERER   "software"
Since
This macro is available since SDL 3.2.0.

Typedef Documentation

◆ RendererLogicalPresentation

using SDL::RendererLogicalPresentation = typedef SDL_RendererLogicalPresentation
Since
This enum is available since SDL 3.2.0.

◆ TextureAccess

using SDL::TextureAccess = typedef SDL_TextureAccess
Since
This enum is available since SDL 3.2.0.

◆ Vertex

using SDL::Vertex = typedef SDL_Vertex
Since
This struct is available since SDL 3.2.0.

Function Documentation

◆ AddVulkanRenderSemaphores() [1/2]

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

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

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::Renderer::ConvertEventToRenderCoordinates ( Event event) const
inline

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

◆ ConvertEventToRenderCoordinates() [2/2]

void SDL::ConvertEventToRenderCoordinates ( RendererParam  renderer,
Event event 
)
inline

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

◆ CreateRenderer()

Renderer SDL::CreateRenderer ( WindowParam  window,
StringParam  name 
)
inline

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
Renderer.Renderer
Renderer.Renderer
Renderer.Destroy
GetNumRenderDrivers
GetRenderDriver
Renderer.GetName

◆ CreateRendererWithProperties()

Renderer SDL::CreateRendererWithProperties ( PropertiesParam  props)
inline

These are the supported properties:

  • prop::Renderer.CREATE_NAME_STRING: the name of the rendering driver to use, if a specific one is desired
  • prop::Renderer.CREATE_WINDOW_POINTER: the window where rendering is displayed, required if this isn't a software renderer using a surface
  • prop::Renderer.CREATE_SURFACE_POINTER: the surface where rendering is displayed, if you want a software renderer without a window
  • prop::Renderer.CREATE_OUTPUT_COLORSPACE_NUMBER: an Colorspace value describing the colorspace for output to the display, defaults to COLORSPACE_SRGB. The direct3d11, direct3d12, and metal renderers support COLORSPACE_SRGB_LINEAR, which is a linear color space and supports HDR output. If you select COLORSPACE_SRGB_LINEAR, drawing still uses the sRGB colorspace, but values can go beyond 1.0 and float (linear) format textures can be used for HDR content.
  • prop::Renderer.CREATE_PRESENT_VSYNC_NUMBER: non-zero if you want present synchronized with the refresh rate. This property can take any value that is supported by Renderer.SetVSync() for the renderer.

With the vulkan renderer:

  • prop::Renderer.CREATE_VULKAN_INSTANCE_POINTER: the VkInstance to use with the renderer, optional.
  • prop::Renderer.CREATE_VULKAN_SURFACE_NUMBER: the VkSurfaceKHR to use with the renderer, optional.
  • prop::Renderer.CREATE_VULKAN_PHYSICAL_DEVICE_POINTER: the VkPhysicalDevice to use with the renderer, optional.
  • prop::Renderer.CREATE_VULKAN_DEVICE_POINTER: the VkDevice to use with the renderer, optional.
  • prop::Renderer.CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER: the queue family index used for rendering.
  • prop::Renderer.CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER: the queue family index used for presentation.
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
Renderer.Renderer
Renderer.Renderer
Renderer.Destroy
Renderer.GetName

◆ CreateSoftwareRenderer()

Renderer SDL::CreateSoftwareRenderer ( SurfaceParam  surface)
inline

Two other API which can be used to create Renderer: Renderer.Renderer() 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:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Renderer.Destroy

◆ CreateTexture() [1/2]

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

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
Texture.Texture
Texture.Texture
Texture.Destroy
Texture.GetSize
Texture.Update

◆ CreateTexture() [2/2]

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

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
Texture.Texture
Texture.Texture
Texture.Destroy
Texture.GetSize
Texture.Update

◆ CreateTextureFromSurface() [1/2]

Texture SDL::CreateTextureFromSurface ( RendererParam  renderer,
SurfaceParam  surface 
)
inline

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
Texture.Texture
Texture.Texture
Texture.Destroy

◆ CreateTextureFromSurface() [2/2]

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

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
Texture.Texture
Texture.Texture
Texture.Destroy

◆ CreateTextureWithProperties() [1/2]

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

These are the supported properties:

  • prop::Texture.CREATE_COLORSPACE_NUMBER: an Colorspace value describing the texture colorspace, defaults to COLORSPACE_SRGB_LINEAR for floating point textures, COLORSPACE_HDR10 for 10-bit textures, COLORSPACE_SRGB for other RGB textures and COLORSPACE_JPEG for YUV textures.
  • prop::Texture.CREATE_FORMAT_NUMBER: one of the enumerated values in PixelFormat, defaults to the best RGBA format for the renderer
  • prop::Texture.CREATE_ACCESS_NUMBER: one of the enumerated values in TextureAccess, defaults to TEXTUREACCESS_STATIC
  • prop::Texture.CREATE_WIDTH_NUMBER: the width of the texture in pixels, required
  • prop::Texture.CREATE_HEIGHT_NUMBER: the height of the texture in pixels, required
  • prop::Texture.CREATE_SDR_WHITE_POINT_FLOAT: for HDR10 and floating point textures, this defines the value of 100% diffuse white, with higher values being displayed in the High Dynamic Range headroom. This defaults to 100 for HDR10 textures and 1.0 for floating point textures.
  • prop::Texture.CREATE_HDR_HEADROOM_FLOAT: for HDR10 and floating point textures, this defines the maximum dynamic range used by the content, in terms of the SDR white point. This would be equivalent to maxCLL / prop::Texture.CREATE_SDR_WHITE_POINT_FLOAT for HDR10 content. If this is defined, any values outside the range supported by the display will be scaled into the available HDR headroom, otherwise they are clipped.

With the direct3d11 renderer:

  • prop::Texture.CREATE_D3D11_TEXTURE_POINTER: the ID3D11Texture2D associated with the texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_D3D11_TEXTURE_U_POINTER: the ID3D11Texture2D associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_D3D11_TEXTURE_V_POINTER: the ID3D11Texture2D associated with the V plane of a YUV texture, if you want to wrap an existing texture.

With the direct3d12 renderer:

  • prop::Texture.CREATE_D3D12_TEXTURE_POINTER: the ID3D12Resource associated with the texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_D3D12_TEXTURE_U_POINTER: the ID3D12Resource associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_D3D12_TEXTURE_V_POINTER: the ID3D12Resource associated with the V plane of a YUV texture, if you want to wrap an existing texture.

With the metal renderer:

  • prop::Texture.CREATE_METAL_PIXELBUFFER_POINTER: the CVPixelBufferRef associated with the texture, if you want to create a texture from an existing pixel buffer.

With the opengl renderer:

  • prop::Texture.CREATE_OPENGL_TEXTURE_NUMBER: the GLuint texture associated with the texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGL_TEXTURE_UV_NUMBER: the GLuint texture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGL_TEXTURE_U_NUMBER: the GLuint texture associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGL_TEXTURE_V_NUMBER: the GLuint texture associated with the V plane of a YUV texture, if you want to wrap an existing texture.

With the opengles2 renderer:

  • prop::Texture.CREATE_OPENGLES2_TEXTURE_NUMBER: the GLuint texture associated with the texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGLES2_TEXTURE_NUMBER: the GLuint texture associated with the texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGLES2_TEXTURE_UV_NUMBER: the GLuint texture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGLES2_TEXTURE_U_NUMBER: the GLuint texture associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGLES2_TEXTURE_V_NUMBER: the GLuint texture associated with the V plane of a YUV texture, if you want to wrap an existing texture.

With the vulkan renderer:

  • prop::Texture.CREATE_VULKAN_TEXTURE_NUMBER: the VkImage with layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL associated with the 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
Texture.Texture
Texture.Texture
Texture.Destroy
Texture.GetSize
Texture.Update

◆ CreateTextureWithProperties() [2/2]

Texture SDL::CreateTextureWithProperties ( RendererParam  renderer,
PropertiesParam  props 
)
inline

These are the supported properties:

  • prop::Texture.CREATE_COLORSPACE_NUMBER: an Colorspace value describing the texture colorspace, defaults to COLORSPACE_SRGB_LINEAR for floating point textures, COLORSPACE_HDR10 for 10-bit textures, COLORSPACE_SRGB for other RGB textures and COLORSPACE_JPEG for YUV textures.
  • prop::Texture.CREATE_FORMAT_NUMBER: one of the enumerated values in PixelFormat, defaults to the best RGBA format for the renderer
  • prop::Texture.CREATE_ACCESS_NUMBER: one of the enumerated values in TextureAccess, defaults to TEXTUREACCESS_STATIC
  • prop::Texture.CREATE_WIDTH_NUMBER: the width of the texture in pixels, required
  • prop::Texture.CREATE_HEIGHT_NUMBER: the height of the texture in pixels, required
  • prop::Texture.CREATE_SDR_WHITE_POINT_FLOAT: for HDR10 and floating point textures, this defines the value of 100% diffuse white, with higher values being displayed in the High Dynamic Range headroom. This defaults to 100 for HDR10 textures and 1.0 for floating point textures.
  • prop::Texture.CREATE_HDR_HEADROOM_FLOAT: for HDR10 and floating point textures, this defines the maximum dynamic range used by the content, in terms of the SDR white point. This would be equivalent to maxCLL / prop::Texture.CREATE_SDR_WHITE_POINT_FLOAT for HDR10 content. If this is defined, any values outside the range supported by the display will be scaled into the available HDR headroom, otherwise they are clipped.

With the direct3d11 renderer:

  • prop::Texture.CREATE_D3D11_TEXTURE_POINTER: the ID3D11Texture2D associated with the texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_D3D11_TEXTURE_U_POINTER: the ID3D11Texture2D associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_D3D11_TEXTURE_V_POINTER: the ID3D11Texture2D associated with the V plane of a YUV texture, if you want to wrap an existing texture.

With the direct3d12 renderer:

  • prop::Texture.CREATE_D3D12_TEXTURE_POINTER: the ID3D12Resource associated with the texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_D3D12_TEXTURE_U_POINTER: the ID3D12Resource associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_D3D12_TEXTURE_V_POINTER: the ID3D12Resource associated with the V plane of a YUV texture, if you want to wrap an existing texture.

With the metal renderer:

  • prop::Texture.CREATE_METAL_PIXELBUFFER_POINTER: the CVPixelBufferRef associated with the texture, if you want to create a texture from an existing pixel buffer.

With the opengl renderer:

  • prop::Texture.CREATE_OPENGL_TEXTURE_NUMBER: the GLuint texture associated with the texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGL_TEXTURE_UV_NUMBER: the GLuint texture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGL_TEXTURE_U_NUMBER: the GLuint texture associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGL_TEXTURE_V_NUMBER: the GLuint texture associated with the V plane of a YUV texture, if you want to wrap an existing texture.

With the opengles2 renderer:

  • prop::Texture.CREATE_OPENGLES2_TEXTURE_NUMBER: the GLuint texture associated with the texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGLES2_TEXTURE_NUMBER: the GLuint texture associated with the texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGLES2_TEXTURE_UV_NUMBER: the GLuint texture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGLES2_TEXTURE_U_NUMBER: the GLuint texture associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • prop::Texture.CREATE_OPENGLES2_TEXTURE_V_NUMBER: the GLuint texture associated with the V plane of a YUV texture, if you want to wrap an existing texture.

With the vulkan renderer:

  • prop::Texture.CREATE_VULKAN_TEXTURE_NUMBER: the VkImage with layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL associated with the 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
Texture.Texture
Texture.Texture
Texture.Destroy
Texture.GetSize
Texture.Update

◆ CreateWindowAndRenderer()

std::pair< Window, Renderer > SDL::CreateWindowAndRenderer ( StringParam  title,
const PointRaw size,
WindowFlags  window_flags = 0 
)
inline
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()).
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
Renderer.Renderer
Window.Window

◆ Destroy() [1/2]

void SDL::Renderer::Destroy ( )
inline

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
Renderer.Renderer

◆ Destroy() [2/2]

void SDL::Texture::Destroy ( )
inline

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
Texture.Texture
Texture.Texture

◆ DestroyRenderer()

void SDL::DestroyRenderer ( RendererRaw  renderer)
inline

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
Renderer.Renderer

◆ DestroyTexture()

void SDL::DestroyTexture ( TextureRaw  texture)
inline

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
Texture.Texture
Texture.Texture

◆ Flush()

void SDL::Renderer::Flush ( )
inline

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 ( RendererParam  renderer)
inline

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
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
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
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

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
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
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
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()

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

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()

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

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

◆ GetDrawBlendMode()

BlendMode SDL::Renderer::GetDrawBlendMode ( ) const
inline
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()

void SDL::Renderer::GetDrawColor ( Uint8 r,
Uint8 g,
Uint8 b,
Uint8 a 
) const
inline
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()

void SDL::Renderer::GetDrawColorFloat ( float *  r,
float *  g,
float *  b,
float *  a 
) const
inline
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

◆ GetLogicalPresentation()

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

This function gets the width and height of the logical rendering output, or the output size in pixels 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 to be filled with the width.
han int to be filled with the height.
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.SetLogicalPresentation

◆ GetLogicalPresentationRect()

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

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

◆ GetName()

const char * SDL::Renderer::GetName ( ) const
inline
Returns
the name of the selected renderer, or nullptr on failure; 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.Renderer

◆ GetNumRenderDrivers()

int SDL::GetNumRenderDrivers ( )
inline

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
Renderer.Renderer
GetRenderDriver

◆ GetOutputSize()

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

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

◆ GetProperties() [1/2]

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

The following read-only properties are provided by SDL:

  • prop::Renderer.NAME_STRING: the name of the rendering driver
  • prop::Renderer.WINDOW_POINTER: the window where rendering is displayed, if any
  • prop::Renderer.SURFACE_POINTER: the surface where rendering is displayed, if this is a software renderer without a window
  • prop::Renderer.VSYNC_NUMBER: the current vsync setting
  • prop::Renderer.MAX_TEXTURE_SIZE_NUMBER: the maximum texture width and height
  • prop::Renderer.TEXTURE_FORMATS_POINTER: a (const PixelFormat *) array of pixel formats, terminated with PIXELFORMAT_UNKNOWN, representing the available texture formats for this renderer.
  • prop::Renderer.OUTPUT_COLORSPACE_NUMBER: an Colorspace value describing the colorspace for output to the display, defaults to COLORSPACE_SRGB.
  • prop::Renderer.HDR_ENABLED_BOOLEAN: true if the output colorspace is COLORSPACE_SRGB_LINEAR and the renderer is showing on a display with HDR enabled. This property can change dynamically when EVENT_WINDOW_HDR_STATE_CHANGED is sent.
  • prop::Renderer.SDR_WHITE_POINT_FLOAT: the value of SDR white in the COLORSPACE_SRGB_LINEAR colorspace. When HDR is enabled, this value is automatically multiplied into the color scale. This property can change dynamically when EVENT_WINDOW_HDR_STATE_CHANGED is sent.
  • prop::Renderer.HDR_HEADROOM_FLOAT: the additional high dynamic range that can be displayed, in terms of the SDR white point. When HDR is not enabled, this will be 1.0. This property can change dynamically when EVENT_WINDOW_HDR_STATE_CHANGED is sent.

With the direct3d renderer:

  • prop::Renderer.D3D9_DEVICE_POINTER: the IDirect3DDevice9 associated with the renderer

With the direct3d11 renderer:

  • prop::Renderer.D3D11_DEVICE_POINTER: the ID3D11Device associated with the renderer
  • prop::Renderer.D3D11_SWAPCHAIN_POINTER: the IDXGISwapChain1 associated with the renderer. This may change when the window is resized.

With the direct3d12 renderer:

  • prop::Renderer.D3D12_DEVICE_POINTER: the ID3D12Device associated with the renderer
  • prop::Renderer.D3D12_SWAPCHAIN_POINTER: the IDXGISwapChain4 associated with the renderer.
  • prop::Renderer.D3D12_COMMAND_QUEUE_POINTER: the ID3D12CommandQueue associated with the renderer

With the vulkan renderer:

  • prop::Renderer.VULKAN_INSTANCE_POINTER: the VkInstance associated with the renderer
  • prop::Renderer.VULKAN_SURFACE_NUMBER: the VkSurfaceKHR associated with the renderer
  • prop::Renderer.VULKAN_PHYSICAL_DEVICE_POINTER: the VkPhysicalDevice associated with the renderer
  • prop::Renderer.VULKAN_DEVICE_POINTER: the VkDevice associated with the renderer
  • prop::Renderer.VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER: the queue family index used for rendering
  • prop::Renderer.VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER: the queue family index used for presentation
  • prop::Renderer.VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER: the number of swapchain images, or potential frames in flight, used by the Vulkan renderer

With the gpu renderer:

  • prop::Renderer.GPU_DEVICE_POINTER: the GPUDevice associated with the 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

The following read-only properties are provided by SDL:

  • prop::Texture.COLORSPACE_NUMBER: an Colorspace value describing the texture colorspace.
  • prop::Texture.FORMAT_NUMBER: one of the enumerated values in PixelFormat.
  • prop::Texture.ACCESS_NUMBER: one of the enumerated values in TextureAccess.
  • prop::Texture.WIDTH_NUMBER: the width of the texture in pixels.
  • prop::Texture.HEIGHT_NUMBER: the height of the texture in pixels.
  • prop::Texture.SDR_WHITE_POINT_FLOAT: for HDR10 and floating point textures, this defines the value of 100% diffuse white, with higher values being displayed in the High Dynamic Range headroom. This defaults to 100 for HDR10 textures and 1.0 for other textures.
  • prop::Texture.HDR_HEADROOM_FLOAT: for HDR10 and floating point textures, this defines the maximum dynamic range used by the content, in terms of the SDR white point. If this is defined, any values outside the range supported by the display will be scaled into the available HDR headroom, otherwise they are clipped. This defaults to 1.0 for SDR textures, 4.0 for HDR10 textures, and no default for floating point textures.

With the direct3d11 renderer:

  • prop::Texture.D3D11_TEXTURE_POINTER: the ID3D11Texture2D associated with the texture
  • prop::Texture.D3D11_TEXTURE_U_POINTER: the ID3D11Texture2D associated with the U plane of a YUV texture
  • prop::Texture.D3D11_TEXTURE_V_POINTER: the ID3D11Texture2D associated with the V plane of a YUV texture

With the direct3d12 renderer:

  • prop::Texture.D3D12_TEXTURE_POINTER: the ID3D12Resource associated with the texture
  • prop::Texture.D3D12_TEXTURE_U_POINTER: the ID3D12Resource associated with the U plane of a YUV texture
  • prop::Texture.D3D12_TEXTURE_V_POINTER: the ID3D12Resource associated with the V plane of a YUV texture

With the vulkan renderer:

  • prop::Texture.VULKAN_TEXTURE_NUMBER: the VkImage associated with the texture

With the opengl renderer:

  • prop::Texture.OPENGL_TEXTURE_NUMBER: the GLuint texture associated with the texture
  • prop::Texture.OPENGL_TEXTURE_UV_NUMBER: the GLuint texture associated with the UV plane of an NV12 texture
  • prop::Texture.OPENGL_TEXTURE_U_NUMBER: the GLuint texture associated with the U plane of a YUV texture
  • prop::Texture.OPENGL_TEXTURE_V_NUMBER: the GLuint texture associated with the V plane of a YUV texture
  • prop::Texture.OPENGL_TEXTURE_TARGET_NUMBER: the GLenum for the texture target (GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB, etc)
  • prop::Texture.OPENGL_TEX_W_FLOAT: the texture coordinate width of the texture (0.0 - 1.0)
  • prop::Texture.OPENGL_TEX_H_FLOAT: the texture coordinate height of the texture (0.0 - 1.0)

With the opengles2 renderer:

  • prop::Texture.OPENGLES2_TEXTURE_NUMBER: the GLuint texture associated with the texture
  • prop::Texture.OPENGLES2_TEXTURE_UV_NUMBER: the GLuint texture associated with the UV plane of an NV12 texture
  • prop::Texture.OPENGLES2_TEXTURE_U_NUMBER: the GLuint texture associated with the U plane of a YUV texture
  • prop::Texture.OPENGLES2_TEXTURE_V_NUMBER: the GLuint texture associated with the V plane of a YUV texture
  • prop::Texture.OPENGLES2_TEXTURE_TARGET_NUMBER: the GLenum for the texture target (GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL_OES, etc)
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 ( RendererParam  renderer)
inline

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 ( RendererParam  renderer)
inline
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 ( RendererParam  renderer)
inline
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()

void SDL::GetRenderDrawColor ( RendererParam  renderer,
Uint8 r,
Uint8 g,
Uint8 b,
Uint8 a 
)
inline
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()

void SDL::GetRenderDrawColorFloat ( RendererParam  renderer,
float *  r,
float *  g,
float *  b,
float *  a 
)
inline
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

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
Returns
a pointer to the Renderer that created the texture, or nullptr on failure; 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.

◆ GetRenderer() [2/2]

RendererRef SDL::Window::GetRenderer ( ) const
inline
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 ( TextureParam  texture)
inline
Parameters
texturethe texture to query.
Returns
a pointer to the Renderer that created the texture, or nullptr on failure; 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.

◆ GetRendererName()

const char * SDL::GetRendererName ( RendererParam  renderer)
inline
Parameters
rendererthe rendering context.
Returns
the name of the selected renderer, or nullptr on failure; 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.Renderer
Renderer.Renderer

◆ GetRendererProperties()

PropertiesRef SDL::GetRendererProperties ( RendererParam  renderer)
inline

The following read-only properties are provided by SDL:

  • prop::Renderer.NAME_STRING: the name of the rendering driver
  • prop::Renderer.WINDOW_POINTER: the window where rendering is displayed, if any
  • prop::Renderer.SURFACE_POINTER: the surface where rendering is displayed, if this is a software renderer without a window
  • prop::Renderer.VSYNC_NUMBER: the current vsync setting
  • prop::Renderer.MAX_TEXTURE_SIZE_NUMBER: the maximum texture width and height
  • prop::Renderer.TEXTURE_FORMATS_POINTER: a (const PixelFormat *) array of pixel formats, terminated with PIXELFORMAT_UNKNOWN, representing the available texture formats for this renderer.
  • prop::Renderer.OUTPUT_COLORSPACE_NUMBER: an Colorspace value describing the colorspace for output to the display, defaults to COLORSPACE_SRGB.
  • prop::Renderer.HDR_ENABLED_BOOLEAN: true if the output colorspace is COLORSPACE_SRGB_LINEAR and the renderer is showing on a display with HDR enabled. This property can change dynamically when EVENT_WINDOW_HDR_STATE_CHANGED is sent.
  • prop::Renderer.SDR_WHITE_POINT_FLOAT: the value of SDR white in the COLORSPACE_SRGB_LINEAR colorspace. When HDR is enabled, this value is automatically multiplied into the color scale. This property can change dynamically when EVENT_WINDOW_HDR_STATE_CHANGED is sent.
  • prop::Renderer.HDR_HEADROOM_FLOAT: the additional high dynamic range that can be displayed, in terms of the SDR white point. When HDR is not enabled, this will be 1.0. This property can change dynamically when EVENT_WINDOW_HDR_STATE_CHANGED is sent.

With the direct3d renderer:

  • prop::Renderer.D3D9_DEVICE_POINTER: the IDirect3DDevice9 associated with the renderer

With the direct3d11 renderer:

  • prop::Renderer.D3D11_DEVICE_POINTER: the ID3D11Device associated with the renderer
  • prop::Renderer.D3D11_SWAPCHAIN_POINTER: the IDXGISwapChain1 associated with the renderer. This may change when the window is resized.

With the direct3d12 renderer:

  • prop::Renderer.D3D12_DEVICE_POINTER: the ID3D12Device associated with the renderer
  • prop::Renderer.D3D12_SWAPCHAIN_POINTER: the IDXGISwapChain4 associated with the renderer.
  • prop::Renderer.D3D12_COMMAND_QUEUE_POINTER: the ID3D12CommandQueue associated with the renderer

With the vulkan renderer:

  • prop::Renderer.VULKAN_INSTANCE_POINTER: the VkInstance associated with the renderer
  • prop::Renderer.VULKAN_SURFACE_NUMBER: the VkSurfaceKHR associated with the renderer
  • prop::Renderer.VULKAN_PHYSICAL_DEVICE_POINTER: the VkPhysicalDevice associated with the renderer
  • prop::Renderer.VULKAN_DEVICE_POINTER: the VkDevice associated with the renderer
  • prop::Renderer.VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER: the queue family index used for rendering
  • prop::Renderer.VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER: the queue family index used for presentation
  • prop::Renderer.VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER: the number of swapchain images, or potential frames in flight, used by the Vulkan renderer

With the gpu renderer:

  • prop::Renderer.GPU_DEVICE_POINTER: the GPUDevice associated with the 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()

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

This function gets the width and height of the logical rendering output, or the output size in pixels 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 to be filled with the width.
han int to be filled with the height.
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.SetLogicalPresentation

◆ GetRenderLogicalPresentationRect()

FRect SDL::GetRenderLogicalPresentationRect ( RendererParam  renderer)
inline

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::Renderer::GetRenderMetalCommandEncoder ( )
inline

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.
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.GetRenderMetalLayer

◆ GetRenderMetalCommandEncoder() [2/2]

void * SDL::GetRenderMetalCommandEncoder ( RendererParam  renderer)
inline

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.
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.GetRenderMetalLayer

◆ GetRenderMetalLayer() [1/2]

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

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.
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.GetRenderMetalCommandEncoder

◆ GetRenderMetalLayer() [2/2]

void * SDL::GetRenderMetalLayer ( RendererParam  renderer)
inline

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.
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.GetRenderMetalCommandEncoder

◆ GetRenderOutputSize()

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

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 ( RendererParam  renderer)
inline

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()

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

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 ( RendererParam  renderer)
inline

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

◆ GetRenderViewport()

Rect SDL::GetRenderViewport ( RendererParam  renderer)
inline

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.IsViewportSet
Renderer.SetViewport

◆ GetRenderVSync()

int SDL::GetRenderVSync ( RendererParam  renderer)
inline
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 ( RendererParam  renderer)
inline
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

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()

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

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
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
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

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 ( TextureParam  texture)
inline
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 ( TextureParam  texture)
inline
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 ( TextureParam  texture)
inline
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 ( TextureParam  texture,
Uint8 r,
Uint8 g,
Uint8 b 
)
inline
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 ( TextureParam  texture,
float *  r,
float *  g,
float *  b 
)
inline
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

◆ GetTextureProperties()

PropertiesRef SDL::GetTextureProperties ( TextureParam  texture)
inline

The following read-only properties are provided by SDL:

  • prop::Texture.COLORSPACE_NUMBER: an Colorspace value describing the texture colorspace.
  • prop::Texture.FORMAT_NUMBER: one of the enumerated values in PixelFormat.
  • prop::Texture.ACCESS_NUMBER: one of the enumerated values in TextureAccess.
  • prop::Texture.WIDTH_NUMBER: the width of the texture in pixels.
  • prop::Texture.HEIGHT_NUMBER: the height of the texture in pixels.
  • prop::Texture.SDR_WHITE_POINT_FLOAT: for HDR10 and floating point textures, this defines the value of 100% diffuse white, with higher values being displayed in the High Dynamic Range headroom. This defaults to 100 for HDR10 textures and 1.0 for other textures.
  • prop::Texture.HDR_HEADROOM_FLOAT: for HDR10 and floating point textures, this defines the maximum dynamic range used by the content, in terms of the SDR white point. If this is defined, any values outside the range supported by the display will be scaled into the available HDR headroom, otherwise they are clipped. This defaults to 1.0 for SDR textures, 4.0 for HDR10 textures, and no default for floating point textures.

With the direct3d11 renderer:

  • prop::Texture.D3D11_TEXTURE_POINTER: the ID3D11Texture2D associated with the texture
  • prop::Texture.D3D11_TEXTURE_U_POINTER: the ID3D11Texture2D associated with the U plane of a YUV texture
  • prop::Texture.D3D11_TEXTURE_V_POINTER: the ID3D11Texture2D associated with the V plane of a YUV texture

With the direct3d12 renderer:

  • prop::Texture.D3D12_TEXTURE_POINTER: the ID3D12Resource associated with the texture
  • prop::Texture.D3D12_TEXTURE_U_POINTER: the ID3D12Resource associated with the U plane of a YUV texture
  • prop::Texture.D3D12_TEXTURE_V_POINTER: the ID3D12Resource associated with the V plane of a YUV texture

With the vulkan renderer:

  • prop::Texture.VULKAN_TEXTURE_NUMBER: the VkImage associated with the texture

With the opengl renderer:

  • prop::Texture.OPENGL_TEXTURE_NUMBER: the GLuint texture associated with the texture
  • prop::Texture.OPENGL_TEXTURE_UV_NUMBER: the GLuint texture associated with the UV plane of an NV12 texture
  • prop::Texture.OPENGL_TEXTURE_U_NUMBER: the GLuint texture associated with the U plane of a YUV texture
  • prop::Texture.OPENGL_TEXTURE_V_NUMBER: the GLuint texture associated with the V plane of a YUV texture
  • prop::Texture.OPENGL_TEXTURE_TARGET_NUMBER: the GLenum for the texture target (GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB, etc)
  • prop::Texture.OPENGL_TEX_W_FLOAT: the texture coordinate width of the texture (0.0 - 1.0)
  • prop::Texture.OPENGL_TEX_H_FLOAT: the texture coordinate height of the texture (0.0 - 1.0)

With the opengles2 renderer:

  • prop::Texture.OPENGLES2_TEXTURE_NUMBER: the GLuint texture associated with the texture
  • prop::Texture.OPENGLES2_TEXTURE_UV_NUMBER: the GLuint texture associated with the UV plane of an NV12 texture
  • prop::Texture.OPENGLES2_TEXTURE_U_NUMBER: the GLuint texture associated with the U plane of a YUV texture
  • prop::Texture.OPENGLES2_TEXTURE_V_NUMBER: the GLuint texture associated with the V plane of a YUV texture
  • prop::Texture.OPENGLES2_TEXTURE_TARGET_NUMBER: the GLenum for the texture target (GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL_OES, etc)
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 ( TextureParam  texture)
inline
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 ( TextureParam  texture,
float *  w,
float *  h 
)
inline
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

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.IsViewportSet
Renderer.SetViewport

◆ GetVSync()

int SDL::Renderer::GetVSync ( ) const
inline
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
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.

◆ IsClipEnabled()

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

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

◆ IsViewportSet()

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

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

◆ Lock()

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

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.

           `TEXTUREACCESS_STREAMING`.
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 ( TextureParam  texture,
OptionalRef< const SDL_Rect >  rect,
void **  pixels,
int *  pitch 
)
inline

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 ( TextureParam  texture,
OptionalRef< const SDL_Rect >  rect = std::nullopt 
)
inline

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()

Surface SDL::Texture::LockToSurface ( OptionalRef< const SDL_Rect >  rect = std::nullopt)
inline

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.

           `TEXTUREACCESS_STREAMING`.
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

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 still update the screen with any current drawing that has been done to the window itself.

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
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

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::Renderer::RenderClear ( )
inline

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

◆ RenderClear() [2/2]

void SDL::RenderClear ( RendererParam  renderer)
inline

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

◆ RenderClipEnabled()

bool SDL::RenderClipEnabled ( RendererParam  renderer)
inline

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::Renderer::RenderCoordinatesFromWindow ( const FPointRaw window_coord) const
inline

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

◆ RenderCoordinatesFromWindow() [2/2]

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

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

◆ RenderCoordinatesToWindow() [1/2]

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

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

◆ RenderCoordinatesToWindow() [2/2]

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

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

◆ RenderDebugText() [1/2]

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

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). One can use logical presentation or scaling to adjust it, but it will be blurry.
  • 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
SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE

◆ RenderDebugText() [2/2]

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

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). One can use logical presentation or scaling to adjust it, but it will be blurry.
  • 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
SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE

◆ RenderDebugTextFormat() [1/2]

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

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
SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE

◆ RenderDebugTextFormat() [2/2]

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

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
SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE

◆ RenderFillRect() [1/2]

void SDL::Renderer::RenderFillRect ( OptionalRef< const FRectRaw rect)
inline
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 ( RendererParam  renderer,
OptionalRef< const FRectRaw rect 
)
inline
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::RenderFillRects ( RendererParam  renderer,
SpanRef< const FRectRaw rects 
)
inline
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

◆ RenderFillRects() [2/2]

void SDL::Renderer::RenderFillRects ( SpanRef< const FRectRaw rects)
inline
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

◆ RenderGeometry() [1/2]

void SDL::RenderGeometry ( RendererParam  renderer,
TextureParam  texture,
std::span< const Vertex vertices,
std::span< const int >  indices = {} 
)
inline
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

◆ RenderGeometry() [2/2]

void SDL::Renderer::RenderGeometry ( TextureParam  texture,
std::span< const Vertex vertices,
std::span< const int >  indices = {} 
)
inline
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

◆ RenderGeometryRaw() [1/2]

void SDL::RenderGeometryRaw ( RendererParam  renderer,
TextureParam  texture,
const float *  xy,
int  xy_stride,
const FColor color,
int  color_stride,
const float *  uv,
int  uv_stride,
int  num_vertices,
const void *  indices,
int  num_indices,
int  size_indices 
)
inline
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

◆ RenderGeometryRaw() [2/2]

void SDL::Renderer::RenderGeometryRaw ( TextureParam  texture,
const float *  xy,
int  xy_stride,
const FColor color,
int  color_stride,
const float *  uv,
int  uv_stride,
int  num_vertices,
const void *  indices,
int  num_indices,
int  size_indices 
)
inline
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

◆ RenderLine() [1/2]

void SDL::Renderer::RenderLine ( const FPointRaw p1,
const FPointRaw p2 
)
inline
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 ( RendererParam  renderer,
const FPointRaw p1,
const FPointRaw p2 
)
inline
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::RenderLines ( RendererParam  renderer,
SpanRef< const FPointRaw points 
)
inline
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

◆ RenderLines() [2/2]

void SDL::Renderer::RenderLines ( SpanRef< const FPointRaw points)
inline
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

◆ RenderPoint() [1/2]

void SDL::Renderer::RenderPoint ( const FPointRaw p)
inline
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 ( RendererParam  renderer,
const FPointRaw p 
)
inline
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::RenderPoints ( RendererParam  renderer,
SpanRef< const FPointRaw points 
)
inline
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

◆ RenderPoints() [2/2]

void SDL::Renderer::RenderPoints ( SpanRef< const FPointRaw points)
inline
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

◆ RenderPresent()

void SDL::RenderPresent ( RendererParam  renderer)
inline

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 still update the screen with any current drawing that has been done to the window itself.

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.Renderer
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 ( RendererParam  renderer,
OptionalRef< const RectRaw rect = {} 
)
inline

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
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 ( RendererParam  renderer,
OptionalRef< const FRectRaw rect 
)
inline
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::RenderRects ( RendererParam  renderer,
SpanRef< const FRectRaw rects 
)
inline
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

◆ RenderRects() [2/2]

void SDL::Renderer::RenderRects ( SpanRef< const FRectRaw rects)
inline
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

◆ RenderTexture() [1/2]

void SDL::RenderTexture ( RendererParam  renderer,
TextureParam  texture,
OptionalRef< const FRectRaw srcrect,
OptionalRef< const FRectRaw dstrect 
)
inline
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

◆ RenderTexture() [2/2]

void SDL::Renderer::RenderTexture ( TextureParam  texture,
OptionalRef< const FRectRaw srcrect,
OptionalRef< const FRectRaw dstrect 
)
inline
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

◆ RenderTexture9Grid() [1/2]

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

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

◆ RenderTexture9Grid() [2/2]

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

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

◆ RenderTextureAffine() [1/2]

void SDL::RenderTextureAffine ( RendererParam  renderer,
TextureParam  texture,
OptionalRef< const FRectRaw srcrect,
OptionalRef< const FPointRaw origin,
OptionalRef< const FPointRaw right,
OptionalRef< const FPointRaw down 
)
inline
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

◆ RenderTextureAffine() [2/2]

void SDL::Renderer::RenderTextureAffine ( TextureParam  texture,
OptionalRef< const FRectRaw srcrect,
OptionalRef< const FPointRaw origin,
OptionalRef< const FPointRaw right,
OptionalRef< const FPointRaw down 
)
inline
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

◆ RenderTextureRotated() [1/2]

void SDL::RenderTextureRotated ( RendererParam  renderer,
TextureParam  texture,
OptionalRef< const FRectRaw srcrect,
OptionalRef< const FRectRaw dstrect,
double  angle,
OptionalRef< const FPointRaw center,
FlipMode  flip = FlipMode::SDL_FLIP_NONE 
)
inline
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

◆ RenderTextureRotated() [2/2]

void SDL::Renderer::RenderTextureRotated ( TextureParam  texture,
OptionalRef< const FRectRaw srcrect,
OptionalRef< const FRectRaw dstrect,
double  angle,
OptionalRef< const FPointRaw center,
FlipMode  flip = FlipMode::SDL_FLIP_NONE 
)
inline
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

◆ RenderTextureTiled() [1/2]

void SDL::RenderTextureTiled ( RendererParam  renderer,
TextureParam  texture,
OptionalRef< const FRectRaw srcrect,
float  scale,
OptionalRef< const FRectRaw dstrect 
)
inline

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

◆ RenderTextureTiled() [2/2]

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

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

◆ RenderViewportSet()

bool SDL::RenderViewportSet ( RendererParam  renderer)
inline

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

◆ SetAlphaMod()

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

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

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

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

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

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

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

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

◆ SetDrawBlendMode()

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

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 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 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

◆ SetLogicalPresentation()

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

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.

For the renderer's window, letterboxing is drawn into the framebuffer if logical presentation is enabled during Renderer.Present; be sure to reenable it before presenting if you were toggling it, otherwise the letterbox areas might have artifacts from previous frames (or artifacts from external overlays, etc). Letterboxing is never drawn into texture render targets; be sure to call Renderer.RenderClear() before drawing into the texture so the letterboxing areas are cleared, if appropriate.

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

◆ SetRenderClipRect()

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

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 ( RendererParam  renderer,
float  scale 
)
inline

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 ( RendererParam  renderer,
BlendMode  blendMode 
)
inline

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 ( RendererParam  renderer,
ColorRaw  c 
)
inline

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 ( RendererParam  renderer,
const FColorRaw c 
)
inline

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 ( RendererParam  renderer,
const PointRaw size,
RendererLogicalPresentation  mode 
)
inline

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.

For the renderer's window, letterboxing is drawn into the framebuffer if logical presentation is enabled during Renderer.Present; be sure to reenable it before presenting if you were toggling it, otherwise the letterbox areas might have artifacts from previous frames (or artifacts from external overlays, etc). Letterboxing is never drawn into texture render targets; be sure to call Renderer.RenderClear() before drawing into the texture so the letterboxing areas are cleared, if appropriate.

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 ( RendererParam  renderer,
const FPointRaw scale 
)
inline

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 ( RendererParam  renderer,
TextureParam  texture 
)
inline

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

◆ SetRenderViewport()

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

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.IsViewportSet

◆ SetRenderVSync()

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

When a renderer is created, vsync defaults to SDL_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., SDL_RENDERER_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or SDL_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

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

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 ( TextureParam  texture)
inline

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 ( TextureParam  texture,
Uint8  alpha 
)
inline

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 ( TextureParam  texture,
float  alpha 
)
inline

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 ( TextureParam  texture,
BlendMode  blendMode 
)
inline

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 ( TextureParam  texture,
Uint8  r,
Uint8  g,
Uint8  b 
)
inline

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 ( TextureParam  texture,
float  r,
float  g,
float  b 
)
inline

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

◆ SetTextureScaleMode()

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

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

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.IsViewportSet

◆ SetVSync()

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

When a renderer is created, vsync defaults to SDL_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., SDL_RENDERER_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or SDL_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

◆ Unlock()

void SDL::Texture::Unlock ( )
inline

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 ( TextureParam  texture)
inline

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()

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

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

◆ UpdateNV()

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

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 ( TextureParam  texture,
OptionalRef< const RectRaw rect,
const Uint8 Yplane,
int  Ypitch,
const Uint8 UVplane,
int  UVpitch 
)
inline

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()

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

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

◆ 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

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 ( TextureParam  texture,
OptionalRef< const RectRaw rect,
const Uint8 Yplane,
int  Ypitch,
const Uint8 Uplane,
int  Upitch,
const Uint8 Vplane,
int  Vpitch 
)
inline

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

Variable Documentation

◆ LOGICAL_PRESENTATION_DISABLED

constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_DISABLED
constexpr
Initial value:
=
SDL_LOGICAL_PRESENTATION_DISABLED

◆ LOGICAL_PRESENTATION_INTEGER_SCALE

constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_INTEGER_SCALE
constexpr
Initial value:
=
SDL_LOGICAL_PRESENTATION_INTEGER_SCALE

◆ LOGICAL_PRESENTATION_LETTERBOX

constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_LETTERBOX
constexpr
Initial value:
=
SDL_LOGICAL_PRESENTATION_LETTERBOX

◆ LOGICAL_PRESENTATION_OVERSCAN

constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_OVERSCAN
constexpr
Initial value:
=
SDL_LOGICAL_PRESENTATION_OVERSCAN

◆ LOGICAL_PRESENTATION_STRETCH

constexpr RendererLogicalPresentation SDL::LOGICAL_PRESENTATION_STRETCH
constexpr
Initial value:
=
SDL_LOGICAL_PRESENTATION_STRETCH

◆ TEXTUREACCESS_STATIC

constexpr TextureAccess SDL::TEXTUREACCESS_STATIC
constexpr
Initial value:
=
SDL_TEXTUREACCESS_STATIC

◆ TEXTUREACCESS_STREAMING

constexpr TextureAccess SDL::TEXTUREACCESS_STREAMING
constexpr
Initial value:
=
SDL_TEXTUREACCESS_STREAMING

◆ TEXTUREACCESS_TARGET

constexpr TextureAccess SDL::TEXTUREACCESS_TARGET
constexpr
Initial value:
=
SDL_TEXTUREACCESS_TARGET