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