SDL3pp
A slim C++ wrapper for SDL3
|
Header file for SDL 2D rendering functions. More...
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, Renderer > | SDL::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... | |
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
#define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE 8 |
The font is monospaced and square, so this applies to all characters.
#define SDL_SOFTWARE_RENDERER "software" |
using SDL::RendererLogicalPresentation = typedef SDL_RendererLogicalPresentation |
using SDL::TextureAccess = typedef SDL_TextureAccess |
using SDL::Vertex = typedef SDL_Vertex |
|
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.
renderer | the rendering context. |
wait_stage_mask | the VkPipelineStageFlags for the wait. |
wait_semaphore | a VkSempahore to wait on before rendering the current frame, or 0 if not needed. |
signal_semaphore | a VkSempahore that SDL will signal when rendering for the current frame is complete, or 0 if not needed. |
Error | on failure. |
|
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.
wait_stage_mask | the VkPipelineStageFlags for the wait. |
wait_semaphore | a VkSempahore to wait on before rendering the current frame, or 0 if not needed. |
signal_semaphore | a VkSempahore that SDL will signal when rendering for the current frame is complete, or 0 if not needed. |
Error | on failure. |
|
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.
event | the event to modify. |
Error | on failure. |
|
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.
renderer | the rendering context. |
event | the event to modify. |
Error | on failure. |
|
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.
window | the window where rendering is displayed. |
name | the name of the rendering driver to initialize, or nullptr to let SDL choose one. |
|
inline |
These are the supported properties:
prop::Renderer.CREATE_NAME_STRING
: the name of the rendering driver to use, if a specific one is desiredprop::Renderer.CREATE_WINDOW_POINTER
: the window where rendering is displayed, required if this isn't a software renderer using a surfaceprop::Renderer.CREATE_SURFACE_POINTER
: the surface where rendering is displayed, if you want a software renderer without a windowprop::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.props | the properties to use. |
|
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.
surface | the Surface structure representing the surface where rendering is done. |
|
inline |
The contents of a texture when first created are not defined.
format | one of the enumerated values in PixelFormat. |
access | one of the enumerated values in TextureAccess. |
size | the width and height of the texture in pixels. |
|
inline |
The contents of a texture when first created are not defined.
renderer | the rendering context. |
format | one of the enumerated values in PixelFormat. |
access | one of the enumerated values in TextureAccess. |
size | the width and height of the texture in pixels. |
|
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.
renderer | the rendering context. |
surface | the Surface structure containing pixel data used to fill the texture. |
|
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.
surface | the Surface structure containing pixel data used to fill the texture. |
|
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 rendererprop::Texture.CREATE_ACCESS_NUMBER
: one of the enumerated values in TextureAccess, defaults to TEXTUREACCESS_STATICprop::Texture.CREATE_WIDTH_NUMBER
: the width of the texture in pixels, requiredprop::Texture.CREATE_HEIGHT_NUMBER
: the height of the texture in pixels, requiredprop::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.props | the properties to use. |
|
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 rendererprop::Texture.CREATE_ACCESS_NUMBER
: one of the enumerated values in TextureAccess, defaults to TEXTUREACCESS_STATICprop::Texture.CREATE_WIDTH_NUMBER
: the width of the texture in pixels, requiredprop::Texture.CREATE_HEIGHT_NUMBER
: the height of the texture in pixels, requiredprop::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.renderer | the rendering context. |
props | the properties to use. |
|
inline |
title | the title of the window, in UTF-8 encoding. |
size | the width and height of the window. |
window_flags | the flags used to create the window (see Window.Window()). |
Error | on failure. |
|
inline |
This should be called before destroying the associated window.
|
inline |
Passing nullptr or an otherwise invalid texture will set the SDL error message to "Invalid texture".
|
inline |
This should be called before destroying the associated window.
renderer | the rendering context. |
|
inline |
Passing nullptr or an otherwise invalid texture will set the SDL error message to "Invalid texture".
texture | the texture to destroy. |
|
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.
Error | on failure. |
|
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.
renderer | the rendering context. |
Error | on failure. |
|
inline |
|
inline |
|
inline |
Error | on failure. |
|
inline |
Each render target has its own clip rectangle. This function gets the cliprect for the current render target.
Error | on failure. |
r | a pointer filled in with the current red color value. |
g | a pointer filled in with the current green color value. |
b | a pointer filled in with the current blue color value. |
Error | on failure. |
|
inline |
r | a pointer filled in with the current red color value. |
g | a pointer filled in with the current green color value. |
b | a pointer filled in with the current blue color value. |
Error | on failure. |
|
inline |
Error | on failure. |
|
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().
w | a pointer filled in with the current width. |
h | a pointer filled in with the current height. |
Error | on failure. |
|
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().
renderer | the rendering context. |
w | a pointer filled in with the current width. |
h | a pointer filled in with the current height. |
Error | on failure. |
|
inline |
Error | on failure. |
r | a pointer filled in with the red value used to draw on the rendering target. |
g | a pointer filled in with the green value used to draw on the rendering target. |
b | a pointer filled in with the blue value used to draw on the rendering target. |
a | a pointer filled in with the alpha value used to draw on the rendering target; usually ALPHA_OPAQUE (255). |
Error | on failure. |
|
inline |
r | a pointer filled in with the red value used to draw on the rendering target. |
g | a pointer filled in with the green value used to draw on the rendering target. |
b | a pointer filled in with the blue value used to draw on the rendering target. |
a | a pointer filled in with the alpha value used to draw on the rendering target. |
Error | on failure. |
|
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.
w | an int to be filled with the width. |
h | an int to be filled with the height. |
mode | the presentation mode used. |
Error | on failure. |
|
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.
Error | on failure. |
|
inline |
|
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.
|
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.
w | a pointer filled in with the width in pixels. |
h | a pointer filled in with the height in pixels. |
Error | on failure. |
|
inline |
The following read-only properties are provided by SDL:
prop::Renderer.NAME_STRING
: the name of the rendering driverprop::Renderer.WINDOW_POINTER
: the window where rendering is displayed, if anyprop::Renderer.SURFACE_POINTER
: the surface where rendering is displayed, if this is a software renderer without a windowprop::Renderer.VSYNC_NUMBER
: the current vsync settingprop::Renderer.MAX_TEXTURE_SIZE_NUMBER
: the maximum texture width and heightprop::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 rendererWith the direct3d11 renderer:
prop::Renderer.D3D11_DEVICE_POINTER
: the ID3D11Device associated with the rendererprop::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 rendererprop::Renderer.D3D12_SWAPCHAIN_POINTER
: the IDXGISwapChain4 associated with the renderer.prop::Renderer.D3D12_COMMAND_QUEUE_POINTER
: the ID3D12CommandQueue associated with the rendererWith the vulkan renderer:
prop::Renderer.VULKAN_INSTANCE_POINTER
: the VkInstance associated with the rendererprop::Renderer.VULKAN_SURFACE_NUMBER
: the VkSurfaceKHR associated with the rendererprop::Renderer.VULKAN_PHYSICAL_DEVICE_POINTER
: the VkPhysicalDevice associated with the rendererprop::Renderer.VULKAN_DEVICE_POINTER
: the VkDevice associated with the rendererprop::Renderer.VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER
: the queue family index used for renderingprop::Renderer.VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER
: the queue family index used for presentationprop::Renderer.VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER
: the number of swapchain images, or potential frames in flight, used by the Vulkan rendererWith the gpu renderer:
prop::Renderer.GPU_DEVICE_POINTER
: the GPUDevice associated with the rendererError | on failure. |
|
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 textureprop::Texture.D3D11_TEXTURE_U_POINTER
: the ID3D11Texture2D associated with the U plane of a YUV textureprop::Texture.D3D11_TEXTURE_V_POINTER
: the ID3D11Texture2D associated with the V plane of a YUV textureWith the direct3d12 renderer:
prop::Texture.D3D12_TEXTURE_POINTER
: the ID3D12Resource associated with the textureprop::Texture.D3D12_TEXTURE_U_POINTER
: the ID3D12Resource associated with the U plane of a YUV textureprop::Texture.D3D12_TEXTURE_V_POINTER
: the ID3D12Resource associated with the V plane of a YUV textureWith the vulkan renderer:
prop::Texture.VULKAN_TEXTURE_NUMBER
: the VkImage associated with the textureWith the opengl renderer:
prop::Texture.OPENGL_TEXTURE_NUMBER
: the GLuint texture associated with the textureprop::Texture.OPENGL_TEXTURE_UV_NUMBER
: the GLuint texture associated with the UV plane of an NV12 textureprop::Texture.OPENGL_TEXTURE_U_NUMBER
: the GLuint texture associated with the U plane of a YUV textureprop::Texture.OPENGL_TEXTURE_V_NUMBER
: the GLuint texture associated with the V plane of a YUV textureprop::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 textureprop::Texture.OPENGLES2_TEXTURE_UV_NUMBER
: the GLuint texture associated with the UV plane of an NV12 textureprop::Texture.OPENGLES2_TEXTURE_U_NUMBER
: the GLuint texture associated with the U plane of a YUV textureprop::Texture.OPENGLES2_TEXTURE_V_NUMBER
: the GLuint texture associated with the V plane of a YUV textureprop::Texture.OPENGLES2_TEXTURE_TARGET_NUMBER
: the GLenum for the texture target (GL_TEXTURE_2D
, GL_TEXTURE_EXTERNAL_OES
, etc)Error | on failure. |
|
inline |
Each render target has its own clip rectangle. This function gets the cliprect for the current render target.
renderer | the rendering context. |
Error | on failure. |
|
inline |
renderer | the rendering context. |
Error | on failure. |
|
inline |
renderer | the rendering context. |
Error | on failure. |
|
inline |
renderer | the rendering context. |
r | a pointer filled in with the red value used to draw on the rendering target. |
g | a pointer filled in with the green value used to draw on the rendering target. |
b | a pointer filled in with the blue value used to draw on the rendering target. |
a | a pointer filled in with the alpha value used to draw on the rendering target; usually ALPHA_OPAQUE (255). |
Error | on failure. |
|
inline |
renderer | the rendering context. |
r | a pointer filled in with the red value used to draw on the rendering target. |
g | a pointer filled in with the green value used to draw on the rendering target. |
b | a pointer filled in with the blue value used to draw on the rendering target. |
a | a pointer filled in with the alpha value used to draw on the rendering target. |
Error | on failure. |
|
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.
index | the index of the rendering driver; the value ranges from 0 to GetNumRenderDrivers() - 1. |
|
inline |
|
inline |
|
inline |
texture | the texture to query. |
|
inline |
renderer | the rendering context. |
|
inline |
The following read-only properties are provided by SDL:
prop::Renderer.NAME_STRING
: the name of the rendering driverprop::Renderer.WINDOW_POINTER
: the window where rendering is displayed, if anyprop::Renderer.SURFACE_POINTER
: the surface where rendering is displayed, if this is a software renderer without a windowprop::Renderer.VSYNC_NUMBER
: the current vsync settingprop::Renderer.MAX_TEXTURE_SIZE_NUMBER
: the maximum texture width and heightprop::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 rendererWith the direct3d11 renderer:
prop::Renderer.D3D11_DEVICE_POINTER
: the ID3D11Device associated with the rendererprop::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 rendererprop::Renderer.D3D12_SWAPCHAIN_POINTER
: the IDXGISwapChain4 associated with the renderer.prop::Renderer.D3D12_COMMAND_QUEUE_POINTER
: the ID3D12CommandQueue associated with the rendererWith the vulkan renderer:
prop::Renderer.VULKAN_INSTANCE_POINTER
: the VkInstance associated with the rendererprop::Renderer.VULKAN_SURFACE_NUMBER
: the VkSurfaceKHR associated with the rendererprop::Renderer.VULKAN_PHYSICAL_DEVICE_POINTER
: the VkPhysicalDevice associated with the rendererprop::Renderer.VULKAN_DEVICE_POINTER
: the VkDevice associated with the rendererprop::Renderer.VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER
: the queue family index used for renderingprop::Renderer.VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER
: the queue family index used for presentationprop::Renderer.VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER
: the number of swapchain images, or potential frames in flight, used by the Vulkan rendererWith the gpu renderer:
prop::Renderer.GPU_DEVICE_POINTER
: the GPUDevice associated with the rendererrenderer | the rendering context. |
Error | on failure. |
|
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.
renderer | the rendering context. |
w | an int to be filled with the width. |
h | an int to be filled with the height. |
mode | the presentation mode used. |
Error | on failure. |
|
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.
renderer | the rendering context. |
Error | on failure. |
|
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!
id<MTLRenderCommandEncoder>
on success. Error | on failure. |
|
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!
renderer | the renderer to query. |
id<MTLRenderCommandEncoder>
on success. Error | on failure. |
|
inline |
This function returns void *
, so SDL doesn't have to include Metal's headers, but it can be safely cast to a CAMetalLayer *
.
CAMetalLayer *
on success. Error | on failure. |
|
inline |
This function returns void *
, so SDL doesn't have to include Metal's headers, but it can be safely cast to a CAMetalLayer *
.
renderer | the renderer to query. |
CAMetalLayer *
on success. Error | on failure. |
|
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.
renderer | the rendering context. |
w | a pointer filled in with the width in pixels. |
h | a pointer filled in with the height in pixels. |
Error | on failure. |
|
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.
renderer | the rendering context. |
Error | on failure. |
|
inline |
Each render target has its own scale. This function gets the scale for the current render target.
renderer | the rendering context. |
scaleX | a pointer filled in with the horizontal scaling factor. |
scaleY | a pointer filled in with the vertical scaling factor. |
Error | on failure. |
|
inline |
The default render target is the window for which the renderer was created, and is reported a nullptr here.
renderer | the rendering context. |
|
inline |
Each render target has its own viewport. This function gets the viewport for the current render target.
renderer | the rendering context. |
Error | on failure. |
|
inline |
renderer | the renderer to toggle. |
Error | on failure. |
|
inline |
|
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.
Error | on failure. |
|
inline |
Each render target has its own scale. This function gets the scale for the current render target.
scaleX | a pointer filled in with the horizontal scaling factor. |
scaleY | a pointer filled in with the vertical scaling factor. |
Error | on failure. |
|
inline |
Error | on failure. |
|
inline |
w | a pointer filled in with the width of the texture in pixels. This argument can be nullptr if you don't need this information. |
h | a pointer filled in with the height of the texture in pixels. This argument can be nullptr if you don't need this information. |
Error | on failure. |
|
inline |
The default render target is the window for which the renderer was created, and is reported a nullptr here.
|
inline |
|
inline |
|
inline |
texture | the texture to query. |
Error | on failure. |
|
inline |
texture | the texture to query. |
r | a pointer filled in with the current red color value. |
g | a pointer filled in with the current green color value. |
b | a pointer filled in with the current blue color value. |
Error | on failure. |
|
inline |
texture | the texture to query. |
r | a pointer filled in with the current red color value. |
g | a pointer filled in with the current green color value. |
b | a pointer filled in with the current blue color value. |
Error | on failure. |
|
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 textureprop::Texture.D3D11_TEXTURE_U_POINTER
: the ID3D11Texture2D associated with the U plane of a YUV textureprop::Texture.D3D11_TEXTURE_V_POINTER
: the ID3D11Texture2D associated with the V plane of a YUV textureWith the direct3d12 renderer:
prop::Texture.D3D12_TEXTURE_POINTER
: the ID3D12Resource associated with the textureprop::Texture.D3D12_TEXTURE_U_POINTER
: the ID3D12Resource associated with the U plane of a YUV textureprop::Texture.D3D12_TEXTURE_V_POINTER
: the ID3D12Resource associated with the V plane of a YUV textureWith the vulkan renderer:
prop::Texture.VULKAN_TEXTURE_NUMBER
: the VkImage associated with the textureWith the opengl renderer:
prop::Texture.OPENGL_TEXTURE_NUMBER
: the GLuint texture associated with the textureprop::Texture.OPENGL_TEXTURE_UV_NUMBER
: the GLuint texture associated with the UV plane of an NV12 textureprop::Texture.OPENGL_TEXTURE_U_NUMBER
: the GLuint texture associated with the U plane of a YUV textureprop::Texture.OPENGL_TEXTURE_V_NUMBER
: the GLuint texture associated with the V plane of a YUV textureprop::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 textureprop::Texture.OPENGLES2_TEXTURE_UV_NUMBER
: the GLuint texture associated with the UV plane of an NV12 textureprop::Texture.OPENGLES2_TEXTURE_U_NUMBER
: the GLuint texture associated with the U plane of a YUV textureprop::Texture.OPENGLES2_TEXTURE_V_NUMBER
: the GLuint texture associated with the V plane of a YUV textureprop::Texture.OPENGLES2_TEXTURE_TARGET_NUMBER
: the GLenum for the texture target (GL_TEXTURE_2D
, GL_TEXTURE_EXTERNAL_OES
, etc)texture | the texture to query. |
Error | on failure. |
|
inline |
texture | the texture to query. |
Error | on failure. |
|
inline |
texture | the texture to query. |
w | a pointer filled in with the width of the texture in pixels. This argument can be nullptr if you don't need this information. |
h | a pointer filled in with the height of the texture in pixels. This argument can be nullptr if you don't need this information. |
Error | on failure. |
|
inline |
|
inline |
Error | on failure. |
|
inline |
|
inline |
Each render target has its own clip rectangle. This function checks the cliprect for the current render target.
|
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.
|
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`.
rect | an Rect structure representing the area to lock for access; nullptr to lock the entire texture. |
pixels | this is filled in with a pointer to the locked pixels, appropriately offset by the locked area. |
pitch | this is filled in with the pitch of the locked pixels; the pitch is the length of one row in bytes. |
Error | on failure. |
|
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.
texture | the texture to lock for access, which was created with TEXTUREACCESS_STREAMING . |
rect | an Rect structure representing the area to lock for access; nullptr to lock the entire texture. |
pixels | this is filled in with a pointer to the locked pixels, appropriately offset by the locked area. |
pitch | this is filled in with the pitch of the locked pixels; the pitch is the length of one row in bytes. |
Error | on failure. |
|
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.
texture | the texture to lock for access, which must be created with TEXTUREACCESS_STREAMING . |
rect | a pointer to the rectangle to lock for access. If the rect is nullptr, the entire texture will be locked. |
Error | on failure. |
|
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`.
rect | a pointer to the rectangle to lock for access. If the rect is nullptr, the entire texture will be locked. |
Error | on failure. |
|
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.
Error | on failure. |
|
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().
rect | an Rect structure representing the area to read, which will be clipped to the current viewport, or nullptr for the entire viewport. |
Error | on failure. |
|
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.
Error | on failure. |
|
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.
renderer | the rendering context. |
Error | on failure. |
|
inline |
Each render target has its own clip rectangle. This function checks the cliprect for the current render target.
renderer | the rendering context. |
This takes into account several states:
window_coord | the x, y coordinate in window coordinates. |
Error | on failure. |
|
inline |
This takes into account several states:
renderer | the rendering context. |
window_coord | the x, y coordinate in window coordinates. |
Error | on failure. |
This takes into account several states:
coord | the x, y coordinate in render coordinates. |
Error | on failure. |
|
inline |
This takes into account several states:
renderer | the rendering context. |
coord | the x, y coordinates in render coordinates. |
Error | on failure. |
|
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:
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().
p | the x, y coordinates where the top-left corner of the text will draw. |
str | the string to render. |
Error | on failure. |
|
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:
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().
renderer | the renderer which should draw a line of text. |
p | the x,y coordinates where the top-left corner of the text will draw. |
str | the string to render. |
Error | on failure. |
|
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.
p | the x, y coordinates where the top-left corner of the text will draw. |
fmt | the format string to draw. |
args | additional parameters matching {} tokens in the fmt string, if any. |
Error | on failure. |
|
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.
renderer | the renderer which should draw the text. |
p | the x,y coordinate where the top-left corner of the text will draw. |
fmt | the format string to draw. |
args | additional parameters matching % tokens in the fmt string, if any. |
Error | on failure. |
|
inline |
rect | a pointer to the destination rectangle, or std::nullopt for the entire rendering target. |
Error | on failure. |
|
inline |
renderer | the renderer which should fill a rectangle. |
rect | a pointer to the destination rectangle, or nullptr for the entire rendering target. |
Error | on failure. |
|
inline |
renderer | the renderer which should fill multiple rectangles. |
rects | a pointer to an array of destination rectangles. |
Error | on failure. |
rects | a pointer to an array of destination rectangles. |
Error | on failure. |
|
inline |
renderer | the rendering context. |
texture | (optional) The SDL texture to use. |
vertices | vertices. |
indices | (optional) An array of integer indices into the 'vertices' array, if nullptr all vertices will be rendered in sequential order. |
Error | on failure. |
|
inline |
texture | (optional) The SDL texture to use. |
vertices | vertices. |
indices | (optional) An array of integer indices into the 'vertices' array, if nullptr all vertices will be rendered in sequential order. |
Error | on failure. |
|
inline |
renderer | the rendering context. |
texture | (optional) The SDL texture to use. |
xy | vertex positions. |
xy_stride | byte size to move from one element to the next element. |
color | vertex colors (as FColor). |
color_stride | byte size to move from one element to the next element. |
uv | vertex normalized texture coordinates. |
uv_stride | byte size to move from one element to the next element. |
num_vertices | number of vertices. |
indices | (optional) An array of indices into the 'vertices' arrays, if nullptr all vertices will be rendered in sequential order. |
num_indices | number of indices. |
size_indices | index size: 1 (byte), 2 (short), 4 (int). |
Error | on failure. |
|
inline |
texture | (optional) The SDL texture to use. |
xy | vertex positions. |
xy_stride | byte size to move from one element to the next element. |
color | vertex colors (as FColor). |
color_stride | byte size to move from one element to the next element. |
uv | vertex normalized texture coordinates. |
uv_stride | byte size to move from one element to the next element. |
num_vertices | number of vertices. |
indices | (optional) An array of indices into the 'vertices' arrays, if nullptr all vertices will be rendered in sequential order. |
num_indices | number of indices. |
size_indices | index size: 1 (byte), 2 (short), 4 (int). |
Error | on failure. |
p1 | the x,y coordinate of the start point. |
p2 | the x,y coordinate of the end point. |
Error | on failure. |
|
inline |
renderer | the renderer which should draw a line. |
p1 | the x,y coordinates of the start point. |
p2 | the x,y coordinates of the end point. |
Error | on failure. |
|
inline |
renderer | the renderer which should draw multiple lines. |
points | the points along the lines. |
Error | on failure. |
points | the points along the lines. |
Error | on failure. |
|
inline |
p | the x, y coordinates of the point. |
Error | on failure. |
|
inline |
renderer | the renderer which should draw a point. |
p | the x, y coordinate of the point. |
Error | on failure. |
|
inline |
renderer | the renderer which should draw multiple points. |
points | the points to draw. |
Error | on failure. |
points | the points to draw. |
Error | on failure. |
|
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.
renderer | the rendering context. |
Error | on failure. |
|
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().
renderer | the rendering context. |
rect | an Rect structure representing the area to read, which will be clipped to the current viewport, or nullptr for the entire viewport. |
Error | on failure. |
|
inline |
rect | a pointer to the destination rectangle, or std::nullopt to outline the entire rendering target. |
Error | on failure. |
|
inline |
renderer | the renderer which should draw a rectangle. |
rect | a pointer to the destination rectangle, or nullptr to outline the entire rendering target. |
Error | on failure. |
|
inline |
renderer | the renderer which should draw multiple rectangles. |
rects | a pointer to an array of destination rectangles. |
Error | on failure. |
rects | a pointer to an array of destination rectangles. |
Error | on failure. |
|
inline |
renderer | the renderer which should copy parts of a texture. |
texture | the source texture. |
srcrect | a pointer to the source rectangle, or nullptr for the entire texture. |
dstrect | a pointer to the destination rectangle, or nullptr for the entire rendering target. |
Error | on failure. |
|
inline |
texture | the source texture. |
srcrect | a pointer to the source rectangle, or nullptr for the entire texture. |
dstrect | a pointer to the destination rectangle, or nullptr for the entire rendering target. |
Error | on failure. |
|
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.
renderer | the renderer which should copy parts of a texture. |
texture | the source texture. |
srcrect | the Rect structure representing the rectangle to be used for the 9-grid, or nullptr to use the entire texture. |
left_width | the width, in pixels, of the left corners in srcrect . |
right_width | the width, in pixels, of the right corners in srcrect . |
top_height | the height, in pixels, of the top corners in srcrect . |
bottom_height | the height, in pixels, of the bottom corners in srcrect . |
scale | the scale used to transform the corner of srcrect into the corner of dstrect , or 0.0f for an unscaled copy. |
dstrect | a pointer to the destination rectangle, or nullptr for the entire rendering target. |
Error | on failure. |
|
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.
texture | the source texture. |
srcrect | the Rect structure representing the rectangle to be used for the 9-grid, or nullptr to use the entire texture. |
left_width | the width, in pixels, of the left corners in srcrect . |
right_width | the width, in pixels, of the right corners in srcrect . |
top_height | the height, in pixels, of the top corners in srcrect . |
bottom_height | the height, in pixels, of the bottom corners in srcrect . |
scale | the scale used to transform the corner of srcrect into the corner of dstrect , or 0.0f for an unscaled copy. |
dstrect | a pointer to the destination rectangle, or nullptr for the entire rendering target. |
Error | on failure. |
|
inline |
renderer | the renderer which should copy parts of a texture. |
texture | the source texture. |
srcrect | a pointer to the source rectangle, or nullptr for the entire texture. |
origin | a pointer to a point indicating where the top-left corner of srcrect should be mapped to, or nullptr for the rendering target's origin. |
right | a 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. |
down | a 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. |
Error | on failure. |
|
inline |
texture | the source texture. |
srcrect | a pointer to the source rectangle, or nullptr for the entire texture. |
origin | a pointer to a point indicating where the top-left corner of srcrect should be mapped to, or nullptr for the rendering target's origin. |
right | a 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. |
down | a 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. |
Error | on failure. |
|
inline |
renderer | the renderer which should copy parts of a texture. |
texture | the source texture. |
srcrect | a pointer to the source rectangle, or nullptr for the entire texture. |
dstrect | a pointer to the destination rectangle, or nullptr for the entire rendering target. |
angle | an angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction. |
center | a 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). |
flip | an FlipMode value stating which flipping actions should be performed on the texture. |
Error | on failure. |
|
inline |
texture | the source texture. |
srcrect | a pointer to the source rectangle, or nullptr for the entire texture. |
dstrect | a pointer to the destination rectangle, or nullptr for the entire rendering target. |
angle | an angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction. |
center | a 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). |
flip | an FlipMode value stating which flipping actions should be performed on the texture. |
Error | on failure. |
|
inline |
The pixels in srcrect
will be repeated as many times as needed to completely fill dstrect
.
renderer | the renderer which should copy parts of a texture. |
texture | the source texture. |
srcrect | a pointer to the source rectangle, or nullptr for the entire texture. |
scale | the scale used to transform srcrect into the destination rectangle, e.g. a 32x32 texture with a scale of 2 would fill 64x64 tiles. |
dstrect | a pointer to the destination rectangle, or nullptr for the entire rendering target. |
Error | on failure. |
|
inline |
The pixels in srcrect
will be repeated as many times as needed to completely fill dstrect
.
texture | the source texture. |
srcrect | a pointer to the source rectangle, or nullptr for the entire texture. |
scale | the scale used to transform srcrect into the destination rectangle, e.g. a 32x32 texture with a scale of 2 would fill 64x64 tiles. |
dstrect | a pointer to the destination rectangle, or nullptr for the entire rendering target. |
Error | on failure. |
|
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.
renderer | the rendering context. |
|
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.
alpha | the source alpha value multiplied into copy operations. |
Error | on failure. |
|
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.
alpha | the source alpha value multiplied into copy operations. |
Error | on failure. |
|
inline |
If the blend mode is not supported, the closest supported mode is chosen and this function returns false.
blendMode | the BlendMode to use for texture blending. |
Error | on failure. |
|
inline |
Each render target has its own clip rectangle. This function sets the cliprect for the current render target.
rect | an Rect structure representing the clip area, relative to the viewport, or nullptr to disable clipping. |
Error | on failure. |
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.
r | the red color value multiplied into copy operations. |
g | the green color value multiplied into copy operations. |
b | the blue color value multiplied into copy operations. |
Error | on failure. |
|
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.
r | the red color value multiplied into copy operations. |
g | the green color value multiplied into copy operations. |
b | the blue color value multiplied into copy operations. |
Error | on failure. |
|
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.
scale | the color scale value. |
Error | on failure. |
|
inline |
If the blend mode is not supported, the closest supported mode is chosen.
blendMode | the BlendMode to use for blending. |
Error | on failure. |
|
inline |
Set the color for drawing or filling rectangles, lines, and points, and for Renderer.RenderClear().
c | the color value used to draw on the rendering target. |
Error | on failure. |
|
inline |
Set the color for drawing or filling rectangles, lines, and points, and for Renderer.RenderClear().
c | the RGBA values used to draw on the rendering target. |
Error | on failure. |
|
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().
size | the width and height of the logical resolution. |
mode | the presentation mode used. |
Error | on failure. |
|
inline |
Each render target has its own clip rectangle. This function sets the cliprect for the current render target.
renderer | the rendering context. |
rect | an Rect structure representing the clip area, relative to the viewport, or nullptr to disable clipping. |
Error | on failure. |
|
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.
renderer | the rendering context. |
scale | the color scale value. |
Error | on failure. |
|
inline |
If the blend mode is not supported, the closest supported mode is chosen.
renderer | the rendering context. |
blendMode | the BlendMode to use for blending. |
Error | on failure. |
|
inline |
Set the color for drawing or filling rectangles, lines, and points, and for Renderer.RenderClear().
renderer | the rendering context. |
c | the color used to draw on the rendering target. |
Error | on failure. |
|
inline |
Set the color for drawing or filling rectangles, lines, and points, and for Renderer.RenderClear().
renderer | the rendering context. |
c | the color used to draw on the rendering target. |
Error | on failure. |
|
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().
renderer | the rendering context. |
size | the width and height of the logical resolution. |
mode | the presentation mode used. |
Error | on failure. |
|
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.
renderer | the rendering context. |
scale | the horizontal and vertical scaling factors. |
Error | on failure. |
|
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.
renderer | the rendering context. |
texture | the targeted texture, which must be created with the TEXTUREACCESS_TARGET flag, or nullptr to render to the window instead of a texture. |
Error | on failure. |
|
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.
renderer | the rendering context. |
rect | the Rect structure representing the drawing area, or nullptr to set the viewport to the entire target. |
Error | on failure. |
|
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.
renderer | the renderer to toggle. |
vsync | the vertical refresh sync interval. |
Error | on failure. |
|
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.
scale | the x, y scaling factors. |
Error | on failure. |
|
inline |
The default texture scale mode is SCALEMODE_LINEAR.
If the scale mode is not supported, the closest supported mode is chosen.
scaleMode | the ScaleMode to use for texture scaling. |
Error | on failure. |
|
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.
texture | the targeted texture, which must be created with the TEXTUREACCESS_TARGET flag, or nullptr to render to the window instead of a texture. |
Error | on failure. |
|
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.
texture | the texture to update. |
alpha | the source alpha value multiplied into copy operations. |
Error | on failure. |
|
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.
texture | the texture to update. |
alpha | the source alpha value multiplied into copy operations. |
Error | on failure. |
|
inline |
If the blend mode is not supported, the closest supported mode is chosen and this function returns false.
texture | the texture to update. |
blendMode | the BlendMode to use for texture blending. |
Error | on failure. |
|
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.
texture | the texture to update. |
r | the red color value multiplied into copy operations. |
g | the green color value multiplied into copy operations. |
b | the blue color value multiplied into copy operations. |
Error | on failure. |
|
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.
texture | the texture to update. |
r | the red color value multiplied into copy operations. |
g | the green color value multiplied into copy operations. |
b | the blue color value multiplied into copy operations. |
Error | on failure. |
|
inline |
The default texture scale mode is SCALEMODE_LINEAR.
If the scale mode is not supported, the closest supported mode is chosen.
texture | the texture to update. |
scaleMode | the ScaleMode to use for texture scaling. |
Error | on failure. |
|
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.
rect | the Rect structure representing the drawing area, or nullptr to set the viewport to the entire target. |
Error | on failure. |
|
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.
vsync | the vertical refresh sync interval. |
Error | on failure. |
|
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.
|
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.
texture | a texture locked by Texture.Lock(). |
|
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.
rect | an Rect structure representing the area to update, or nullptr to update the entire texture. |
pixels | the raw pixel data in the format of the texture. |
pitch | the number of bytes in a row of pixel data, including padding between lines. |
Error | on failure. |
|
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.
rect | a pointer to the rectangle of pixels to update, or nullptr to update the entire texture. |
Yplane | the raw pixel data for the Y plane. |
Ypitch | the number of bytes between rows of pixel data for the Y plane. |
UVplane | the raw pixel data for the UV plane. |
UVpitch | the number of bytes between rows of pixel data for the UV plane. |
Error | on failure. |
|
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.
texture | the texture to update. |
rect | a pointer to the rectangle of pixels to update, or nullptr to update the entire texture. |
Yplane | the raw pixel data for the Y plane. |
Ypitch | the number of bytes between rows of pixel data for the Y plane. |
UVplane | the raw pixel data for the UV plane. |
UVpitch | the number of bytes between rows of pixel data for the UV plane. |
Error | on failure. |
|
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.
texture | the texture to update. |
rect | an Rect structure representing the area to update, or nullptr to update the entire texture. |
pixels | the raw pixel data in the format of the texture. |
pitch | the number of bytes in a row of pixel data, including padding between lines. |
Error | on failure. |
|
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.
rect | a pointer to the rectangle of pixels to update, or nullptr to update the entire texture. |
Yplane | the raw pixel data for the Y plane. |
Ypitch | the number of bytes between rows of pixel data for the Y plane. |
Uplane | the raw pixel data for the U plane. |
Upitch | the number of bytes between rows of pixel data for the U plane. |
Vplane | the raw pixel data for the V plane. |
Vpitch | the number of bytes between rows of pixel data for the V plane. |
Error | on failure. |
|
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.
texture | the texture to update. |
rect | a pointer to the rectangle of pixels to update, or nullptr to update the entire texture. |
Yplane | the raw pixel data for the Y plane. |
Ypitch | the number of bytes between rows of pixel data for the Y plane. |
Uplane | the raw pixel data for the U plane. |
Upitch | the number of bytes between rows of pixel data for the U plane. |
Vplane | the raw pixel data for the V plane. |
Vpitch | the number of bytes between rows of pixel data for the V plane. |
Error | on failure. |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |