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