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