Path: blob/master/thirdparty/sdl/include/SDL3/SDL_render.h
9912 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021/**22* # CategoryRender23*24* Header file for SDL 2D rendering functions.25*26* This API supports the following features:27*28* - single pixel points29* - single pixel lines30* - filled rectangles31* - texture images32* - 2D polygons33*34* The primitives may be drawn in opaque, blended, or additive modes.35*36* The texture images may be drawn in opaque, blended, or additive modes. They37* can have an additional color tint or alpha modulation applied to them, and38* may also be stretched with linear interpolation.39*40* This API is designed to accelerate simple 2D operations. You may want more41* functionality such as polygons and particle effects and in that case you42* should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of the43* many good 3D engines.44*45* These functions must be called from the main thread. See this bug for46* details: https://github.com/libsdl-org/SDL/issues/98647*/4849#ifndef SDL_render_h_50#define SDL_render_h_5152#include <SDL3/SDL_stdinc.h>53#include <SDL3/SDL_blendmode.h>54#include <SDL3/SDL_error.h>55#include <SDL3/SDL_events.h>56#include <SDL3/SDL_pixels.h>57#include <SDL3/SDL_properties.h>58#include <SDL3/SDL_rect.h>59#include <SDL3/SDL_surface.h>60#include <SDL3/SDL_video.h>6162#include <SDL3/SDL_begin_code.h>63/* Set up for C function definitions, even when using C++ */64#ifdef __cplusplus65extern "C" {66#endif6768/**69* The name of the software renderer.70*71* \since This macro is available since SDL 3.2.0.72*/73#define SDL_SOFTWARE_RENDERER "software"7475/**76* Vertex structure.77*78* \since This struct is available since SDL 3.2.0.79*/80typedef struct SDL_Vertex81{82SDL_FPoint position; /**< Vertex position, in SDL_Renderer coordinates */83SDL_FColor color; /**< Vertex color */84SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */85} SDL_Vertex;8687/**88* The access pattern allowed for a texture.89*90* \since This enum is available since SDL 3.2.0.91*/92typedef enum SDL_TextureAccess93{94SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */95SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */96SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */97} SDL_TextureAccess;9899/**100* How the logical size is mapped to the output.101*102* \since This enum is available since SDL 3.2.0.103*/104typedef enum SDL_RendererLogicalPresentation105{106SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */107SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */108SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with black bars */109SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */110SDL_LOGICAL_PRESENTATION_INTEGER_SCALE /**< The rendered content is scaled up by integer multiples to fit the output resolution */111} SDL_RendererLogicalPresentation;112113/**114* A structure representing rendering state115*116* \since This struct is available since SDL 3.2.0.117*/118typedef struct SDL_Renderer SDL_Renderer;119120#ifndef SDL_INTERNAL121122/**123* An efficient driver-specific representation of pixel data124*125* \since This struct is available since SDL 3.2.0.126*127* \sa SDL_CreateTexture128* \sa SDL_CreateTextureFromSurface129* \sa SDL_CreateTextureWithProperties130* \sa SDL_DestroyTexture131*/132struct SDL_Texture133{134SDL_PixelFormat format; /**< The format of the texture, read-only */135int w; /**< The width of the texture, read-only. */136int h; /**< The height of the texture, read-only. */137138int refcount; /**< Application reference count, used when freeing texture */139};140#endif /* !SDL_INTERNAL */141142typedef struct SDL_Texture SDL_Texture;143144/* Function prototypes */145146/**147* Get the number of 2D rendering drivers available for the current display.148*149* A render driver is a set of code that handles rendering and texture150* management on a particular display. Normally there is only one, but some151* drivers may have several available with different capabilities.152*153* There may be none if SDL was compiled without render support.154*155* \returns the number of built in render drivers.156*157* \threadsafety It is safe to call this function from any thread.158*159* \since This function is available since SDL 3.2.0.160*161* \sa SDL_CreateRenderer162* \sa SDL_GetRenderDriver163*/164extern SDL_DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);165166/**167* Use this function to get the name of a built in 2D rendering driver.168*169* The list of rendering drivers is given in the order that they are normally170* initialized by default; the drivers that seem more reasonable to choose171* first (as far as the SDL developers believe) are earlier in the list.172*173* The names of drivers are all simple, low-ASCII identifiers, like "opengl",174* "direct3d12" or "metal". These never have Unicode characters, and are not175* meant to be proper names.176*177* \param index the index of the rendering driver; the value ranges from 0 to178* SDL_GetNumRenderDrivers() - 1.179* \returns the name of the rendering driver at the requested index, or NULL180* if an invalid index was specified.181*182* \threadsafety It is safe to call this function from any thread.183*184* \since This function is available since SDL 3.2.0.185*186* \sa SDL_GetNumRenderDrivers187*/188extern SDL_DECLSPEC const char * SDLCALL SDL_GetRenderDriver(int index);189190/**191* Create a window and default renderer.192*193* \param title the title of the window, in UTF-8 encoding.194* \param width the width of the window.195* \param height the height of the window.196* \param window_flags the flags used to create the window (see197* SDL_CreateWindow()).198* \param window a pointer filled with the window, or NULL on error.199* \param renderer a pointer filled with the renderer, or NULL on error.200* \returns true on success or false on failure; call SDL_GetError() for more201* information.202*203* \threadsafety This function should only be called on the main thread.204*205* \since This function is available since SDL 3.2.0.206*207* \sa SDL_CreateRenderer208* \sa SDL_CreateWindow209*/210extern SDL_DECLSPEC bool SDLCALL SDL_CreateWindowAndRenderer(const char *title, int width, int height, SDL_WindowFlags window_flags, SDL_Window **window, SDL_Renderer **renderer);211212/**213* Create a 2D rendering context for a window.214*215* If you want a specific renderer, you can specify its name here. A list of216* available renderers can be obtained by calling SDL_GetRenderDriver()217* multiple times, with indices from 0 to SDL_GetNumRenderDrivers()-1. If you218* don't need a specific renderer, specify NULL and SDL will attempt to choose219* the best option for you, based on what is available on the user's system.220*221* If `name` is a comma-separated list, SDL will try each name, in the order222* listed, until one succeeds or all of them fail.223*224* By default the rendering size matches the window size in pixels, but you225* can call SDL_SetRenderLogicalPresentation() to change the content size and226* scaling options.227*228* \param window the window where rendering is displayed.229* \param name the name of the rendering driver to initialize, or NULL to let230* SDL choose one.231* \returns a valid rendering context or NULL if there was an error; call232* SDL_GetError() for more information.233*234* \threadsafety This function should only be called on the main thread.235*236* \since This function is available since SDL 3.2.0.237*238* \sa SDL_CreateRendererWithProperties239* \sa SDL_CreateSoftwareRenderer240* \sa SDL_DestroyRenderer241* \sa SDL_GetNumRenderDrivers242* \sa SDL_GetRenderDriver243* \sa SDL_GetRendererName244*/245extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name);246247/**248* Create a 2D rendering context for a window, with the specified properties.249*250* These are the supported properties:251*252* - `SDL_PROP_RENDERER_CREATE_NAME_STRING`: the name of the rendering driver253* to use, if a specific one is desired254* - `SDL_PROP_RENDERER_CREATE_WINDOW_POINTER`: the window where rendering is255* displayed, required if this isn't a software renderer using a surface256* - `SDL_PROP_RENDERER_CREATE_SURFACE_POINTER`: the surface where rendering257* is displayed, if you want a software renderer without a window258* - `SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace259* value describing the colorspace for output to the display, defaults to260* SDL_COLORSPACE_SRGB. The direct3d11, direct3d12, and metal renderers261* support SDL_COLORSPACE_SRGB_LINEAR, which is a linear color space and262* supports HDR output. If you select SDL_COLORSPACE_SRGB_LINEAR, drawing263* still uses the sRGB colorspace, but values can go beyond 1.0 and float264* (linear) format textures can be used for HDR content.265* - `SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER`: non-zero if you want266* present synchronized with the refresh rate. This property can take any267* value that is supported by SDL_SetRenderVSync() for the renderer.268*269* With the vulkan renderer:270*271* - `SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER`: the VkInstance to use272* with the renderer, optional.273* - `SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR to use274* with the renderer, optional.275* - `SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER`: the276* VkPhysicalDevice to use with the renderer, optional.277* - `SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER`: the VkDevice to use278* with the renderer, optional.279* - `SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the280* queue family index used for rendering.281* - `SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the282* queue family index used for presentation.283*284* \param props the properties to use.285* \returns a valid rendering context or NULL if there was an error; call286* SDL_GetError() for more information.287*288* \threadsafety This function should only be called on the main thread.289*290* \since This function is available since SDL 3.2.0.291*292* \sa SDL_CreateProperties293* \sa SDL_CreateRenderer294* \sa SDL_CreateSoftwareRenderer295* \sa SDL_DestroyRenderer296* \sa SDL_GetRendererName297*/298extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_PropertiesID props);299300#define SDL_PROP_RENDERER_CREATE_NAME_STRING "SDL.renderer.create.name"301#define SDL_PROP_RENDERER_CREATE_WINDOW_POINTER "SDL.renderer.create.window"302#define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "SDL.renderer.create.surface"303#define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.create.output_colorspace"304#define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER "SDL.renderer.create.present_vsync"305#define SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER "SDL.renderer.create.vulkan.instance"306#define SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER "SDL.renderer.create.vulkan.surface"307#define SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.create.vulkan.physical_device"308#define SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER "SDL.renderer.create.vulkan.device"309#define SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.graphics_queue_family_index"310#define SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.present_queue_family_index"311312/**313* Create a 2D software rendering context for a surface.314*315* Two other API which can be used to create SDL_Renderer:316* SDL_CreateRenderer() and SDL_CreateWindowAndRenderer(). These can _also_317* create a software renderer, but they are intended to be used with an318* SDL_Window as the final destination and not an SDL_Surface.319*320* \param surface the SDL_Surface structure representing the surface where321* rendering is done.322* \returns a valid rendering context or NULL if there was an error; call323* SDL_GetError() for more information.324*325* \threadsafety This function should only be called on the main thread.326*327* \since This function is available since SDL 3.2.0.328*329* \sa SDL_DestroyRenderer330*/331extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface *surface);332333/**334* Get the renderer associated with a window.335*336* \param window the window to query.337* \returns the rendering context on success or NULL on failure; call338* SDL_GetError() for more information.339*340* \threadsafety It is safe to call this function from any thread.341*342* \since This function is available since SDL 3.2.0.343*/344extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window *window);345346/**347* Get the window associated with a renderer.348*349* \param renderer the renderer to query.350* \returns the window on success or NULL on failure; call SDL_GetError() for351* more information.352*353* \threadsafety It is safe to call this function from any thread.354*355* \since This function is available since SDL 3.2.0.356*/357extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetRenderWindow(SDL_Renderer *renderer);358359/**360* Get the name of a renderer.361*362* \param renderer the rendering context.363* \returns the name of the selected renderer, or NULL on failure; call364* SDL_GetError() for more information.365*366* \threadsafety It is safe to call this function from any thread.367*368* \since This function is available since SDL 3.2.0.369*370* \sa SDL_CreateRenderer371* \sa SDL_CreateRendererWithProperties372*/373extern SDL_DECLSPEC const char * SDLCALL SDL_GetRendererName(SDL_Renderer *renderer);374375/**376* Get the properties associated with a renderer.377*378* The following read-only properties are provided by SDL:379*380* - `SDL_PROP_RENDERER_NAME_STRING`: the name of the rendering driver381* - `SDL_PROP_RENDERER_WINDOW_POINTER`: the window where rendering is382* displayed, if any383* - `SDL_PROP_RENDERER_SURFACE_POINTER`: the surface where rendering is384* displayed, if this is a software renderer without a window385* - `SDL_PROP_RENDERER_VSYNC_NUMBER`: the current vsync setting386* - `SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER`: the maximum texture width387* and height388* - `SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`: a (const SDL_PixelFormat *)389* array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN,390* representing the available texture formats for this renderer.391* - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace value392* describing the colorspace for output to the display, defaults to393* SDL_COLORSPACE_SRGB.394* - `SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN`: true if the output colorspace is395* SDL_COLORSPACE_SRGB_LINEAR and the renderer is showing on a display with396* HDR enabled. This property can change dynamically when397* SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.398* - `SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT`: the value of SDR white in the399* SDL_COLORSPACE_SRGB_LINEAR colorspace. When HDR is enabled, this value is400* automatically multiplied into the color scale. This property can change401* dynamically when SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.402* - `SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT`: the additional high dynamic range403* that can be displayed, in terms of the SDR white point. When HDR is not404* enabled, this will be 1.0. This property can change dynamically when405* SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.406*407* With the direct3d renderer:408*409* - `SDL_PROP_RENDERER_D3D9_DEVICE_POINTER`: the IDirect3DDevice9 associated410* with the renderer411*412* With the direct3d11 renderer:413*414* - `SDL_PROP_RENDERER_D3D11_DEVICE_POINTER`: the ID3D11Device associated415* with the renderer416* - `SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER`: the IDXGISwapChain1417* associated with the renderer. This may change when the window is resized.418*419* With the direct3d12 renderer:420*421* - `SDL_PROP_RENDERER_D3D12_DEVICE_POINTER`: the ID3D12Device associated422* with the renderer423* - `SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER`: the IDXGISwapChain4424* associated with the renderer.425* - `SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER`: the ID3D12CommandQueue426* associated with the renderer427*428* With the vulkan renderer:429*430* - `SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER`: the VkInstance associated431* with the renderer432* - `SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR associated433* with the renderer434* - `SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER`: the VkPhysicalDevice435* associated with the renderer436* - `SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER`: the VkDevice associated with437* the renderer438* - `SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the queue439* family index used for rendering440* - `SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the queue441* family index used for presentation442* - `SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER`: the number of443* swapchain images, or potential frames in flight, used by the Vulkan444* renderer445*446* With the gpu renderer:447*448* - `SDL_PROP_RENDERER_GPU_DEVICE_POINTER`: the SDL_GPUDevice associated with449* the renderer450*451* \param renderer the rendering context.452* \returns a valid property ID on success or 0 on failure; call453* SDL_GetError() for more information.454*455* \threadsafety It is safe to call this function from any thread.456*457* \since This function is available since SDL 3.2.0.458*/459extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Renderer *renderer);460461#define SDL_PROP_RENDERER_NAME_STRING "SDL.renderer.name"462#define SDL_PROP_RENDERER_WINDOW_POINTER "SDL.renderer.window"463#define SDL_PROP_RENDERER_SURFACE_POINTER "SDL.renderer.surface"464#define SDL_PROP_RENDERER_VSYNC_NUMBER "SDL.renderer.vsync"465#define SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER "SDL.renderer.max_texture_size"466#define SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER "SDL.renderer.texture_formats"467#define SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.output_colorspace"468#define SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN "SDL.renderer.HDR_enabled"469#define SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT "SDL.renderer.SDR_white_point"470#define SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT "SDL.renderer.HDR_headroom"471#define SDL_PROP_RENDERER_D3D9_DEVICE_POINTER "SDL.renderer.d3d9.device"472#define SDL_PROP_RENDERER_D3D11_DEVICE_POINTER "SDL.renderer.d3d11.device"473#define SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER "SDL.renderer.d3d11.swap_chain"474#define SDL_PROP_RENDERER_D3D12_DEVICE_POINTER "SDL.renderer.d3d12.device"475#define SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER "SDL.renderer.d3d12.swap_chain"476#define SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER "SDL.renderer.d3d12.command_queue"477#define SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER "SDL.renderer.vulkan.instance"478#define SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER "SDL.renderer.vulkan.surface"479#define SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.vulkan.physical_device"480#define SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER "SDL.renderer.vulkan.device"481#define SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.graphics_queue_family_index"482#define SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.present_queue_family_index"483#define SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER "SDL.renderer.vulkan.swapchain_image_count"484#define SDL_PROP_RENDERER_GPU_DEVICE_POINTER "SDL.renderer.gpu.device"485486/**487* Get the output size in pixels of a rendering context.488*489* This returns the true output size in pixels, ignoring any render targets or490* logical size and presentation.491*492* For the output size of the current rendering target, with logical size493* adjustments, use SDL_GetCurrentRenderOutputSize() instead.494*495* \param renderer the rendering context.496* \param w a pointer filled in with the width in pixels.497* \param h a pointer filled in with the height in pixels.498* \returns true on success or false on failure; call SDL_GetError() for more499* information.500*501* \threadsafety This function should only be called on the main thread.502*503* \since This function is available since SDL 3.2.0.504*505* \sa SDL_GetCurrentRenderOutputSize506*/507extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);508509/**510* Get the current output size in pixels of a rendering context.511*512* If a rendering target is active, this will return the size of the rendering513* target in pixels, otherwise return the value of SDL_GetRenderOutputSize().514*515* Rendering target or not, the output will be adjusted by the current logical516* presentation state, dictated by SDL_SetRenderLogicalPresentation().517*518* \param renderer the rendering context.519* \param w a pointer filled in with the current width.520* \param h a pointer filled in with the current height.521* \returns true on success or false on failure; call SDL_GetError() for more522* information.523*524* \threadsafety This function should only be called on the main thread.525*526* \since This function is available since SDL 3.2.0.527*528* \sa SDL_GetRenderOutputSize529*/530extern SDL_DECLSPEC bool SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);531532/**533* Create a texture for a rendering context.534*535* The contents of a texture when first created are not defined.536*537* \param renderer the rendering context.538* \param format one of the enumerated values in SDL_PixelFormat.539* \param access one of the enumerated values in SDL_TextureAccess.540* \param w the width of the texture in pixels.541* \param h the height of the texture in pixels.542* \returns the created texture or NULL on failure; call SDL_GetError() for543* more information.544*545* \threadsafety This function should only be called on the main thread.546*547* \since This function is available since SDL 3.2.0.548*549* \sa SDL_CreateTextureFromSurface550* \sa SDL_CreateTextureWithProperties551* \sa SDL_DestroyTexture552* \sa SDL_GetTextureSize553* \sa SDL_UpdateTexture554*/555extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormat format, SDL_TextureAccess access, int w, int h);556557/**558* Create a texture from an existing surface.559*560* The surface is not modified or freed by this function.561*562* The SDL_TextureAccess hint for the created texture is563* `SDL_TEXTUREACCESS_STATIC`.564*565* The pixel format of the created texture may be different from the pixel566* format of the surface, and can be queried using the567* SDL_PROP_TEXTURE_FORMAT_NUMBER property.568*569* \param renderer the rendering context.570* \param surface the SDL_Surface structure containing pixel data used to fill571* the texture.572* \returns the created texture or NULL on failure; call SDL_GetError() for573* more information.574*575* \threadsafety This function should only be called on the main thread.576*577* \since This function is available since SDL 3.2.0.578*579* \sa SDL_CreateTexture580* \sa SDL_CreateTextureWithProperties581* \sa SDL_DestroyTexture582*/583extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface);584585/**586* Create a texture for a rendering context with the specified properties.587*588* These are the supported properties:589*590* - `SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER`: an SDL_Colorspace value591* describing the texture colorspace, defaults to SDL_COLORSPACE_SRGB_LINEAR592* for floating point textures, SDL_COLORSPACE_HDR10 for 10-bit textures,593* SDL_COLORSPACE_SRGB for other RGB textures and SDL_COLORSPACE_JPEG for594* YUV textures.595* - `SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER`: one of the enumerated values in596* SDL_PixelFormat, defaults to the best RGBA format for the renderer597* - `SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER`: one of the enumerated values in598* SDL_TextureAccess, defaults to SDL_TEXTUREACCESS_STATIC599* - `SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER`: the width of the texture in600* pixels, required601* - `SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`: the height of the texture in602* pixels, required603* - `SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating604* point textures, this defines the value of 100% diffuse white, with higher605* values being displayed in the High Dynamic Range headroom. This defaults606* to 100 for HDR10 textures and 1.0 for floating point textures.607* - `SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT`: for HDR10 and floating608* point textures, this defines the maximum dynamic range used by the609* content, in terms of the SDR white point. This would be equivalent to610* maxCLL / SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT for HDR10 content.611* If this is defined, any values outside the range supported by the display612* will be scaled into the available HDR headroom, otherwise they are613* clipped.614*615* With the direct3d11 renderer:616*617* - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D618* associated with the texture, if you want to wrap an existing texture.619* - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D620* associated with the U plane of a YUV texture, if you want to wrap an621* existing texture.622* - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D623* associated with the V plane of a YUV texture, if you want to wrap an624* existing texture.625*626* With the direct3d12 renderer:627*628* - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER`: the ID3D12Resource629* associated with the texture, if you want to wrap an existing texture.630* - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource631* associated with the U plane of a YUV texture, if you want to wrap an632* existing texture.633* - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource634* associated with the V plane of a YUV texture, if you want to wrap an635* existing texture.636*637* With the metal renderer:638*639* - `SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER`: the CVPixelBufferRef640* associated with the texture, if you want to create a texture from an641* existing pixel buffer.642*643* With the opengl renderer:644*645* - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER`: the GLuint texture646* associated with the texture, if you want to wrap an existing texture.647* - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture648* associated with the UV plane of an NV12 texture, if you want to wrap an649* existing texture.650* - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture651* associated with the U plane of a YUV texture, if you want to wrap an652* existing texture.653* - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture654* associated with the V plane of a YUV texture, if you want to wrap an655* existing texture.656*657* With the opengles2 renderer:658*659* - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture660* associated with the texture, if you want to wrap an existing texture.661* - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture662* associated with the texture, if you want to wrap an existing texture.663* - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture664* associated with the UV plane of an NV12 texture, if you want to wrap an665* existing texture.666* - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture667* associated with the U plane of a YUV texture, if you want to wrap an668* existing texture.669* - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture670* associated with the V plane of a YUV texture, if you want to wrap an671* existing texture.672*673* With the vulkan renderer:674*675* - `SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER`: the VkImage with layout676* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL associated with the texture, if677* you want to wrap an existing texture.678*679* \param renderer the rendering context.680* \param props the properties to use.681* \returns the created texture or NULL on failure; call SDL_GetError() for682* more information.683*684* \threadsafety This function should only be called on the main thread.685*686* \since This function is available since SDL 3.2.0.687*688* \sa SDL_CreateProperties689* \sa SDL_CreateTexture690* \sa SDL_CreateTextureFromSurface691* \sa SDL_DestroyTexture692* \sa SDL_GetTextureSize693* \sa SDL_UpdateTexture694*/695extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props);696697#define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace"698#define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format"699#define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access"700#define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width"701#define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height"702#define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point"703#define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom"704#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture"705#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u"706#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v"707#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture"708#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u"709#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v"710#define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer"711#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture"712#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv"713#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u"714#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v"715#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture"716#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv"717#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u"718#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v"719#define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture"720721/**722* Get the properties associated with a texture.723*724* The following read-only properties are provided by SDL:725*726* - `SDL_PROP_TEXTURE_COLORSPACE_NUMBER`: an SDL_Colorspace value describing727* the texture colorspace.728* - `SDL_PROP_TEXTURE_FORMAT_NUMBER`: one of the enumerated values in729* SDL_PixelFormat.730* - `SDL_PROP_TEXTURE_ACCESS_NUMBER`: one of the enumerated values in731* SDL_TextureAccess.732* - `SDL_PROP_TEXTURE_WIDTH_NUMBER`: the width of the texture in pixels.733* - `SDL_PROP_TEXTURE_HEIGHT_NUMBER`: the height of the texture in pixels.734* - `SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point735* textures, this defines the value of 100% diffuse white, with higher736* values being displayed in the High Dynamic Range headroom. This defaults737* to 100 for HDR10 textures and 1.0 for other textures.738* - `SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point739* textures, this defines the maximum dynamic range used by the content, in740* terms of the SDR white point. If this is defined, any values outside the741* range supported by the display will be scaled into the available HDR742* headroom, otherwise they are clipped. This defaults to 1.0 for SDR743* textures, 4.0 for HDR10 textures, and no default for floating point744* textures.745*746* With the direct3d11 renderer:747*748* - `SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D associated749* with the texture750* - `SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D751* associated with the U plane of a YUV texture752* - `SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D753* associated with the V plane of a YUV texture754*755* With the direct3d12 renderer:756*757* - `SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER`: the ID3D12Resource associated758* with the texture759* - `SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource associated760* with the U plane of a YUV texture761* - `SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource associated762* with the V plane of a YUV texture763*764* With the vulkan renderer:765*766* - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER`: the VkImage associated with the767* texture768*769* With the opengl renderer:770*771* - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER`: the GLuint texture associated772* with the texture773* - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture774* associated with the UV plane of an NV12 texture775* - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture associated776* with the U plane of a YUV texture777* - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture associated778* with the V plane of a YUV texture779* - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER`: the GLenum for the780* texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_RECTANGLE_ARB`, etc)781* - `SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT`: the texture coordinate width of782* the texture (0.0 - 1.0)783* - `SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT`: the texture coordinate height of784* the texture (0.0 - 1.0)785*786* With the opengles2 renderer:787*788* - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture789* associated with the texture790* - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture791* associated with the UV plane of an NV12 texture792* - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture793* associated with the U plane of a YUV texture794* - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture795* associated with the V plane of a YUV texture796* - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`: the GLenum for the797* texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc)798*799* \param texture the texture to query.800* \returns a valid property ID on success or 0 on failure; call801* SDL_GetError() for more information.802*803* \threadsafety It is safe to call this function from any thread.804*805* \since This function is available since SDL 3.2.0.806*/807extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture);808809#define SDL_PROP_TEXTURE_COLORSPACE_NUMBER "SDL.texture.colorspace"810#define SDL_PROP_TEXTURE_FORMAT_NUMBER "SDL.texture.format"811#define SDL_PROP_TEXTURE_ACCESS_NUMBER "SDL.texture.access"812#define SDL_PROP_TEXTURE_WIDTH_NUMBER "SDL.texture.width"813#define SDL_PROP_TEXTURE_HEIGHT_NUMBER "SDL.texture.height"814#define SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT "SDL.texture.SDR_white_point"815#define SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT "SDL.texture.HDR_headroom"816#define SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER "SDL.texture.d3d11.texture"817#define SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER "SDL.texture.d3d11.texture_u"818#define SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER "SDL.texture.d3d11.texture_v"819#define SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER "SDL.texture.d3d12.texture"820#define SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER "SDL.texture.d3d12.texture_u"821#define SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER "SDL.texture.d3d12.texture_v"822#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER "SDL.texture.opengl.texture"823#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.opengl.texture_uv"824#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.opengl.texture_u"825#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.opengl.texture_v"826#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER "SDL.texture.opengl.target"827#define SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT "SDL.texture.opengl.tex_w"828#define SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT "SDL.texture.opengl.tex_h"829#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.opengles2.texture"830#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.opengles2.texture_uv"831#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.opengles2.texture_u"832#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v"833#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER "SDL.texture.opengles2.target"834#define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER "SDL.texture.vulkan.texture"835836/**837* Get the renderer that created an SDL_Texture.838*839* \param texture the texture to query.840* \returns a pointer to the SDL_Renderer that created the texture, or NULL on841* failure; call SDL_GetError() for more information.842*843* \threadsafety It is safe to call this function from any thread.844*845* \since This function is available since SDL 3.2.0.846*/847extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRendererFromTexture(SDL_Texture *texture);848849/**850* Get the size of a texture, as floating point values.851*852* \param texture the texture to query.853* \param w a pointer filled in with the width of the texture in pixels. This854* argument can be NULL if you don't need this information.855* \param h a pointer filled in with the height of the texture in pixels. This856* argument can be NULL if you don't need this information.857* \returns true on success or false on failure; call SDL_GetError() for more858* information.859*860* \threadsafety This function should only be called on the main thread.861*862* \since This function is available since SDL 3.2.0.863*/864extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h);865866/**867* Set an additional color value multiplied into render copy operations.868*869* When this texture is rendered, during the copy operation each source color870* channel is modulated by the appropriate color value according to the871* following formula:872*873* `srcC = srcC * (color / 255)`874*875* Color modulation is not always supported by the renderer; it will return876* false if color modulation is not supported.877*878* \param texture the texture to update.879* \param r the red color value multiplied into copy operations.880* \param g the green color value multiplied into copy operations.881* \param b the blue color value multiplied into copy operations.882* \returns true on success or false on failure; call SDL_GetError() for more883* information.884*885* \threadsafety This function should only be called on the main thread.886*887* \since This function is available since SDL 3.2.0.888*889* \sa SDL_GetTextureColorMod890* \sa SDL_SetTextureAlphaMod891* \sa SDL_SetTextureColorModFloat892*/893extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b);894895896/**897* Set an additional color value multiplied into render copy operations.898*899* When this texture is rendered, during the copy operation each source color900* channel is modulated by the appropriate color value according to the901* following formula:902*903* `srcC = srcC * color`904*905* Color modulation is not always supported by the renderer; it will return906* false if color modulation is not supported.907*908* \param texture the texture to update.909* \param r the red color value multiplied into copy operations.910* \param g the green color value multiplied into copy operations.911* \param b the blue color value multiplied into copy operations.912* \returns true on success or false on failure; call SDL_GetError() for more913* information.914*915* \threadsafety This function should only be called on the main thread.916*917* \since This function is available since SDL 3.2.0.918*919* \sa SDL_GetTextureColorModFloat920* \sa SDL_SetTextureAlphaModFloat921* \sa SDL_SetTextureColorMod922*/923extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorModFloat(SDL_Texture *texture, float r, float g, float b);924925926/**927* Get the additional color value multiplied into render copy operations.928*929* \param texture the texture to query.930* \param r a pointer filled in with the current red color value.931* \param g a pointer filled in with the current green color value.932* \param b a pointer filled in with the current blue color value.933* \returns true on success or false on failure; call SDL_GetError() for more934* information.935*936* \threadsafety This function should only be called on the main thread.937*938* \since This function is available since SDL 3.2.0.939*940* \sa SDL_GetTextureAlphaMod941* \sa SDL_GetTextureColorModFloat942* \sa SDL_SetTextureColorMod943*/944extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b);945946/**947* Get the additional color value multiplied into render copy operations.948*949* \param texture the texture to query.950* \param r a pointer filled in with the current red color value.951* \param g a pointer filled in with the current green color value.952* \param b a pointer filled in with the current blue color value.953* \returns true on success or false on failure; call SDL_GetError() for more954* information.955*956* \threadsafety This function should only be called on the main thread.957*958* \since This function is available since SDL 3.2.0.959*960* \sa SDL_GetTextureAlphaModFloat961* \sa SDL_GetTextureColorMod962* \sa SDL_SetTextureColorModFloat963*/964extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorModFloat(SDL_Texture *texture, float *r, float *g, float *b);965966/**967* Set an additional alpha value multiplied into render copy operations.968*969* When this texture is rendered, during the copy operation the source alpha970* value is modulated by this alpha value according to the following formula:971*972* `srcA = srcA * (alpha / 255)`973*974* Alpha modulation is not always supported by the renderer; it will return975* false if alpha modulation is not supported.976*977* \param texture the texture to update.978* \param alpha the source alpha value multiplied into copy operations.979* \returns true on success or false on failure; call SDL_GetError() for more980* information.981*982* \threadsafety This function should only be called on the main thread.983*984* \since This function is available since SDL 3.2.0.985*986* \sa SDL_GetTextureAlphaMod987* \sa SDL_SetTextureAlphaModFloat988* \sa SDL_SetTextureColorMod989*/990extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha);991992/**993* Set an additional alpha value multiplied into render copy operations.994*995* When this texture is rendered, during the copy operation the source alpha996* value is modulated by this alpha value according to the following formula:997*998* `srcA = srcA * alpha`999*1000* Alpha modulation is not always supported by the renderer; it will return1001* false if alpha modulation is not supported.1002*1003* \param texture the texture to update.1004* \param alpha the source alpha value multiplied into copy operations.1005* \returns true on success or false on failure; call SDL_GetError() for more1006* information.1007*1008* \threadsafety This function should only be called on the main thread.1009*1010* \since This function is available since SDL 3.2.0.1011*1012* \sa SDL_GetTextureAlphaModFloat1013* \sa SDL_SetTextureAlphaMod1014* \sa SDL_SetTextureColorModFloat1015*/1016extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaModFloat(SDL_Texture *texture, float alpha);10171018/**1019* Get the additional alpha value multiplied into render copy operations.1020*1021* \param texture the texture to query.1022* \param alpha a pointer filled in with the current alpha value.1023* \returns true on success or false on failure; call SDL_GetError() for more1024* information.1025*1026* \threadsafety This function should only be called on the main thread.1027*1028* \since This function is available since SDL 3.2.0.1029*1030* \sa SDL_GetTextureAlphaModFloat1031* \sa SDL_GetTextureColorMod1032* \sa SDL_SetTextureAlphaMod1033*/1034extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha);10351036/**1037* Get the additional alpha value multiplied into render copy operations.1038*1039* \param texture the texture to query.1040* \param alpha a pointer filled in with the current alpha value.1041* \returns true on success or false on failure; call SDL_GetError() for more1042* information.1043*1044* \threadsafety This function should only be called on the main thread.1045*1046* \since This function is available since SDL 3.2.0.1047*1048* \sa SDL_GetTextureAlphaMod1049* \sa SDL_GetTextureColorModFloat1050* \sa SDL_SetTextureAlphaModFloat1051*/1052extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaModFloat(SDL_Texture *texture, float *alpha);10531054/**1055* Set the blend mode for a texture, used by SDL_RenderTexture().1056*1057* If the blend mode is not supported, the closest supported mode is chosen1058* and this function returns false.1059*1060* \param texture the texture to update.1061* \param blendMode the SDL_BlendMode to use for texture blending.1062* \returns true on success or false on failure; call SDL_GetError() for more1063* information.1064*1065* \threadsafety This function should only be called on the main thread.1066*1067* \since This function is available since SDL 3.2.0.1068*1069* \sa SDL_GetTextureBlendMode1070*/1071extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode);10721073/**1074* Get the blend mode used for texture copy operations.1075*1076* \param texture the texture to query.1077* \param blendMode a pointer filled in with the current SDL_BlendMode.1078* \returns true on success or false on failure; call SDL_GetError() for more1079* information.1080*1081* \threadsafety This function should only be called on the main thread.1082*1083* \since This function is available since SDL 3.2.0.1084*1085* \sa SDL_SetTextureBlendMode1086*/1087extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode);10881089/**1090* Set the scale mode used for texture scale operations.1091*1092* The default texture scale mode is SDL_SCALEMODE_LINEAR.1093*1094* If the scale mode is not supported, the closest supported mode is chosen.1095*1096* \param texture the texture to update.1097* \param scaleMode the SDL_ScaleMode to use for texture scaling.1098* \returns true on success or false on failure; call SDL_GetError() for more1099* information.1100*1101* \threadsafety This function should only be called on the main thread.1102*1103* \since This function is available since SDL 3.2.0.1104*1105* \sa SDL_GetTextureScaleMode1106*/1107extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode);11081109/**1110* Get the scale mode used for texture scale operations.1111*1112* \param texture the texture to query.1113* \param scaleMode a pointer filled in with the current scale mode.1114* \returns true on success or false on failure; call SDL_GetError() for more1115* information.1116*1117* \threadsafety This function should only be called on the main thread.1118*1119* \since This function is available since SDL 3.2.0.1120*1121* \sa SDL_SetTextureScaleMode1122*/1123extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode);11241125/**1126* Update the given texture rectangle with new pixel data.1127*1128* The pixel data must be in the pixel format of the texture, which can be1129* queried using the SDL_PROP_TEXTURE_FORMAT_NUMBER property.1130*1131* This is a fairly slow function, intended for use with static textures that1132* do not change often.1133*1134* If the texture is intended to be updated often, it is preferred to create1135* the texture as streaming and use the locking functions referenced below.1136* While this function will work with streaming textures, for optimization1137* reasons you may not get the pixels back if you lock the texture afterward.1138*1139* \param texture the texture to update.1140* \param rect an SDL_Rect structure representing the area to update, or NULL1141* to update the entire texture.1142* \param pixels the raw pixel data in the format of the texture.1143* \param pitch the number of bytes in a row of pixel data, including padding1144* between lines.1145* \returns true on success or false on failure; call SDL_GetError() for more1146* information.1147*1148* \threadsafety This function should only be called on the main thread.1149*1150* \since This function is available since SDL 3.2.0.1151*1152* \sa SDL_LockTexture1153* \sa SDL_UnlockTexture1154* \sa SDL_UpdateNVTexture1155* \sa SDL_UpdateYUVTexture1156*/1157extern SDL_DECLSPEC bool SDLCALL SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch);11581159/**1160* Update a rectangle within a planar YV12 or IYUV texture with new pixel1161* data.1162*1163* You can use SDL_UpdateTexture() as long as your pixel data is a contiguous1164* block of Y and U/V planes in the proper order, but this function is1165* available if your pixel data is not contiguous.1166*1167* \param texture the texture to update.1168* \param rect a pointer to the rectangle of pixels to update, or NULL to1169* update the entire texture.1170* \param Yplane the raw pixel data for the Y plane.1171* \param Ypitch the number of bytes between rows of pixel data for the Y1172* plane.1173* \param Uplane the raw pixel data for the U plane.1174* \param Upitch the number of bytes between rows of pixel data for the U1175* plane.1176* \param Vplane the raw pixel data for the V plane.1177* \param Vpitch the number of bytes between rows of pixel data for the V1178* plane.1179* \returns true on success or false on failure; call SDL_GetError() for more1180* information.1181*1182* \threadsafety This function should only be called on the main thread.1183*1184* \since This function is available since SDL 3.2.0.1185*1186* \sa SDL_UpdateNVTexture1187* \sa SDL_UpdateTexture1188*/1189extern SDL_DECLSPEC bool SDLCALL SDL_UpdateYUVTexture(SDL_Texture *texture,1190const SDL_Rect *rect,1191const Uint8 *Yplane, int Ypitch,1192const Uint8 *Uplane, int Upitch,1193const Uint8 *Vplane, int Vpitch);11941195/**1196* Update a rectangle within a planar NV12 or NV21 texture with new pixels.1197*1198* You can use SDL_UpdateTexture() as long as your pixel data is a contiguous1199* block of NV12/21 planes in the proper order, but this function is available1200* if your pixel data is not contiguous.1201*1202* \param texture the texture to update.1203* \param rect a pointer to the rectangle of pixels to update, or NULL to1204* update the entire texture.1205* \param Yplane the raw pixel data for the Y plane.1206* \param Ypitch the number of bytes between rows of pixel data for the Y1207* plane.1208* \param UVplane the raw pixel data for the UV plane.1209* \param UVpitch the number of bytes between rows of pixel data for the UV1210* plane.1211* \returns true on success or false on failure; call SDL_GetError() for more1212* information.1213*1214* \threadsafety This function should only be called on the main thread.1215*1216* \since This function is available since SDL 3.2.0.1217*1218* \sa SDL_UpdateTexture1219* \sa SDL_UpdateYUVTexture1220*/1221extern SDL_DECLSPEC bool SDLCALL SDL_UpdateNVTexture(SDL_Texture *texture,1222const SDL_Rect *rect,1223const Uint8 *Yplane, int Ypitch,1224const Uint8 *UVplane, int UVpitch);12251226/**1227* Lock a portion of the texture for **write-only** pixel access.1228*1229* As an optimization, the pixels made available for editing don't necessarily1230* contain the old texture data. This is a write-only operation, and if you1231* need to keep a copy of the texture data you should do that at the1232* application level.1233*1234* You must use SDL_UnlockTexture() to unlock the pixels and apply any1235* changes.1236*1237* \param texture the texture to lock for access, which was created with1238* `SDL_TEXTUREACCESS_STREAMING`.1239* \param rect an SDL_Rect structure representing the area to lock for access;1240* NULL to lock the entire texture.1241* \param pixels this is filled in with a pointer to the locked pixels,1242* appropriately offset by the locked area.1243* \param pitch this is filled in with the pitch of the locked pixels; the1244* pitch is the length of one row in bytes.1245* \returns true on success or false if the texture is not valid or was not1246* created with `SDL_TEXTUREACCESS_STREAMING`; call SDL_GetError()1247* for more information.1248*1249* \threadsafety This function should only be called on the main thread.1250*1251* \since This function is available since SDL 3.2.0.1252*1253* \sa SDL_LockTextureToSurface1254* \sa SDL_UnlockTexture1255*/1256extern SDL_DECLSPEC bool SDLCALL SDL_LockTexture(SDL_Texture *texture,1257const SDL_Rect *rect,1258void **pixels, int *pitch);12591260/**1261* Lock a portion of the texture for **write-only** pixel access, and expose1262* it as a SDL surface.1263*1264* Besides providing an SDL_Surface instead of raw pixel data, this function1265* operates like SDL_LockTexture.1266*1267* As an optimization, the pixels made available for editing don't necessarily1268* contain the old texture data. This is a write-only operation, and if you1269* need to keep a copy of the texture data you should do that at the1270* application level.1271*1272* You must use SDL_UnlockTexture() to unlock the pixels and apply any1273* changes.1274*1275* The returned surface is freed internally after calling SDL_UnlockTexture()1276* or SDL_DestroyTexture(). The caller should not free it.1277*1278* \param texture the texture to lock for access, which must be created with1279* `SDL_TEXTUREACCESS_STREAMING`.1280* \param rect a pointer to the rectangle to lock for access. If the rect is1281* NULL, the entire texture will be locked.1282* \param surface a pointer to an SDL surface of size **rect**. Don't assume1283* any specific pixel content.1284* \returns true on success or false on failure; call SDL_GetError() for more1285* information.1286*1287* \threadsafety This function should only be called on the main thread.1288*1289* \since This function is available since SDL 3.2.0.1290*1291* \sa SDL_LockTexture1292* \sa SDL_UnlockTexture1293*/1294extern SDL_DECLSPEC bool SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Surface **surface);12951296/**1297* Unlock a texture, uploading the changes to video memory, if needed.1298*1299* **Warning**: Please note that SDL_LockTexture() is intended to be1300* write-only; it will not guarantee the previous contents of the texture will1301* be provided. You must fully initialize any area of a texture that you lock1302* before unlocking it, as the pixels might otherwise be uninitialized memory.1303*1304* Which is to say: locking and immediately unlocking a texture can result in1305* corrupted textures, depending on the renderer in use.1306*1307* \param texture a texture locked by SDL_LockTexture().1308*1309* \threadsafety This function should only be called on the main thread.1310*1311* \since This function is available since SDL 3.2.0.1312*1313* \sa SDL_LockTexture1314*/1315extern SDL_DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture);13161317/**1318* Set a texture as the current rendering target.1319*1320* The default render target is the window for which the renderer was created.1321* To stop rendering to a texture and render to the window again, call this1322* function with a NULL `texture`.1323*1324* Viewport, cliprect, scale, and logical presentation are unique to each1325* render target. Get and set functions for these states apply to the current1326* render target set by this function, and those states persist on each target1327* when the current render target changes.1328*1329* \param renderer the rendering context.1330* \param texture the targeted texture, which must be created with the1331* `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the1332* window instead of a texture.1333* \returns true on success or false on failure; call SDL_GetError() for more1334* information.1335*1336* \threadsafety This function should only be called on the main thread.1337*1338* \since This function is available since SDL 3.2.0.1339*1340* \sa SDL_GetRenderTarget1341*/1342extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture);13431344/**1345* Get the current render target.1346*1347* The default render target is the window for which the renderer was created,1348* and is reported a NULL here.1349*1350* \param renderer the rendering context.1351* \returns the current render target or NULL for the default render target.1352*1353* \threadsafety This function should only be called on the main thread.1354*1355* \since This function is available since SDL 3.2.0.1356*1357* \sa SDL_SetRenderTarget1358*/1359extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);13601361/**1362* Set a device-independent resolution and presentation mode for rendering.1363*1364* This function sets the width and height of the logical rendering output.1365* The renderer will act as if the current render target is always the1366* requested dimensions, scaling to the actual resolution as necessary.1367*1368* This can be useful for games that expect a fixed size, but would like to1369* scale the output to whatever is available, regardless of how a user resizes1370* a window, or if the display is high DPI.1371*1372* Logical presentation can be used with both render target textures and the1373* renderer's window; the state is unique to each render target, and this1374* function sets the state for the current render target. It might be useful1375* to draw to a texture that matches the window dimensions with logical1376* presentation enabled, and then draw that texture across the entire window1377* with logical presentation disabled. Be careful not to render both with1378* logical presentation enabled, however, as this could produce1379* double-letterboxing, etc.1380*1381* You can disable logical coordinates by setting the mode to1382* SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel1383* resolution of the render target; it is safe to toggle logical presentation1384* during the rendering of a frame: perhaps most of the rendering is done to1385* specific dimensions but to make fonts look sharp, the app turns off logical1386* presentation while drawing text, for example.1387*1388* For the renderer's window, letterboxing is drawn into the framebuffer if1389* logical presentation is enabled during SDL_RenderPresent; be sure to1390* reenable it before presenting if you were toggling it, otherwise the1391* letterbox areas might have artifacts from previous frames (or artifacts1392* from external overlays, etc). Letterboxing is never drawn into texture1393* render targets; be sure to call SDL_RenderClear() before drawing into the1394* texture so the letterboxing areas are cleared, if appropriate.1395*1396* You can convert coordinates in an event into rendering coordinates using1397* SDL_ConvertEventToRenderCoordinates().1398*1399* \param renderer the rendering context.1400* \param w the width of the logical resolution.1401* \param h the height of the logical resolution.1402* \param mode the presentation mode used.1403* \returns true on success or false on failure; call SDL_GetError() for more1404* information.1405*1406* \threadsafety This function should only be called on the main thread.1407*1408* \since This function is available since SDL 3.2.0.1409*1410* \sa SDL_ConvertEventToRenderCoordinates1411* \sa SDL_GetRenderLogicalPresentation1412* \sa SDL_GetRenderLogicalPresentationRect1413*/1414extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode);14151416/**1417* Get device independent resolution and presentation mode for rendering.1418*1419* This function gets the width and height of the logical rendering output, or1420* the output size in pixels if a logical resolution is not enabled.1421*1422* Each render target has its own logical presentation state. This function1423* gets the state for the current render target.1424*1425* \param renderer the rendering context.1426* \param w an int to be filled with the width.1427* \param h an int to be filled with the height.1428* \param mode the presentation mode used.1429* \returns true on success or false on failure; call SDL_GetError() for more1430* information.1431*1432* \threadsafety This function should only be called on the main thread.1433*1434* \since This function is available since SDL 3.2.0.1435*1436* \sa SDL_SetRenderLogicalPresentation1437*/1438extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode);14391440/**1441* Get the final presentation rectangle for rendering.1442*1443* This function returns the calculated rectangle used for logical1444* presentation, based on the presentation mode and output size. If logical1445* presentation is disabled, it will fill the rectangle with the output size,1446* in pixels.1447*1448* Each render target has its own logical presentation state. This function1449* gets the rectangle for the current render target.1450*1451* \param renderer the rendering context.1452* \param rect a pointer filled in with the final presentation rectangle, may1453* be NULL.1454* \returns true on success or false on failure; call SDL_GetError() for more1455* information.1456*1457* \threadsafety This function should only be called on the main thread.1458*1459* \since This function is available since SDL 3.2.0.1460*1461* \sa SDL_SetRenderLogicalPresentation1462*/1463extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentationRect(SDL_Renderer *renderer, SDL_FRect *rect);14641465/**1466* Get a point in render coordinates when given a point in window coordinates.1467*1468* This takes into account several states:1469*1470* - The window dimensions.1471* - The logical presentation settings (SDL_SetRenderLogicalPresentation)1472* - The scale (SDL_SetRenderScale)1473* - The viewport (SDL_SetRenderViewport)1474*1475* \param renderer the rendering context.1476* \param window_x the x coordinate in window coordinates.1477* \param window_y the y coordinate in window coordinates.1478* \param x a pointer filled with the x coordinate in render coordinates.1479* \param y a pointer filled with the y coordinate in render coordinates.1480* \returns true on success or false on failure; call SDL_GetError() for more1481* information.1482*1483* \threadsafety This function should only be called on the main thread.1484*1485* \since This function is available since SDL 3.2.0.1486*1487* \sa SDL_SetRenderLogicalPresentation1488* \sa SDL_SetRenderScale1489*/1490extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y);14911492/**1493* Get a point in window coordinates when given a point in render coordinates.1494*1495* This takes into account several states:1496*1497* - The window dimensions.1498* - The logical presentation settings (SDL_SetRenderLogicalPresentation)1499* - The scale (SDL_SetRenderScale)1500* - The viewport (SDL_SetRenderViewport)1501*1502* \param renderer the rendering context.1503* \param x the x coordinate in render coordinates.1504* \param y the y coordinate in render coordinates.1505* \param window_x a pointer filled with the x coordinate in window1506* coordinates.1507* \param window_y a pointer filled with the y coordinate in window1508* coordinates.1509* \returns true on success or false on failure; call SDL_GetError() for more1510* information.1511*1512* \threadsafety This function should only be called on the main thread.1513*1514* \since This function is available since SDL 3.2.0.1515*1516* \sa SDL_SetRenderLogicalPresentation1517* \sa SDL_SetRenderScale1518* \sa SDL_SetRenderViewport1519*/1520extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y);15211522/**1523* Convert the coordinates in an event to render coordinates.1524*1525* This takes into account several states:1526*1527* - The window dimensions.1528* - The logical presentation settings (SDL_SetRenderLogicalPresentation)1529* - The scale (SDL_SetRenderScale)1530* - The viewport (SDL_SetRenderViewport)1531*1532* Various event types are converted with this function: mouse, touch, pen,1533* etc.1534*1535* Touch coordinates are converted from normalized coordinates in the window1536* to non-normalized rendering coordinates.1537*1538* Relative mouse coordinates (xrel and yrel event fields) are _also_1539* converted. Applications that do not want these fields converted should use1540* SDL_RenderCoordinatesFromWindow() on the specific event fields instead of1541* converting the entire event structure.1542*1543* Once converted, coordinates may be outside the rendering area.1544*1545* \param renderer the rendering context.1546* \param event the event to modify.1547* \returns true on success or false on failure; call SDL_GetError() for more1548* information.1549*1550* \threadsafety This function should only be called on the main thread.1551*1552* \since This function is available since SDL 3.2.0.1553*1554* \sa SDL_RenderCoordinatesFromWindow1555*/1556extern SDL_DECLSPEC bool SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event);15571558/**1559* Set the drawing area for rendering on the current target.1560*1561* Drawing will clip to this area (separately from any clipping done with1562* SDL_SetRenderClipRect), and the top left of the area will become coordinate1563* (0, 0) for future drawing commands.1564*1565* The area's width and height must be >= 0.1566*1567* Each render target has its own viewport. This function sets the viewport1568* for the current render target.1569*1570* \param renderer the rendering context.1571* \param rect the SDL_Rect structure representing the drawing area, or NULL1572* to set the viewport to the entire target.1573* \returns true on success or false on failure; call SDL_GetError() for more1574* information.1575*1576* \threadsafety This function should only be called on the main thread.1577*1578* \since This function is available since SDL 3.2.0.1579*1580* \sa SDL_GetRenderViewport1581* \sa SDL_RenderViewportSet1582*/1583extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderViewport(SDL_Renderer *renderer, const SDL_Rect *rect);15841585/**1586* Get the drawing area for the current target.1587*1588* Each render target has its own viewport. This function gets the viewport1589* for the current render target.1590*1591* \param renderer the rendering context.1592* \param rect an SDL_Rect structure filled in with the current drawing area.1593* \returns true on success or false on failure; call SDL_GetError() for more1594* information.1595*1596* \threadsafety This function should only be called on the main thread.1597*1598* \since This function is available since SDL 3.2.0.1599*1600* \sa SDL_RenderViewportSet1601* \sa SDL_SetRenderViewport1602*/1603extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect);16041605/**1606* Return whether an explicit rectangle was set as the viewport.1607*1608* This is useful if you're saving and restoring the viewport and want to know1609* whether you should restore a specific rectangle or NULL.1610*1611* Each render target has its own viewport. This function checks the viewport1612* for the current render target.1613*1614* \param renderer the rendering context.1615* \returns true if the viewport was set to a specific rectangle, or false if1616* it was set to NULL (the entire target).1617*1618* \threadsafety This function should only be called on the main thread.1619*1620* \since This function is available since SDL 3.2.0.1621*1622* \sa SDL_GetRenderViewport1623* \sa SDL_SetRenderViewport1624*/1625extern SDL_DECLSPEC bool SDLCALL SDL_RenderViewportSet(SDL_Renderer *renderer);16261627/**1628* Get the safe area for rendering within the current viewport.1629*1630* Some devices have portions of the screen which are partially obscured or1631* not interactive, possibly due to on-screen controls, curved edges, camera1632* notches, TV overscan, etc. This function provides the area of the current1633* viewport which is safe to have interactible content. You should continue1634* rendering into the rest of the render target, but it should not contain1635* visually important or interactible content.1636*1637* \param renderer the rendering context.1638* \param rect a pointer filled in with the area that is safe for interactive1639* content.1640* \returns true on success or false on failure; call SDL_GetError() for more1641* information.1642*1643* \threadsafety This function should only be called on the main thread.1644*1645* \since This function is available since SDL 3.2.0.1646*/1647extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderSafeArea(SDL_Renderer *renderer, SDL_Rect *rect);16481649/**1650* Set the clip rectangle for rendering on the specified target.1651*1652* Each render target has its own clip rectangle. This function sets the1653* cliprect for the current render target.1654*1655* \param renderer the rendering context.1656* \param rect an SDL_Rect structure representing the clip area, relative to1657* the viewport, or NULL to disable clipping.1658* \returns true on success or false on failure; call SDL_GetError() for more1659* information.1660*1661* \threadsafety This function should only be called on the main thread.1662*1663* \since This function is available since SDL 3.2.0.1664*1665* \sa SDL_GetRenderClipRect1666* \sa SDL_RenderClipEnabled1667*/1668extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect);16691670/**1671* Get the clip rectangle for the current target.1672*1673* Each render target has its own clip rectangle. This function gets the1674* cliprect for the current render target.1675*1676* \param renderer the rendering context.1677* \param rect an SDL_Rect structure filled in with the current clipping area1678* or an empty rectangle if clipping is disabled.1679* \returns true on success or false on failure; call SDL_GetError() for more1680* information.1681*1682* \threadsafety This function should only be called on the main thread.1683*1684* \since This function is available since SDL 3.2.0.1685*1686* \sa SDL_RenderClipEnabled1687* \sa SDL_SetRenderClipRect1688*/1689extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect);16901691/**1692* Get whether clipping is enabled on the given render target.1693*1694* Each render target has its own clip rectangle. This function checks the1695* cliprect for the current render target.1696*1697* \param renderer the rendering context.1698* \returns true if clipping is enabled or false if not; call SDL_GetError()1699* for more information.1700*1701* \threadsafety This function should only be called on the main thread.1702*1703* \since This function is available since SDL 3.2.0.1704*1705* \sa SDL_GetRenderClipRect1706* \sa SDL_SetRenderClipRect1707*/1708extern SDL_DECLSPEC bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer);17091710/**1711* Set the drawing scale for rendering on the current target.1712*1713* The drawing coordinates are scaled by the x/y scaling factors before they1714* are used by the renderer. This allows resolution independent drawing with a1715* single coordinate system.1716*1717* If this results in scaling or subpixel drawing by the rendering backend, it1718* will be handled using the appropriate quality hints. For best results use1719* integer scaling factors.1720*1721* Each render target has its own scale. This function sets the scale for the1722* current render target.1723*1724* \param renderer the rendering context.1725* \param scaleX the horizontal scaling factor.1726* \param scaleY the vertical scaling factor.1727* \returns true on success or false on failure; call SDL_GetError() for more1728* information.1729*1730* \threadsafety This function should only be called on the main thread.1731*1732* \since This function is available since SDL 3.2.0.1733*1734* \sa SDL_GetRenderScale1735*/1736extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY);17371738/**1739* Get the drawing scale for the current target.1740*1741* Each render target has its own scale. This function gets the scale for the1742* current render target.1743*1744* \param renderer the rendering context.1745* \param scaleX a pointer filled in with the horizontal scaling factor.1746* \param scaleY a pointer filled in with the vertical scaling factor.1747* \returns true on success or false on failure; call SDL_GetError() for more1748* information.1749*1750* \threadsafety This function should only be called on the main thread.1751*1752* \since This function is available since SDL 3.2.0.1753*1754* \sa SDL_SetRenderScale1755*/1756extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY);17571758/**1759* Set the color used for drawing operations.1760*1761* Set the color for drawing or filling rectangles, lines, and points, and for1762* SDL_RenderClear().1763*1764* \param renderer the rendering context.1765* \param r the red value used to draw on the rendering target.1766* \param g the green value used to draw on the rendering target.1767* \param b the blue value used to draw on the rendering target.1768* \param a the alpha value used to draw on the rendering target; usually1769* `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to1770* specify how the alpha channel is used.1771* \returns true on success or false on failure; call SDL_GetError() for more1772* information.1773*1774* \threadsafety This function should only be called on the main thread.1775*1776* \since This function is available since SDL 3.2.0.1777*1778* \sa SDL_GetRenderDrawColor1779* \sa SDL_SetRenderDrawColorFloat1780*/1781extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a);17821783/**1784* Set the color used for drawing operations (Rect, Line and Clear).1785*1786* Set the color for drawing or filling rectangles, lines, and points, and for1787* SDL_RenderClear().1788*1789* \param renderer the rendering context.1790* \param r the red value used to draw on the rendering target.1791* \param g the green value used to draw on the rendering target.1792* \param b the blue value used to draw on the rendering target.1793* \param a the alpha value used to draw on the rendering target. Use1794* SDL_SetRenderDrawBlendMode to specify how the alpha channel is1795* used.1796* \returns true on success or false on failure; call SDL_GetError() for more1797* information.1798*1799* \threadsafety This function should only be called on the main thread.1800*1801* \since This function is available since SDL 3.2.0.1802*1803* \sa SDL_GetRenderDrawColorFloat1804* \sa SDL_SetRenderDrawColor1805*/1806extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColorFloat(SDL_Renderer *renderer, float r, float g, float b, float a);18071808/**1809* Get the color used for drawing operations (Rect, Line and Clear).1810*1811* \param renderer the rendering context.1812* \param r a pointer filled in with the red value used to draw on the1813* rendering target.1814* \param g a pointer filled in with the green value used to draw on the1815* rendering target.1816* \param b a pointer filled in with the blue value used to draw on the1817* rendering target.1818* \param a a pointer filled in with the alpha value used to draw on the1819* rendering target; usually `SDL_ALPHA_OPAQUE` (255).1820* \returns true on success or false on failure; call SDL_GetError() for more1821* information.1822*1823* \threadsafety This function should only be called on the main thread.1824*1825* \since This function is available since SDL 3.2.0.1826*1827* \sa SDL_GetRenderDrawColorFloat1828* \sa SDL_SetRenderDrawColor1829*/1830extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColor(SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);18311832/**1833* Get the color used for drawing operations (Rect, Line and Clear).1834*1835* \param renderer the rendering context.1836* \param r a pointer filled in with the red value used to draw on the1837* rendering target.1838* \param g a pointer filled in with the green value used to draw on the1839* rendering target.1840* \param b a pointer filled in with the blue value used to draw on the1841* rendering target.1842* \param a a pointer filled in with the alpha value used to draw on the1843* rendering target.1844* \returns true on success or false on failure; call SDL_GetError() for more1845* information.1846*1847* \threadsafety This function should only be called on the main thread.1848*1849* \since This function is available since SDL 3.2.0.1850*1851* \sa SDL_SetRenderDrawColorFloat1852* \sa SDL_GetRenderDrawColor1853*/1854extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColorFloat(SDL_Renderer *renderer, float *r, float *g, float *b, float *a);18551856/**1857* Set the color scale used for render operations.1858*1859* The color scale is an additional scale multiplied into the pixel color1860* value while rendering. This can be used to adjust the brightness of colors1861* during HDR rendering, or changing HDR video brightness when playing on an1862* SDR display.1863*1864* The color scale does not affect the alpha channel, only the color1865* brightness.1866*1867* \param renderer the rendering context.1868* \param scale the color scale value.1869* \returns true on success or false on failure; call SDL_GetError() for more1870* information.1871*1872* \threadsafety This function should only be called on the main thread.1873*1874* \since This function is available since SDL 3.2.0.1875*1876* \sa SDL_GetRenderColorScale1877*/1878extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderColorScale(SDL_Renderer *renderer, float scale);18791880/**1881* Get the color scale used for render operations.1882*1883* \param renderer the rendering context.1884* \param scale a pointer filled in with the current color scale value.1885* \returns true on success or false on failure; call SDL_GetError() for more1886* information.1887*1888* \threadsafety This function should only be called on the main thread.1889*1890* \since This function is available since SDL 3.2.0.1891*1892* \sa SDL_SetRenderColorScale1893*/1894extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderColorScale(SDL_Renderer *renderer, float *scale);18951896/**1897* Set the blend mode used for drawing operations (Fill and Line).1898*1899* If the blend mode is not supported, the closest supported mode is chosen.1900*1901* \param renderer the rendering context.1902* \param blendMode the SDL_BlendMode to use for blending.1903* \returns true on success or false on failure; call SDL_GetError() for more1904* information.1905*1906* \threadsafety This function should only be called on the main thread.1907*1908* \since This function is available since SDL 3.2.0.1909*1910* \sa SDL_GetRenderDrawBlendMode1911*/1912extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode);19131914/**1915* Get the blend mode used for drawing operations.1916*1917* \param renderer the rendering context.1918* \param blendMode a pointer filled in with the current SDL_BlendMode.1919* \returns true on success or false on failure; call SDL_GetError() for more1920* information.1921*1922* \threadsafety This function should only be called on the main thread.1923*1924* \since This function is available since SDL 3.2.0.1925*1926* \sa SDL_SetRenderDrawBlendMode1927*/1928extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode);19291930/**1931* Clear the current rendering target with the drawing color.1932*1933* This function clears the entire rendering target, ignoring the viewport and1934* the clip rectangle. Note, that clearing will also set/fill all pixels of1935* the rendering target to current renderer draw color, so make sure to invoke1936* SDL_SetRenderDrawColor() when needed.1937*1938* \param renderer the rendering context.1939* \returns true on success or false on failure; call SDL_GetError() for more1940* information.1941*1942* \threadsafety This function should only be called on the main thread.1943*1944* \since This function is available since SDL 3.2.0.1945*1946* \sa SDL_SetRenderDrawColor1947*/1948extern SDL_DECLSPEC bool SDLCALL SDL_RenderClear(SDL_Renderer *renderer);19491950/**1951* Draw a point on the current rendering target at subpixel precision.1952*1953* \param renderer the renderer which should draw a point.1954* \param x the x coordinate of the point.1955* \param y the y coordinate of the point.1956* \returns true on success or false on failure; call SDL_GetError() for more1957* information.1958*1959* \threadsafety This function should only be called on the main thread.1960*1961* \since This function is available since SDL 3.2.0.1962*1963* \sa SDL_RenderPoints1964*/1965extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoint(SDL_Renderer *renderer, float x, float y);19661967/**1968* Draw multiple points on the current rendering target at subpixel precision.1969*1970* \param renderer the renderer which should draw multiple points.1971* \param points the points to draw.1972* \param count the number of points to draw.1973* \returns true on success or false on failure; call SDL_GetError() for more1974* information.1975*1976* \threadsafety This function should only be called on the main thread.1977*1978* \since This function is available since SDL 3.2.0.1979*1980* \sa SDL_RenderPoint1981*/1982extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count);19831984/**1985* Draw a line on the current rendering target at subpixel precision.1986*1987* \param renderer the renderer which should draw a line.1988* \param x1 the x coordinate of the start point.1989* \param y1 the y coordinate of the start point.1990* \param x2 the x coordinate of the end point.1991* \param y2 the y coordinate of the end point.1992* \returns true on success or false on failure; call SDL_GetError() for more1993* information.1994*1995* \threadsafety This function should only be called on the main thread.1996*1997* \since This function is available since SDL 3.2.0.1998*1999* \sa SDL_RenderLines2000*/2001extern SDL_DECLSPEC bool SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2);20022003/**2004* Draw a series of connected lines on the current rendering target at2005* subpixel precision.2006*2007* \param renderer the renderer which should draw multiple lines.2008* \param points the points along the lines.2009* \param count the number of points, drawing count-1 lines.2010* \returns true on success or false on failure; call SDL_GetError() for more2011* information.2012*2013* \threadsafety This function should only be called on the main thread.2014*2015* \since This function is available since SDL 3.2.0.2016*2017* \sa SDL_RenderLine2018*/2019extern SDL_DECLSPEC bool SDLCALL SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count);20202021/**2022* Draw a rectangle on the current rendering target at subpixel precision.2023*2024* \param renderer the renderer which should draw a rectangle.2025* \param rect a pointer to the destination rectangle, or NULL to outline the2026* entire rendering target.2027* \returns true on success or false on failure; call SDL_GetError() for more2028* information.2029*2030* \threadsafety This function should only be called on the main thread.2031*2032* \since This function is available since SDL 3.2.0.2033*2034* \sa SDL_RenderRects2035*/2036extern SDL_DECLSPEC bool SDLCALL SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect);20372038/**2039* Draw some number of rectangles on the current rendering target at subpixel2040* precision.2041*2042* \param renderer the renderer which should draw multiple rectangles.2043* \param rects a pointer to an array of destination rectangles.2044* \param count the number of rectangles.2045* \returns true on success or false on failure; call SDL_GetError() for more2046* information.2047*2048* \threadsafety This function should only be called on the main thread.2049*2050* \since This function is available since SDL 3.2.0.2051*2052* \sa SDL_RenderRect2053*/2054extern SDL_DECLSPEC bool SDLCALL SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);20552056/**2057* Fill a rectangle on the current rendering target with the drawing color at2058* subpixel precision.2059*2060* \param renderer the renderer which should fill a rectangle.2061* \param rect a pointer to the destination rectangle, or NULL for the entire2062* rendering target.2063* \returns true on success or false on failure; call SDL_GetError() for more2064* information.2065*2066* \threadsafety This function should only be called on the main thread.2067*2068* \since This function is available since SDL 3.2.0.2069*2070* \sa SDL_RenderFillRects2071*/2072extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect);20732074/**2075* Fill some number of rectangles on the current rendering target with the2076* drawing color at subpixel precision.2077*2078* \param renderer the renderer which should fill multiple rectangles.2079* \param rects a pointer to an array of destination rectangles.2080* \param count the number of rectangles.2081* \returns true on success or false on failure; call SDL_GetError() for more2082* information.2083*2084* \threadsafety This function should only be called on the main thread.2085*2086* \since This function is available since SDL 3.2.0.2087*2088* \sa SDL_RenderFillRect2089*/2090extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);20912092/**2093* Copy a portion of the texture to the current rendering target at subpixel2094* precision.2095*2096* \param renderer the renderer which should copy parts of a texture.2097* \param texture the source texture.2098* \param srcrect a pointer to the source rectangle, or NULL for the entire2099* texture.2100* \param dstrect a pointer to the destination rectangle, or NULL for the2101* entire rendering target.2102* \returns true on success or false on failure; call SDL_GetError() for more2103* information.2104*2105* \threadsafety This function should only be called on the main thread.2106*2107* \since This function is available since SDL 3.2.0.2108*2109* \sa SDL_RenderTextureRotated2110* \sa SDL_RenderTextureTiled2111*/2112extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect);21132114/**2115* Copy a portion of the source texture to the current rendering target, with2116* rotation and flipping, at subpixel precision.2117*2118* \param renderer the renderer which should copy parts of a texture.2119* \param texture the source texture.2120* \param srcrect a pointer to the source rectangle, or NULL for the entire2121* texture.2122* \param dstrect a pointer to the destination rectangle, or NULL for the2123* entire rendering target.2124* \param angle an angle in degrees that indicates the rotation that will be2125* applied to dstrect, rotating it in a clockwise direction.2126* \param center a pointer to a point indicating the point around which2127* dstrect will be rotated (if NULL, rotation will be done2128* around dstrect.w/2, dstrect.h/2).2129* \param flip an SDL_FlipMode value stating which flipping actions should be2130* performed on the texture.2131* \returns true on success or false on failure; call SDL_GetError() for more2132* information.2133*2134* \threadsafety This function should only be called on the main thread.2135*2136* \since This function is available since SDL 3.2.0.2137*2138* \sa SDL_RenderTexture2139*/2140extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,2141const SDL_FRect *srcrect, const SDL_FRect *dstrect,2142double angle, const SDL_FPoint *center,2143SDL_FlipMode flip);21442145/**2146* Copy a portion of the source texture to the current rendering target, with2147* affine transform, at subpixel precision.2148*2149* \param renderer the renderer which should copy parts of a texture.2150* \param texture the source texture.2151* \param srcrect a pointer to the source rectangle, or NULL for the entire2152* texture.2153* \param origin a pointer to a point indicating where the top-left corner of2154* srcrect should be mapped to, or NULL for the rendering2155* target's origin.2156* \param right a pointer to a point indicating where the top-right corner of2157* srcrect should be mapped to, or NULL for the rendering2158* target's top-right corner.2159* \param down a pointer to a point indicating where the bottom-left corner of2160* srcrect should be mapped to, or NULL for the rendering target's2161* bottom-left corner.2162* \returns true on success or false on failure; call SDL_GetError() for more2163* information.2164*2165* \threadsafety You may only call this function from the main thread.2166*2167* \since This function is available since SDL 3.2.0.2168*2169* \sa SDL_RenderTexture2170*/2171extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureAffine(SDL_Renderer *renderer, SDL_Texture *texture,2172const SDL_FRect *srcrect, const SDL_FPoint *origin,2173const SDL_FPoint *right, const SDL_FPoint *down);21742175/**2176* Tile a portion of the texture to the current rendering target at subpixel2177* precision.2178*2179* The pixels in `srcrect` will be repeated as many times as needed to2180* completely fill `dstrect`.2181*2182* \param renderer the renderer which should copy parts of a texture.2183* \param texture the source texture.2184* \param srcrect a pointer to the source rectangle, or NULL for the entire2185* texture.2186* \param scale the scale used to transform srcrect into the destination2187* rectangle, e.g. a 32x32 texture with a scale of 2 would fill2188* 64x64 tiles.2189* \param dstrect a pointer to the destination rectangle, or NULL for the2190* entire rendering target.2191* \returns true on success or false on failure; call SDL_GetError() for more2192* information.2193*2194* \threadsafety This function should only be called on the main thread.2195*2196* \since This function is available since SDL 3.2.0.2197*2198* \sa SDL_RenderTexture2199*/2200extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float scale, const SDL_FRect *dstrect);22012202/**2203* Perform a scaled copy using the 9-grid algorithm to the current rendering2204* target at subpixel precision.2205*2206* The pixels in the texture are split into a 3x3 grid, using the different2207* corner sizes for each corner, and the sides and center making up the2208* remaining pixels. The corners are then scaled using `scale` and fit into2209* the corners of the destination rectangle. The sides and center are then2210* stretched into place to cover the remaining destination rectangle.2211*2212* \param renderer the renderer which should copy parts of a texture.2213* \param texture the source texture.2214* \param srcrect the SDL_Rect structure representing the rectangle to be used2215* for the 9-grid, or NULL to use the entire texture.2216* \param left_width the width, in pixels, of the left corners in `srcrect`.2217* \param right_width the width, in pixels, of the right corners in `srcrect`.2218* \param top_height the height, in pixels, of the top corners in `srcrect`.2219* \param bottom_height the height, in pixels, of the bottom corners in2220* `srcrect`.2221* \param scale the scale used to transform the corner of `srcrect` into the2222* corner of `dstrect`, or 0.0f for an unscaled copy.2223* \param dstrect a pointer to the destination rectangle, or NULL for the2224* entire rendering target.2225* \returns true on success or false on failure; call SDL_GetError() for more2226* information.2227*2228* \threadsafety This function should only be called on the main thread.2229*2230* \since This function is available since SDL 3.2.0.2231*2232* \sa SDL_RenderTexture2233*/2234extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect);22352236/**2237* Render a list of triangles, optionally using a texture and indices into the2238* vertex array Color and alpha modulation is done per vertex2239* (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).2240*2241* \param renderer the rendering context.2242* \param texture (optional) The SDL texture to use.2243* \param vertices vertices.2244* \param num_vertices number of vertices.2245* \param indices (optional) An array of integer indices into the 'vertices'2246* array, if NULL all vertices will be rendered in sequential2247* order.2248* \param num_indices number of indices.2249* \returns true on success or false on failure; call SDL_GetError() for more2250* information.2251*2252* \threadsafety This function should only be called on the main thread.2253*2254* \since This function is available since SDL 3.2.0.2255*2256* \sa SDL_RenderGeometryRaw2257*/2258extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,2259SDL_Texture *texture,2260const SDL_Vertex *vertices, int num_vertices,2261const int *indices, int num_indices);22622263/**2264* Render a list of triangles, optionally using a texture and indices into the2265* vertex arrays Color and alpha modulation is done per vertex2266* (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).2267*2268* \param renderer the rendering context.2269* \param texture (optional) The SDL texture to use.2270* \param xy vertex positions.2271* \param xy_stride byte size to move from one element to the next element.2272* \param color vertex colors (as SDL_FColor).2273* \param color_stride byte size to move from one element to the next element.2274* \param uv vertex normalized texture coordinates.2275* \param uv_stride byte size to move from one element to the next element.2276* \param num_vertices number of vertices.2277* \param indices (optional) An array of indices into the 'vertices' arrays,2278* if NULL all vertices will be rendered in sequential order.2279* \param num_indices number of indices.2280* \param size_indices index size: 1 (byte), 2 (short), 4 (int).2281* \returns true on success or false on failure; call SDL_GetError() for more2282* information.2283*2284* \threadsafety This function should only be called on the main thread.2285*2286* \since This function is available since SDL 3.2.0.2287*2288* \sa SDL_RenderGeometry2289*/2290extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,2291SDL_Texture *texture,2292const float *xy, int xy_stride,2293const SDL_FColor *color, int color_stride,2294const float *uv, int uv_stride,2295int num_vertices,2296const void *indices, int num_indices, int size_indices);22972298/**2299* Read pixels from the current rendering target.2300*2301* The returned surface contains pixels inside the desired area clipped to the2302* current viewport, and should be freed with SDL_DestroySurface().2303*2304* Note that this returns the actual pixels on the screen, so if you are using2305* logical presentation you should use SDL_GetRenderLogicalPresentationRect()2306* to get the area containing your content.2307*2308* **WARNING**: This is a very slow operation, and should not be used2309* frequently. If you're using this on the main rendering target, it should be2310* called after rendering and before SDL_RenderPresent().2311*2312* \param renderer the rendering context.2313* \param rect an SDL_Rect structure representing the area to read, which will2314* be clipped to the current viewport, or NULL for the entire2315* viewport.2316* \returns a new SDL_Surface on success or NULL on failure; call2317* SDL_GetError() for more information.2318*2319* \threadsafety This function should only be called on the main thread.2320*2321* \since This function is available since SDL 3.2.0.2322*/2323extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect);23242325/**2326* Update the screen with any rendering performed since the previous call.2327*2328* SDL's rendering functions operate on a backbuffer; that is, calling a2329* rendering function such as SDL_RenderLine() does not directly put a line on2330* the screen, but rather updates the backbuffer. As such, you compose your2331* entire scene and *present* the composed backbuffer to the screen as a2332* complete picture.2333*2334* Therefore, when using SDL's rendering API, one does all drawing intended2335* for the frame, and then calls this function once per frame to present the2336* final drawing to the user.2337*2338* The backbuffer should be considered invalidated after each present; do not2339* assume that previous contents will exist between frames. You are strongly2340* encouraged to call SDL_RenderClear() to initialize the backbuffer before2341* starting each new frame's drawing, even if you plan to overwrite every2342* pixel.2343*2344* Please note, that in case of rendering to a texture - there is **no need**2345* to call `SDL_RenderPresent` after drawing needed objects to a texture, and2346* should not be done; you are only required to change back the rendering2347* target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as2348* textures by themselves do not have a concept of backbuffers. Calling2349* SDL_RenderPresent while rendering to a texture will still update the screen2350* with any current drawing that has been done _to the window itself_.2351*2352* \param renderer the rendering context.2353* \returns true on success or false on failure; call SDL_GetError() for more2354* information.2355*2356* \threadsafety This function should only be called on the main thread.2357*2358* \since This function is available since SDL 3.2.0.2359*2360* \sa SDL_CreateRenderer2361* \sa SDL_RenderClear2362* \sa SDL_RenderFillRect2363* \sa SDL_RenderFillRects2364* \sa SDL_RenderLine2365* \sa SDL_RenderLines2366* \sa SDL_RenderPoint2367* \sa SDL_RenderPoints2368* \sa SDL_RenderRect2369* \sa SDL_RenderRects2370* \sa SDL_SetRenderDrawBlendMode2371* \sa SDL_SetRenderDrawColor2372*/2373extern SDL_DECLSPEC bool SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);23742375/**2376* Destroy the specified texture.2377*2378* Passing NULL or an otherwise invalid texture will set the SDL error message2379* to "Invalid texture".2380*2381* \param texture the texture to destroy.2382*2383* \threadsafety This function should only be called on the main thread.2384*2385* \since This function is available since SDL 3.2.0.2386*2387* \sa SDL_CreateTexture2388* \sa SDL_CreateTextureFromSurface2389*/2390extern SDL_DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);23912392/**2393* Destroy the rendering context for a window and free all associated2394* textures.2395*2396* This should be called before destroying the associated window.2397*2398* \param renderer the rendering context.2399*2400* \threadsafety This function should only be called on the main thread.2401*2402* \since This function is available since SDL 3.2.0.2403*2404* \sa SDL_CreateRenderer2405*/2406extern SDL_DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);24072408/**2409* Force the rendering context to flush any pending commands and state.2410*2411* You do not need to (and in fact, shouldn't) call this function unless you2412* are planning to call into OpenGL/Direct3D/Metal/whatever directly, in2413* addition to using an SDL_Renderer.2414*2415* This is for a very-specific case: if you are using SDL's render API, and2416* you plan to make OpenGL/D3D/whatever calls in addition to SDL render API2417* calls. If this applies, you should call this function between calls to2418* SDL's render API and the low-level API you're using in cooperation.2419*2420* In all other cases, you can ignore this function.2421*2422* This call makes SDL flush any pending rendering work it was queueing up to2423* do later in a single batch, and marks any internal cached state as invalid,2424* so it'll prepare all its state again later, from scratch.2425*2426* This means you do not need to save state in your rendering code to protect2427* the SDL renderer. However, there lots of arbitrary pieces of Direct3D and2428* OpenGL state that can confuse things; you should use your best judgment and2429* be prepared to make changes if specific state needs to be protected.2430*2431* \param renderer the rendering context.2432* \returns true on success or false on failure; call SDL_GetError() for more2433* information.2434*2435* \threadsafety This function should only be called on the main thread.2436*2437* \since This function is available since SDL 3.2.0.2438*/2439extern SDL_DECLSPEC bool SDLCALL SDL_FlushRenderer(SDL_Renderer *renderer);24402441/**2442* Get the CAMetalLayer associated with the given Metal renderer.2443*2444* This function returns `void *`, so SDL doesn't have to include Metal's2445* headers, but it can be safely cast to a `CAMetalLayer *`.2446*2447* \param renderer the renderer to query.2448* \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a2449* Metal renderer.2450*2451* \threadsafety This function should only be called on the main thread.2452*2453* \since This function is available since SDL 3.2.0.2454*2455* \sa SDL_GetRenderMetalCommandEncoder2456*/2457extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalLayer(SDL_Renderer *renderer);24582459/**2460* Get the Metal command encoder for the current frame.2461*2462* This function returns `void *`, so SDL doesn't have to include Metal's2463* headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.2464*2465* This will return NULL if Metal refuses to give SDL a drawable to render to,2466* which might happen if the window is hidden/minimized/offscreen. This2467* doesn't apply to command encoders for render targets, just the window's2468* backbuffer. Check your return values!2469*2470* \param renderer the renderer to query.2471* \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the2472* renderer isn't a Metal renderer or there was an error.2473*2474* \threadsafety This function should only be called on the main thread.2475*2476* \since This function is available since SDL 3.2.0.2477*2478* \sa SDL_GetRenderMetalLayer2479*/2480extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalCommandEncoder(SDL_Renderer *renderer);248124822483/**2484* Add a set of synchronization semaphores for the current frame.2485*2486* The Vulkan renderer will wait for `wait_semaphore` before submitting2487* rendering commands and signal `signal_semaphore` after rendering commands2488* are complete for this frame.2489*2490* This should be called each frame that you want semaphore synchronization.2491* The Vulkan renderer may have multiple frames in flight on the GPU, so you2492* should have multiple semaphores that are used for synchronization. Querying2493* SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the2494* maximum number of semaphores you'll need.2495*2496* \param renderer the rendering context.2497* \param wait_stage_mask the VkPipelineStageFlags for the wait.2498* \param wait_semaphore a VkSempahore to wait on before rendering the current2499* frame, or 0 if not needed.2500* \param signal_semaphore a VkSempahore that SDL will signal when rendering2501* for the current frame is complete, or 0 if not2502* needed.2503* \returns true on success or false on failure; call SDL_GetError() for more2504* information.2505*2506* \threadsafety It is **NOT** safe to call this function from two threads at2507* once.2508*2509* \since This function is available since SDL 3.2.0.2510*/2511extern SDL_DECLSPEC bool SDLCALL SDL_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore);25122513/**2514* Toggle VSync of the given renderer.2515*2516* When a renderer is created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED.2517*2518* The `vsync` parameter can be 1 to synchronize present with every vertical2519* refresh, 2 to synchronize present with every second vertical refresh, etc.,2520* SDL_RENDERER_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or2521* SDL_RENDERER_VSYNC_DISABLED to disable. Not every value is supported by2522* every driver, so you should check the return value to see whether the2523* requested setting is supported.2524*2525* \param renderer the renderer to toggle.2526* \param vsync the vertical refresh sync interval.2527* \returns true on success or false on failure; call SDL_GetError() for more2528* information.2529*2530* \threadsafety This function should only be called on the main thread.2531*2532* \since This function is available since SDL 3.2.0.2533*2534* \sa SDL_GetRenderVSync2535*/2536extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync);25372538#define SDL_RENDERER_VSYNC_DISABLED 02539#define SDL_RENDERER_VSYNC_ADAPTIVE (-1)25402541/**2542* Get VSync of the given renderer.2543*2544* \param renderer the renderer to toggle.2545* \param vsync an int filled with the current vertical refresh sync interval.2546* See SDL_SetRenderVSync() for the meaning of the value.2547* \returns true on success or false on failure; call SDL_GetError() for more2548* information.2549*2550* \threadsafety This function should only be called on the main thread.2551*2552* \since This function is available since SDL 3.2.0.2553*2554* \sa SDL_SetRenderVSync2555*/2556extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync);25572558/**2559* The size, in pixels, of a single SDL_RenderDebugText() character.2560*2561* The font is monospaced and square, so this applies to all characters.2562*2563* \since This macro is available since SDL 3.2.0.2564*2565* \sa SDL_RenderDebugText2566*/2567#define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE 825682569/**2570* Draw debug text to an SDL_Renderer.2571*2572* This function will render a string of text to an SDL_Renderer. Note that2573* this is a convenience function for debugging, with severe limitations, and2574* not intended to be used for production apps and games.2575*2576* Among these limitations:2577*2578* - It accepts UTF-8 strings, but will only renders ASCII characters.2579* - It has a single, tiny size (8x8 pixels). One can use logical presentation2580* or scaling to adjust it, but it will be blurry.2581* - It uses a simple, hardcoded bitmap font. It does not allow different font2582* selections and it does not support truetype, for proper scaling.2583* - It does no word-wrapping and does not treat newline characters as a line2584* break. If the text goes out of the window, it's gone.2585*2586* For serious text rendering, there are several good options, such as2587* SDL_ttf, stb_truetype, or other external libraries.2588*2589* On first use, this will create an internal texture for rendering glyphs.2590* This texture will live until the renderer is destroyed.2591*2592* The text is drawn in the color specified by SDL_SetRenderDrawColor().2593*2594* \param renderer the renderer which should draw a line of text.2595* \param x the x coordinate where the top-left corner of the text will draw.2596* \param y the y coordinate where the top-left corner of the text will draw.2597* \param str the string to render.2598* \returns true on success or false on failure; call SDL_GetError() for more2599* information.2600*2601* \threadsafety This function should only be called on the main thread.2602*2603* \since This function is available since SDL 3.2.0.2604*2605* \sa SDL_RenderDebugTextFormat2606* \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE2607*/2608extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugText(SDL_Renderer *renderer, float x, float y, const char *str);26092610/**2611* Draw debug text to an SDL_Renderer.2612*2613* This function will render a printf()-style format string to a renderer.2614* Note that this is a convinence function for debugging, with severe2615* limitations, and is not intended to be used for production apps and games.2616*2617* For the full list of limitations and other useful information, see2618* SDL_RenderDebugText.2619*2620* \param renderer the renderer which should draw the text.2621* \param x the x coordinate where the top-left corner of the text will draw.2622* \param y the y coordinate where the top-left corner of the text will draw.2623* \param fmt the format string to draw.2624* \param ... additional parameters matching % tokens in the `fmt` string, if2625* any.2626* \returns true on success or false on failure; call SDL_GetError() for more2627* information.2628*2629* \threadsafety This function should only be called on the main thread.2630*2631* \since This function is available since SDL 3.2.0.2632*2633* \sa SDL_RenderDebugText2634* \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE2635*/2636extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugTextFormat(SDL_Renderer *renderer, float x, float y, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(4);26372638/* Ends C function definitions when using C++ */2639#ifdef __cplusplus2640}2641#endif2642#include <SDL3/SDL_close_code.h>26432644#endif /* SDL_render_h_ */264526462647