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