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