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