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