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