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