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 APIs 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. For NV12 style
807 * textures this is the single two plane VkImage holding both the Y and UV
808 * planes, and for YUV style textures it is the VkImage holding the Y plane.
809 * - `SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_U_NUMBER`: the VkImage associated
810 * with the U plane of a YUV texture, if you want to wrap an existing
811 * texture.
812 * - `SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_V_NUMBER`: the VkImage associated
813 * with the V plane of a YUV texture, if you want to wrap an existing
814 * texture.
815 * - `SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER`: the VkImageLayout for the
816 * VkImage, defaults to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL.
817 * - `SDL_PROP_TEXTURE_CREATE_VULKAN_USAGE_NUMBER`: additional VK_IMAGE_USAGE
818 * bits that should be used when creating the texture. VkImage, defaults to
819 * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL.
820 * - `SDL_PROP_TEXTURE_CREATE_VULKAN_ANDROID_HARDWARE_BUFFER_POINTER`: the
821 * AHardwareBuffer to sample from, if you want to use an existing Android
822 * hardware buffer as the texture. You must use SDL_PIXELFORMAT_EXTERNAL_OES
823 * for the texture format. You can't directly update the texture or use it
824 * as a render target. If the Android buffer contents change, you must
825 * recreate the texture to pick up the changes. The texture holds a
826 * reference to the buffer, so you can release your own reference once the
827 * texture has been created.
828 *
829 * With the GPU renderer:
830 *
831 * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER`: the SDL_GPUTexture
832 * associated with the texture, if you want to wrap an existing texture.
833 * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_NUMBER`: the SDL_GPUTexture
834 * associated with the UV plane of an NV12 texture, if you want to wrap an
835 * existing texture.
836 * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_NUMBER`: the SDL_GPUTexture
837 * associated with the U plane of a YUV texture, if you want to wrap an
838 * existing texture.
839 * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_NUMBER`: the SDL_GPUTexture
840 * associated with the V plane of a YUV texture, if you want to wrap an
841 * existing texture.
842 *
843 * \param renderer the rendering context.
844 * \param props the properties to use.
845 * \returns the created texture or NULL on failure; call SDL_GetError() for
846 * more information.
847 *
848 * \threadsafety This function should only be called on the main thread.
849 *
850 * \since This function is available since SDL 3.2.0.
851 *
852 * \sa SDL_CreateProperties
853 * \sa SDL_CreateTexture
854 * \sa SDL_CreateTextureFromSurface
855 * \sa SDL_DestroyTexture
856 * \sa SDL_GetTextureSize
857 * \sa SDL_UpdateTexture
858 */
860
861#define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace"
862#define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format"
863#define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access"
864#define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width"
865#define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height"
866#define SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER "SDL.texture.create.palette"
867#define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point"
868#define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom"
869#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture"
870#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u"
871#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v"
872#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture"
873#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u"
874#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v"
875#define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer"
876#define SDL_PROP_TEXTURE_CREATE_METAL_TEXTURE_POINTER "SDL.texture.create.metal.texture"
877#define SDL_PROP_TEXTURE_CREATE_METAL_TEXTURE_UV_POINTER "SDL.texture.create.metal.texture_uv"
878#define SDL_PROP_TEXTURE_CREATE_METAL_TEXTURE_U_POINTER "SDL.texture.create.metal.texture_u"
879#define SDL_PROP_TEXTURE_CREATE_METAL_TEXTURE_V_POINTER "SDL.texture.create.metal.texture_v"
880#define SDL_PROP_TEXTURE_CREATE_METAL_TEXTURE_USAGE_NUMBER "SDL.texture.create.metal.texture_usage"
881#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture"
882#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv"
883#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u"
884#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v"
885#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture"
886#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv"
887#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u"
888#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v"
889#define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture"
890#define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_U_NUMBER "SDL.texture.create.vulkan.texture_u"
891#define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_V_NUMBER "SDL.texture.create.vulkan.texture_v"
892#define SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER "SDL.texture.create.vulkan.layout"
893#define SDL_PROP_TEXTURE_CREATE_VULKAN_USAGE_NUMBER "SDL.texture.create.vulkan.usage"
894#define SDL_PROP_TEXTURE_CREATE_VULKAN_ANDROID_HARDWARE_BUFFER_POINTER "SDL.texture.create.vulkan.android_hardware_buffer"
895#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER "SDL.texture.create.gpu.texture"
896#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_POINTER "SDL.texture.create.gpu.texture_uv"
897#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_POINTER "SDL.texture.create.gpu.texture_u"
898#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_POINTER "SDL.texture.create.gpu.texture_v"
899
900/**
901 * Get the properties associated with a texture.
902 *
903 * The following read-only properties are provided by SDL:
904 *
905 * - `SDL_PROP_TEXTURE_COLORSPACE_NUMBER`: an SDL_Colorspace value describing
906 * the texture colorspace.
907 * - `SDL_PROP_TEXTURE_FORMAT_NUMBER`: one of the enumerated values in
908 * SDL_PixelFormat.
909 * - `SDL_PROP_TEXTURE_ACCESS_NUMBER`: one of the enumerated values in
910 * SDL_TextureAccess.
911 * - `SDL_PROP_TEXTURE_WIDTH_NUMBER`: the width of the texture in pixels.
912 * - `SDL_PROP_TEXTURE_HEIGHT_NUMBER`: the height of the texture in pixels.
913 * - `SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point
914 * textures, this defines the value of 100% diffuse white, with higher
915 * values being displayed in the High Dynamic Range headroom. This defaults
916 * to 100 for HDR10 textures and 1.0 for other textures.
917 * - `SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point
918 * textures, this defines the maximum dynamic range used by the content, in
919 * terms of the SDR white point. If this is defined, any values outside the
920 * range supported by the display will be scaled into the available HDR
921 * headroom, otherwise they are clipped. This defaults to 1.0 for SDR
922 * textures, 4.0 for HDR10 textures, and no default for floating point
923 * textures.
924 *
925 * With the direct3d11 renderer:
926 *
927 * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D associated
928 * with the texture
929 * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D
930 * associated with the U plane of a YUV texture
931 * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D
932 * associated with the V plane of a YUV texture
933 *
934 * With the direct3d12 renderer:
935 *
936 * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER`: the ID3D12Resource associated
937 * with the texture
938 * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource associated
939 * with the U plane of a YUV texture
940 * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource associated
941 * with the V plane of a YUV texture
942 *
943 * With the metal renderer:
944 *
945 * - `SDL_PROP_TEXTURE_METAL_TEXTURE_POINTER`: the MTLTexture associated with
946 * the texture
947 * - `SDL_PROP_TEXTURE_METAL_TEXTURE_UV_POINTER`: the MTLTexture associated
948 * with the UV plane of an NV12 texture
949 * - `SDL_PROP_TEXTURE_METAL_TEXTURE_U_POINTER`: the MTLTexture associated
950 * with the U plane of a YUV texture style texture
951 * - `SDL_PROP_TEXTURE_METAL_TEXTURE_V_POINTER`: the MTLTexture associated
952 * with the V plane of a YUV texture
953 *
954 * With the vulkan renderer:
955 *
956 * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER`: the VkImage associated with the
957 * texture. For NV12 style textures this is the single two plane VkImage
958 * holding both the Y and UV planes, and for YUV style textures it is the
959 * VkImage holding the Y plane.
960 * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_U_NUMBER`: the VkImage associated with
961 * the U plane of a YUV texture
962 * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_V_NUMBER`: the VkImage associated with
963 * the V plane of a YUV texture
964 *
965 * With the opengl renderer:
966 *
967 * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER`: the GLuint texture associated
968 * with the texture
969 * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture
970 * associated with the UV plane of an NV12 texture
971 * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture associated
972 * with the U plane of a YUV texture
973 * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture associated
974 * with the V plane of a YUV texture
975 * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER`: the GLenum for the
976 * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_RECTANGLE_ARB`, etc)
977 * - `SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT`: the texture coordinate width of
978 * the texture (0.0 - 1.0)
979 * - `SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT`: the texture coordinate height of
980 * the texture (0.0 - 1.0)
981 *
982 * With the opengles2 renderer:
983 *
984 * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
985 * associated with the texture
986 * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture
987 * associated with the UV plane of an NV12 texture
988 * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture
989 * associated with the U plane of a YUV texture
990 * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture
991 * associated with the V plane of a YUV texture
992 * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`: the GLenum for the
993 * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc)
994 *
995 * With the gpu renderer:
996 *
997 * - `SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER`: the SDL_GPUTexture associated
998 * with the texture
999 * - `SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER`: the SDL_GPUTexture associated
1000 * with the UV plane of an NV12 texture
1001 * - `SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER`: the SDL_GPUTexture associated
1002 * with the U plane of a YUV texture
1003 * - `SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER`: the SDL_GPUTexture associated
1004 * with the V plane of a YUV texture
1005 *
1006 * \param texture the texture to query.
1007 * \returns a valid property ID on success or 0 on failure; call
1008 * SDL_GetError() for more information.
1009 *
1010 * \threadsafety It is safe to call this function from any thread.
1011 *
1012 * \since This function is available since SDL 3.2.0.
1013 */
1014extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture);
1015
1016#define SDL_PROP_TEXTURE_COLORSPACE_NUMBER "SDL.texture.colorspace"
1017#define SDL_PROP_TEXTURE_FORMAT_NUMBER "SDL.texture.format"
1018#define SDL_PROP_TEXTURE_ACCESS_NUMBER "SDL.texture.access"
1019#define SDL_PROP_TEXTURE_WIDTH_NUMBER "SDL.texture.width"
1020#define SDL_PROP_TEXTURE_HEIGHT_NUMBER "SDL.texture.height"
1021#define SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT "SDL.texture.SDR_white_point"
1022#define SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT "SDL.texture.HDR_headroom"
1023#define SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER "SDL.texture.d3d11.texture"
1024#define SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER "SDL.texture.d3d11.texture_u"
1025#define SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER "SDL.texture.d3d11.texture_v"
1026#define SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER "SDL.texture.d3d12.texture"
1027#define SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER "SDL.texture.d3d12.texture_u"
1028#define SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER "SDL.texture.d3d12.texture_v"
1029#define SDL_PROP_TEXTURE_METAL_TEXTURE_POINTER "SDL.texture.metal.texture"
1030#define SDL_PROP_TEXTURE_METAL_TEXTURE_UV_POINTER "SDL.texture.metal.texture_uv"
1031#define SDL_PROP_TEXTURE_METAL_TEXTURE_U_POINTER "SDL.texture.metal.texture_u"
1032#define SDL_PROP_TEXTURE_METAL_TEXTURE_V_POINTER "SDL.texture.metal.texture_v"
1033#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER "SDL.texture.opengl.texture"
1034#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.opengl.texture_uv"
1035#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.opengl.texture_u"
1036#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.opengl.texture_v"
1037#define SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER "SDL.texture.opengl.target"
1038#define SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT "SDL.texture.opengl.tex_w"
1039#define SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT "SDL.texture.opengl.tex_h"
1040#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.opengles2.texture"
1041#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.opengles2.texture_uv"
1042#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.opengles2.texture_u"
1043#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v"
1044#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER "SDL.texture.opengles2.target"
1045#define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER "SDL.texture.vulkan.texture"
1046#define SDL_PROP_TEXTURE_VULKAN_TEXTURE_U_NUMBER "SDL.texture.vulkan.texture_u"
1047#define SDL_PROP_TEXTURE_VULKAN_TEXTURE_V_NUMBER "SDL.texture.vulkan.texture_v"
1048#define SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER "SDL.texture.gpu.texture"
1049#define SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER "SDL.texture.gpu.texture_uv"
1050#define SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER "SDL.texture.gpu.texture_u"
1051#define SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER "SDL.texture.gpu.texture_v"
1052
1053/**
1054 * Get the renderer that created an SDL_Texture.
1055 *
1056 * \param texture the texture to query.
1057 * \returns a pointer to the SDL_Renderer that created the texture, or NULL on
1058 * failure; call SDL_GetError() for more information.
1059 *
1060 * \threadsafety It is safe to call this function from any thread.
1061 *
1062 * \since This function is available since SDL 3.2.0.
1063 */
1064extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRendererFromTexture(SDL_Texture *texture);
1065
1066/**
1067 * Get the size of a texture, as floating point values.
1068 *
1069 * \param texture the texture to query.
1070 * \param w a pointer filled in with the width of the texture in pixels. This
1071 * argument can be NULL if you don't need this information.
1072 * \param h a pointer filled in with the height of the texture in pixels. This
1073 * argument can be NULL if you don't need this information.
1074 * \returns true on success or false on failure; call SDL_GetError() for more
1075 * information.
1076 *
1077 * \threadsafety This function should only be called on the main thread.
1078 *
1079 * \since This function is available since SDL 3.2.0.
1080 */
1081extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h);
1082
1083/**
1084 * Set the palette used by a texture.
1085 *
1086 * Setting the palette keeps an internal reference to the palette, which can
1087 * be safely destroyed afterwards.
1088 *
1089 * A single palette can be shared with many textures.
1090 *
1091 * \param texture the texture to update.
1092 * \param palette the SDL_Palette structure to use.
1093 * \returns true on success or false on failure; call SDL_GetError() for more
1094 * information.
1095 *
1096 * \threadsafety This function should only be called on the main thread.
1097 *
1098 * \since This function is available since SDL 3.4.0.
1099 *
1100 * \sa SDL_CreatePalette
1101 * \sa SDL_GetTexturePalette
1102 */
1103extern SDL_DECLSPEC bool SDLCALL SDL_SetTexturePalette(SDL_Texture *texture, SDL_Palette *palette);
1104
1105/**
1106 * Get the palette used by a texture.
1107 *
1108 * \param texture the texture to query.
1109 * \returns a pointer to the palette used by the texture, or NULL if there is
1110 * no palette used.
1111 *
1112 * \threadsafety This function should only be called on the main thread.
1113 *
1114 * \since This function is available since SDL 3.4.0.
1115 *
1116 * \sa SDL_SetTexturePalette
1117 */
1118extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetTexturePalette(SDL_Texture *texture);
1119
1120/**
1121 * Set an additional color value multiplied into render copy operations.
1122 *
1123 * When this texture is rendered, during the copy operation each source color
1124 * channel is modulated by the appropriate color value according to the
1125 * following formula:
1126 *
1127 * `srcC = srcC * (color / 255)`
1128 *
1129 * Color modulation is not always supported by the renderer; it will return
1130 * false if color modulation is not supported.
1131 *
1132 * \param texture the texture to update.
1133 * \param r the red color value multiplied into copy operations.
1134 * \param g the green color value multiplied into copy operations.
1135 * \param b the blue color value multiplied into copy operations.
1136 * \returns true on success or false on failure; call SDL_GetError() for more
1137 * information.
1138 *
1139 * \threadsafety This function should only be called on the main thread.
1140 *
1141 * \since This function is available since SDL 3.2.0.
1142 *
1143 * \sa SDL_GetTextureColorMod
1144 * \sa SDL_SetTextureAlphaMod
1145 * \sa SDL_SetTextureColorModFloat
1146 */
1147extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b);
1148
1149
1150/**
1151 * Set an additional color value multiplied into render copy operations.
1152 *
1153 * When this texture is rendered, during the copy operation each source color
1154 * channel is modulated by the appropriate color value according to the
1155 * following formula:
1156 *
1157 * `srcC = srcC * color`
1158 *
1159 * Color modulation is not always supported by the renderer; it will return
1160 * false if color modulation is not supported.
1161 *
1162 * \param texture the texture to update.
1163 * \param r the red color value multiplied into copy operations.
1164 * \param g the green color value multiplied into copy operations.
1165 * \param b the blue color value multiplied into copy operations.
1166 * \returns true on success or false on failure; call SDL_GetError() for more
1167 * information.
1168 *
1169 * \threadsafety This function should only be called on the main thread.
1170 *
1171 * \since This function is available since SDL 3.2.0.
1172 *
1173 * \sa SDL_GetTextureColorModFloat
1174 * \sa SDL_SetTextureAlphaModFloat
1175 * \sa SDL_SetTextureColorMod
1176 */
1177extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorModFloat(SDL_Texture *texture, float r, float g, float b);
1178
1179
1180/**
1181 * Get the additional color value multiplied into render copy operations.
1182 *
1183 * \param texture the texture to query.
1184 * \param r a pointer filled in with the current red color value.
1185 * \param g a pointer filled in with the current green color value.
1186 * \param b a pointer filled in with the current blue color value.
1187 * \returns true on success or false on failure; call SDL_GetError() for more
1188 * information.
1189 *
1190 * \threadsafety This function should only be called on the main thread.
1191 *
1192 * \since This function is available since SDL 3.2.0.
1193 *
1194 * \sa SDL_GetTextureAlphaMod
1195 * \sa SDL_GetTextureColorModFloat
1196 * \sa SDL_SetTextureColorMod
1197 */
1198extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b);
1199
1200/**
1201 * Get the additional color value multiplied into render copy operations.
1202 *
1203 * \param texture the texture to query.
1204 * \param r a pointer filled in with the current red color value.
1205 * \param g a pointer filled in with the current green color value.
1206 * \param b a pointer filled in with the current blue color value.
1207 * \returns true on success or false on failure; call SDL_GetError() for more
1208 * information.
1209 *
1210 * \threadsafety This function should only be called on the main thread.
1211 *
1212 * \since This function is available since SDL 3.2.0.
1213 *
1214 * \sa SDL_GetTextureAlphaModFloat
1215 * \sa SDL_GetTextureColorMod
1216 * \sa SDL_SetTextureColorModFloat
1217 */
1218extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorModFloat(SDL_Texture *texture, float *r, float *g, float *b);
1219
1220/**
1221 * Set an additional alpha value multiplied into render copy operations.
1222 *
1223 * When this texture is rendered, during the copy operation the source alpha
1224 * value is modulated by this alpha value according to the following formula:
1225 *
1226 * `srcA = srcA * (alpha / 255)`
1227 *
1228 * Alpha modulation is not always supported by the renderer; it will return
1229 * false if alpha modulation is not supported.
1230 *
1231 * \param texture the texture to update.
1232 * \param alpha the source alpha value multiplied into copy operations.
1233 * \returns true on success or false on failure; call SDL_GetError() for more
1234 * information.
1235 *
1236 * \threadsafety This function should only be called on the main thread.
1237 *
1238 * \since This function is available since SDL 3.2.0.
1239 *
1240 * \sa SDL_GetTextureAlphaMod
1241 * \sa SDL_SetTextureAlphaModFloat
1242 * \sa SDL_SetTextureColorMod
1243 */
1244extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha);
1245
1246/**
1247 * Set an additional alpha value multiplied into render copy operations.
1248 *
1249 * When this texture is rendered, during the copy operation the source alpha
1250 * value is modulated by this alpha value according to the following formula:
1251 *
1252 * `srcA = srcA * alpha`
1253 *
1254 * Alpha modulation is not always supported by the renderer; it will return
1255 * false if alpha modulation is not supported.
1256 *
1257 * \param texture the texture to update.
1258 * \param alpha the source alpha value multiplied into copy operations.
1259 * \returns true on success or false on failure; call SDL_GetError() for more
1260 * information.
1261 *
1262 * \threadsafety This function should only be called on the main thread.
1263 *
1264 * \since This function is available since SDL 3.2.0.
1265 *
1266 * \sa SDL_GetTextureAlphaModFloat
1267 * \sa SDL_SetTextureAlphaMod
1268 * \sa SDL_SetTextureColorModFloat
1269 */
1270extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaModFloat(SDL_Texture *texture, float alpha);
1271
1272/**
1273 * Get the additional alpha value multiplied into render copy operations.
1274 *
1275 * \param texture the texture to query.
1276 * \param alpha a pointer filled in with the current alpha value.
1277 * \returns true on success or false on failure; call SDL_GetError() for more
1278 * information.
1279 *
1280 * \threadsafety This function should only be called on the main thread.
1281 *
1282 * \since This function is available since SDL 3.2.0.
1283 *
1284 * \sa SDL_GetTextureAlphaModFloat
1285 * \sa SDL_GetTextureColorMod
1286 * \sa SDL_SetTextureAlphaMod
1287 */
1288extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha);
1289
1290/**
1291 * Get the additional alpha value multiplied into render copy operations.
1292 *
1293 * \param texture the texture to query.
1294 * \param alpha a pointer filled in with the current alpha value.
1295 * \returns true on success or false on failure; call SDL_GetError() for more
1296 * information.
1297 *
1298 * \threadsafety This function should only be called on the main thread.
1299 *
1300 * \since This function is available since SDL 3.2.0.
1301 *
1302 * \sa SDL_GetTextureAlphaMod
1303 * \sa SDL_GetTextureColorModFloat
1304 * \sa SDL_SetTextureAlphaModFloat
1305 */
1306extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaModFloat(SDL_Texture *texture, float *alpha);
1307
1308/**
1309 * Set the blend mode for a texture.
1310 *
1311 * This blend mode is used for any drawing that involves this texture.
1312 *
1313 * If the blend mode is not supported, the closest supported mode is chosen
1314 * and this function returns false.
1315 *
1316 * \param texture the texture to update.
1317 * \param blendMode the SDL_BlendMode to use for texture blending.
1318 * \returns true on success or false on failure; call SDL_GetError() for more
1319 * information.
1320 *
1321 * \threadsafety This function should only be called on the main thread.
1322 *
1323 * \since This function is available since SDL 3.2.0.
1324 *
1325 * \sa SDL_GetTextureBlendMode
1326 * \sa SDL_SetRenderDrawBlendMode
1327 */
1328extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode);
1329
1330/**
1331 * Get the blend mode used for texture copy operations.
1332 *
1333 * \param texture the texture to query.
1334 * \param blendMode a pointer filled in with the current SDL_BlendMode.
1335 * \returns true on success or false on failure; call SDL_GetError() for more
1336 * information.
1337 *
1338 * \threadsafety This function should only be called on the main thread.
1339 *
1340 * \since This function is available since SDL 3.2.0.
1341 *
1342 * \sa SDL_SetTextureBlendMode
1343 */
1344extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode);
1345
1346/**
1347 * Set the scale mode used for texture scale operations.
1348 *
1349 * The default texture scale mode is SDL_SCALEMODE_LINEAR.
1350 *
1351 * If the scale mode is not supported, the closest supported mode is chosen.
1352 *
1353 * \param texture the texture to update.
1354 * \param scaleMode the SDL_ScaleMode to use for texture scaling.
1355 * \returns true on success or false on failure; call SDL_GetError() for more
1356 * information.
1357 *
1358 * \threadsafety This function should only be called on the main thread.
1359 *
1360 * \since This function is available since SDL 3.2.0.
1361 *
1362 * \sa SDL_GetTextureScaleMode
1363 */
1364extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode);
1365
1366/**
1367 * Get the scale mode used for texture scale operations.
1368 *
1369 * \param texture the texture to query.
1370 * \param scaleMode a pointer filled in with the current scale mode.
1371 * \returns true on success or false on failure; call SDL_GetError() for more
1372 * information.
1373 *
1374 * \threadsafety This function should only be called on the main thread.
1375 *
1376 * \since This function is available since SDL 3.2.0.
1377 *
1378 * \sa SDL_SetTextureScaleMode
1379 */
1380extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode);
1381
1382/**
1383 * Update the given texture rectangle with new pixel data.
1384 *
1385 * The pixel data must be in the pixel format of the texture, which can be
1386 * queried using the SDL_PROP_TEXTURE_FORMAT_NUMBER property.
1387 *
1388 * This is a fairly slow function, intended for use with static textures that
1389 * do not change often.
1390 *
1391 * If the texture is intended to be updated often, it is preferred to create
1392 * the texture as streaming and use the locking functions referenced below.
1393 * While this function will work with streaming textures, for optimization
1394 * reasons you may not get the pixels back if you lock the texture afterward.
1395 *
1396 * \param texture the texture to update.
1397 * \param rect an SDL_Rect structure representing the area to update, or NULL
1398 * to update the entire texture.
1399 * \param pixels the raw pixel data in the format of the texture.
1400 * \param pitch the number of bytes in a row of pixel data, including padding
1401 * between lines.
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_LockTexture
1410 * \sa SDL_UnlockTexture
1411 * \sa SDL_UpdateNVTexture
1412 * \sa SDL_UpdateYUVTexture
1413 */
1414extern SDL_DECLSPEC bool SDLCALL SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch);
1415
1416/**
1417 * Update a rectangle within a planar YV12 or IYUV texture with new pixel
1418 * data.
1419 *
1420 * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
1421 * block of Y and U/V planes in the proper order, but this function is
1422 * available if your pixel data is not contiguous.
1423 *
1424 * \param texture the texture to update.
1425 * \param rect a pointer to the rectangle of pixels to update, or NULL to
1426 * update the entire texture.
1427 * \param Yplane the raw pixel data for the Y plane.
1428 * \param Ypitch the number of bytes between rows of pixel data for the Y
1429 * plane.
1430 * \param Uplane the raw pixel data for the U plane.
1431 * \param Upitch the number of bytes between rows of pixel data for the U
1432 * plane.
1433 * \param Vplane the raw pixel data for the V plane.
1434 * \param Vpitch the number of bytes between rows of pixel data for the V
1435 * plane.
1436 * \returns true on success or false on failure; call SDL_GetError() for more
1437 * information.
1438 *
1439 * \threadsafety This function should only be called on the main thread.
1440 *
1441 * \since This function is available since SDL 3.2.0.
1442 *
1443 * \sa SDL_UpdateNVTexture
1444 * \sa SDL_UpdateTexture
1445 */
1446extern SDL_DECLSPEC bool SDLCALL SDL_UpdateYUVTexture(SDL_Texture *texture,
1447 const SDL_Rect *rect,
1448 const Uint8 *Yplane, int Ypitch,
1449 const Uint8 *Uplane, int Upitch,
1450 const Uint8 *Vplane, int Vpitch);
1451
1452/**
1453 * Update a rectangle within a planar NV12 or NV21 texture with new pixels.
1454 *
1455 * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
1456 * block of NV12/21 planes in the proper order, but this function is available
1457 * if your pixel data is not contiguous.
1458 *
1459 * \param texture the texture to update.
1460 * \param rect a pointer to the rectangle of pixels to update, or NULL to
1461 * update the entire texture.
1462 * \param Yplane the raw pixel data for the Y plane.
1463 * \param Ypitch the number of bytes between rows of pixel data for the Y
1464 * plane.
1465 * \param UVplane the raw pixel data for the UV plane.
1466 * \param UVpitch the number of bytes between rows of pixel data for the UV
1467 * plane.
1468 * \returns true on success or false on failure; call SDL_GetError() for more
1469 * information.
1470 *
1471 * \threadsafety This function should only be called on the main thread.
1472 *
1473 * \since This function is available since SDL 3.2.0.
1474 *
1475 * \sa SDL_UpdateTexture
1476 * \sa SDL_UpdateYUVTexture
1477 */
1478extern SDL_DECLSPEC bool SDLCALL SDL_UpdateNVTexture(SDL_Texture *texture,
1479 const SDL_Rect *rect,
1480 const Uint8 *Yplane, int Ypitch,
1481 const Uint8 *UVplane, int UVpitch);
1482
1483/**
1484 * Lock a portion of the texture for **write-only** pixel access.
1485 *
1486 * As an optimization, the pixels made available for editing don't necessarily
1487 * contain the old texture data. This is a write-only operation, and if you
1488 * need to keep a copy of the texture data you should do that at the
1489 * application level.
1490 *
1491 * You must use SDL_UnlockTexture() to unlock the pixels and apply any
1492 * changes.
1493 *
1494 * \param texture the texture to lock for access, which was created with
1495 * `SDL_TEXTUREACCESS_STREAMING`.
1496 * \param rect an SDL_Rect structure representing the area to lock for access;
1497 * NULL to lock the entire texture.
1498 * \param pixels this is filled in with a pointer to the locked pixels,
1499 * appropriately offset by the locked area.
1500 * \param pitch this is filled in with the pitch of the locked pixels; the
1501 * pitch is the length of one row in bytes.
1502 * \returns true on success or false if the texture is not valid or was not
1503 * created with `SDL_TEXTUREACCESS_STREAMING`; call SDL_GetError()
1504 * for more information.
1505 *
1506 * \threadsafety This function should only be called on the main thread.
1507 *
1508 * \since This function is available since SDL 3.2.0.
1509 *
1510 * \sa SDL_LockTextureToSurface
1511 * \sa SDL_UnlockTexture
1512 */
1513extern SDL_DECLSPEC bool SDLCALL SDL_LockTexture(SDL_Texture *texture,
1514 const SDL_Rect *rect,
1515 void **pixels, int *pitch);
1516
1517/**
1518 * Lock a portion of the texture for **write-only** pixel access, and expose
1519 * it as a SDL surface.
1520 *
1521 * Besides providing an SDL_Surface instead of raw pixel data, this function
1522 * operates like SDL_LockTexture.
1523 *
1524 * As an optimization, the pixels made available for editing don't necessarily
1525 * contain the old texture data. This is a write-only operation, and if you
1526 * need to keep a copy of the texture data you should do that at the
1527 * application level.
1528 *
1529 * You must use SDL_UnlockTexture() to unlock the pixels and apply any
1530 * changes.
1531 *
1532 * The returned surface is freed internally after calling SDL_UnlockTexture()
1533 * or SDL_DestroyTexture(). The caller should not free it.
1534 *
1535 * \param texture the texture to lock for access, which must be created with
1536 * `SDL_TEXTUREACCESS_STREAMING`.
1537 * \param rect a pointer to the rectangle to lock for access. If the rect is
1538 * NULL, the entire texture will be locked.
1539 * \param surface a pointer to an SDL surface of size **rect**. Don't assume
1540 * any specific pixel content.
1541 * \returns true on success or false on failure; call SDL_GetError() for more
1542 * information.
1543 *
1544 * \threadsafety This function should only be called on the main thread.
1545 *
1546 * \since This function is available since SDL 3.2.0.
1547 *
1548 * \sa SDL_LockTexture
1549 * \sa SDL_UnlockTexture
1550 */
1551extern SDL_DECLSPEC bool SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Surface **surface);
1552
1553/**
1554 * Unlock a texture, uploading the changes to video memory, if needed.
1555 *
1556 * **Warning**: Please note that SDL_LockTexture() is intended to be
1557 * write-only; it will not guarantee the previous contents of the texture will
1558 * be provided. You must fully initialize any area of a texture that you lock
1559 * before unlocking it, as the pixels might otherwise be uninitialized memory.
1560 *
1561 * Which is to say: locking and immediately unlocking a texture can result in
1562 * corrupted textures, depending on the renderer in use.
1563 *
1564 * \param texture a texture locked by SDL_LockTexture().
1565 *
1566 * \threadsafety This function should only be called on the main thread.
1567 *
1568 * \since This function is available since SDL 3.2.0.
1569 *
1570 * \sa SDL_LockTexture
1571 */
1572extern SDL_DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture);
1573
1574/**
1575 * Set a texture as the current rendering target.
1576 *
1577 * The default render target is the window for which the renderer was created.
1578 * To stop rendering to a texture and render to the window again, call this
1579 * function with a NULL `texture`.
1580 *
1581 * Viewport, cliprect, scale, and logical presentation are unique to each
1582 * render target. Get and set functions for these states apply to the current
1583 * render target set by this function, and those states persist on each target
1584 * when the current render target changes.
1585 *
1586 * \param renderer the rendering context.
1587 * \param texture the targeted texture, which must be created with the
1588 * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the
1589 * window instead of a texture.
1590 * \returns true on success or false on failure; call SDL_GetError() for more
1591 * information.
1592 *
1593 * \threadsafety This function should only be called on the main thread.
1594 *
1595 * \since This function is available since SDL 3.2.0.
1596 *
1597 * \sa SDL_GetRenderTarget
1598 */
1599extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture);
1600
1601/**
1602 * Get the current render target.
1603 *
1604 * The default render target is the window for which the renderer was created,
1605 * and is reported a NULL here.
1606 *
1607 * \param renderer the rendering context.
1608 * \returns the current render target or NULL for the default render target.
1609 *
1610 * \threadsafety This function should only be called on the main thread.
1611 *
1612 * \since This function is available since SDL 3.2.0.
1613 *
1614 * \sa SDL_SetRenderTarget
1615 */
1617
1618/**
1619 * Set a device-independent resolution and presentation mode for rendering.
1620 *
1621 * This function sets the width and height of the logical rendering output.
1622 * The renderer will act as if the current render target is always the
1623 * requested dimensions, scaling to the actual resolution as necessary.
1624 *
1625 * This can be useful for games that expect a fixed size, but would like to
1626 * scale the output to whatever is available, regardless of how a user resizes
1627 * a window, or if the display is high DPI.
1628 *
1629 * Logical presentation can be used with both render target textures and the
1630 * renderer's window; the state is unique to each render target, and this
1631 * function sets the state for the current render target. It might be useful
1632 * to draw to a texture that matches the window dimensions with logical
1633 * presentation enabled, and then draw that texture across the entire window
1634 * with logical presentation disabled. Be careful not to render both with
1635 * logical presentation enabled, however, as this could produce
1636 * double-letterboxing, etc.
1637 *
1638 * You can disable logical coordinates by setting the mode to
1639 * SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel
1640 * resolution of the render target; it is safe to toggle logical presentation
1641 * during the rendering of a frame: perhaps most of the rendering is done to
1642 * specific dimensions but to make fonts look sharp, the app turns off logical
1643 * presentation while drawing text, for example.
1644 *
1645 * You can convert coordinates in an event into rendering coordinates using
1646 * SDL_ConvertEventToRenderCoordinates().
1647 *
1648 * \param renderer the rendering context.
1649 * \param w the width of the logical resolution.
1650 * \param h the height of the logical resolution.
1651 * \param mode the presentation mode used.
1652 * \returns true on success or false on failure; call SDL_GetError() for more
1653 * information.
1654 *
1655 * \threadsafety This function should only be called on the main thread.
1656 *
1657 * \since This function is available since SDL 3.2.0.
1658 *
1659 * \sa SDL_ConvertEventToRenderCoordinates
1660 * \sa SDL_GetRenderLogicalPresentation
1661 * \sa SDL_GetRenderLogicalPresentationRect
1662 */
1664
1665/**
1666 * Get device independent resolution and presentation mode for rendering.
1667 *
1668 * This function gets the width and height of the logical rendering output, or
1669 * 0 if a logical resolution is not enabled.
1670 *
1671 * Each render target has its own logical presentation state. This function
1672 * gets the state for the current render target.
1673 *
1674 * \param renderer the rendering context.
1675 * \param w an int filled with the logical presentation width.
1676 * \param h an int filled with the logical presentation height.
1677 * \param mode a variable filled with the logical presentation mode being
1678 * used.
1679 * \returns true on success or false on failure; call SDL_GetError() for more
1680 * information.
1681 *
1682 * \threadsafety This function should only be called on the main thread.
1683 *
1684 * \since This function is available since SDL 3.2.0.
1685 *
1686 * \sa SDL_SetRenderLogicalPresentation
1687 */
1688extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode);
1689
1690/**
1691 * Get the final presentation rectangle for rendering.
1692 *
1693 * This function returns the calculated rectangle used for logical
1694 * presentation, based on the presentation mode and output size. If logical
1695 * presentation is disabled, it will fill the rectangle with the output size,
1696 * in pixels.
1697 *
1698 * Each render target has its own logical presentation state. This function
1699 * gets the rectangle for the current render target.
1700 *
1701 * \param renderer the rendering context.
1702 * \param rect a pointer filled in with the final presentation rectangle, may
1703 * be NULL.
1704 * \returns true on success or false on failure; call SDL_GetError() for more
1705 * information.
1706 *
1707 * \threadsafety This function should only be called on the main thread.
1708 *
1709 * \since This function is available since SDL 3.2.0.
1710 *
1711 * \sa SDL_SetRenderLogicalPresentation
1712 */
1714
1715/**
1716 * Get a point in render coordinates when given a point in window coordinates.
1717 *
1718 * This takes into account several states:
1719 *
1720 * - The window dimensions.
1721 * - The logical presentation settings (SDL_SetRenderLogicalPresentation)
1722 * - The scale (SDL_SetRenderScale)
1723 * - The viewport (SDL_SetRenderViewport)
1724 *
1725 * \param renderer the rendering context.
1726 * \param window_x the x coordinate in window coordinates.
1727 * \param window_y the y coordinate in window coordinates.
1728 * \param x a pointer filled with the x coordinate in render coordinates.
1729 * \param y a pointer filled with the y coordinate in render coordinates.
1730 * \returns true on success or false on failure; call SDL_GetError() for more
1731 * information.
1732 *
1733 * \threadsafety This function should only be called on the main thread.
1734 *
1735 * \since This function is available since SDL 3.2.0.
1736 *
1737 * \sa SDL_SetRenderLogicalPresentation
1738 * \sa SDL_SetRenderScale
1739 */
1740extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y);
1741
1742/**
1743 * Get a point in window coordinates when given a point in render coordinates.
1744 *
1745 * This takes into account several states:
1746 *
1747 * - The window dimensions.
1748 * - The logical presentation settings (SDL_SetRenderLogicalPresentation)
1749 * - The scale (SDL_SetRenderScale)
1750 * - The viewport (SDL_SetRenderViewport)
1751 *
1752 * \param renderer the rendering context.
1753 * \param x the x coordinate in render coordinates.
1754 * \param y the y coordinate in render coordinates.
1755 * \param window_x a pointer filled with the x coordinate in window
1756 * coordinates.
1757 * \param window_y a pointer filled with the y coordinate in window
1758 * coordinates.
1759 * \returns true on success or false on failure; call SDL_GetError() for more
1760 * information.
1761 *
1762 * \threadsafety This function should only be called on the main thread.
1763 *
1764 * \since This function is available since SDL 3.2.0.
1765 *
1766 * \sa SDL_SetRenderLogicalPresentation
1767 * \sa SDL_SetRenderScale
1768 * \sa SDL_SetRenderViewport
1769 */
1770extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y);
1771
1772/**
1773 * Convert the coordinates in an event to render coordinates.
1774 *
1775 * This takes into account several states:
1776 *
1777 * - The window dimensions.
1778 * - The logical presentation settings (SDL_SetRenderLogicalPresentation)
1779 * - The scale (SDL_SetRenderScale)
1780 * - The viewport (SDL_SetRenderViewport)
1781 *
1782 * Various event types are converted with this function: mouse, touch, pen,
1783 * etc.
1784 *
1785 * Touch coordinates are converted from normalized coordinates in the window
1786 * to non-normalized rendering coordinates.
1787 *
1788 * Relative mouse coordinates (xrel and yrel event fields) are _also_
1789 * converted. Applications that do not want these fields converted should use
1790 * SDL_RenderCoordinatesFromWindow() on the specific event fields instead of
1791 * converting the entire event structure.
1792 *
1793 * Once converted, coordinates may be outside the rendering area.
1794 *
1795 * \param renderer the rendering context.
1796 * \param event the event to modify.
1797 * \returns true if the event is converted or doesn't need conversion, or
1798 * false on failure; call SDL_GetError() for more information.
1799 *
1800 * \threadsafety This function should only be called on the main thread.
1801 *
1802 * \since This function is available since SDL 3.2.0.
1803 *
1804 * \sa SDL_RenderCoordinatesFromWindow
1805 */
1806extern SDL_DECLSPEC bool SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event);
1807
1808/**
1809 * Set the drawing area for rendering on the current target.
1810 *
1811 * Drawing will clip to this area (separately from any clipping done with
1812 * SDL_SetRenderClipRect), and the top left of the area will become coordinate
1813 * (0, 0) for future drawing commands.
1814 *
1815 * The area's width and height must be >= 0.
1816 *
1817 * Each render target has its own viewport. This function sets the viewport
1818 * for the current render target.
1819 *
1820 * \param renderer the rendering context.
1821 * \param rect the SDL_Rect structure representing the drawing area, or NULL
1822 * to set the viewport to the entire target.
1823 * \returns true on success or false on failure; call SDL_GetError() for more
1824 * information.
1825 *
1826 * \threadsafety This function should only be called on the main thread.
1827 *
1828 * \since This function is available since SDL 3.2.0.
1829 *
1830 * \sa SDL_GetRenderViewport
1831 * \sa SDL_RenderViewportSet
1832 * \sa SDL_SetRenderViewportFloat
1833 */
1834extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderViewport(SDL_Renderer *renderer, const SDL_Rect *rect);
1835
1836/**
1837 * Get the drawing area for the current target.
1838 *
1839 * Each render target has its own viewport. This function gets the viewport
1840 * for the current render target.
1841 *
1842 * \param renderer the rendering context.
1843 * \param rect an SDL_Rect structure filled in with the current drawing area.
1844 * \returns true on success or false on failure; call SDL_GetError() for more
1845 * information.
1846 *
1847 * \threadsafety This function should only be called on the main thread.
1848 *
1849 * \since This function is available since SDL 3.2.0.
1850 *
1851 * \sa SDL_GetRenderViewportFloat
1852 * \sa SDL_RenderViewportSet
1853 * \sa SDL_SetRenderViewport
1854 */
1855extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect);
1856
1857/**
1858 * Set the drawing area for rendering on the current target.
1859 *
1860 * Drawing will clip to this area (separately from any clipping done with
1861 * SDL_SetRenderClipRect), and the top left of the area will become coordinate
1862 * (0, 0) for future drawing commands.
1863 *
1864 * The area's width and height must be >= 0.
1865 *
1866 * Each render target has its own viewport. This function sets the viewport
1867 * for the current render target.
1868 *
1869 * \param renderer the rendering context.
1870 * \param rect the SDL_FRect structure representing the drawing area, or NULL
1871 * to set the viewport to the entire target.
1872 * \returns true on success or false on failure; call SDL_GetError() for more
1873 * information.
1874 *
1875 * \threadsafety This function should only be called on the main thread.
1876 *
1877 * \since This function is available since SDL 3.6.0.
1878 *
1879 * \sa SDL_GetRenderViewportFloat
1880 * \sa SDL_RenderViewportSet
1881 */
1882extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderViewportFloat(SDL_Renderer *renderer, const SDL_FRect *rect);
1883
1884/**
1885 * Get the drawing area for the current target.
1886 *
1887 * Each render target has its own viewport. This function gets the viewport
1888 * for the current render target.
1889 *
1890 * \param renderer the rendering context.
1891 * \param rect an SDL_FRect structure filled in with the current drawing area.
1892 * \returns true on success or false on failure; call SDL_GetError() for more
1893 * information.
1894 *
1895 * \threadsafety This function should only be called on the main thread.
1896 *
1897 * \since This function is available since SDL 3.6.0.
1898 *
1899 * \sa SDL_RenderViewportSet
1900 * \sa SDL_SetRenderViewportFloat
1901 */
1902extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderViewportFloat(SDL_Renderer *renderer, SDL_FRect *rect);
1903
1904/**
1905 * Return whether an explicit rectangle was set as the viewport.
1906 *
1907 * This is useful if you're saving and restoring the viewport and want to know
1908 * whether you should restore a specific rectangle or NULL.
1909 *
1910 * Each render target has its own viewport. This function checks the viewport
1911 * for the current render target.
1912 *
1913 * \param renderer the rendering context.
1914 * \returns true if the viewport was set to a specific rectangle, or false if
1915 * it was set to NULL (the entire target).
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_GetRenderViewport
1922 * \sa SDL_GetRenderViewportFloat
1923 * \sa SDL_SetRenderViewport
1924 * \sa SDL_SetRenderViewportFloat
1925 */
1926extern SDL_DECLSPEC bool SDLCALL SDL_RenderViewportSet(SDL_Renderer *renderer);
1927
1928/**
1929 * Get the safe area for rendering within the current viewport.
1930 *
1931 * Some devices have portions of the screen which are partially obscured or
1932 * not interactive, possibly due to on-screen controls, curved edges, camera
1933 * notches, TV overscan, etc. This function provides the area of the current
1934 * viewport which is safe to have interactible content. You should continue
1935 * rendering into the rest of the render target, but it should not contain
1936 * visually important or interactible content.
1937 *
1938 * \param renderer the rendering context.
1939 * \param rect a pointer filled in with the area that is safe for interactive
1940 * content.
1941 * \returns true on success or false on failure; call SDL_GetError() for more
1942 * information.
1943 *
1944 * \threadsafety This function should only be called on the main thread.
1945 *
1946 * \since This function is available since SDL 3.2.0.
1947 */
1948extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderSafeArea(SDL_Renderer *renderer, SDL_Rect *rect);
1949
1950/**
1951 * Set the clip rectangle for rendering on the specified target.
1952 *
1953 * Each render target has its own clip rectangle. This function sets the
1954 * cliprect for the current render target.
1955 *
1956 * \param renderer the rendering context.
1957 * \param rect an SDL_Rect structure representing the clip area, relative to
1958 * the viewport, or NULL to disable clipping.
1959 * \returns true on success or false on failure; call SDL_GetError() for more
1960 * information.
1961 *
1962 * \threadsafety This function should only be called on the main thread.
1963 *
1964 * \since This function is available since SDL 3.2.0.
1965 *
1966 * \sa SDL_GetRenderClipRect
1967 * \sa SDL_RenderClipEnabled
1968 * \sa SDL_SetRenderClipRectFloat
1969 */
1970extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect);
1971
1972/**
1973 * Get the clip rectangle for the current target.
1974 *
1975 * Each render target has its own clip rectangle. This function gets the
1976 * cliprect for the current render target.
1977 *
1978 * \param renderer the rendering context.
1979 * \param rect an SDL_Rect structure filled in with the current clipping area
1980 * or an empty rectangle if clipping is disabled.
1981 * \returns true on success or false on failure; call SDL_GetError() for more
1982 * information.
1983 *
1984 * \threadsafety This function should only be called on the main thread.
1985 *
1986 * \since This function is available since SDL 3.2.0.
1987 *
1988 * \sa SDL_GetRenderClipRectFloat
1989 * \sa SDL_RenderClipEnabled
1990 * \sa SDL_SetRenderClipRect
1991 */
1992extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect);
1993
1994/**
1995 * Set the clip rectangle for rendering on the specified target.
1996 *
1997 * Each render target has its own clip rectangle. This function sets the
1998 * cliprect for the current render target.
1999 *
2000 * \param renderer the rendering context.
2001 * \param rect an SDL_FRect structure representing the clip area, relative to
2002 * the viewport, or NULL to disable clipping.
2003 * \returns true on success or false on failure; call SDL_GetError() for more
2004 * information.
2005 *
2006 * \threadsafety This function should only be called on the main thread.
2007 *
2008 * \since This function is available since SDL 3.6.0.
2009 *
2010 * \sa SDL_GetRenderClipRectFloat
2011 * \sa SDL_RenderClipEnabled
2012 */
2013extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderClipRectFloat(SDL_Renderer *renderer, const SDL_FRect *rect);
2014
2015/**
2016 * Get the clip rectangle for the current target.
2017 *
2018 * Each render target has its own clip rectangle. This function gets the
2019 * cliprect for the current render target.
2020 *
2021 * \param renderer the rendering context.
2022 * \param rect an SDL_FRect structure filled in with the current clipping area
2023 * or an empty rectangle if clipping is disabled.
2024 * \returns true on success or false on failure; call SDL_GetError() for more
2025 * information.
2026 *
2027 * \threadsafety This function should only be called on the main thread.
2028 *
2029 * \since This function is available since SDL 3.6.0.
2030 *
2031 * \sa SDL_RenderClipEnabled
2032 * \sa SDL_SetRenderClipRectFloat
2033 */
2034extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderClipRectFloat(SDL_Renderer *renderer, SDL_FRect *rect);
2035
2036/**
2037 * Get whether clipping is enabled on the given render target.
2038 *
2039 * Each render target has its own clip rectangle. This function checks the
2040 * cliprect for the current render target.
2041 *
2042 * \param renderer the rendering context.
2043 * \returns true if clipping is enabled or false if not; call SDL_GetError()
2044 * for more information.
2045 *
2046 * \threadsafety This function should only be called on the main thread.
2047 *
2048 * \since This function is available since SDL 3.2.0.
2049 *
2050 * \sa SDL_GetRenderClipRect
2051 * \sa SDL_GetRenderClipRectFloat
2052 * \sa SDL_SetRenderClipRect
2053 * \sa SDL_SetRenderClipRectFloat
2054 */
2055extern SDL_DECLSPEC bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer);
2056
2057/**
2058 * Set the drawing scale for rendering on the current target.
2059 *
2060 * The drawing coordinates are scaled by the x/y scaling factors before they
2061 * are used by the renderer. This allows resolution independent drawing with a
2062 * single coordinate system.
2063 *
2064 * If this results in scaling or subpixel drawing by the rendering backend, it
2065 * will be handled using the appropriate quality hints. For best results use
2066 * integer scaling factors.
2067 *
2068 * Each render target has its own scale. This function sets the scale for the
2069 * current render target.
2070 *
2071 * \param renderer the rendering context.
2072 * \param scaleX the horizontal scaling factor.
2073 * \param scaleY the vertical scaling factor.
2074 * \returns true on success or false on failure; call SDL_GetError() for more
2075 * information.
2076 *
2077 * \threadsafety This function should only be called on the main thread.
2078 *
2079 * \since This function is available since SDL 3.2.0.
2080 *
2081 * \sa SDL_GetRenderScale
2082 */
2083extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY);
2084
2085/**
2086 * Get the drawing scale for the current target.
2087 *
2088 * Each render target has its own scale. This function gets the scale for the
2089 * current render target.
2090 *
2091 * \param renderer the rendering context.
2092 * \param scaleX a pointer filled in with the horizontal scaling factor.
2093 * \param scaleY a pointer filled in with the vertical scaling factor.
2094 * \returns true on success or false on failure; call SDL_GetError() for more
2095 * information.
2096 *
2097 * \threadsafety This function should only be called on the main thread.
2098 *
2099 * \since This function is available since SDL 3.2.0.
2100 *
2101 * \sa SDL_SetRenderScale
2102 */
2103extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY);
2104
2105/**
2106 * Set the color used for drawing operations.
2107 *
2108 * Set the color for drawing or filling rectangles, lines, and points, and for
2109 * SDL_RenderClear().
2110 *
2111 * \param renderer the rendering context.
2112 * \param r the red value used to draw on the rendering target.
2113 * \param g the green value used to draw on the rendering target.
2114 * \param b the blue value used to draw on the rendering target.
2115 * \param a the alpha value used to draw on the rendering target; usually
2116 * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
2117 * specify how the alpha channel is used.
2118 * \returns true on success or false on failure; call SDL_GetError() for more
2119 * information.
2120 *
2121 * \threadsafety This function should only be called on the main thread.
2122 *
2123 * \since This function is available since SDL 3.2.0.
2124 *
2125 * \sa SDL_GetRenderDrawColor
2126 * \sa SDL_SetRenderDrawColorFloat
2127 */
2128extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
2129
2130/**
2131 * Set the color used for drawing operations (Rect, Line and Clear).
2132 *
2133 * Set the color for drawing or filling rectangles, lines, and points, and for
2134 * SDL_RenderClear().
2135 *
2136 * \param renderer the rendering context.
2137 * \param r the red value used to draw on the rendering target.
2138 * \param g the green value used to draw on the rendering target.
2139 * \param b the blue value used to draw on the rendering target.
2140 * \param a the alpha value used to draw on the rendering target. Use
2141 * SDL_SetRenderDrawBlendMode to specify how the alpha channel is
2142 * used.
2143 * \returns true on success or false on failure; call SDL_GetError() for more
2144 * information.
2145 *
2146 * \threadsafety This function should only be called on the main thread.
2147 *
2148 * \since This function is available since SDL 3.2.0.
2149 *
2150 * \sa SDL_GetRenderDrawColorFloat
2151 * \sa SDL_SetRenderDrawColor
2152 */
2153extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColorFloat(SDL_Renderer *renderer, float r, float g, float b, float a);
2154
2155/**
2156 * Get the color used for drawing operations (Rect, Line and Clear).
2157 *
2158 * \param renderer the rendering context.
2159 * \param r a pointer filled in with the red value used to draw on the
2160 * rendering target.
2161 * \param g a pointer filled in with the green value used to draw on the
2162 * rendering target.
2163 * \param b a pointer filled in with the blue value used to draw on the
2164 * rendering target.
2165 * \param a a pointer filled in with the alpha value used to draw on the
2166 * rendering target; usually `SDL_ALPHA_OPAQUE` (255).
2167 * \returns true on success or false on failure; call SDL_GetError() for more
2168 * information.
2169 *
2170 * \threadsafety This function should only be called on the main thread.
2171 *
2172 * \since This function is available since SDL 3.2.0.
2173 *
2174 * \sa SDL_GetRenderDrawColorFloat
2175 * \sa SDL_SetRenderDrawColor
2176 */
2177extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColor(SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
2178
2179/**
2180 * Get the color used for drawing operations (Rect, Line and Clear).
2181 *
2182 * \param renderer the rendering context.
2183 * \param r a pointer filled in with the red value used to draw on the
2184 * rendering target.
2185 * \param g a pointer filled in with the green value used to draw on the
2186 * rendering target.
2187 * \param b a pointer filled in with the blue value used to draw on the
2188 * rendering target.
2189 * \param a a pointer filled in with the alpha value used to draw on the
2190 * rendering target.
2191 * \returns true on success or false on failure; call SDL_GetError() for more
2192 * information.
2193 *
2194 * \threadsafety This function should only be called on the main thread.
2195 *
2196 * \since This function is available since SDL 3.2.0.
2197 *
2198 * \sa SDL_SetRenderDrawColorFloat
2199 * \sa SDL_GetRenderDrawColor
2200 */
2201extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColorFloat(SDL_Renderer *renderer, float *r, float *g, float *b, float *a);
2202
2203/**
2204 * Set the color scale used for render operations.
2205 *
2206 * The color scale is an additional scale multiplied into the pixel color
2207 * value while rendering. This can be used to adjust the brightness of colors
2208 * during HDR rendering, or changing HDR video brightness when playing on an
2209 * SDR display.
2210 *
2211 * The color scale does not affect the alpha channel, only the color
2212 * brightness.
2213 *
2214 * \param renderer the rendering context.
2215 * \param scale the color scale value.
2216 * \returns true on success or false on failure; call SDL_GetError() for more
2217 * information.
2218 *
2219 * \threadsafety This function should only be called on the main thread.
2220 *
2221 * \since This function is available since SDL 3.2.0.
2222 *
2223 * \sa SDL_GetRenderColorScale
2224 */
2225extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderColorScale(SDL_Renderer *renderer, float scale);
2226
2227/**
2228 * Get the color scale used for render operations.
2229 *
2230 * \param renderer the rendering context.
2231 * \param scale a pointer filled in with the current color scale value.
2232 * \returns true on success or false on failure; call SDL_GetError() for more
2233 * information.
2234 *
2235 * \threadsafety This function should only be called on the main thread.
2236 *
2237 * \since This function is available since SDL 3.2.0.
2238 *
2239 * \sa SDL_SetRenderColorScale
2240 */
2241extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderColorScale(SDL_Renderer *renderer, float *scale);
2242
2243/**
2244 * Set the blend mode used for drawing operations.
2245 *
2246 * This blend mode is used for any drawing that doesn't involve textures.
2247 *
2248 * If the blend mode is not supported, the closest supported mode is chosen.
2249 *
2250 * \param renderer the rendering context.
2251 * \param blendMode the SDL_BlendMode to use for blending.
2252 * \returns true on success or false on failure; call SDL_GetError() for more
2253 * information.
2254 *
2255 * \threadsafety This function should only be called on the main thread.
2256 *
2257 * \since This function is available since SDL 3.2.0.
2258 *
2259 * \sa SDL_GetRenderDrawBlendMode
2260 * \sa SDL_SetTextureBlendMode
2261 */
2262extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode);
2263
2264/**
2265 * Get the blend mode used for drawing operations.
2266 *
2267 * \param renderer the rendering context.
2268 * \param blendMode a pointer filled in with the current SDL_BlendMode.
2269 * \returns true on success or false on failure; call SDL_GetError() for more
2270 * information.
2271 *
2272 * \threadsafety This function should only be called on the main thread.
2273 *
2274 * \since This function is available since SDL 3.2.0.
2275 *
2276 * \sa SDL_SetRenderDrawBlendMode
2277 */
2278extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode);
2279
2280/**
2281 * Clear the current rendering target with the drawing color.
2282 *
2283 * This function clears the entire rendering target, ignoring the viewport and
2284 * the clip rectangle. Note, that clearing will also set/fill all pixels of
2285 * the rendering target to current renderer draw color, so make sure to invoke
2286 * SDL_SetRenderDrawColor() when needed.
2287 *
2288 * \param renderer the rendering context.
2289 * \returns true on success or false on failure; call SDL_GetError() for more
2290 * information.
2291 *
2292 * \threadsafety This function should only be called on the main thread.
2293 *
2294 * \since This function is available since SDL 3.2.0.
2295 *
2296 * \sa SDL_SetRenderDrawColor
2297 */
2298extern SDL_DECLSPEC bool SDLCALL SDL_RenderClear(SDL_Renderer *renderer);
2299
2300/**
2301 * Draw a point on the current rendering target at subpixel precision.
2302 *
2303 * \param renderer the renderer which should draw a point.
2304 * \param x the x coordinate of the point.
2305 * \param y the y coordinate of the point.
2306 * \returns true on success or false on failure; call SDL_GetError() for more
2307 * information.
2308 *
2309 * \threadsafety This function should only be called on the main thread.
2310 *
2311 * \since This function is available since SDL 3.2.0.
2312 *
2313 * \sa SDL_RenderPoints
2314 */
2315extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoint(SDL_Renderer *renderer, float x, float y);
2316
2317/**
2318 * Draw multiple points on the current rendering target at subpixel precision.
2319 *
2320 * \param renderer the renderer which should draw multiple points.
2321 * \param points the points to draw.
2322 * \param count the number of points to draw.
2323 * \returns true on success or false on failure; call SDL_GetError() for more
2324 * information.
2325 *
2326 * \threadsafety This function should only be called on the main thread.
2327 *
2328 * \since This function is available since SDL 3.2.0.
2329 *
2330 * \sa SDL_RenderPoint
2331 */
2332extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
2333
2334/**
2335 * Draw a line on the current rendering target at subpixel precision.
2336 *
2337 * \param renderer the renderer which should draw a line.
2338 * \param x1 the x coordinate of the start point.
2339 * \param y1 the y coordinate of the start point.
2340 * \param x2 the x coordinate of the end point.
2341 * \param y2 the y coordinate of the end point.
2342 * \returns true on success or false on failure; call SDL_GetError() for more
2343 * information.
2344 *
2345 * \threadsafety This function should only be called on the main thread.
2346 *
2347 * \since This function is available since SDL 3.2.0.
2348 *
2349 * \sa SDL_RenderLines
2350 */
2351extern SDL_DECLSPEC bool SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2);
2352
2353/**
2354 * Draw a series of connected lines on the current rendering target at
2355 * subpixel precision.
2356 *
2357 * \param renderer the renderer which should draw multiple lines.
2358 * \param points the points along the lines.
2359 * \param count the number of points, drawing count-1 lines.
2360 * \returns true on success or false on failure; call SDL_GetError() for more
2361 * information.
2362 *
2363 * \threadsafety This function should only be called on the main thread.
2364 *
2365 * \since This function is available since SDL 3.2.0.
2366 *
2367 * \sa SDL_RenderLine
2368 */
2369extern SDL_DECLSPEC bool SDLCALL SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
2370
2371/**
2372 * Draw a rectangle on the current rendering target at subpixel precision.
2373 *
2374 * \param renderer the renderer which should draw a rectangle.
2375 * \param rect a pointer to the destination rectangle, or NULL to outline the
2376 * entire rendering target.
2377 * \returns true on success or false on failure; call SDL_GetError() for more
2378 * information.
2379 *
2380 * \threadsafety This function should only be called on the main thread.
2381 *
2382 * \since This function is available since SDL 3.2.0.
2383 *
2384 * \sa SDL_RenderRects
2385 */
2386extern SDL_DECLSPEC bool SDLCALL SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect);
2387
2388/**
2389 * Draw some number of rectangles on the current rendering target at subpixel
2390 * precision.
2391 *
2392 * \param renderer the renderer which should draw multiple rectangles.
2393 * \param rects a pointer to an array of destination rectangles.
2394 * \param count the number of rectangles.
2395 * \returns true on success or false on failure; call SDL_GetError() for more
2396 * information.
2397 *
2398 * \threadsafety This function should only be called on the main thread.
2399 *
2400 * \since This function is available since SDL 3.2.0.
2401 *
2402 * \sa SDL_RenderRect
2403 */
2404extern SDL_DECLSPEC bool SDLCALL SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
2405
2406/**
2407 * Fill a rectangle on the current rendering target with the drawing color at
2408 * subpixel precision.
2409 *
2410 * \param renderer the renderer which should fill a rectangle.
2411 * \param rect a pointer to the destination rectangle, or NULL for the entire
2412 * rendering target.
2413 * \returns true on success or false on failure; call SDL_GetError() for more
2414 * information.
2415 *
2416 * \threadsafety This function should only be called on the main thread.
2417 *
2418 * \since This function is available since SDL 3.2.0.
2419 *
2420 * \sa SDL_RenderFillRects
2421 */
2422extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect);
2423
2424/**
2425 * Fill some number of rectangles on the current rendering target with the
2426 * drawing color at subpixel precision.
2427 *
2428 * \param renderer the renderer which should fill multiple rectangles.
2429 * \param rects a pointer to an array of destination rectangles.
2430 * \param count the number of rectangles.
2431 * \returns true on success or false on failure; call SDL_GetError() for more
2432 * information.
2433 *
2434 * \threadsafety This function should only be called on the main thread.
2435 *
2436 * \since This function is available since SDL 3.2.0.
2437 *
2438 * \sa SDL_RenderFillRect
2439 */
2440extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
2441
2442/**
2443 * Copy a portion of the texture to the current rendering target at subpixel
2444 * precision.
2445 *
2446 * \param renderer the renderer which should copy parts of a texture.
2447 * \param texture the source texture.
2448 * \param srcrect a pointer to the source rectangle, or NULL for the entire
2449 * texture.
2450 * \param dstrect a pointer to the destination rectangle, or NULL for the
2451 * entire rendering target.
2452 * \returns true on success or false on failure; call SDL_GetError() for more
2453 * information.
2454 *
2455 * \threadsafety This function should only be called on the main thread.
2456 *
2457 * \since This function is available since SDL 3.2.0.
2458 *
2459 * \sa SDL_RenderTextureRotated
2460 * \sa SDL_RenderTextureTiled
2461 */
2462extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect);
2463
2464/**
2465 * Copy a portion of the source texture to the current rendering target, with
2466 * rotation and flipping, at subpixel precision.
2467 *
2468 * \param renderer the renderer which should copy parts of a texture.
2469 * \param texture the source texture.
2470 * \param srcrect a pointer to the source rectangle, or NULL for the entire
2471 * texture.
2472 * \param dstrect a pointer to the destination rectangle, or NULL for the
2473 * entire rendering target.
2474 * \param angle an angle in degrees that indicates the rotation that will be
2475 * applied to dstrect, rotating it in a clockwise direction.
2476 * \param center a pointer to a point indicating the point around which
2477 * dstrect will be rotated (if NULL, rotation will be done
2478 * around dstrect.w/2, dstrect.h/2).
2479 * \param flip an SDL_FlipMode value stating which flipping actions should be
2480 * performed on the texture.
2481 * \returns true on success or false on failure; call SDL_GetError() for more
2482 * information.
2483 *
2484 * \threadsafety This function should only be called on the main thread.
2485 *
2486 * \since This function is available since SDL 3.2.0.
2487 *
2488 * \sa SDL_RenderTexture
2489 */
2490extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
2491 const SDL_FRect *srcrect, const SDL_FRect *dstrect,
2492 double angle, const SDL_FPoint *center,
2493 SDL_FlipMode flip);
2494
2495/**
2496 * Copy a portion of the source texture to the current rendering target, with
2497 * affine transform, at subpixel precision.
2498 *
2499 * \param renderer the renderer which should copy parts of a texture.
2500 * \param texture the source texture.
2501 * \param srcrect a pointer to the source rectangle, or NULL for the entire
2502 * texture.
2503 * \param origin a pointer to a point indicating where the top-left corner of
2504 * srcrect should be mapped to, or NULL for the rendering
2505 * target's origin.
2506 * \param right a pointer to a point indicating where the top-right corner of
2507 * srcrect should be mapped to, or NULL for the rendering
2508 * target's top-right corner.
2509 * \param down a pointer to a point indicating where the bottom-left corner of
2510 * srcrect should be mapped to, or NULL for the rendering target's
2511 * bottom-left corner.
2512 * \returns true on success or false on failure; call SDL_GetError() for more
2513 * information.
2514 *
2515 * \threadsafety You may only call this function from the main thread.
2516 *
2517 * \since This function is available since SDL 3.2.0.
2518 *
2519 * \sa SDL_RenderTexture
2520 */
2521extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureAffine(SDL_Renderer *renderer, SDL_Texture *texture,
2522 const SDL_FRect *srcrect, const SDL_FPoint *origin,
2523 const SDL_FPoint *right, const SDL_FPoint *down);
2524
2525/**
2526 * Tile a portion of the texture to the current rendering target at subpixel
2527 * precision.
2528 *
2529 * The pixels in `srcrect` will be repeated as many times as needed to
2530 * completely fill `dstrect`.
2531 *
2532 * \param renderer the renderer which should copy parts of a texture.
2533 * \param texture the source texture.
2534 * \param srcrect a pointer to the source rectangle, or NULL for the entire
2535 * texture.
2536 * \param scale the scale used to transform srcrect into the destination
2537 * rectangle, e.g. a 32x32 texture with a scale of 2 would fill
2538 * 64x64 tiles.
2539 * \param dstrect a pointer to the destination rectangle, or NULL for the
2540 * entire rendering target.
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_RenderTexture
2549 */
2550extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float scale, const SDL_FRect *dstrect);
2551
2552/**
2553 * Perform a scaled copy using the 9-grid algorithm to the current rendering
2554 * target at subpixel precision.
2555 *
2556 * The pixels in the texture are split into a 3x3 grid, using the different
2557 * corner sizes for each corner, and the sides and center making up the
2558 * remaining pixels. The corners are then scaled using `scale` and fit into
2559 * the corners of the destination rectangle. The sides and center are then
2560 * stretched into place to cover the remaining destination rectangle.
2561 *
2562 * \param renderer the renderer which should copy parts of a texture.
2563 * \param texture the source texture.
2564 * \param srcrect the SDL_Rect structure representing the rectangle to be used
2565 * for the 9-grid, or NULL to use the entire texture.
2566 * \param left_width the width, in pixels, of the left corners in `srcrect`.
2567 * \param right_width the width, in pixels, of the right corners in `srcrect`.
2568 * \param top_height the height, in pixels, of the top corners in `srcrect`.
2569 * \param bottom_height the height, in pixels, of the bottom corners in
2570 * `srcrect`.
2571 * \param scale the scale used to transform the corner of `srcrect` into the
2572 * corner of `dstrect`, or 0.0f for an unscaled copy.
2573 * \param dstrect a pointer to the destination rectangle, or NULL for the
2574 * entire rendering target.
2575 * \returns true on success or false on failure; call SDL_GetError() for more
2576 * information.
2577 *
2578 * \threadsafety This function should only be called on the main thread.
2579 *
2580 * \since This function is available since SDL 3.2.0.
2581 *
2582 * \sa SDL_RenderTexture
2583 * \sa SDL_RenderTexture9GridTiled
2584 */
2585extern 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);
2586
2587/**
2588 * Perform a scaled copy using the 9-grid algorithm to the current rendering
2589 * target at subpixel precision.
2590 *
2591 * The pixels in the texture are split into a 3x3 grid, using the different
2592 * corner sizes for each corner, and the sides and center making up the
2593 * remaining pixels. The corners are then scaled using `scale` and fit into
2594 * the corners of the destination rectangle. The sides and center are then
2595 * tiled into place to cover the remaining destination rectangle.
2596 *
2597 * \param renderer the renderer which should copy parts of a texture.
2598 * \param texture the source texture.
2599 * \param srcrect the SDL_Rect structure representing the rectangle to be used
2600 * for the 9-grid, or NULL to use the entire texture.
2601 * \param left_width the width, in pixels, of the left corners in `srcrect`.
2602 * \param right_width the width, in pixels, of the right corners in `srcrect`.
2603 * \param top_height the height, in pixels, of the top corners in `srcrect`.
2604 * \param bottom_height the height, in pixels, of the bottom corners in
2605 * `srcrect`.
2606 * \param scale the scale used to transform the corner of `srcrect` into the
2607 * corner of `dstrect`, or 0.0f for an unscaled copy.
2608 * \param dstrect a pointer to the destination rectangle, or NULL for the
2609 * entire rendering target.
2610 * \param tileScale the scale used to transform the borders and center of
2611 * `srcrect` into the borders and middle of `dstrect`, or
2612 * 1.0f for an unscaled copy.
2613 * \returns true on success or false on failure; call SDL_GetError() for more
2614 * information.
2615 *
2616 * \threadsafety This function should only be called on the main thread.
2617 *
2618 * \since This function is available since SDL 3.4.0.
2619 *
2620 * \sa SDL_RenderTexture
2621 * \sa SDL_RenderTexture9Grid
2622 */
2623extern 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);
2624
2625/**
2626 * Render a list of triangles, optionally using a texture and indices into the
2627 * vertex array.
2628 *
2629 * Color and alpha modulation is done per vertex (SDL_SetTextureColorMod and
2630 * SDL_SetTextureAlphaMod are ignored).
2631 *
2632 * \param renderer the rendering context.
2633 * \param texture (optional) The SDL texture to use.
2634 * \param vertices vertices.
2635 * \param num_vertices number of vertices.
2636 * \param indices (optional) An array of integer indices into the 'vertices'
2637 * array, if NULL all vertices will be rendered in sequential
2638 * order.
2639 * \param num_indices number of indices.
2640 * \returns true on success or false on failure; call SDL_GetError() for more
2641 * information.
2642 *
2643 * \threadsafety This function should only be called on the main thread.
2644 *
2645 * \since This function is available since SDL 3.2.0.
2646 *
2647 * \sa SDL_RenderGeometryRaw
2648 * \sa SDL_SetRenderTextureAddressMode
2649 */
2650extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
2651 SDL_Texture *texture,
2652 const SDL_Vertex *vertices, int num_vertices,
2653 const int *indices, int num_indices);
2654
2655/**
2656 * Render a list of triangles, optionally using a texture and indices into the
2657 * vertex arrays.
2658 *
2659 * Color and alpha modulation is done per vertex (SDL_SetTextureColorMod and
2660 * SDL_SetTextureAlphaMod are ignored).
2661 *
2662 * \param renderer the rendering context.
2663 * \param texture (optional) The SDL texture to use.
2664 * \param xy vertex positions.
2665 * \param xy_stride byte size to move from one element to the next element.
2666 * \param color vertex colors (as SDL_FColor).
2667 * \param color_stride byte size to move from one element to the next element.
2668 * \param uv vertex normalized texture coordinates.
2669 * \param uv_stride byte size to move from one element to the next element.
2670 * \param num_vertices number of vertices.
2671 * \param indices (optional) An array of indices into the 'vertices' arrays,
2672 * if NULL all vertices will be rendered in sequential order.
2673 * \param num_indices number of indices.
2674 * \param size_indices index size: 1 (byte), 2 (short), 4 (int).
2675 * \returns true on success or false on failure; call SDL_GetError() for more
2676 * information.
2677 *
2678 * \threadsafety This function should only be called on the main thread.
2679 *
2680 * \since This function is available since SDL 3.2.0.
2681 *
2682 * \sa SDL_RenderGeometry
2683 * \sa SDL_SetRenderTextureAddressMode
2684 */
2685extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
2686 SDL_Texture *texture,
2687 const float *xy, int xy_stride,
2688 const SDL_FColor *color, int color_stride,
2689 const float *uv, int uv_stride,
2690 int num_vertices,
2691 const void *indices, int num_indices, int size_indices);
2692
2693/**
2694 * Set the texture addressing mode used in SDL_RenderGeometry().
2695 *
2696 * \param renderer the rendering context.
2697 * \param u_mode the SDL_TextureAddressMode to use for horizontal texture
2698 * coordinates in SDL_RenderGeometry().
2699 * \param v_mode the SDL_TextureAddressMode to use for vertical texture
2700 * coordinates in SDL_RenderGeometry().
2701 * \returns true on success or false on failure; call SDL_GetError() for more
2702 * information.
2703 *
2704 * \threadsafety This function should only be called on the main thread.
2705 *
2706 * \since This function is available since SDL 3.4.0.
2707 *
2708 * \sa SDL_RenderGeometry
2709 * \sa SDL_RenderGeometryRaw
2710 * \sa SDL_GetRenderTextureAddressMode
2711 */
2713
2714/**
2715 * Get the texture addressing mode used in SDL_RenderGeometry().
2716 *
2717 * \param renderer the rendering context.
2718 * \param u_mode a pointer filled in with the SDL_TextureAddressMode to use
2719 * for horizontal texture coordinates in SDL_RenderGeometry(),
2720 * may be NULL.
2721 * \param v_mode a pointer filled in with the SDL_TextureAddressMode to use
2722 * for vertical texture coordinates in SDL_RenderGeometry(), may
2723 * be NULL.
2724 * \returns true on success or false on failure; call SDL_GetError() for more
2725 * information.
2726 *
2727 * \threadsafety This function should only be called on the main thread.
2728 *
2729 * \since This function is available since SDL 3.4.0.
2730 *
2731 * \sa SDL_SetRenderTextureAddressMode
2732 */
2734
2735/**
2736 * Read pixels from the current rendering target.
2737 *
2738 * The returned surface contains pixels inside the desired area clipped to the
2739 * current viewport, and should be freed with SDL_DestroySurface().
2740 *
2741 * Note that this returns the actual pixels on the screen, so if you are using
2742 * logical presentation you should use SDL_GetRenderLogicalPresentationRect()
2743 * to get the area containing your content.
2744 *
2745 * **WARNING**: This is a very slow operation, and should not be used
2746 * frequently. If you're using this on the main rendering target, it should be
2747 * called after rendering and before SDL_RenderPresent().
2748 *
2749 * \param renderer the rendering context.
2750 * \param rect an SDL_Rect structure representing the area to read, which will
2751 * be clipped to the current viewport, or NULL for the entire
2752 * viewport.
2753 * \returns a new SDL_Surface on success or NULL on failure; call
2754 * SDL_GetError() for more information.
2755 *
2756 * \threadsafety This function should only be called on the main thread.
2757 *
2758 * \since This function is available since SDL 3.2.0.
2759 */
2760extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect);
2761
2762/**
2763 * Update the screen with any rendering performed since the previous call.
2764 *
2765 * SDL's rendering functions operate on a backbuffer; that is, calling a
2766 * rendering function such as SDL_RenderLine() does not directly put a line on
2767 * the screen, but rather updates the backbuffer. As such, you compose your
2768 * entire scene and *present* the composed backbuffer to the screen as a
2769 * complete picture.
2770 *
2771 * Therefore, when using SDL's rendering API, one does all drawing intended
2772 * for the frame, and then calls this function once per frame to present the
2773 * final drawing to the user.
2774 *
2775 * The backbuffer should be considered invalidated after each present; do not
2776 * assume that previous contents will exist between frames. You are strongly
2777 * encouraged to call SDL_RenderClear() to initialize the backbuffer before
2778 * starting each new frame's drawing, even if you plan to overwrite every
2779 * pixel.
2780 *
2781 * Please note, that in case of rendering to a texture - there is **no need**
2782 * to call `SDL_RenderPresent` after drawing needed objects to a texture, and
2783 * should not be done; you are only required to change back the rendering
2784 * target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as
2785 * textures by themselves do not have a concept of backbuffers. Calling
2786 * SDL_RenderPresent while rendering to a texture will fail.
2787 *
2788 * \param renderer the rendering context.
2789 * \returns true on success or false on failure; call SDL_GetError() for more
2790 * information.
2791 *
2792 * \threadsafety This function should only be called on the main thread.
2793 *
2794 * \since This function is available since SDL 3.2.0.
2795 *
2796 * \sa SDL_CreateRenderer
2797 * \sa SDL_RenderClear
2798 * \sa SDL_RenderFillRect
2799 * \sa SDL_RenderFillRects
2800 * \sa SDL_RenderLine
2801 * \sa SDL_RenderLines
2802 * \sa SDL_RenderPoint
2803 * \sa SDL_RenderPoints
2804 * \sa SDL_RenderRect
2805 * \sa SDL_RenderRects
2806 * \sa SDL_SetRenderDrawBlendMode
2807 * \sa SDL_SetRenderDrawColor
2808 */
2809extern SDL_DECLSPEC bool SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
2810
2811/**
2812 * Destroy the specified texture.
2813 *
2814 * Passing NULL or an otherwise invalid texture will set the SDL error message
2815 * to "Invalid texture".
2816 *
2817 * \param texture the texture to destroy.
2818 *
2819 * \threadsafety This function should only be called on the main thread.
2820 *
2821 * \since This function is available since SDL 3.2.0.
2822 *
2823 * \sa SDL_CreateTexture
2824 * \sa SDL_CreateTextureFromSurface
2825 */
2826extern SDL_DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
2827
2828/**
2829 * Destroy the rendering context for a window and free all associated
2830 * textures.
2831 *
2832 * This should be called before destroying the associated window.
2833 *
2834 * \param renderer the rendering context.
2835 *
2836 * \threadsafety This function should only be called on the main thread.
2837 *
2838 * \since This function is available since SDL 3.2.0.
2839 *
2840 * \sa SDL_CreateRenderer
2841 */
2842extern SDL_DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
2843
2844/**
2845 * Force the rendering context to flush any pending commands and state.
2846 *
2847 * You do not need to (and in fact, shouldn't) call this function unless you
2848 * are planning to call into OpenGL/Direct3D/Metal/whatever directly, in
2849 * addition to using an SDL_Renderer.
2850 *
2851 * This is for a very-specific case: if you are using SDL's render API, and
2852 * you plan to make OpenGL/D3D/whatever calls in addition to SDL render API
2853 * calls. If this applies, you should call this function between calls to
2854 * SDL's render API and the low-level API you're using in cooperation.
2855 *
2856 * In all other cases, you can ignore this function.
2857 *
2858 * This call makes SDL flush any pending rendering work it was queueing up to
2859 * do later in a single batch, and marks any internal cached state as invalid,
2860 * so it'll prepare all its state again later, from scratch.
2861 *
2862 * This means you do not need to save state in your rendering code to protect
2863 * the SDL renderer. However, there lots of arbitrary pieces of Direct3D and
2864 * OpenGL state that can confuse things; you should use your best judgment and
2865 * be prepared to make changes if specific state needs to be protected.
2866 *
2867 * \param renderer the rendering context.
2868 * \returns true on success or false on failure; call SDL_GetError() for more
2869 * information.
2870 *
2871 * \threadsafety This function should only be called on the main thread.
2872 *
2873 * \since This function is available since SDL 3.2.0.
2874 */
2875extern SDL_DECLSPEC bool SDLCALL SDL_FlushRenderer(SDL_Renderer *renderer);
2876
2877/**
2878 * Get the CAMetalLayer associated with the given Metal renderer.
2879 *
2880 * This function returns `void *`, so SDL doesn't have to include Metal's
2881 * headers, but it can be safely cast to a `CAMetalLayer *`.
2882 *
2883 * \param renderer the renderer to query.
2884 * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
2885 * Metal renderer.
2886 *
2887 * \threadsafety This function should only be called on the main thread.
2888 *
2889 * \since This function is available since SDL 3.2.0.
2890 *
2891 * \sa SDL_GetRenderMetalCommandEncoder
2892 */
2893extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalLayer(SDL_Renderer *renderer);
2894
2895/**
2896 * Get the Metal command encoder for the current frame.
2897 *
2898 * This function returns `void *`, so SDL doesn't have to include Metal's
2899 * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
2900 *
2901 * This will return NULL if Metal refuses to give SDL a drawable to render to,
2902 * which might happen if the window is hidden/minimized/offscreen. This
2903 * doesn't apply to command encoders for render targets, just the window's
2904 * backbuffer. Check your return values!
2905 *
2906 * \param renderer the renderer to query.
2907 * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
2908 * renderer isn't a Metal renderer or there was an error.
2909 *
2910 * \threadsafety This function should only be called on the main thread.
2911 *
2912 * \since This function is available since SDL 3.2.0.
2913 *
2914 * \sa SDL_GetRenderMetalLayer
2915 */
2916extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalCommandEncoder(SDL_Renderer *renderer);
2917
2918
2919/**
2920 * Add a set of synchronization semaphores for the current frame.
2921 *
2922 * The Vulkan renderer will wait for `wait_semaphore` before submitting
2923 * rendering commands and signal `signal_semaphore` after rendering commands
2924 * are complete for this frame.
2925 *
2926 * This should be called each frame that you want semaphore synchronization.
2927 * The Vulkan renderer may have multiple frames in flight on the GPU, so you
2928 * should have multiple semaphores that are used for synchronization. Querying
2929 * SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the
2930 * maximum number of semaphores you'll need.
2931 *
2932 * \param renderer the rendering context.
2933 * \param wait_stage_mask the VkPipelineStageFlags for the wait.
2934 * \param wait_semaphore a VkSempahore to wait on before rendering the current
2935 * frame, or 0 if not needed.
2936 * \param signal_semaphore a VkSempahore that SDL will signal when rendering
2937 * for the current frame is complete, or 0 if not
2938 * needed.
2939 * \returns true on success or false on failure; call SDL_GetError() for more
2940 * information.
2941 *
2942 * \threadsafety It is **NOT** safe to call this function from two threads at
2943 * once.
2944 *
2945 * \since This function is available since SDL 3.2.0.
2946 */
2947extern SDL_DECLSPEC bool SDLCALL SDL_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore);
2948
2949/**
2950 * Toggle VSync of the given renderer.
2951 *
2952 * When a renderer is created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED.
2953 *
2954 * The `vsync` parameter can be 1 to synchronize present with every vertical
2955 * refresh, 2 to synchronize present with every second vertical refresh, etc.,
2956 * SDL_RENDERER_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or
2957 * SDL_RENDERER_VSYNC_DISABLED to disable. Not every value is supported by
2958 * every driver, so you should check the return value to see whether the
2959 * requested setting is supported.
2960 *
2961 * \param renderer the renderer to toggle.
2962 * \param vsync the vertical refresh sync interval.
2963 * \returns true on success or false on failure; call SDL_GetError() for more
2964 * information.
2965 *
2966 * \threadsafety This function should only be called on the main thread.
2967 *
2968 * \since This function is available since SDL 3.2.0.
2969 *
2970 * \sa SDL_GetRenderVSync
2971 */
2972extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync);
2973
2974#define SDL_RENDERER_VSYNC_DISABLED 0
2975#define SDL_RENDERER_VSYNC_ADAPTIVE (-1)
2976
2977/**
2978 * Get VSync of the given renderer.
2979 *
2980 * \param renderer the renderer to toggle.
2981 * \param vsync an int filled with the current vertical refresh sync interval.
2982 * See SDL_SetRenderVSync() for the meaning of the value.
2983 * \returns true on success or false on failure; call SDL_GetError() for more
2984 * information.
2985 *
2986 * \threadsafety This function should only be called on the main thread.
2987 *
2988 * \since This function is available since SDL 3.2.0.
2989 *
2990 * \sa SDL_SetRenderVSync
2991 */
2992extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync);
2993
2994/**
2995 * The size, in pixels, of a single SDL_RenderDebugText() character.
2996 *
2997 * The font is monospaced and square, so this applies to all characters.
2998 *
2999 * \since This macro is available since SDL 3.2.0.
3000 *
3001 * \sa SDL_RenderDebugText
3002 */
3003#define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE 8
3004
3005/**
3006 * Draw debug text to an SDL_Renderer.
3007 *
3008 * This function will render a string of text to an SDL_Renderer. Note that
3009 * this is a convenience function for debugging, with severe limitations, and
3010 * not intended to be used for production apps and games.
3011 *
3012 * Among these limitations:
3013 *
3014 * - It accepts UTF-8 strings, but will only renders ASCII characters.
3015 * - It has a single, tiny size (8x8 pixels). You can use logical presentation
3016 * or SDL_SetRenderScale() to adjust it.
3017 * - It uses a simple, hardcoded bitmap font. It does not allow different font
3018 * selections and it does not support truetype, for proper scaling.
3019 * - It does no word-wrapping and does not treat newline characters as a line
3020 * break. If the text goes out of the window, it's gone.
3021 *
3022 * For serious text rendering, there are several good options, such as
3023 * SDL_ttf, stb_truetype, or other external libraries.
3024 *
3025 * On first use, this will create an internal texture for rendering glyphs.
3026 * This texture will live until the renderer is destroyed.
3027 *
3028 * The text is drawn in the color specified by SDL_SetRenderDrawColor().
3029 *
3030 * \param renderer the renderer which should draw a line of text.
3031 * \param x the x coordinate where the top-left corner of the text will draw.
3032 * \param y the y coordinate where the top-left corner of the text will draw.
3033 * \param str the string to render.
3034 * \returns true on success or false on failure; call SDL_GetError() for more
3035 * information.
3036 *
3037 * \threadsafety This function should only be called on the main thread.
3038 *
3039 * \since This function is available since SDL 3.2.0.
3040 *
3041 * \sa SDL_RenderDebugTextFormat
3042 * \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE
3043 */
3044extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugText(SDL_Renderer *renderer, float x, float y, const char *str);
3045
3046/**
3047 * Draw debug text to an SDL_Renderer.
3048 *
3049 * This function will render a printf()-style format string to a renderer.
3050 * Note that this is a convenience function for debugging, with severe
3051 * limitations, and is not intended to be used for production apps and games.
3052 *
3053 * For the full list of limitations and other useful information, see
3054 * SDL_RenderDebugText.
3055 *
3056 * \param renderer the renderer which should draw the text.
3057 * \param x the x coordinate where the top-left corner of the text will draw.
3058 * \param y the y coordinate where the top-left corner of the text will draw.
3059 * \param fmt the format string to draw.
3060 * \param ... additional parameters matching % tokens in the `fmt` string, if
3061 * any.
3062 * \returns true on success or false on failure; call SDL_GetError() for more
3063 * information.
3064 *
3065 * \threadsafety This function should only be called on the main thread.
3066 *
3067 * \since This function is available since SDL 3.2.0.
3068 *
3069 * \sa SDL_RenderDebugText
3070 * \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE
3071 */
3072extern 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);
3073
3074/**
3075 * Set default scale mode for new textures for given renderer.
3076 *
3077 * When a renderer is created, scale_mode defaults to SDL_SCALEMODE_LINEAR.
3078 *
3079 * \param renderer the renderer to update.
3080 * \param scale_mode the scale mode to change to for new textures.
3081 * \returns true on success or false on failure; call SDL_GetError() for more
3082 * information.
3083 *
3084 * \threadsafety This function should only be called on the main thread.
3085 *
3086 * \since This function is available since SDL 3.4.0.
3087 *
3088 * \sa SDL_GetDefaultTextureScaleMode
3089 */
3090extern SDL_DECLSPEC bool SDLCALL SDL_SetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode scale_mode);
3091
3092/**
3093 * Get default texture scale mode of the given renderer.
3094 *
3095 * \param renderer the renderer to get data from.
3096 * \param scale_mode a SDL_ScaleMode filled with current default scale mode.
3097 * See SDL_SetDefaultTextureScaleMode() for the meaning of
3098 * the value.
3099 * \returns true on success or false on failure; call SDL_GetError() for more
3100 * information.
3101 *
3102 * \threadsafety This function should only be called on the main thread.
3103 *
3104 * \since This function is available since SDL 3.4.0.
3105 *
3106 * \sa SDL_SetDefaultTextureScaleMode
3107 */
3108extern SDL_DECLSPEC bool SDLCALL SDL_GetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode *scale_mode);
3109
3110/**
3111 * A structure specifying the parameters of a GPU render state.
3112 *
3113 * \since This struct is available since SDL 3.4.0.
3114 *
3115 * \sa SDL_CreateGPURenderState
3116 */
3118{
3119 SDL_GPUShader *fragment_shader; /**< The fragment shader to use when this render state is active */
3120
3121 Sint32 num_sampler_bindings; /**< The number of additional fragment samplers to bind when this render state is active */
3122 const SDL_GPUTextureSamplerBinding *sampler_bindings; /**< Additional fragment samplers to bind when this render state is active */
3123
3124 Sint32 num_storage_textures; /**< The number of storage textures to bind when this render state is active */
3125 SDL_GPUTexture *const *storage_textures; /**< Storage textures to bind when this render state is active */
3126
3127 Sint32 num_storage_buffers; /**< The number of storage buffers to bind when this render state is active */
3128 SDL_GPUBuffer *const *storage_buffers; /**< Storage buffers to bind when this render state is active */
3129
3130 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
3132
3133/**
3134 * A custom GPU render state.
3135 *
3136 * \since This struct is available since SDL 3.4.0.
3137 *
3138 * \sa SDL_CreateGPURenderState
3139 * \sa SDL_SetGPURenderStateFragmentUniforms
3140 * \sa SDL_SetGPURenderState
3141 * \sa SDL_DestroyGPURenderState
3142 */
3144
3145/**
3146 * Create custom GPU render state.
3147 *
3148 * \param renderer the renderer to use.
3149 * \param createinfo a struct describing the GPU render state to create.
3150 * \returns a custom GPU render state or NULL on failure; call SDL_GetError()
3151 * for more information.
3152 *
3153 * \threadsafety This function should be called on the thread that created the
3154 * renderer.
3155 *
3156 * \since This function is available since SDL 3.4.0.
3157 *
3158 * \sa SDL_SetGPURenderStateFragmentUniforms
3159 * \sa SDL_SetGPURenderState
3160 * \sa SDL_DestroyGPURenderState
3161 */
3163
3164/**
3165 * Set sampler bindings variables in a custom GPU render state.
3166 *
3167 * The data is copied and will be binded using SDL_BindGPUFragmentSamplers()
3168 * during draw call execution.
3169 *
3170 * \param state the state to modify.
3171 * \param num_sampler_bindings The number of additional fragment samplers to
3172 * bind.
3173 * \param sampler_bindings Additional fragment samplers to bind.
3174 * \returns true on success or false on failure; call SDL_GetError() for more
3175 * information.
3176 *
3177 * \threadsafety This function should be called on the thread that created the
3178 * renderer.
3179 *
3180 * \since This function is available since SDL 3.6.0.
3181 */
3182extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderStateSamplerBindings(SDL_GPURenderState *state, int num_sampler_bindings, const SDL_GPUTextureSamplerBinding *sampler_bindings);
3183
3184/**
3185 * Set storage textures variables in a custom GPU render state.
3186 *
3187 * The data is copied and will be binded using
3188 * SDL_BindGPUFragmentStorageTextures() during draw call execution.
3189 *
3190 * \param state the state to modify.
3191 * \param num_storage_textures The number of storage textures to bind.
3192 * \param storage_textures Storage textures to bind.
3193 * \returns true on success or false on failure; call SDL_GetError() for more
3194 * information.
3195 *
3196 * \threadsafety This function should be called on the thread that created the
3197 * renderer.
3198 *
3199 * \since This function is available since SDL 3.6.0.
3200 */
3201extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderStateStorageTextures(SDL_GPURenderState *state, int num_storage_textures, SDL_GPUTexture *const *storage_textures);
3202
3203/**
3204 * Set storage buffers variables in a custom GPU render state.
3205 *
3206 * The data is copied and will be binded using
3207 * SDL_BindGPUFragmentStorageBuffers() during draw call execution.
3208 *
3209 * \param state the state to modify.
3210 * \param num_storage_buffers The number of storage buffers to bind.
3211 * \param storage_buffers Storage buffers to bind.
3212 * \returns true on success or false on failure; call SDL_GetError() for more
3213 * information.
3214 *
3215 * \threadsafety This function should be called on the thread that created the
3216 * renderer.
3217 *
3218 * \since This function is available since SDL 3.6.0.
3219 */
3220extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderStateStorageBuffers(SDL_GPURenderState *state, int num_storage_buffers, SDL_GPUBuffer *const *storage_buffers);
3221
3222/**
3223 * Set fragment shader uniform variables in a custom GPU render state.
3224 *
3225 * The data is copied and will be pushed using
3226 * SDL_PushGPUFragmentUniformData() during draw call execution.
3227 *
3228 * \param state the state to modify.
3229 * \param slot_index the fragment uniform slot to push data to.
3230 * \param data client data to write.
3231 * \param length the length of the data to write.
3232 * \returns true on success or false on failure; call SDL_GetError() for more
3233 * information.
3234 *
3235 * \threadsafety This function should be called on the thread that created the
3236 * renderer.
3237 *
3238 * \since This function is available since SDL 3.4.0.
3239 */
3240extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderStateFragmentUniforms(SDL_GPURenderState *state, Uint32 slot_index, const void *data, Uint32 length);
3241
3242/**
3243 * Set custom GPU render state.
3244 *
3245 * This function sets custom GPU render state for subsequent draw calls. This
3246 * allows using custom shaders with the GPU renderer.
3247 *
3248 * \param renderer the renderer to use.
3249 * \param state the state to to use, or NULL to clear custom GPU render state.
3250 * \returns true on success or false on failure; call SDL_GetError() for more
3251 * information.
3252 *
3253 * \threadsafety This function should be called on the thread that created the
3254 * renderer.
3255 *
3256 * \since This function is available since SDL 3.4.0.
3257 */
3258extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderState(SDL_Renderer *renderer, SDL_GPURenderState *state);
3259
3260/**
3261 * Destroy custom GPU render state.
3262 *
3263 * \param state the state to destroy.
3264 *
3265 * \threadsafety This function should be called on the thread that created the
3266 * renderer.
3267 *
3268 * \since This function is available since SDL 3.4.0.
3269 *
3270 * \sa SDL_CreateGPURenderState
3271 */
3272extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPURenderState(SDL_GPURenderState *state);
3273
3274#ifdef SDL_PLATFORM_GDK
3275
3276/**
3277 * Call this to suspend Render operations on Xbox after receiving the
3278 * SDL_EVENT_DID_ENTER_BACKGROUND event.
3279 *
3280 * Do NOT call any SDL_Render functions after calling this function! This must
3281 * also be called before calling SDL_GDKSuspendComplete.
3282 *
3283 * This function MUST be called on the application's render thread.
3284 *
3285 * \param renderer the renderer which should suspend operation.
3286 *
3287 * \since This function is available since SDL 3.6.0.
3288 *
3289 * \sa SDL_AddEventWatch
3290 */
3291extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendRenderer(SDL_Renderer *renderer);
3292
3293/**
3294 * Call this to resume Render operations on Xbox after receiving the
3295 * SDL_EVENT_WILL_ENTER_FOREGROUND event.
3296 *
3297 * When resuming, this function MUST be called before calling any other
3298 * SDL_Render functions.
3299 *
3300 * This function MUST be called on the application's render thread.
3301 *
3302 * \param renderer the renderer which should resume operation.
3303 *
3304 * \since This function is available since SDL 3.6.0.
3305 *
3306 * \sa SDL_AddEventWatch
3307 */
3308extern SDL_DECLSPEC void SDLCALL SDL_GDKResumeRenderer(SDL_Renderer *renderer);
3309
3310#endif /* SDL_PLATFORM_GDK */
3311
3312/* Ends C function definitions when using C++ */
3313#ifdef __cplusplus
3314}
3315#endif
3316#include <SDL3/SDL_close_code.h>
3317
3318#endif /* SDL_render_h_ */
Uint32 SDL_BlendMode
struct SDL_GPUTexture SDL_GPUTexture
Definition SDL_gpu.h:476
struct SDL_GPUBuffer SDL_GPUBuffer
Definition SDL_gpu.h:438
struct SDL_GPUShader SDL_GPUShader
Definition SDL_gpu.h:499
struct SDL_GPUDevice SDL_GPUDevice
Definition SDL_gpu.h:414
SDL_PixelFormat
Definition SDL_pixels.h:551
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_GetRenderViewportFloat(SDL_Renderer *renderer, SDL_FRect *rect)
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_SetRenderClipRectFloat(SDL_Renderer *renderer, const SDL_FRect *rect)
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)
bool SDL_SetRenderViewportFloat(SDL_Renderer *renderer, const SDL_FRect *rect)
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)
bool SDL_GetRenderClipRectFloat(SDL_Renderer *renderer, SDL_FRect *rect)
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