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