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