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