1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/**
23 * # CategoryRender
24 *
25 * Header file for SDL 2D rendering functions.
26 *
27 * This API supports the following features:
28 *
29 * - single pixel points
30 * - single pixel lines
31 * - filled rectangles
32 * - texture images
33 * - 2D polygons
34 *
35 * The primitives may be drawn in opaque, blended, or additive modes.
36 *
37 * The texture images may be drawn in opaque, blended, or additive modes. They
38 * can have an additional color tint or alpha modulation applied to them, and
39 * may also be stretched with linear interpolation.
40 *
41 * This API is designed to accelerate simple 2D operations. You may want more
42 * functionality such as polygons and particle effects and in that case you
43 * should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of the
44 * many good 3D engines.
45 *
46 * These functions must be called from the main thread. See this bug for
47 * details: https://github.com/libsdl-org/SDL/issues/986
48 */
49
50#ifndef SDL_render_h_
51#define SDL_render_h_
52
53#include <SDL3/SDL_stdinc.h>
54#include <SDL3/SDL_blendmode.h>
55#include <SDL3/SDL_error.h>
56#include <SDL3/SDL_events.h>
57#include <SDL3/SDL_pixels.h>
58#include <SDL3/SDL_properties.h>
59#include <SDL3/SDL_rect.h>
60#include <SDL3/SDL_surface.h>
61#include <SDL3/SDL_video.h>
62#include <SDL3/SDL_gpu.h>
63
64#include <SDL3/SDL_begin_code.h>
65/* Set up for C function definitions, even when using C++ */
66#ifdef __cplusplus
67extern "C" {
68#endif
69
70/**
71 * The name of the software renderer.
72 *
73 * \since This macro is available since SDL 3.2.0.
74 */
75#define SDL_SOFTWARE_RENDERER "software"
76
77/**
78 * Vertex structure.
79 *
80 * \since This struct is available since SDL 3.2.0.
81 */
82typedef struct SDL_Vertex
83{
84 SDL_FPoint position; /**< Vertex position, in SDL_Renderer coordinates */
85 SDL_FColor color; /**< Vertex color */
86 SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */
87} SDL_Vertex;
88
89/**
90 * The access pattern allowed for a texture.
91 *
92 * \since This enum is available since SDL 3.2.0.
93 */
94typedef enum SDL_TextureAccess
95{
96 SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */
97 SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
98 SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */
99} SDL_TextureAccess;
100
101/**
102 * How the logical size is mapped to the output.
103 *
104 * \since This enum is available since SDL 3.2.0.
105 */
106typedef enum SDL_RendererLogicalPresentation
107{
108 SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */
109 SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */
110 SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with black bars */
111 SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */
112 SDL_LOGICAL_PRESENTATION_INTEGER_SCALE /**< The rendered content is scaled up by integer multiples to fit the output resolution */
113} SDL_RendererLogicalPresentation;
114
115/**
116 * A structure representing rendering state
117 *
118 * \since This struct is available since SDL 3.2.0.
119 */
120typedef struct SDL_Renderer SDL_Renderer;
121
122#ifndef SDL_INTERNAL
123
124/**
125 * An efficient driver-specific representation of pixel data
126 *
127 * \since This struct is available since SDL 3.2.0.
128 *
129 * \sa SDL_CreateTexture
130 * \sa SDL_CreateTextureFromSurface
131 * \sa SDL_CreateTextureWithProperties
132 * \sa SDL_DestroyTexture
133 */
134struct SDL_Texture
135{
136 SDL_PixelFormat format; /**< The format of the texture, read-only */
137 int w; /**< The width of the texture, read-only. */
138 int h; /**< The height of the texture, read-only. */
139
140 int refcount; /**< Application reference count, used when freeing texture */
141};
142#endif /* !SDL_INTERNAL */
143
144typedef struct SDL_Texture SDL_Texture;
145
146/* Function prototypes */
147
148/**
149 * Get the number of 2D rendering drivers available for the current display.
150 *
151 * A render driver is a set of code that handles rendering and texture
152 * management on a particular display. Normally there is only one, but some
153 * drivers may have several available with different capabilities.
154 *
155 * There may be none if SDL was compiled without render support.
156 *
157 * \returns the number of built in render drivers.
158 *
159 * \threadsafety It is safe to call this function from any thread.
160 *
161 * \since This function is available since SDL 3.2.0.
162 *
163 * \sa SDL_CreateRenderer
164 * \sa SDL_GetRenderDriver
165 */
166extern SDL_DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
167
168/**
169 * Use this function to get the name of a built in 2D rendering driver.
170 *
171 * The list of rendering drivers is given in the order that they are normally
172 * initialized by default; the drivers that seem more reasonable to choose
173 * first (as far as the SDL developers believe) are earlier in the list.
174 *
175 * The names of drivers are all simple, low-ASCII identifiers, like "opengl",
176 * "direct3d12" or "metal". These never have Unicode characters, and are not
177 * meant to be proper names.
178 *
179 * \param index the index of the rendering driver; the value ranges from 0 to
180 * SDL_GetNumRenderDrivers() - 1.
181 * \returns the name of the rendering driver at the requested index, or NULL
182 * if an invalid index was specified.
183 *
184 * \threadsafety It is safe to call this function from any thread.
185 *
186 * \since This function is available since SDL 3.2.0.
187 *
188 * \sa SDL_GetNumRenderDrivers
189 */
190extern SDL_DECLSPEC const char * SDLCALL SDL_GetRenderDriver(int index);
191
192/**
193 * Create a window and default renderer.
194 *
195 * \param title the title of the window, in UTF-8 encoding.
196 * \param width the width of the window.
197 * \param height the height of the window.
198 * \param window_flags the flags used to create the window (see
199 * SDL_CreateWindow()).
200 * \param window a pointer filled with the window, or NULL on error.
201 * \param renderer a pointer filled with the renderer, or NULL on error.
202 * \returns true on success or false on failure; call SDL_GetError() for more
203 * information.
204 *
205 * \threadsafety This function should only be called on the main thread.
206 *
207 * \since This function is available since SDL 3.2.0.
208 *
209 * \sa SDL_CreateRenderer
210 * \sa SDL_CreateWindow
211 */
212extern SDL_DECLSPEC bool SDLCALL SDL_CreateWindowAndRenderer(const char *title, int width, int height, SDL_WindowFlags window_flags, SDL_Window **window, SDL_Renderer **renderer);
213
214/**
215 * Create a 2D rendering context for a window.
216 *
217 * If you want a specific renderer, you can specify its name here. A list of
218 * available renderers can be obtained by calling SDL_GetRenderDriver()
219 * multiple times, with indices from 0 to SDL_GetNumRenderDrivers()-1. If you
220 * don't need a specific renderer, specify NULL and SDL will attempt to choose
221 * the best option for you, based on what is available on the user's system.
222 *
223 * If `name` is a comma-separated list, SDL will try each name, in the order
224 * listed, until one succeeds or all of them fail.
225 *
226 * By default the rendering size matches the window size in pixels, but you
227 * can call SDL_SetRenderLogicalPresentation() to change the content size and
228 * scaling options.
229 *
230 * \param window the window where rendering is displayed.
231 * \param name the name of the rendering driver to initialize, or NULL to let
232 * SDL choose one.
233 * \returns a valid rendering context or NULL if there was an error; call
234 * SDL_GetError() for more information.
235 *
236 * \threadsafety This function should only be called on the main thread.
237 *
238 * \since This function is available since SDL 3.2.0.
239 *
240 * \sa SDL_CreateRendererWithProperties
241 * \sa SDL_CreateSoftwareRenderer
242 * \sa SDL_DestroyRenderer
243 * \sa SDL_GetNumRenderDrivers
244 * \sa SDL_GetRenderDriver
245 * \sa SDL_GetRendererName
246 */
247extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name);
248
249/**
250 * Create a 2D rendering context for a window, with the specified properties.
251 *
252 * These are the supported properties:
253 *
254 * - `SDL_PROP_RENDERER_CREATE_NAME_STRING`: the name of the rendering driver
255 * to use, if a specific one is desired
256 * - `SDL_PROP_RENDERER_CREATE_WINDOW_POINTER`: the window where rendering is
257 * displayed, required if this isn't a software renderer using a surface
258 * - `SDL_PROP_RENDERER_CREATE_SURFACE_POINTER`: the surface where rendering
259 * is displayed, if you want a software renderer without a window
260 * - `SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace
261 * value describing the colorspace for output to the display, defaults to
262 * SDL_COLORSPACE_SRGB. The direct3d11, direct3d12, and metal renderers
263 * support SDL_COLORSPACE_SRGB_LINEAR, which is a linear color space and
264 * supports HDR output. If you select SDL_COLORSPACE_SRGB_LINEAR, drawing
265 * still uses the sRGB colorspace, but values can go beyond 1.0 and float
266 * (linear) format textures can be used for HDR content.
267 * - `SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER`: non-zero if you want
268 * present synchronized with the refresh rate. This property can take any
269 * value that is supported by SDL_SetRenderVSync() for the renderer.
270 *
271 * With the vulkan renderer:
272 *
273 * - `SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER`: the VkInstance to use
274 * with the renderer, optional.
275 * - `SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR to use
276 * with the renderer, optional.
277 * - `SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER`: the
278 * VkPhysicalDevice to use with the renderer, optional.
279 * - `SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER`: the VkDevice to use
280 * with the renderer, optional.
281 * - `SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the
282 * queue family index used for rendering.
283 * - `SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the
284 * queue family index used for presentation.
285 *
286 * \param props the properties to use.
287 * \returns a valid rendering context or NULL if there was an error; call
288 * SDL_GetError() for more information.
289 *
290 * \threadsafety This function should only be called on the main thread.
291 *
292 * \since This function is available since SDL 3.2.0.
293 *
294 * \sa SDL_CreateProperties
295 * \sa SDL_CreateRenderer
296 * \sa SDL_CreateSoftwareRenderer
297 * \sa SDL_DestroyRenderer
298 * \sa SDL_GetRendererName
299 */
300extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_PropertiesID props);
301
302#define SDL_PROP_RENDERER_CREATE_NAME_STRING "SDL.renderer.create.name"
303#define SDL_PROP_RENDERER_CREATE_WINDOW_POINTER "SDL.renderer.create.window"
304#define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "SDL.renderer.create.surface"
305#define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.create.output_colorspace"
306#define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER "SDL.renderer.create.present_vsync"
307#define SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER "SDL.renderer.create.vulkan.instance"
308#define SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER "SDL.renderer.create.vulkan.surface"
309#define SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.create.vulkan.physical_device"
310#define SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER "SDL.renderer.create.vulkan.device"
311#define SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.graphics_queue_family_index"
312#define SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.present_queue_family_index"
313
314/**
315 * Create a 2D software rendering context for a surface.
316 *
317 * Two other API which can be used to create SDL_Renderer:
318 * SDL_CreateRenderer() and SDL_CreateWindowAndRenderer(). These can _also_
319 * create a software renderer, but they are intended to be used with an
320 * SDL_Window as the final destination and not an SDL_Surface.
321 *
322 * \param surface the SDL_Surface structure representing the surface where
323 * rendering is done.
324 * \returns a valid rendering context or NULL if there was an error; call
325 * SDL_GetError() for more information.
326 *
327 * \threadsafety This function should only be called on the main thread.
328 *
329 * \since This function is available since SDL 3.2.0.
330 *
331 * \sa SDL_DestroyRenderer
332 */
333extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface *surface);
334
335/**
336 * Get the renderer associated with a window.
337 *
338 * \param window the window to query.
339 * \returns the rendering context on success or NULL on failure; call
340 * SDL_GetError() for more information.
341 *
342 * \threadsafety It is safe to call this function from any thread.
343 *
344 * \since This function is available since SDL 3.2.0.
345 */
346extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window *window);
347
348/**
349 * Get the window associated with a renderer.
350 *
351 * \param renderer the renderer to query.
352 * \returns the window on success or NULL on failure; call SDL_GetError() for
353 * more information.
354 *
355 * \threadsafety It is safe to call this function from any thread.
356 *
357 * \since This function is available since SDL 3.2.0.
358 */
359extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetRenderWindow(SDL_Renderer *renderer);
360
361/**
362 * Get the name of a renderer.
363 *
364 * \param renderer the rendering context.
365 * \returns the name of the selected renderer, or NULL on failure; call
366 * SDL_GetError() for more information.
367 *
368 * \threadsafety It is safe to call this function from any thread.
369 *
370 * \since This function is available since SDL 3.2.0.
371 *
372 * \sa SDL_CreateRenderer
373 * \sa SDL_CreateRendererWithProperties
374 */
375extern SDL_DECLSPEC const char * SDLCALL SDL_GetRendererName(SDL_Renderer *renderer);
376
377/**
378 * Get the properties associated with a renderer.
379 *
380 * The following read-only properties are provided by SDL:
381 *
382 * - `SDL_PROP_RENDERER_NAME_STRING`: the name of the rendering driver
383 * - `SDL_PROP_RENDERER_WINDOW_POINTER`: the window where rendering is
384 * displayed, if any
385 * - `SDL_PROP_RENDERER_SURFACE_POINTER`: the surface where rendering is
386 * displayed, if this is a software renderer without a window
387 * - `SDL_PROP_RENDERER_VSYNC_NUMBER`: the current vsync setting
388 * - `SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER`: the maximum texture width
389 * and height
390 * - `SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`: a (const SDL_PixelFormat *)
391 * array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN,
392 * representing the available texture formats for this renderer.
393 * - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace value
394 * describing the colorspace for output to the display, defaults to
395 * SDL_COLORSPACE_SRGB.
396 * - `SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN`: true if the output colorspace is
397 * SDL_COLORSPACE_SRGB_LINEAR and the renderer is showing on a display with
398 * HDR enabled. This property can change dynamically when
399 * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
400 * - `SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT`: the value of SDR white in the
401 * SDL_COLORSPACE_SRGB_LINEAR colorspace. When HDR is enabled, this value is
402 * automatically multiplied into the color scale. This property can change
403 * dynamically when SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
404 * - `SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT`: the additional high dynamic range
405 * that can be displayed, in terms of the SDR white point. When HDR is not
406 * enabled, this will be 1.0. This property can change dynamically when
407 * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
408 *
409 * With the direct3d renderer:
410 *
411 * - `SDL_PROP_RENDERER_D3D9_DEVICE_POINTER`: the IDirect3DDevice9 associated
412 * with the renderer
413 *
414 * With the direct3d11 renderer:
415 *
416 * - `SDL_PROP_RENDERER_D3D11_DEVICE_POINTER`: the ID3D11Device associated
417 * with the renderer
418 * - `SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER`: the IDXGISwapChain1
419 * associated with the renderer. This may change when the window is resized.
420 *
421 * With the direct3d12 renderer:
422 *
423 * - `SDL_PROP_RENDERER_D3D12_DEVICE_POINTER`: the ID3D12Device associated
424 * with the renderer
425 * - `SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER`: the IDXGISwapChain4
426 * associated with the renderer.
427 * - `SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER`: the ID3D12CommandQueue
428 * associated with the renderer
429 *
430 * With the vulkan renderer:
431 *
432 * - `SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER`: the VkInstance associated
433 * with the renderer
434 * - `SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR associated
435 * with the renderer
436 * - `SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER`: the VkPhysicalDevice
437 * associated with the renderer
438 * - `SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER`: the VkDevice associated with
439 * the renderer
440 * - `SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the queue
441 * family index used for rendering
442 * - `SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the queue
443 * family index used for presentation
444 * - `SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER`: the number of
445 * swapchain images, or potential frames in flight, used by the Vulkan
446 * renderer
447 *
448 * With the gpu renderer:
449 *
450 * - `SDL_PROP_RENDERER_GPU_DEVICE_POINTER`: the SDL_GPUDevice associated with
451 * the renderer
452 *
453 * \param renderer the rendering context.
454 * \returns a valid property ID on success or 0 on failure; call
455 * SDL_GetError() for more information.
456 *
457 * \threadsafety It is safe to call this function from any thread.
458 *
459 * \since This function is available since SDL 3.2.0.
460 */
461extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Renderer *renderer);
462
463#define SDL_PROP_RENDERER_NAME_STRING "SDL.renderer.name"
464#define SDL_PROP_RENDERER_WINDOW_POINTER "SDL.renderer.window"
465#define SDL_PROP_RENDERER_SURFACE_POINTER "SDL.renderer.surface"
466#define SDL_PROP_RENDERER_VSYNC_NUMBER "SDL.renderer.vsync"
467#define SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER "SDL.renderer.max_texture_size"
468#define SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER "SDL.renderer.texture_formats"
469#define SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.output_colorspace"
470#define SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN "SDL.renderer.HDR_enabled"
471#define SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT "SDL.renderer.SDR_white_point"
472#define SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT "SDL.renderer.HDR_headroom"
473#define SDL_PROP_RENDERER_D3D9_DEVICE_POINTER "SDL.renderer.d3d9.device"
474#define SDL_PROP_RENDERER_D3D11_DEVICE_POINTER "SDL.renderer.d3d11.device"
475#define SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER "SDL.renderer.d3d11.swap_chain"
476#define SDL_PROP_RENDERER_D3D12_DEVICE_POINTER "SDL.renderer.d3d12.device"
477#define SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER "SDL.renderer.d3d12.swap_chain"
478#define SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER "SDL.renderer.d3d12.command_queue"
479#define SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER "SDL.renderer.vulkan.instance"
480#define SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER "SDL.renderer.vulkan.surface"
481#define SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.vulkan.physical_device"
482#define SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER "SDL.renderer.vulkan.device"
483#define SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.graphics_queue_family_index"
484#define SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.present_queue_family_index"
485#define SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER "SDL.renderer.vulkan.swapchain_image_count"
486#define SDL_PROP_RENDERER_GPU_DEVICE_POINTER "SDL.renderer.gpu.device"
487
488/**
489 * Get the output size in pixels of a rendering context.
490 *
491 * This returns the true output size in pixels, ignoring any render targets or
492 * logical size and presentation.
493 *
494 * For the output size of the current rendering target, with logical size
495 * adjustments, use SDL_GetCurrentRenderOutputSize() instead.
496 *
497 * \param renderer the rendering context.
498 * \param w a pointer filled in with the width in pixels.
499 * \param h a pointer filled in with the height in pixels.
500 * \returns true on success or false on failure; call SDL_GetError() for more
501 * information.
502 *
503 * \threadsafety This function should only be called on the main thread.
504 *
505 * \since This function is available since SDL 3.2.0.
506 *
507 * \sa SDL_GetCurrentRenderOutputSize
508 */
509extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
510
511/**
512 * Get the current output size in pixels of a rendering context.
513 *
514 * If a rendering target is active, this will return the size of the rendering
515 * target in pixels, otherwise return the value of SDL_GetRenderOutputSize().
516 *
517 * Rendering target or not, the output will be adjusted by the current logical
518 * presentation state, dictated by SDL_SetRenderLogicalPresentation().
519 *
520 * \param renderer the rendering context.
521 * \param w a pointer filled in with the current width.
522 * \param h a pointer filled in with the current height.
523 * \returns true on success or false on failure; call SDL_GetError() for more
524 * information.
525 *
526 * \threadsafety This function should only be called on the main thread.
527 *
528 * \since This function is available since SDL 3.2.0.
529 *
530 * \sa SDL_GetRenderOutputSize
531 */
532extern SDL_DECLSPEC bool SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
533
534/**
535 * Create a texture for a rendering context.
536 *
537 * The contents of a texture when first created are not defined.
538 *
539 * \param renderer the rendering context.
540 * \param format one of the enumerated values in SDL_PixelFormat.
541 * \param access one of the enumerated values in SDL_TextureAccess.
542 * \param w the width of the texture in pixels.
543 * \param h the height of the texture in pixels.
544 * \returns the created texture or NULL on failure; call SDL_GetError() for
545 * more information.
546 *
547 * \threadsafety This function should only be called on the main thread.
548 *
549 * \since This function is available since SDL 3.2.0.
550 *
551 * \sa SDL_CreateTextureFromSurface
552 * \sa SDL_CreateTextureWithProperties
553 * \sa SDL_DestroyTexture
554 * \sa SDL_GetTextureSize
555 * \sa SDL_UpdateTexture
556 */
557extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormat format, SDL_TextureAccess access, int w, int h);
558
559/**
560 * Create a texture from an existing surface.
561 *
562 * The surface is not modified or freed by this function.
563 *
564 * The SDL_TextureAccess hint for the created texture is
565 * `SDL_TEXTUREACCESS_STATIC`.
566 *
567 * The pixel format of the created texture may be different from the pixel
568 * format of the surface, and can be queried using the
569 * SDL_PROP_TEXTURE_FORMAT_NUMBER property.
570 *
571 * \param renderer the rendering context.
572 * \param surface the SDL_Surface structure containing pixel data used to fill
573 * the texture.
574 * \returns the created texture or NULL on failure; call SDL_GetError() for
575 * more information.
576 *
577 * \threadsafety This function should only be called on the main thread.
578 *
579 * \since This function is available since SDL 3.2.0.
580 *
581 * \sa SDL_CreateTexture
582 * \sa SDL_CreateTextureWithProperties
583 * \sa SDL_DestroyTexture
584 */
585extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface);
586
587/**
588 * Create a texture for a rendering context with the specified properties.
589 *
590 * These are the supported properties:
591 *
592 * - `SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER`: an SDL_Colorspace value
593 * describing the texture colorspace, defaults to SDL_COLORSPACE_SRGB_LINEAR
594 * for floating point textures, SDL_COLORSPACE_HDR10 for 10-bit textures,
595 * SDL_COLORSPACE_SRGB for other RGB textures and SDL_COLORSPACE_JPEG for
596 * YUV textures.
597 * - `SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER`: one of the enumerated values in
598 * SDL_PixelFormat, defaults to the best RGBA format for the renderer
599 * - `SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER`: one of the enumerated values in
600 * SDL_TextureAccess, defaults to SDL_TEXTUREACCESS_STATIC
601 * - `SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER`: the width of the texture in
602 * pixels, required
603 * - `SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`: the height of the texture in
604 * pixels, required
605 * - `SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating
606 * point textures, this defines the value of 100% diffuse white, with higher
607 * values being displayed in the High Dynamic Range headroom. This defaults
608 * to 100 for HDR10 textures and 1.0 for floating point textures.
609 * - `SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT`: for HDR10 and floating
610 * point textures, this defines the maximum dynamic range used by the
611 * content, in terms of the SDR white point. This would be equivalent to
612 * maxCLL / SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT for HDR10 content.
613 * If this is defined, any values outside the range supported by the display
614 * will be scaled into the available HDR headroom, otherwise they are
615 * clipped.
616 *
617 * With the direct3d11 renderer:
618 *
619 * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D
620 * associated with the texture, if you want to wrap an existing texture.
621 * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D
622 * associated with the U plane of a YUV texture, if you want to wrap an
623 * existing texture.
624 * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D
625 * associated with the V plane of a YUV texture, if you want to wrap an
626 * existing texture.
627 *
628 * With the direct3d12 renderer:
629 *
630 * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER`: the ID3D12Resource
631 * associated with the texture, if you want to wrap an existing texture.
632 * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource
633 * associated with the U plane of a YUV texture, if you want to wrap an
634 * existing texture.
635 * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource
636 * associated with the V plane of a YUV texture, if you want to wrap an
637 * existing texture.
638 *
639 * With the metal renderer:
640 *
641 * - `SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER`: the CVPixelBufferRef
642 * associated with the texture, if you want to create a texture from an
643 * existing pixel buffer.
644 *
645 * With the opengl renderer:
646 *
647 * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER`: the GLuint texture
648 * associated with the texture, if you want to wrap an existing texture.
649 * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture
650 * associated with the UV plane of an NV12 texture, if you want to wrap an
651 * existing texture.
652 * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture
653 * associated with the U plane of a YUV texture, if you want to wrap an
654 * existing texture.
655 * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture
656 * associated with the V plane of a YUV texture, if you want to wrap an
657 * existing texture.
658 *
659 * With the opengles2 renderer:
660 *
661 * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
662 * associated with the texture, if you want to wrap an existing texture.
663 * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
664 * associated with the texture, if you want to wrap an existing texture.
665 * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture
666 * associated with the UV plane of an NV12 texture, if you want to wrap an
667 * existing texture.
668 * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture
669 * associated with the U plane of a YUV texture, if you want to wrap an
670 * existing texture.
671 * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture
672 * associated with the V plane of a YUV texture, if you want to wrap an
673 * existing texture.
674 *
675 * With the vulkan renderer:
676 *
677 * - `SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER`: the VkImage with layout
678 * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL associated with the texture, if
679 * you want to wrap an existing texture.
680 *
681 * \param renderer the rendering context.
682 * \param props the properties to use.
683 * \returns the created texture or NULL on failure; call SDL_GetError() for
684 * more information.
685 *
686 * \threadsafety This function should only be called on the main thread.
687 *
688 * \since This function is available since SDL 3.2.0.
689 *
690 * \sa SDL_CreateProperties
691 * \sa SDL_CreateTexture
692 * \sa SDL_CreateTextureFromSurface
693 * \sa SDL_DestroyTexture
694 * \sa SDL_GetTextureSize
695 * \sa SDL_UpdateTexture
696 */
697extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props);
698
699#define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace"
700#define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format"
701#define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access"
702#define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width"
703#define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height"
704#define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point"
705#define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom"
706#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture"
707#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u"
708#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v"
709#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture"
710#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u"
711#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v"
712#define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer"
713#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture"
714#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv"
715#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u"
716#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v"
717#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture"
718#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv"
719#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u"
720#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v"
721#define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture"
722
723/**
724 * Get the properties associated with a texture.
725 *
726 * The following read-only properties are provided by SDL:
727 *
728 * - `SDL_PROP_TEXTURE_COLORSPACE_NUMBER`: an SDL_Colorspace value describing
729 * the texture colorspace.
730 * - `SDL_PROP_TEXTURE_FORMAT_NUMBER`: one of the enumerated values in
731 * SDL_PixelFormat.
732 * - `SDL_PROP_TEXTURE_ACCESS_NUMBER`: one of the enumerated values in
733 * SDL_TextureAccess.
734 * - `SDL_PROP_TEXTURE_WIDTH_NUMBER`: the width of the texture in pixels.
735 * - `SDL_PROP_TEXTURE_HEIGHT_NUMBER`: the height of the texture in pixels.
736 * - `SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point
737 * textures, this defines the value of 100% diffuse white, with higher
738 * values being displayed in the High Dynamic Range headroom. This defaults
739 * to 100 for HDR10 textures and 1.0 for other textures.
740 * - `SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point
741 * textures, this defines the maximum dynamic range used by the content, in
742 * terms of the SDR white point. If this is defined, any values outside the
743 * range supported by the display will be scaled into the available HDR
744 * headroom, otherwise they are clipped. This defaults to 1.0 for SDR
745 * textures, 4.0 for HDR10 textures, and no default for floating point
746 * textures.
747 *
748 * With the direct3d11 renderer:
749 *
750 * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D associated
751 * with the texture
752 * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D
753 * associated with the U plane of a YUV texture
754 * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D
755 * associated with the V plane of a YUV texture
756 *
757 * With the direct3d12 renderer:
758 *
759 * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER`: the ID3D12Resource associated
760 * with the texture
761 * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource associated
762 * with the U plane of a YUV texture
763 * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource associated
764 * with the V plane of a YUV texture
765 *
766 * With the vulkan renderer:
767 *
768 * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER`: the VkImage associated with the
769 * texture
770 *
771 * With the opengl renderer:
772 *
773 * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER`: the GLuint texture associated
774 * with the texture
775 * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture
776 * associated with the UV plane of an NV12 texture
777 * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture associated
778 * with the U plane of a YUV texture
779 * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture associated
780 * with the V plane of a YUV texture
781 * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER`: the GLenum for the
782 * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_RECTANGLE_ARB`, etc)
783 * - `SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT`: the texture coordinate width of
784 * the texture (0.0 - 1.0)
785 * - `SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT`: the texture coordinate height of
786 * the texture (0.0 - 1.0)
787 *
788 * With the opengles2 renderer:
789 *
790 * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
791 * associated with the texture
792 * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture
793 * associated with the UV plane of an NV12 texture
794 * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture
795 * associated with the U plane of a YUV texture
796 * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture
797 * associated with the V plane of a YUV texture
798 * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`: the GLenum for the
799 * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc)
800 *
801 * \param texture the texture to query.
802 * \returns a valid property ID on success or 0 on failure; call
803 * SDL_GetError() for more information.
804 *
805 * \threadsafety It is safe to call this function from any thread.
806 *
807 * \since This function is available since SDL 3.2.0.
808 */
809extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture);
810
811#define SDL_PROP_TEXTURE_COLORSPACE_NUMBER "SDL.texture.colorspace"
812#define SDL_PROP_TEXTURE_FORMAT_NUMBER "SDL.texture.format"
813#define SDL_PROP_TEXTURE_ACCESS_NUMBER "SDL.texture.access"
814#define SDL_PROP_TEXTURE_WIDTH_NUMBER "SDL.texture.width"
815#define SDL_PROP_TEXTURE_HEIGHT_NUMBER "SDL.texture.height"
816#define SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT "SDL.texture.SDR_white_point"
817#define SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT "SDL.texture.HDR_headroom"
818#define SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER "SDL.texture.d3d11.texture"
819#define SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER "SDL.texture.d3d11.texture_u"
820#define SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER "SDL.texture.d3d11.texture_v"
821#define SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER "SDL.texture.d3d12.texture"
822#define SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER "SDL.texture.d3d12.texture_u"
823#define SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER "SDL.texture.d3d12.texture_v"
824#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER "SDL.texture.opengl.texture"
825#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.opengl.texture_uv"
826#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.opengl.texture_u"
827#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.opengl.texture_v"
828#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER "SDL.texture.opengl.target"
829#define SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT "SDL.texture.opengl.tex_w"
830#define SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT "SDL.texture.opengl.tex_h"
831#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.opengles2.texture"
832#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.opengles2.texture_uv"
833#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.opengles2.texture_u"
834#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v"
835#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER "SDL.texture.opengles2.target"
836#define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER "SDL.texture.vulkan.texture"
837
838/**
839 * Get the renderer that created an SDL_Texture.
840 *
841 * \param texture the texture to query.
842 * \returns a pointer to the SDL_Renderer that created the texture, or NULL on
843 * failure; call SDL_GetError() for more information.
844 *
845 * \threadsafety It is safe to call this function from any thread.
846 *
847 * \since This function is available since SDL 3.2.0.
848 */
849extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRendererFromTexture(SDL_Texture *texture);
850
851/**
852 * Get the size of a texture, as floating point values.
853 *
854 * \param texture the texture to query.
855 * \param w a pointer filled in with the width of the texture in pixels. This
856 * argument can be NULL if you don't need this information.
857 * \param h a pointer filled in with the height of the texture in pixels. This
858 * argument can be NULL if you don't need this information.
859 * \returns true on success or false on failure; call SDL_GetError() for more
860 * information.
861 *
862 * \threadsafety This function should only be called on the main thread.
863 *
864 * \since This function is available since SDL 3.2.0.
865 */
866extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h);
867
868/**
869 * Set an additional color value multiplied into render copy operations.
870 *
871 * When this texture is rendered, during the copy operation each source color
872 * channel is modulated by the appropriate color value according to the
873 * following formula:
874 *
875 * `srcC = srcC * (color / 255)`
876 *
877 * Color modulation is not always supported by the renderer; it will return
878 * false if color modulation is not supported.
879 *
880 * \param texture the texture to update.
881 * \param r the red color value multiplied into copy operations.
882 * \param g the green color value multiplied into copy operations.
883 * \param b the blue color value multiplied into copy operations.
884 * \returns true on success or false on failure; call SDL_GetError() for more
885 * information.
886 *
887 * \threadsafety This function should only be called on the main thread.
888 *
889 * \since This function is available since SDL 3.2.0.
890 *
891 * \sa SDL_GetTextureColorMod
892 * \sa SDL_SetTextureAlphaMod
893 * \sa SDL_SetTextureColorModFloat
894 */
895extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b);
896
897
898/**
899 * Set an additional color value multiplied into render copy operations.
900 *
901 * When this texture is rendered, during the copy operation each source color
902 * channel is modulated by the appropriate color value according to the
903 * following formula:
904 *
905 * `srcC = srcC * color`
906 *
907 * Color modulation is not always supported by the renderer; it will return
908 * false if color modulation is not supported.
909 *
910 * \param texture the texture to update.
911 * \param r the red color value multiplied into copy operations.
912 * \param g the green color value multiplied into copy operations.
913 * \param b the blue color value multiplied into copy operations.
914 * \returns true on success or false on failure; call SDL_GetError() for more
915 * information.
916 *
917 * \threadsafety This function should only be called on the main thread.
918 *
919 * \since This function is available since SDL 3.2.0.
920 *
921 * \sa SDL_GetTextureColorModFloat
922 * \sa SDL_SetTextureAlphaModFloat
923 * \sa SDL_SetTextureColorMod
924 */
925extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorModFloat(SDL_Texture *texture, float r, float g, float b);
926
927
928/**
929 * Get the additional color value multiplied into render copy operations.
930 *
931 * \param texture the texture to query.
932 * \param r a pointer filled in with the current red color value.
933 * \param g a pointer filled in with the current green color value.
934 * \param b a pointer filled in with the current blue color value.
935 * \returns true on success or false on failure; call SDL_GetError() for more
936 * information.
937 *
938 * \threadsafety This function should only be called on the main thread.
939 *
940 * \since This function is available since SDL 3.2.0.
941 *
942 * \sa SDL_GetTextureAlphaMod
943 * \sa SDL_GetTextureColorModFloat
944 * \sa SDL_SetTextureColorMod
945 */
946extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b);
947
948/**
949 * Get the additional color value multiplied into render copy operations.
950 *
951 * \param texture the texture to query.
952 * \param r a pointer filled in with the current red color value.
953 * \param g a pointer filled in with the current green color value.
954 * \param b a pointer filled in with the current blue color value.
955 * \returns true on success or false on failure; call SDL_GetError() for more
956 * information.
957 *
958 * \threadsafety This function should only be called on the main thread.
959 *
960 * \since This function is available since SDL 3.2.0.
961 *
962 * \sa SDL_GetTextureAlphaModFloat
963 * \sa SDL_GetTextureColorMod
964 * \sa SDL_SetTextureColorModFloat
965 */
966extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorModFloat(SDL_Texture *texture, float *r, float *g, float *b);
967
968/**
969 * Set an additional alpha value multiplied into render copy operations.
970 *
971 * When this texture is rendered, during the copy operation the source alpha
972 * value is modulated by this alpha value according to the following formula:
973 *
974 * `srcA = srcA * (alpha / 255)`
975 *
976 * Alpha modulation is not always supported by the renderer; it will return
977 * false if alpha modulation is not supported.
978 *
979 * \param texture the texture to update.
980 * \param alpha the source alpha value multiplied into copy operations.
981 * \returns true on success or false on failure; call SDL_GetError() for more
982 * information.
983 *
984 * \threadsafety This function should only be called on the main thread.
985 *
986 * \since This function is available since SDL 3.2.0.
987 *
988 * \sa SDL_GetTextureAlphaMod
989 * \sa SDL_SetTextureAlphaModFloat
990 * \sa SDL_SetTextureColorMod
991 */
992extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha);
993
994/**
995 * Set an additional alpha value multiplied into render copy operations.
996 *
997 * When this texture is rendered, during the copy operation the source alpha
998 * value is modulated by this alpha value according to the following formula:
999 *
1000 * `srcA = srcA * alpha`
1001 *
1002 * Alpha modulation is not always supported by the renderer; it will return
1003 * false if alpha modulation is not supported.
1004 *
1005 * \param texture the texture to update.
1006 * \param alpha the source alpha value multiplied into copy operations.
1007 * \returns true on success or false on failure; call SDL_GetError() for more
1008 * information.
1009 *
1010 * \threadsafety This function should only be called on the main thread.
1011 *
1012 * \since This function is available since SDL 3.2.0.
1013 *
1014 * \sa SDL_GetTextureAlphaModFloat
1015 * \sa SDL_SetTextureAlphaMod
1016 * \sa SDL_SetTextureColorModFloat
1017 */
1018extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaModFloat(SDL_Texture *texture, float alpha);
1019
1020/**
1021 * Get the additional alpha value multiplied into render copy operations.
1022 *
1023 * \param texture the texture to query.
1024 * \param alpha a pointer filled in with the current alpha value.
1025 * \returns true on success or false on failure; call SDL_GetError() for more
1026 * information.
1027 *
1028 * \threadsafety This function should only be called on the main thread.
1029 *
1030 * \since This function is available since SDL 3.2.0.
1031 *
1032 * \sa SDL_GetTextureAlphaModFloat
1033 * \sa SDL_GetTextureColorMod
1034 * \sa SDL_SetTextureAlphaMod
1035 */
1036extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha);
1037
1038/**
1039 * Get the additional alpha value multiplied into render copy operations.
1040 *
1041 * \param texture the texture to query.
1042 * \param alpha a pointer filled in with the current alpha value.
1043 * \returns true on success or false on failure; call SDL_GetError() for more
1044 * information.
1045 *
1046 * \threadsafety This function should only be called on the main thread.
1047 *
1048 * \since This function is available since SDL 3.2.0.
1049 *
1050 * \sa SDL_GetTextureAlphaMod
1051 * \sa SDL_GetTextureColorModFloat
1052 * \sa SDL_SetTextureAlphaModFloat
1053 */
1054extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaModFloat(SDL_Texture *texture, float *alpha);
1055
1056/**
1057 * Set the blend mode for a texture, used by SDL_RenderTexture().
1058 *
1059 * If the blend mode is not supported, the closest supported mode is chosen
1060 * and this function returns false.
1061 *
1062 * \param texture the texture to update.
1063 * \param blendMode the SDL_BlendMode to use for texture blending.
1064 * \returns true on success or false on failure; call SDL_GetError() for more
1065 * information.
1066 *
1067 * \threadsafety This function should only be called on the main thread.
1068 *
1069 * \since This function is available since SDL 3.2.0.
1070 *
1071 * \sa SDL_GetTextureBlendMode
1072 */
1073extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode);
1074
1075/**
1076 * Get the blend mode used for texture copy operations.
1077 *
1078 * \param texture the texture to query.
1079 * \param blendMode a pointer filled in with the current SDL_BlendMode.
1080 * \returns true on success or false on failure; call SDL_GetError() for more
1081 * information.
1082 *
1083 * \threadsafety This function should only be called on the main thread.
1084 *
1085 * \since This function is available since SDL 3.2.0.
1086 *
1087 * \sa SDL_SetTextureBlendMode
1088 */
1089extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode);
1090
1091/**
1092 * Set the scale mode used for texture scale operations.
1093 *
1094 * The default texture scale mode is SDL_SCALEMODE_LINEAR.
1095 *
1096 * If the scale mode is not supported, the closest supported mode is chosen.
1097 *
1098 * \param texture the texture to update.
1099 * \param scaleMode the SDL_ScaleMode to use for texture scaling.
1100 * \returns true on success or false on failure; call SDL_GetError() for more
1101 * information.
1102 *
1103 * \threadsafety This function should only be called on the main thread.
1104 *
1105 * \since This function is available since SDL 3.2.0.
1106 *
1107 * \sa SDL_GetTextureScaleMode
1108 */
1109extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode);
1110
1111/**
1112 * Get the scale mode used for texture scale operations.
1113 *
1114 * \param texture the texture to query.
1115 * \param scaleMode a pointer filled in with the current scale mode.
1116 * \returns true on success or false on failure; call SDL_GetError() for more
1117 * information.
1118 *
1119 * \threadsafety This function should only be called on the main thread.
1120 *
1121 * \since This function is available since SDL 3.2.0.
1122 *
1123 * \sa SDL_SetTextureScaleMode
1124 */
1125extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode);
1126
1127/**
1128 * Update the given texture rectangle with new pixel data.
1129 *
1130 * The pixel data must be in the pixel format of the texture, which can be
1131 * queried using the SDL_PROP_TEXTURE_FORMAT_NUMBER property.
1132 *
1133 * This is a fairly slow function, intended for use with static textures that
1134 * do not change often.
1135 *
1136 * If the texture is intended to be updated often, it is preferred to create
1137 * the texture as streaming and use the locking functions referenced below.
1138 * While this function will work with streaming textures, for optimization
1139 * reasons you may not get the pixels back if you lock the texture afterward.
1140 *
1141 * \param texture the texture to update.
1142 * \param rect an SDL_Rect structure representing the area to update, or NULL
1143 * to update the entire texture.
1144 * \param pixels the raw pixel data in the format of the texture.
1145 * \param pitch the number of bytes in a row of pixel data, including padding
1146 * between lines.
1147 * \returns true on success or false on failure; call SDL_GetError() for more
1148 * information.
1149 *
1150 * \threadsafety This function should only be called on the main thread.
1151 *
1152 * \since This function is available since SDL 3.2.0.
1153 *
1154 * \sa SDL_LockTexture
1155 * \sa SDL_UnlockTexture
1156 * \sa SDL_UpdateNVTexture
1157 * \sa SDL_UpdateYUVTexture
1158 */
1159extern SDL_DECLSPEC bool SDLCALL SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch);
1160
1161/**
1162 * Update a rectangle within a planar YV12 or IYUV texture with new pixel
1163 * data.
1164 *
1165 * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
1166 * block of Y and U/V planes in the proper order, but this function is
1167 * available if your pixel data is not contiguous.
1168 *
1169 * \param texture the texture to update.
1170 * \param rect a pointer to the rectangle of pixels to update, or NULL to
1171 * update the entire texture.
1172 * \param Yplane the raw pixel data for the Y plane.
1173 * \param Ypitch the number of bytes between rows of pixel data for the Y
1174 * plane.
1175 * \param Uplane the raw pixel data for the U plane.
1176 * \param Upitch the number of bytes between rows of pixel data for the U
1177 * plane.
1178 * \param Vplane the raw pixel data for the V plane.
1179 * \param Vpitch the number of bytes between rows of pixel data for the V
1180 * plane.
1181 * \returns true on success or false on failure; call SDL_GetError() for more
1182 * information.
1183 *
1184 * \threadsafety This function should only be called on the main thread.
1185 *
1186 * \since This function is available since SDL 3.2.0.
1187 *
1188 * \sa SDL_UpdateNVTexture
1189 * \sa SDL_UpdateTexture
1190 */
1191extern SDL_DECLSPEC bool SDLCALL SDL_UpdateYUVTexture(SDL_Texture *texture,
1192 const SDL_Rect *rect,
1193 const Uint8 *Yplane, int Ypitch,
1194 const Uint8 *Uplane, int Upitch,
1195 const Uint8 *Vplane, int Vpitch);
1196
1197/**
1198 * Update a rectangle within a planar NV12 or NV21 texture with new pixels.
1199 *
1200 * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
1201 * block of NV12/21 planes in the proper order, but this function is available
1202 * if your pixel data is not contiguous.
1203 *
1204 * \param texture the texture to update.
1205 * \param rect a pointer to the rectangle of pixels to update, or NULL to
1206 * update the entire texture.
1207 * \param Yplane the raw pixel data for the Y plane.
1208 * \param Ypitch the number of bytes between rows of pixel data for the Y
1209 * plane.
1210 * \param UVplane the raw pixel data for the UV plane.
1211 * \param UVpitch the number of bytes between rows of pixel data for the UV
1212 * plane.
1213 * \returns true on success or false on failure; call SDL_GetError() for more
1214 * information.
1215 *
1216 * \threadsafety This function should only be called on the main thread.
1217 *
1218 * \since This function is available since SDL 3.2.0.
1219 *
1220 * \sa SDL_UpdateTexture
1221 * \sa SDL_UpdateYUVTexture
1222 */
1223extern SDL_DECLSPEC bool SDLCALL SDL_UpdateNVTexture(SDL_Texture *texture,
1224 const SDL_Rect *rect,
1225 const Uint8 *Yplane, int Ypitch,
1226 const Uint8 *UVplane, int UVpitch);
1227
1228/**
1229 * Lock a portion of the texture for **write-only** pixel access.
1230 *
1231 * As an optimization, the pixels made available for editing don't necessarily
1232 * contain the old texture data. This is a write-only operation, and if you
1233 * need to keep a copy of the texture data you should do that at the
1234 * application level.
1235 *
1236 * You must use SDL_UnlockTexture() to unlock the pixels and apply any
1237 * changes.
1238 *
1239 * \param texture the texture to lock for access, which was created with
1240 * `SDL_TEXTUREACCESS_STREAMING`.
1241 * \param rect an SDL_Rect structure representing the area to lock for access;
1242 * NULL to lock the entire texture.
1243 * \param pixels this is filled in with a pointer to the locked pixels,
1244 * appropriately offset by the locked area.
1245 * \param pitch this is filled in with the pitch of the locked pixels; the
1246 * pitch is the length of one row in bytes.
1247 * \returns true on success or false if the texture is not valid or was not
1248 * created with `SDL_TEXTUREACCESS_STREAMING`; call SDL_GetError()
1249 * for more information.
1250 *
1251 * \threadsafety This function should only be called on the main thread.
1252 *
1253 * \since This function is available since SDL 3.2.0.
1254 *
1255 * \sa SDL_LockTextureToSurface
1256 * \sa SDL_UnlockTexture
1257 */
1258extern SDL_DECLSPEC bool SDLCALL SDL_LockTexture(SDL_Texture *texture,
1259 const SDL_Rect *rect,
1260 void **pixels, int *pitch);
1261
1262/**
1263 * Lock a portion of the texture for **write-only** pixel access, and expose
1264 * it as a SDL surface.
1265 *
1266 * Besides providing an SDL_Surface instead of raw pixel data, this function
1267 * operates like SDL_LockTexture.
1268 *
1269 * As an optimization, the pixels made available for editing don't necessarily
1270 * contain the old texture data. This is a write-only operation, and if you
1271 * need to keep a copy of the texture data you should do that at the
1272 * application level.
1273 *
1274 * You must use SDL_UnlockTexture() to unlock the pixels and apply any
1275 * changes.
1276 *
1277 * The returned surface is freed internally after calling SDL_UnlockTexture()
1278 * or SDL_DestroyTexture(). The caller should not free it.
1279 *
1280 * \param texture the texture to lock for access, which must be created with
1281 * `SDL_TEXTUREACCESS_STREAMING`.
1282 * \param rect a pointer to the rectangle to lock for access. If the rect is
1283 * NULL, the entire texture will be locked.
1284 * \param surface a pointer to an SDL surface of size **rect**. Don't assume
1285 * any specific pixel content.
1286 * \returns true on success or false on failure; call SDL_GetError() for more
1287 * information.
1288 *
1289 * \threadsafety This function should only be called on the main thread.
1290 *
1291 * \since This function is available since SDL 3.2.0.
1292 *
1293 * \sa SDL_LockTexture
1294 * \sa SDL_UnlockTexture
1295 */
1296extern SDL_DECLSPEC bool SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Surface **surface);
1297
1298/**
1299 * Unlock a texture, uploading the changes to video memory, if needed.
1300 *
1301 * **Warning**: Please note that SDL_LockTexture() is intended to be
1302 * write-only; it will not guarantee the previous contents of the texture will
1303 * be provided. You must fully initialize any area of a texture that you lock
1304 * before unlocking it, as the pixels might otherwise be uninitialized memory.
1305 *
1306 * Which is to say: locking and immediately unlocking a texture can result in
1307 * corrupted textures, depending on the renderer in use.
1308 *
1309 * \param texture a texture locked by SDL_LockTexture().
1310 *
1311 * \threadsafety This function should only be called on the main thread.
1312 *
1313 * \since This function is available since SDL 3.2.0.
1314 *
1315 * \sa SDL_LockTexture
1316 */
1317extern SDL_DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture);
1318
1319/**
1320 * Set a texture as the current rendering target.
1321 *
1322 * The default render target is the window for which the renderer was created.
1323 * To stop rendering to a texture and render to the window again, call this
1324 * function with a NULL `texture`.
1325 *
1326 * Viewport, cliprect, scale, and logical presentation are unique to each
1327 * render target. Get and set functions for these states apply to the current
1328 * render target set by this function, and those states persist on each target
1329 * when the current render target changes.
1330 *
1331 * \param renderer the rendering context.
1332 * \param texture the targeted texture, which must be created with the
1333 * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the
1334 * window instead of a texture.
1335 * \returns true on success or false on failure; call SDL_GetError() for more
1336 * information.
1337 *
1338 * \threadsafety This function should only be called on the main thread.
1339 *
1340 * \since This function is available since SDL 3.2.0.
1341 *
1342 * \sa SDL_GetRenderTarget
1343 */
1344extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture);
1345
1346/**
1347 * Get the current render target.
1348 *
1349 * The default render target is the window for which the renderer was created,
1350 * and is reported a NULL here.
1351 *
1352 * \param renderer the rendering context.
1353 * \returns the current render target or NULL for the default render target.
1354 *
1355 * \threadsafety This function should only be called on the main thread.
1356 *
1357 * \since This function is available since SDL 3.2.0.
1358 *
1359 * \sa SDL_SetRenderTarget
1360 */
1361extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
1362
1363/**
1364 * Set a device-independent resolution and presentation mode for rendering.
1365 *
1366 * This function sets the width and height of the logical rendering output.
1367 * The renderer will act as if the current render target is always the
1368 * requested dimensions, scaling to the actual resolution as necessary.
1369 *
1370 * This can be useful for games that expect a fixed size, but would like to
1371 * scale the output to whatever is available, regardless of how a user resizes
1372 * a window, or if the display is high DPI.
1373 *
1374 * Logical presentation can be used with both render target textures and the
1375 * renderer's window; the state is unique to each render target, and this
1376 * function sets the state for the current render target. It might be useful
1377 * to draw to a texture that matches the window dimensions with logical
1378 * presentation enabled, and then draw that texture across the entire window
1379 * with logical presentation disabled. Be careful not to render both with
1380 * logical presentation enabled, however, as this could produce
1381 * double-letterboxing, etc.
1382 *
1383 * You can disable logical coordinates by setting the mode to
1384 * SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel
1385 * resolution of the render target; it is safe to toggle logical presentation
1386 * during the rendering of a frame: perhaps most of the rendering is done to
1387 * specific dimensions but to make fonts look sharp, the app turns off logical
1388 * presentation while drawing text, for example.
1389 *
1390 * For the renderer's window, letterboxing is drawn into the framebuffer if
1391 * logical presentation is enabled during SDL_RenderPresent; be sure to
1392 * reenable it before presenting if you were toggling it, otherwise the
1393 * letterbox areas might have artifacts from previous frames (or artifacts
1394 * from external overlays, etc). Letterboxing is never drawn into texture
1395 * render targets; be sure to call SDL_RenderClear() before drawing into the
1396 * texture so the letterboxing areas are cleared, if appropriate.
1397 *
1398 * You can convert coordinates in an event into rendering coordinates using
1399 * SDL_ConvertEventToRenderCoordinates().
1400 *
1401 * \param renderer the rendering context.
1402 * \param w the width of the logical resolution.
1403 * \param h the height of the logical resolution.
1404 * \param mode the presentation mode used.
1405 * \returns true on success or false on failure; call SDL_GetError() for more
1406 * information.
1407 *
1408 * \threadsafety This function should only be called on the main thread.
1409 *
1410 * \since This function is available since SDL 3.2.0.
1411 *
1412 * \sa SDL_ConvertEventToRenderCoordinates
1413 * \sa SDL_GetRenderLogicalPresentation
1414 * \sa SDL_GetRenderLogicalPresentationRect
1415 */
1416extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode);
1417
1418/**
1419 * Get device independent resolution and presentation mode for rendering.
1420 *
1421 * This function gets the width and height of the logical rendering output, or
1422 * the output size in pixels if a logical resolution is not enabled.
1423 *
1424 * Each render target has its own logical presentation state. This function
1425 * gets the state for the current render target.
1426 *
1427 * \param renderer the rendering context.
1428 * \param w an int to be filled with the width.
1429 * \param h an int to be filled with the height.
1430 * \param mode the presentation mode used.
1431 * \returns true on success or false on failure; call SDL_GetError() for more
1432 * information.
1433 *
1434 * \threadsafety This function should only be called on the main thread.
1435 *
1436 * \since This function is available since SDL 3.2.0.
1437 *
1438 * \sa SDL_SetRenderLogicalPresentation
1439 */
1440extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode);
1441
1442/**
1443 * Get the final presentation rectangle for rendering.
1444 *
1445 * This function returns the calculated rectangle used for logical
1446 * presentation, based on the presentation mode and output size. If logical
1447 * presentation is disabled, it will fill the rectangle with the output size,
1448 * in pixels.
1449 *
1450 * Each render target has its own logical presentation state. This function
1451 * gets the rectangle for the current render target.
1452 *
1453 * \param renderer the rendering context.
1454 * \param rect a pointer filled in with the final presentation rectangle, may
1455 * be NULL.
1456 * \returns true on success or false on failure; call SDL_GetError() for more
1457 * information.
1458 *
1459 * \threadsafety This function should only be called on the main thread.
1460 *
1461 * \since This function is available since SDL 3.2.0.
1462 *
1463 * \sa SDL_SetRenderLogicalPresentation
1464 */
1465extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentationRect(SDL_Renderer *renderer, SDL_FRect *rect);
1466
1467/**
1468 * Get a point in render coordinates when given a point in window coordinates.
1469 *
1470 * This takes into account several states:
1471 *
1472 * - The window dimensions.
1473 * - The logical presentation settings (SDL_SetRenderLogicalPresentation)
1474 * - The scale (SDL_SetRenderScale)
1475 * - The viewport (SDL_SetRenderViewport)
1476 *
1477 * \param renderer the rendering context.
1478 * \param window_x the x coordinate in window coordinates.
1479 * \param window_y the y coordinate in window coordinates.
1480 * \param x a pointer filled with the x coordinate in render coordinates.
1481 * \param y a pointer filled with the y coordinate in render coordinates.
1482 * \returns true on success or false on failure; call SDL_GetError() for more
1483 * information.
1484 *
1485 * \threadsafety This function should only be called on the main thread.
1486 *
1487 * \since This function is available since SDL 3.2.0.
1488 *
1489 * \sa SDL_SetRenderLogicalPresentation
1490 * \sa SDL_SetRenderScale
1491 */
1492extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y);
1493
1494/**
1495 * Get a point in window coordinates when given a point in render coordinates.
1496 *
1497 * This takes into account several states:
1498 *
1499 * - The window dimensions.
1500 * - The logical presentation settings (SDL_SetRenderLogicalPresentation)
1501 * - The scale (SDL_SetRenderScale)
1502 * - The viewport (SDL_SetRenderViewport)
1503 *
1504 * \param renderer the rendering context.
1505 * \param x the x coordinate in render coordinates.
1506 * \param y the y coordinate in render coordinates.
1507 * \param window_x a pointer filled with the x coordinate in window
1508 * coordinates.
1509 * \param window_y a pointer filled with the y coordinate in window
1510 * coordinates.
1511 * \returns true on success or false on failure; call SDL_GetError() for more
1512 * information.
1513 *
1514 * \threadsafety This function should only be called on the main thread.
1515 *
1516 * \since This function is available since SDL 3.2.0.
1517 *
1518 * \sa SDL_SetRenderLogicalPresentation
1519 * \sa SDL_SetRenderScale
1520 * \sa SDL_SetRenderViewport
1521 */
1522extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y);
1523
1524/**
1525 * Convert the coordinates in an event to render coordinates.
1526 *
1527 * This takes into account several states:
1528 *
1529 * - The window dimensions.
1530 * - The logical presentation settings (SDL_SetRenderLogicalPresentation)
1531 * - The scale (SDL_SetRenderScale)
1532 * - The viewport (SDL_SetRenderViewport)
1533 *
1534 * Various event types are converted with this function: mouse, touch, pen,
1535 * etc.
1536 *
1537 * Touch coordinates are converted from normalized coordinates in the window
1538 * to non-normalized rendering coordinates.
1539 *
1540 * Relative mouse coordinates (xrel and yrel event fields) are _also_
1541 * converted. Applications that do not want these fields converted should use
1542 * SDL_RenderCoordinatesFromWindow() on the specific event fields instead of
1543 * converting the entire event structure.
1544 *
1545 * Once converted, coordinates may be outside the rendering area.
1546 *
1547 * \param renderer the rendering context.
1548 * \param event the event to modify.
1549 * \returns true on success or false on failure; call SDL_GetError() for more
1550 * information.
1551 *
1552 * \threadsafety This function should only be called on the main thread.
1553 *
1554 * \since This function is available since SDL 3.2.0.
1555 *
1556 * \sa SDL_RenderCoordinatesFromWindow
1557 */
1558extern SDL_DECLSPEC bool SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event);
1559
1560/**
1561 * Set the drawing area for rendering on the current target.
1562 *
1563 * Drawing will clip to this area (separately from any clipping done with
1564 * SDL_SetRenderClipRect), and the top left of the area will become coordinate
1565 * (0, 0) for future drawing commands.
1566 *
1567 * The area's width and height must be >= 0.
1568 *
1569 * Each render target has its own viewport. This function sets the viewport
1570 * for the current render target.
1571 *
1572 * \param renderer the rendering context.
1573 * \param rect the SDL_Rect structure representing the drawing area, or NULL
1574 * to set the viewport to the entire target.
1575 * \returns true on success or false on failure; call SDL_GetError() for more
1576 * information.
1577 *
1578 * \threadsafety This function should only be called on the main thread.
1579 *
1580 * \since This function is available since SDL 3.2.0.
1581 *
1582 * \sa SDL_GetRenderViewport
1583 * \sa SDL_RenderViewportSet
1584 */
1585extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderViewport(SDL_Renderer *renderer, const SDL_Rect *rect);
1586
1587/**
1588 * Get the drawing area for the current target.
1589 *
1590 * Each render target has its own viewport. This function gets the viewport
1591 * for the current render target.
1592 *
1593 * \param renderer the rendering context.
1594 * \param rect an SDL_Rect structure filled in with the current drawing area.
1595 * \returns true on success or false on failure; call SDL_GetError() for more
1596 * information.
1597 *
1598 * \threadsafety This function should only be called on the main thread.
1599 *
1600 * \since This function is available since SDL 3.2.0.
1601 *
1602 * \sa SDL_RenderViewportSet
1603 * \sa SDL_SetRenderViewport
1604 */
1605extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect);
1606
1607/**
1608 * Return whether an explicit rectangle was set as the viewport.
1609 *
1610 * This is useful if you're saving and restoring the viewport and want to know
1611 * whether you should restore a specific rectangle or NULL. Note that the
1612 * viewport is always reset when changing rendering targets.
1613 *
1614 * Each render target has its own viewport. This function checks the viewport
1615 * for the current render target.
1616 *
1617 * \param renderer the rendering context.
1618 * \returns true if the viewport was set to a specific rectangle, or false if
1619 * it was set to NULL (the entire target).
1620 *
1621 * \threadsafety This function should only be called on the main thread.
1622 *
1623 * \since This function is available since SDL 3.2.0.
1624 *
1625 * \sa SDL_GetRenderViewport
1626 * \sa SDL_SetRenderViewport
1627 */
1628extern SDL_DECLSPEC bool SDLCALL SDL_RenderViewportSet(SDL_Renderer *renderer);
1629
1630/**
1631 * Get the safe area for rendering within the current viewport.
1632 *
1633 * Some devices have portions of the screen which are partially obscured or
1634 * not interactive, possibly due to on-screen controls, curved edges, camera
1635 * notches, TV overscan, etc. This function provides the area of the current
1636 * viewport which is safe to have interactible content. You should continue
1637 * rendering into the rest of the render target, but it should not contain
1638 * visually important or interactible content.
1639 *
1640 * \param renderer the rendering context.
1641 * \param rect a pointer filled in with the area that is safe for interactive
1642 * content.
1643 * \returns true on success or false on failure; call SDL_GetError() for more
1644 * information.
1645 *
1646 * \threadsafety This function should only be called on the main thread.
1647 *
1648 * \since This function is available since SDL 3.2.0.
1649 */
1650extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderSafeArea(SDL_Renderer *renderer, SDL_Rect *rect);
1651
1652/**
1653 * Set the clip rectangle for rendering on the specified target.
1654 *
1655 * Each render target has its own clip rectangle. This function sets the
1656 * cliprect for the current render target.
1657 *
1658 * \param renderer the rendering context.
1659 * \param rect an SDL_Rect structure representing the clip area, relative to
1660 * the viewport, or NULL to disable clipping.
1661 * \returns true on success or false on failure; call SDL_GetError() for more
1662 * information.
1663 *
1664 * \threadsafety This function should only be called on the main thread.
1665 *
1666 * \since This function is available since SDL 3.2.0.
1667 *
1668 * \sa SDL_GetRenderClipRect
1669 * \sa SDL_RenderClipEnabled
1670 */
1671extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect);
1672
1673/**
1674 * Get the clip rectangle for the current target.
1675 *
1676 * Each render target has its own clip rectangle. This function gets the
1677 * cliprect for the current render target.
1678 *
1679 * \param renderer the rendering context.
1680 * \param rect an SDL_Rect structure filled in with the current clipping area
1681 * or an empty rectangle if clipping is disabled.
1682 * \returns true on success or false on failure; call SDL_GetError() for more
1683 * information.
1684 *
1685 * \threadsafety This function should only be called on the main thread.
1686 *
1687 * \since This function is available since SDL 3.2.0.
1688 *
1689 * \sa SDL_RenderClipEnabled
1690 * \sa SDL_SetRenderClipRect
1691 */
1692extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect);
1693
1694/**
1695 * Get whether clipping is enabled on the given render target.
1696 *
1697 * Each render target has its own clip rectangle. This function checks the
1698 * cliprect for the current render target.
1699 *
1700 * \param renderer the rendering context.
1701 * \returns true if clipping is enabled or false if not; call SDL_GetError()
1702 * for more information.
1703 *
1704 * \threadsafety This function should only be called on the main thread.
1705 *
1706 * \since This function is available since SDL 3.2.0.
1707 *
1708 * \sa SDL_GetRenderClipRect
1709 * \sa SDL_SetRenderClipRect
1710 */
1711extern SDL_DECLSPEC bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer);
1712
1713/**
1714 * Set the drawing scale for rendering on the current target.
1715 *
1716 * The drawing coordinates are scaled by the x/y scaling factors before they
1717 * are used by the renderer. This allows resolution independent drawing with a
1718 * single coordinate system.
1719 *
1720 * If this results in scaling or subpixel drawing by the rendering backend, it
1721 * will be handled using the appropriate quality hints. For best results use
1722 * integer scaling factors.
1723 *
1724 * Each render target has its own scale. This function sets the scale for the
1725 * current render target.
1726 *
1727 * \param renderer the rendering context.
1728 * \param scaleX the horizontal scaling factor.
1729 * \param scaleY the vertical scaling factor.
1730 * \returns true on success or false on failure; call SDL_GetError() for more
1731 * information.
1732 *
1733 * \threadsafety This function should only be called on the main thread.
1734 *
1735 * \since This function is available since SDL 3.2.0.
1736 *
1737 * \sa SDL_GetRenderScale
1738 */
1739extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY);
1740
1741/**
1742 * Get the drawing scale for the current target.
1743 *
1744 * Each render target has its own scale. This function gets the scale for the
1745 * current render target.
1746 *
1747 * \param renderer the rendering context.
1748 * \param scaleX a pointer filled in with the horizontal scaling factor.
1749 * \param scaleY a pointer filled in with the vertical scaling factor.
1750 * \returns true on success or false on failure; call SDL_GetError() for more
1751 * information.
1752 *
1753 * \threadsafety This function should only be called on the main thread.
1754 *
1755 * \since This function is available since SDL 3.2.0.
1756 *
1757 * \sa SDL_SetRenderScale
1758 */
1759extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY);
1760
1761/**
1762 * Set the color used for drawing operations.
1763 *
1764 * Set the color for drawing or filling rectangles, lines, and points, and for
1765 * SDL_RenderClear().
1766 *
1767 * \param renderer the rendering context.
1768 * \param r the red value used to draw on the rendering target.
1769 * \param g the green value used to draw on the rendering target.
1770 * \param b the blue value used to draw on the rendering target.
1771 * \param a the alpha value used to draw on the rendering target; usually
1772 * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
1773 * specify how the alpha channel is used.
1774 * \returns true on success or false on failure; call SDL_GetError() for more
1775 * information.
1776 *
1777 * \threadsafety This function should only be called on the main thread.
1778 *
1779 * \since This function is available since SDL 3.2.0.
1780 *
1781 * \sa SDL_GetRenderDrawColor
1782 * \sa SDL_SetRenderDrawColorFloat
1783 */
1784extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
1785
1786/**
1787 * Set the color used for drawing operations (Rect, Line and Clear).
1788 *
1789 * Set the color for drawing or filling rectangles, lines, and points, and for
1790 * SDL_RenderClear().
1791 *
1792 * \param renderer the rendering context.
1793 * \param r the red value used to draw on the rendering target.
1794 * \param g the green value used to draw on the rendering target.
1795 * \param b the blue value used to draw on the rendering target.
1796 * \param a the alpha value used to draw on the rendering target. Use
1797 * SDL_SetRenderDrawBlendMode to specify how the alpha channel is
1798 * used.
1799 * \returns true on success or false on failure; call SDL_GetError() for more
1800 * information.
1801 *
1802 * \threadsafety This function should only be called on the main thread.
1803 *
1804 * \since This function is available since SDL 3.2.0.
1805 *
1806 * \sa SDL_GetRenderDrawColorFloat
1807 * \sa SDL_SetRenderDrawColor
1808 */
1809extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColorFloat(SDL_Renderer *renderer, float r, float g, float b, float a);
1810
1811/**
1812 * Get the color used for drawing operations (Rect, Line and Clear).
1813 *
1814 * \param renderer the rendering context.
1815 * \param r a pointer filled in with the red value used to draw on the
1816 * rendering target.
1817 * \param g a pointer filled in with the green value used to draw on the
1818 * rendering target.
1819 * \param b a pointer filled in with the blue value used to draw on the
1820 * rendering target.
1821 * \param a a pointer filled in with the alpha value used to draw on the
1822 * rendering target; usually `SDL_ALPHA_OPAQUE` (255).
1823 * \returns true on success or false on failure; call SDL_GetError() for more
1824 * information.
1825 *
1826 * \threadsafety This function should only be called on the main thread.
1827 *
1828 * \since This function is available since SDL 3.2.0.
1829 *
1830 * \sa SDL_GetRenderDrawColorFloat
1831 * \sa SDL_SetRenderDrawColor
1832 */
1833extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColor(SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
1834
1835/**
1836 * Get the color used for drawing operations (Rect, Line and Clear).
1837 *
1838 * \param renderer the rendering context.
1839 * \param r a pointer filled in with the red value used to draw on the
1840 * rendering target.
1841 * \param g a pointer filled in with the green value used to draw on the
1842 * rendering target.
1843 * \param b a pointer filled in with the blue value used to draw on the
1844 * rendering target.
1845 * \param a a pointer filled in with the alpha value used to draw on the
1846 * rendering target.
1847 * \returns true on success or false on failure; call SDL_GetError() for more
1848 * information.
1849 *
1850 * \threadsafety This function should only be called on the main thread.
1851 *
1852 * \since This function is available since SDL 3.2.0.
1853 *
1854 * \sa SDL_SetRenderDrawColorFloat
1855 * \sa SDL_GetRenderDrawColor
1856 */
1857extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColorFloat(SDL_Renderer *renderer, float *r, float *g, float *b, float *a);
1858
1859/**
1860 * Set the color scale used for render operations.
1861 *
1862 * The color scale is an additional scale multiplied into the pixel color
1863 * value while rendering. This can be used to adjust the brightness of colors
1864 * during HDR rendering, or changing HDR video brightness when playing on an
1865 * SDR display.
1866 *
1867 * The color scale does not affect the alpha channel, only the color
1868 * brightness.
1869 *
1870 * \param renderer the rendering context.
1871 * \param scale the color scale value.
1872 * \returns true on success or false on failure; call SDL_GetError() for more
1873 * information.
1874 *
1875 * \threadsafety This function should only be called on the main thread.
1876 *
1877 * \since This function is available since SDL 3.2.0.
1878 *
1879 * \sa SDL_GetRenderColorScale
1880 */
1881extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderColorScale(SDL_Renderer *renderer, float scale);
1882
1883/**
1884 * Get the color scale used for render operations.
1885 *
1886 * \param renderer the rendering context.
1887 * \param scale a pointer filled in with the current color scale value.
1888 * \returns true on success or false on failure; call SDL_GetError() for more
1889 * information.
1890 *
1891 * \threadsafety This function should only be called on the main thread.
1892 *
1893 * \since This function is available since SDL 3.2.0.
1894 *
1895 * \sa SDL_SetRenderColorScale
1896 */
1897extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderColorScale(SDL_Renderer *renderer, float *scale);
1898
1899/**
1900 * Set the blend mode used for drawing operations (Fill and Line).
1901 *
1902 * If the blend mode is not supported, the closest supported mode is chosen.
1903 *
1904 * \param renderer the rendering context.
1905 * \param blendMode the SDL_BlendMode to use for blending.
1906 * \returns true on success or false on failure; call SDL_GetError() for more
1907 * information.
1908 *
1909 * \threadsafety This function should only be called on the main thread.
1910 *
1911 * \since This function is available since SDL 3.2.0.
1912 *
1913 * \sa SDL_GetRenderDrawBlendMode
1914 */
1915extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode);
1916
1917/**
1918 * Get the blend mode used for drawing operations.
1919 *
1920 * \param renderer the rendering context.
1921 * \param blendMode a pointer filled in with the current SDL_BlendMode.
1922 * \returns true on success or false on failure; call SDL_GetError() for more
1923 * information.
1924 *
1925 * \threadsafety This function should only be called on the main thread.
1926 *
1927 * \since This function is available since SDL 3.2.0.
1928 *
1929 * \sa SDL_SetRenderDrawBlendMode
1930 */
1931extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode);
1932
1933/**
1934 * Clear the current rendering target with the drawing color.
1935 *
1936 * This function clears the entire rendering target, ignoring the viewport and
1937 * the clip rectangle. Note, that clearing will also set/fill all pixels of
1938 * the rendering target to current renderer draw color, so make sure to invoke
1939 * SDL_SetRenderDrawColor() when needed.
1940 *
1941 * \param renderer the rendering context.
1942 * \returns true on success or false on failure; call SDL_GetError() for more
1943 * information.
1944 *
1945 * \threadsafety This function should only be called on the main thread.
1946 *
1947 * \since This function is available since SDL 3.2.0.
1948 *
1949 * \sa SDL_SetRenderDrawColor
1950 */
1951extern SDL_DECLSPEC bool SDLCALL SDL_RenderClear(SDL_Renderer *renderer);
1952
1953/**
1954 * Draw a point on the current rendering target at subpixel precision.
1955 *
1956 * \param renderer the renderer which should draw a point.
1957 * \param x the x coordinate of the point.
1958 * \param y the y coordinate of the point.
1959 * \returns true on success or false on failure; call SDL_GetError() for more
1960 * information.
1961 *
1962 * \threadsafety This function should only be called on the main thread.
1963 *
1964 * \since This function is available since SDL 3.2.0.
1965 *
1966 * \sa SDL_RenderPoints
1967 */
1968extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoint(SDL_Renderer *renderer, float x, float y);
1969
1970/**
1971 * Draw multiple points on the current rendering target at subpixel precision.
1972 *
1973 * \param renderer the renderer which should draw multiple points.
1974 * \param points the points to draw.
1975 * \param count the number of points to draw.
1976 * \returns true on success or false on failure; call SDL_GetError() for more
1977 * information.
1978 *
1979 * \threadsafety This function should only be called on the main thread.
1980 *
1981 * \since This function is available since SDL 3.2.0.
1982 *
1983 * \sa SDL_RenderPoint
1984 */
1985extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
1986
1987/**
1988 * Draw a line on the current rendering target at subpixel precision.
1989 *
1990 * \param renderer the renderer which should draw a line.
1991 * \param x1 the x coordinate of the start point.
1992 * \param y1 the y coordinate of the start point.
1993 * \param x2 the x coordinate of the end point.
1994 * \param y2 the y coordinate of the end point.
1995 * \returns true on success or false on failure; call SDL_GetError() for more
1996 * information.
1997 *
1998 * \threadsafety This function should only be called on the main thread.
1999 *
2000 * \since This function is available since SDL 3.2.0.
2001 *
2002 * \sa SDL_RenderLines
2003 */
2004extern SDL_DECLSPEC bool SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2);
2005
2006/**
2007 * Draw a series of connected lines on the current rendering target at
2008 * subpixel precision.
2009 *
2010 * \param renderer the renderer which should draw multiple lines.
2011 * \param points the points along the lines.
2012 * \param count the number of points, drawing count-1 lines.
2013 * \returns true on success or false on failure; call SDL_GetError() for more
2014 * information.
2015 *
2016 * \threadsafety This function should only be called on the main thread.
2017 *
2018 * \since This function is available since SDL 3.2.0.
2019 *
2020 * \sa SDL_RenderLine
2021 */
2022extern SDL_DECLSPEC bool SDLCALL SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
2023
2024/**
2025 * Draw a rectangle on the current rendering target at subpixel precision.
2026 *
2027 * \param renderer the renderer which should draw a rectangle.
2028 * \param rect a pointer to the destination rectangle, or NULL to outline the
2029 * entire rendering target.
2030 * \returns true on success or false on failure; call SDL_GetError() for more
2031 * information.
2032 *
2033 * \threadsafety This function should only be called on the main thread.
2034 *
2035 * \since This function is available since SDL 3.2.0.
2036 *
2037 * \sa SDL_RenderRects
2038 */
2039extern SDL_DECLSPEC bool SDLCALL SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect);
2040
2041/**
2042 * Draw some number of rectangles on the current rendering target at subpixel
2043 * precision.
2044 *
2045 * \param renderer the renderer which should draw multiple rectangles.
2046 * \param rects a pointer to an array of destination rectangles.
2047 * \param count the number of rectangles.
2048 * \returns true on success or false on failure; call SDL_GetError() for more
2049 * information.
2050 *
2051 * \threadsafety This function should only be called on the main thread.
2052 *
2053 * \since This function is available since SDL 3.2.0.
2054 *
2055 * \sa SDL_RenderRect
2056 */
2057extern SDL_DECLSPEC bool SDLCALL SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
2058
2059/**
2060 * Fill a rectangle on the current rendering target with the drawing color at
2061 * subpixel precision.
2062 *
2063 * \param renderer the renderer which should fill a rectangle.
2064 * \param rect a pointer to the destination rectangle, or NULL for the entire
2065 * rendering target.
2066 * \returns true on success or false on failure; call SDL_GetError() for more
2067 * information.
2068 *
2069 * \threadsafety This function should only be called on the main thread.
2070 *
2071 * \since This function is available since SDL 3.2.0.
2072 *
2073 * \sa SDL_RenderFillRects
2074 */
2075extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect);
2076
2077/**
2078 * Fill some number of rectangles on the current rendering target with the
2079 * drawing color at subpixel precision.
2080 *
2081 * \param renderer the renderer which should fill multiple rectangles.
2082 * \param rects a pointer to an array of destination rectangles.
2083 * \param count the number of rectangles.
2084 * \returns true on success or false on failure; call SDL_GetError() for more
2085 * information.
2086 *
2087 * \threadsafety This function should only be called on the main thread.
2088 *
2089 * \since This function is available since SDL 3.2.0.
2090 *
2091 * \sa SDL_RenderFillRect
2092 */
2093extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
2094
2095/**
2096 * Copy a portion of the texture to the current rendering target at subpixel
2097 * precision.
2098 *
2099 * \param renderer the renderer which should copy parts of a texture.
2100 * \param texture the source texture.
2101 * \param srcrect a pointer to the source rectangle, or NULL for the entire
2102 * texture.
2103 * \param dstrect a pointer to the destination rectangle, or NULL for the
2104 * entire rendering target.
2105 * \returns true on success or false on failure; call SDL_GetError() for more
2106 * information.
2107 *
2108 * \threadsafety This function should only be called on the main thread.
2109 *
2110 * \since This function is available since SDL 3.2.0.
2111 *
2112 * \sa SDL_RenderTextureRotated
2113 * \sa SDL_RenderTextureTiled
2114 */
2115extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect);
2116
2117/**
2118 * Copy a portion of the source texture to the current rendering target, with
2119 * rotation and flipping, at subpixel precision.
2120 *
2121 * \param renderer the renderer which should copy parts of a texture.
2122 * \param texture the source texture.
2123 * \param srcrect a pointer to the source rectangle, or NULL for the entire
2124 * texture.
2125 * \param dstrect a pointer to the destination rectangle, or NULL for the
2126 * entire rendering target.
2127 * \param angle an angle in degrees that indicates the rotation that will be
2128 * applied to dstrect, rotating it in a clockwise direction.
2129 * \param center a pointer to a point indicating the point around which
2130 * dstrect will be rotated (if NULL, rotation will be done
2131 * around dstrect.w/2, dstrect.h/2).
2132 * \param flip an SDL_FlipMode value stating which flipping actions should be
2133 * performed on the texture.
2134 * \returns true on success or false on failure; call SDL_GetError() for more
2135 * information.
2136 *
2137 * \threadsafety This function should only be called on the main thread.
2138 *
2139 * \since This function is available since SDL 3.2.0.
2140 *
2141 * \sa SDL_RenderTexture
2142 */
2143extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
2144 const SDL_FRect *srcrect, const SDL_FRect *dstrect,
2145 double angle, const SDL_FPoint *center,
2146 SDL_FlipMode flip);
2147
2148/**
2149 * Copy a portion of the source texture to the current rendering target, with
2150 * affine transform, at subpixel precision.
2151 *
2152 * \param renderer the renderer which should copy parts of a texture.
2153 * \param texture the source texture.
2154 * \param srcrect a pointer to the source rectangle, or NULL for the entire
2155 * texture.
2156 * \param origin a pointer to a point indicating where the top-left corner of
2157 * srcrect should be mapped to, or NULL for the rendering
2158 * target's origin.
2159 * \param right a pointer to a point indicating where the top-right corner of
2160 * srcrect should be mapped to, or NULL for the rendering
2161 * target's top-right corner.
2162 * \param down a pointer to a point indicating where the bottom-left corner of
2163 * srcrect should be mapped to, or NULL for the rendering target's
2164 * bottom-left corner.
2165 * \returns true on success or false on failure; call SDL_GetError() for more
2166 * information.
2167 *
2168 * \threadsafety You may only call this function from the main thread.
2169 *
2170 * \since This function is available since SDL 3.2.0.
2171 *
2172 * \sa SDL_RenderTexture
2173 */
2174extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureAffine(SDL_Renderer *renderer, SDL_Texture *texture,
2175 const SDL_FRect *srcrect, const SDL_FPoint *origin,
2176 const SDL_FPoint *right, const SDL_FPoint *down);
2177
2178/**
2179 * Tile a portion of the texture to the current rendering target at subpixel
2180 * precision.
2181 *
2182 * The pixels in `srcrect` will be repeated as many times as needed to
2183 * completely fill `dstrect`.
2184 *
2185 * \param renderer the renderer which should copy parts of a texture.
2186 * \param texture the source texture.
2187 * \param srcrect a pointer to the source rectangle, or NULL for the entire
2188 * texture.
2189 * \param scale the scale used to transform srcrect into the destination
2190 * rectangle, e.g. a 32x32 texture with a scale of 2 would fill
2191 * 64x64 tiles.
2192 * \param dstrect a pointer to the destination rectangle, or NULL for the
2193 * entire rendering target.
2194 * \returns true on success or false on failure; call SDL_GetError() for more
2195 * information.
2196 *
2197 * \threadsafety This function should only be called on the main thread.
2198 *
2199 * \since This function is available since SDL 3.2.0.
2200 *
2201 * \sa SDL_RenderTexture
2202 */
2203extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float scale, const SDL_FRect *dstrect);
2204
2205/**
2206 * Perform a scaled copy using the 9-grid algorithm to the current rendering
2207 * target at subpixel precision.
2208 *
2209 * The pixels in the texture are split into a 3x3 grid, using the different
2210 * corner sizes for each corner, and the sides and center making up the
2211 * remaining pixels. The corners are then scaled using `scale` and fit into
2212 * the corners of the destination rectangle. The sides and center are then
2213 * stretched into place to cover the remaining destination rectangle.
2214 *
2215 * \param renderer the renderer which should copy parts of a texture.
2216 * \param texture the source texture.
2217 * \param srcrect the SDL_Rect structure representing the rectangle to be used
2218 * for the 9-grid, or NULL to use the entire texture.
2219 * \param left_width the width, in pixels, of the left corners in `srcrect`.
2220 * \param right_width the width, in pixels, of the right corners in `srcrect`.
2221 * \param top_height the height, in pixels, of the top corners in `srcrect`.
2222 * \param bottom_height the height, in pixels, of the bottom corners in
2223 * `srcrect`.
2224 * \param scale the scale used to transform the corner of `srcrect` into the
2225 * corner of `dstrect`, or 0.0f for an unscaled copy.
2226 * \param dstrect a pointer to the destination rectangle, or NULL for the
2227 * entire rendering target.
2228 * \returns true on success or false on failure; call SDL_GetError() for more
2229 * information.
2230 *
2231 * \threadsafety This function should only be called on the main thread.
2232 *
2233 * \since This function is available since SDL 3.2.0.
2234 *
2235 * \sa SDL_RenderTexture
2236 */
2237extern 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);
2238
2239/**
2240 * Perform a scaled copy using the 9-grid algorithm to the current rendering
2241 * target at subpixel precision.
2242 *
2243 * The pixels in the texture are split into a 3x3 grid, using the different
2244 * corner sizes for each corner, and the sides and center making up the
2245 * remaining pixels. The corners are then scaled using `scale` and fit into
2246 * the corners of the destination rectangle. The sides and center are then
2247 * tiled into place to cover the remaining destination rectangle.
2248 *
2249 * \param renderer the renderer which should copy parts of a texture.
2250 * \param texture the source texture.
2251 * \param srcrect the SDL_Rect structure representing the rectangle to be used
2252 * for the 9-grid, or NULL to use the entire texture.
2253 * \param left_width the width, in pixels, of the left corners in `srcrect`.
2254 * \param right_width the width, in pixels, of the right corners in `srcrect`.
2255 * \param top_height the height, in pixels, of the top corners in `srcrect`.
2256 * \param bottom_height the height, in pixels, of the bottom corners in
2257 * `srcrect`.
2258 * \param scale the scale used to transform the corner of `srcrect` into the
2259 * corner of `dstrect`, or 0.0f for an unscaled copy.
2260 * \param dstrect a pointer to the destination rectangle, or NULL for the
2261 * entire rendering target.
2262 * \param tileScale the scale used to transform the borders and center of
2263 * `srcrect` into the borders and middle of `dstrect`, or
2264 * 1.0f for an unscaled copy.
2265 * \returns true on success or false on failure; call SDL_GetError() for more
2266 * information.
2267 *
2268 * \threadsafety This function should only be called on the main thread.
2269 *
2270 * \since This function is available since SDL 3.4.0.
2271 *
2272 * \sa SDL_RenderTexture
2273 */
2274extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9GridTiled(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, float tileScale);
2275
2276/**
2277 * Render a list of triangles, optionally using a texture and indices into the
2278 * vertex array Color and alpha modulation is done per vertex
2279 * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
2280 *
2281 * \param renderer the rendering context.
2282 * \param texture (optional) The SDL texture to use.
2283 * \param vertices vertices.
2284 * \param num_vertices number of vertices.
2285 * \param indices (optional) An array of integer indices into the 'vertices'
2286 * array, if NULL all vertices will be rendered in sequential
2287 * order.
2288 * \param num_indices number of indices.
2289 * \returns true on success or false on failure; call SDL_GetError() for more
2290 * information.
2291 *
2292 * \threadsafety This function should only be called on the main thread.
2293 *
2294 * \since This function is available since SDL 3.2.0.
2295 *
2296 * \sa SDL_RenderGeometryRaw
2297 */
2298extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
2299 SDL_Texture *texture,
2300 const SDL_Vertex *vertices, int num_vertices,
2301 const int *indices, int num_indices);
2302
2303/**
2304 * Render a list of triangles, optionally using a texture and indices into the
2305 * vertex arrays Color and alpha modulation is done per vertex
2306 * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
2307 *
2308 * \param renderer the rendering context.
2309 * \param texture (optional) The SDL texture to use.
2310 * \param xy vertex positions.
2311 * \param xy_stride byte size to move from one element to the next element.
2312 * \param color vertex colors (as SDL_FColor).
2313 * \param color_stride byte size to move from one element to the next element.
2314 * \param uv vertex normalized texture coordinates.
2315 * \param uv_stride byte size to move from one element to the next element.
2316 * \param num_vertices number of vertices.
2317 * \param indices (optional) An array of indices into the 'vertices' arrays,
2318 * if NULL all vertices will be rendered in sequential order.
2319 * \param num_indices number of indices.
2320 * \param size_indices index size: 1 (byte), 2 (short), 4 (int).
2321 * \returns true on success or false on failure; call SDL_GetError() for more
2322 * information.
2323 *
2324 * \threadsafety This function should only be called on the main thread.
2325 *
2326 * \since This function is available since SDL 3.2.0.
2327 *
2328 * \sa SDL_RenderGeometry
2329 */
2330extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
2331 SDL_Texture *texture,
2332 const float *xy, int xy_stride,
2333 const SDL_FColor *color, int color_stride,
2334 const float *uv, int uv_stride,
2335 int num_vertices,
2336 const void *indices, int num_indices, int size_indices);
2337
2338/**
2339 * Read pixels from the current rendering target.
2340 *
2341 * The returned surface contains pixels inside the desired area clipped to the
2342 * current viewport, and should be freed with SDL_DestroySurface().
2343 *
2344 * Note that this returns the actual pixels on the screen, so if you are using
2345 * logical presentation you should use SDL_GetRenderLogicalPresentationRect()
2346 * to get the area containing your content.
2347 *
2348 * **WARNING**: This is a very slow operation, and should not be used
2349 * frequently. If you're using this on the main rendering target, it should be
2350 * called after rendering and before SDL_RenderPresent().
2351 *
2352 * \param renderer the rendering context.
2353 * \param rect an SDL_Rect structure representing the area to read, which will
2354 * be clipped to the current viewport, or NULL for the entire
2355 * viewport.
2356 * \returns a new SDL_Surface on success or NULL on failure; call
2357 * SDL_GetError() for more information.
2358 *
2359 * \threadsafety This function should only be called on the main thread.
2360 *
2361 * \since This function is available since SDL 3.2.0.
2362 */
2363extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect);
2364
2365/**
2366 * Update the screen with any rendering performed since the previous call.
2367 *
2368 * SDL's rendering functions operate on a backbuffer; that is, calling a
2369 * rendering function such as SDL_RenderLine() does not directly put a line on
2370 * the screen, but rather updates the backbuffer. As such, you compose your
2371 * entire scene and *present* the composed backbuffer to the screen as a
2372 * complete picture.
2373 *
2374 * Therefore, when using SDL's rendering API, one does all drawing intended
2375 * for the frame, and then calls this function once per frame to present the
2376 * final drawing to the user.
2377 *
2378 * The backbuffer should be considered invalidated after each present; do not
2379 * assume that previous contents will exist between frames. You are strongly
2380 * encouraged to call SDL_RenderClear() to initialize the backbuffer before
2381 * starting each new frame's drawing, even if you plan to overwrite every
2382 * pixel.
2383 *
2384 * Please note, that in case of rendering to a texture - there is **no need**
2385 * to call `SDL_RenderPresent` after drawing needed objects to a texture, and
2386 * should not be done; you are only required to change back the rendering
2387 * target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as
2388 * textures by themselves do not have a concept of backbuffers. Calling
2389 * SDL_RenderPresent while rendering to a texture will fail.
2390 *
2391 * \param renderer the rendering context.
2392 * \returns true on success or false on failure; call SDL_GetError() for more
2393 * information.
2394 *
2395 * \threadsafety This function should only be called on the main thread.
2396 *
2397 * \since This function is available since SDL 3.2.0.
2398 *
2399 * \sa SDL_CreateRenderer
2400 * \sa SDL_RenderClear
2401 * \sa SDL_RenderFillRect
2402 * \sa SDL_RenderFillRects
2403 * \sa SDL_RenderLine
2404 * \sa SDL_RenderLines
2405 * \sa SDL_RenderPoint
2406 * \sa SDL_RenderPoints
2407 * \sa SDL_RenderRect
2408 * \sa SDL_RenderRects
2409 * \sa SDL_SetRenderDrawBlendMode
2410 * \sa SDL_SetRenderDrawColor
2411 */
2412extern SDL_DECLSPEC bool SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
2413
2414/**
2415 * Destroy the specified texture.
2416 *
2417 * Passing NULL or an otherwise invalid texture will set the SDL error message
2418 * to "Invalid texture".
2419 *
2420 * \param texture the texture to destroy.
2421 *
2422 * \threadsafety This function should only be called on the main thread.
2423 *
2424 * \since This function is available since SDL 3.2.0.
2425 *
2426 * \sa SDL_CreateTexture
2427 * \sa SDL_CreateTextureFromSurface
2428 */
2429extern SDL_DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
2430
2431/**
2432 * Destroy the rendering context for a window and free all associated
2433 * textures.
2434 *
2435 * This should be called before destroying the associated window.
2436 *
2437 * \param renderer the rendering context.
2438 *
2439 * \threadsafety This function should only be called on the main thread.
2440 *
2441 * \since This function is available since SDL 3.2.0.
2442 *
2443 * \sa SDL_CreateRenderer
2444 */
2445extern SDL_DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
2446
2447/**
2448 * Force the rendering context to flush any pending commands and state.
2449 *
2450 * You do not need to (and in fact, shouldn't) call this function unless you
2451 * are planning to call into OpenGL/Direct3D/Metal/whatever directly, in
2452 * addition to using an SDL_Renderer.
2453 *
2454 * This is for a very-specific case: if you are using SDL's render API, and
2455 * you plan to make OpenGL/D3D/whatever calls in addition to SDL render API
2456 * calls. If this applies, you should call this function between calls to
2457 * SDL's render API and the low-level API you're using in cooperation.
2458 *
2459 * In all other cases, you can ignore this function.
2460 *
2461 * This call makes SDL flush any pending rendering work it was queueing up to
2462 * do later in a single batch, and marks any internal cached state as invalid,
2463 * so it'll prepare all its state again later, from scratch.
2464 *
2465 * This means you do not need to save state in your rendering code to protect
2466 * the SDL renderer. However, there lots of arbitrary pieces of Direct3D and
2467 * OpenGL state that can confuse things; you should use your best judgment and
2468 * be prepared to make changes if specific state needs to be protected.
2469 *
2470 * \param renderer the rendering context.
2471 * \returns true on success or false on failure; call SDL_GetError() for more
2472 * information.
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 */
2478extern SDL_DECLSPEC bool SDLCALL SDL_FlushRenderer(SDL_Renderer *renderer);
2479
2480/**
2481 * Get the CAMetalLayer associated with the given Metal renderer.
2482 *
2483 * This function returns `void *`, so SDL doesn't have to include Metal's
2484 * headers, but it can be safely cast to a `CAMetalLayer *`.
2485 *
2486 * \param renderer the renderer to query.
2487 * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
2488 * Metal renderer.
2489 *
2490 * \threadsafety This function should only be called on the main thread.
2491 *
2492 * \since This function is available since SDL 3.2.0.
2493 *
2494 * \sa SDL_GetRenderMetalCommandEncoder
2495 */
2496extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalLayer(SDL_Renderer *renderer);
2497
2498/**
2499 * Get the Metal command encoder for the current frame.
2500 *
2501 * This function returns `void *`, so SDL doesn't have to include Metal's
2502 * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
2503 *
2504 * This will return NULL if Metal refuses to give SDL a drawable to render to,
2505 * which might happen if the window is hidden/minimized/offscreen. This
2506 * doesn't apply to command encoders for render targets, just the window's
2507 * backbuffer. Check your return values!
2508 *
2509 * \param renderer the renderer to query.
2510 * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
2511 * renderer isn't a Metal renderer or there was an error.
2512 *
2513 * \threadsafety This function should only be called on the main thread.
2514 *
2515 * \since This function is available since SDL 3.2.0.
2516 *
2517 * \sa SDL_GetRenderMetalLayer
2518 */
2519extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalCommandEncoder(SDL_Renderer *renderer);
2520
2521
2522/**
2523 * Add a set of synchronization semaphores for the current frame.
2524 *
2525 * The Vulkan renderer will wait for `wait_semaphore` before submitting
2526 * rendering commands and signal `signal_semaphore` after rendering commands
2527 * are complete for this frame.
2528 *
2529 * This should be called each frame that you want semaphore synchronization.
2530 * The Vulkan renderer may have multiple frames in flight on the GPU, so you
2531 * should have multiple semaphores that are used for synchronization. Querying
2532 * SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the
2533 * maximum number of semaphores you'll need.
2534 *
2535 * \param renderer the rendering context.
2536 * \param wait_stage_mask the VkPipelineStageFlags for the wait.
2537 * \param wait_semaphore a VkSempahore to wait on before rendering the current
2538 * frame, or 0 if not needed.
2539 * \param signal_semaphore a VkSempahore that SDL will signal when rendering
2540 * for the current frame is complete, or 0 if not
2541 * needed.
2542 * \returns true on success or false on failure; call SDL_GetError() for more
2543 * information.
2544 *
2545 * \threadsafety It is **NOT** safe to call this function from two threads at
2546 * once.
2547 *
2548 * \since This function is available since SDL 3.2.0.
2549 */
2550extern SDL_DECLSPEC bool SDLCALL SDL_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore);
2551
2552/**
2553 * Toggle VSync of the given renderer.
2554 *
2555 * When a renderer is created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED.
2556 *
2557 * The `vsync` parameter can be 1 to synchronize present with every vertical
2558 * refresh, 2 to synchronize present with every second vertical refresh, etc.,
2559 * SDL_RENDERER_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or
2560 * SDL_RENDERER_VSYNC_DISABLED to disable. Not every value is supported by
2561 * every driver, so you should check the return value to see whether the
2562 * requested setting is supported.
2563 *
2564 * \param renderer the renderer to toggle.
2565 * \param vsync the vertical refresh sync interval.
2566 * \returns true on success or false on failure; call SDL_GetError() for more
2567 * information.
2568 *
2569 * \threadsafety This function should only be called on the main thread.
2570 *
2571 * \since This function is available since SDL 3.2.0.
2572 *
2573 * \sa SDL_GetRenderVSync
2574 */
2575extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync);
2576
2577#define SDL_RENDERER_VSYNC_DISABLED 0
2578#define SDL_RENDERER_VSYNC_ADAPTIVE (-1)
2579
2580/**
2581 * Get VSync of the given renderer.
2582 *
2583 * \param renderer the renderer to toggle.
2584 * \param vsync an int filled with the current vertical refresh sync interval.
2585 * See SDL_SetRenderVSync() for the meaning of the value.
2586 * \returns true on success or false on failure; call SDL_GetError() for more
2587 * information.
2588 *
2589 * \threadsafety This function should only be called on the main thread.
2590 *
2591 * \since This function is available since SDL 3.2.0.
2592 *
2593 * \sa SDL_SetRenderVSync
2594 */
2595extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync);
2596
2597/**
2598 * The size, in pixels, of a single SDL_RenderDebugText() character.
2599 *
2600 * The font is monospaced and square, so this applies to all characters.
2601 *
2602 * \since This macro is available since SDL 3.2.0.
2603 *
2604 * \sa SDL_RenderDebugText
2605 */
2606#define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE 8
2607
2608/**
2609 * Draw debug text to an SDL_Renderer.
2610 *
2611 * This function will render a string of text to an SDL_Renderer. Note that
2612 * this is a convenience function for debugging, with severe limitations, and
2613 * not intended to be used for production apps and games.
2614 *
2615 * Among these limitations:
2616 *
2617 * - It accepts UTF-8 strings, but will only renders ASCII characters.
2618 * - It has a single, tiny size (8x8 pixels). One can use logical presentation
2619 * or scaling to adjust it, but it will be blurry.
2620 * - It uses a simple, hardcoded bitmap font. It does not allow different font
2621 * selections and it does not support truetype, for proper scaling.
2622 * - It does no word-wrapping and does not treat newline characters as a line
2623 * break. If the text goes out of the window, it's gone.
2624 *
2625 * For serious text rendering, there are several good options, such as
2626 * SDL_ttf, stb_truetype, or other external libraries.
2627 *
2628 * On first use, this will create an internal texture for rendering glyphs.
2629 * This texture will live until the renderer is destroyed.
2630 *
2631 * The text is drawn in the color specified by SDL_SetRenderDrawColor().
2632 *
2633 * \param renderer the renderer which should draw a line of text.
2634 * \param x the x coordinate where the top-left corner of the text will draw.
2635 * \param y the y coordinate where the top-left corner of the text will draw.
2636 * \param str the string to render.
2637 * \returns true on success or false on failure; call SDL_GetError() for more
2638 * information.
2639 *
2640 * \threadsafety This function should only be called on the main thread.
2641 *
2642 * \since This function is available since SDL 3.2.0.
2643 *
2644 * \sa SDL_RenderDebugTextFormat
2645 * \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE
2646 */
2647extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugText(SDL_Renderer *renderer, float x, float y, const char *str);
2648
2649/**
2650 * Draw debug text to an SDL_Renderer.
2651 *
2652 * This function will render a printf()-style format string to a renderer.
2653 * Note that this is a convinence function for debugging, with severe
2654 * limitations, and is not intended to be used for production apps and games.
2655 *
2656 * For the full list of limitations and other useful information, see
2657 * SDL_RenderDebugText.
2658 *
2659 * \param renderer the renderer which should draw the text.
2660 * \param x the x coordinate where the top-left corner of the text will draw.
2661 * \param y the y coordinate where the top-left corner of the text will draw.
2662 * \param fmt the format string to draw.
2663 * \param ... additional parameters matching % tokens in the `fmt` string, if
2664 * any.
2665 * \returns true on success or false on failure; call SDL_GetError() for more
2666 * information.
2667 *
2668 * \threadsafety This function should only be called on the main thread.
2669 *
2670 * \since This function is available since SDL 3.2.0.
2671 *
2672 * \sa SDL_RenderDebugText
2673 * \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE
2674 */
2675extern 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);
2676
2677/**
2678 * Set default scale mode for new textures for given renderer.
2679 *
2680 * When a renderer is created, scale_mode defaults to SDL_SCALEMODE_LINEAR.
2681 *
2682 * \param renderer the renderer to update.
2683 * \param scale_mode the scale mode to change to for new textures.
2684 * \returns true on success or false on failure; call SDL_GetError() for more
2685 * information.
2686 *
2687 * \threadsafety This function should only be called on the main thread.
2688 *
2689 * \since This function is available since SDL 3.4.0.
2690 *
2691 * \sa SDL_GetDefaultTextureScaleMode
2692 */
2693extern SDL_DECLSPEC bool SDLCALL SDL_SetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode scale_mode);
2694
2695/**
2696 * Get default texture scale mode of the given renderer.
2697 *
2698 * \param renderer the renderer to get data from.
2699 * \param scale_mode a SDL_ScaleMode filled with current default scale mode.
2700 * See SDL_SetDefaultTextureScaleMode() for the meaning of
2701 * the value.
2702 * \returns true on success or false on failure; call SDL_GetError() for more
2703 * information.
2704 *
2705 * \threadsafety This function should only be called on the main thread.
2706 *
2707 * \since This function is available since SDL 3.4.0.
2708 *
2709 * \sa SDL_SetDefaultTextureScaleMode
2710 */
2711extern SDL_DECLSPEC bool SDLCALL SDL_GetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode *scale_mode);
2712
2713/**
2714 * GPU render state description.
2715 *
2716 * This structure should be initialized using SDL_INIT_INTERFACE().
2717 *
2718 * \since This struct is available since SDL 3.4.0.
2719 *
2720 * \sa SDL_CreateGPURenderState
2721 */
2722typedef struct SDL_GPURenderStateDesc
2723{
2724 Uint32 version; /**< the version of this interface */
2725
2726 SDL_GPUShader *fragment_shader; /**< The fragment shader to use when this render state is active */
2727
2728 Sint32 num_sampler_bindings; /**< The number of additional fragment samplers to bind when this render state is active */
2729 const SDL_GPUTextureSamplerBinding *sampler_bindings; /**< Additional fragment samplers to bind when this render state is active */
2730
2731 Sint32 num_storage_textures; /**< The number of storage textures to bind when this render state is active */
2732 SDL_GPUTexture *const *storage_textures; /**< Storage textures to bind when this render state is active */
2733
2734 Sint32 num_storage_buffers; /**< The number of storage buffers to bind when this render state is active */
2735 SDL_GPUBuffer *const *storage_buffers; /**< Storage buffers to bind when this render state is active */
2736} SDL_GPURenderStateDesc;
2737
2738/* Check the size of SDL_GPURenderStateDesc
2739 *
2740 * If this assert fails, either the compiler is padding to an unexpected size,
2741 * or the interface has been updated and this should be updated to match and
2742 * the code using this interface should be updated to handle the old version.
2743 */
2744SDL_COMPILE_TIME_ASSERT(SDL_GPURenderStateDesc_SIZE,
2745 (sizeof(void *) == 4 && sizeof(SDL_GPURenderStateDesc) == 32) ||
2746 (sizeof(void *) == 8 && sizeof(SDL_GPURenderStateDesc) == 64));
2747
2748/**
2749 * A custom GPU render state.
2750 *
2751 * \since This struct is available since SDL 3.4.0.
2752 *
2753 * \sa SDL_CreateGPURenderState
2754 * \sa SDL_SetGPURenderStateFragmentUniforms
2755 * \sa SDL_SetRenderGPUState
2756 * \sa SDL_DestroyGPURenderState
2757 */
2758typedef struct SDL_GPURenderState SDL_GPURenderState;
2759
2760/**
2761 * Create custom GPU render state.
2762 *
2763 * \param renderer the renderer to use.
2764 * \param desc GPU render state description, initialized using
2765 * SDL_INIT_INTERFACE().
2766 * \returns a custom GPU render state or NULL on failure; call SDL_GetError()
2767 * for more information.
2768 *
2769 * \threadsafety This function should be called on the thread that created the
2770 * renderer.
2771 *
2772 * \since This function is available since SDL 3.4.0.
2773 *
2774 * \sa SDL_SetGPURenderStateFragmentUniforms
2775 * \sa SDL_SetRenderGPUState
2776 * \sa SDL_DestroyGPURenderState
2777 */
2778extern SDL_DECLSPEC SDL_GPURenderState * SDLCALL SDL_CreateGPURenderState(SDL_Renderer *renderer, SDL_GPURenderStateDesc *desc);
2779
2780/**
2781 * Set fragment shader uniform variables in a custom GPU render state.
2782 *
2783 * The data is copied and will be pushed using
2784 * SDL_PushGPUFragmentUniformData() during draw call execution.
2785 *
2786 * \param state the state to modify.
2787 * \param slot_index the fragment uniform slot to push data to.
2788 * \param data client data to write.
2789 * \param length the length of the data to write.
2790 * \returns true on success or false on failure; call SDL_GetError() for more
2791 * information.
2792 *
2793 * \threadsafety This function should be called on the thread that created the
2794 * renderer.
2795 *
2796 * \since This function is available since SDL 3.4.0.
2797 */
2798extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderStateFragmentUniforms(SDL_GPURenderState *state, Uint32 slot_index, const void *data, Uint32 length);
2799
2800/**
2801 * Set custom GPU render state.
2802 *
2803 * This function sets custom GPU render state for subsequent draw calls. This
2804 * allows using custom shaders with the GPU renderer.
2805 *
2806 * \param renderer the renderer to use.
2807 * \param state the state to to use, or NULL to clear custom GPU render state.
2808 * \returns true on success or false on failure; call SDL_GetError() for more
2809 * information.
2810 *
2811 * \threadsafety This function should be called on the thread that created the
2812 * renderer.
2813 *
2814 * \since This function is available since SDL 3.4.0.
2815 */
2816extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderGPUState(SDL_Renderer *renderer, SDL_GPURenderState *state);
2817
2818/**
2819 * Destroy custom GPU render state.
2820 *
2821 * \param state the state to destroy.
2822 *
2823 * \threadsafety This function should be called on the thread that created the
2824 * renderer.
2825 *
2826 * \since This function is available since SDL 3.4.0.
2827 *
2828 * \sa SDL_CreateGPURenderState
2829 */
2830extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPURenderState(SDL_GPURenderState *state);
2831
2832/* Ends C function definitions when using C++ */
2833#ifdef __cplusplus
2834}
2835#endif
2836#include <SDL3/SDL_close_code.h>
2837
2838#endif /* SDL_render_h_ */
2839