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