1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/**
23 * # CategoryRender
24 *
25 * Header file for SDL 2D rendering functions.
26 *
27 * This API supports the following features:
28 *
29 * - single pixel points
30 * - single pixel lines
31 * - filled rectangles
32 * - texture images
33 * - 2D polygons
34 *
35 * The primitives may be drawn in opaque, blended, or additive modes.
36 *
37 * The texture images may be drawn in opaque, blended, or additive modes. They
38 * can have an additional color tint or alpha modulation applied to them, and
39 * may also be stretched with linear interpolation.
40 *
41 * This API is designed to accelerate simple 2D operations. You may want more
42 * functionality such as 3D polygons and particle effects and in that case you
43 * should use SDL's OpenGL/Direct3D support or one of the many good 3D
44 * engines.
45 *
46 * These functions must be called from the main thread. See this bug for
47 * details: https://github.com/libsdl-org/SDL/issues/986
48 */
49
50#ifndef SDL_render_h_
51#define SDL_render_h_
52
53#include "SDL_stdinc.h"
54#include "SDL_rect.h"
55#include "SDL_video.h"
56
57#include "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 SDL_RendererFlags
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 */
73 SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports
74 rendering to texture */
75} SDL_RendererFlags;
76
77/**
78 * Information on the capabilities of a render driver or context.
79 */
80typedef struct SDL_RendererInfo
81{
82 const char *name; /**< The name of the renderer */
83 Uint32 flags; /**< Supported SDL_RendererFlags */
84 Uint32 num_texture_formats; /**< The number of available texture formats */
85 Uint32 texture_formats[16]; /**< The available texture formats */
86 int max_texture_width; /**< The maximum texture width */
87 int max_texture_height; /**< The maximum texture height */
88} SDL_RendererInfo;
89
90/**
91 * Vertex structure
92 */
93typedef struct SDL_Vertex
94{
95 SDL_FPoint position; /**< Vertex position, in SDL_Renderer coordinates */
96 SDL_Color color; /**< Vertex color */
97 SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */
98} SDL_Vertex;
99
100/**
101 * The scaling mode for a texture.
102 */
103typedef enum SDL_ScaleMode
104{
105 SDL_ScaleModeNearest, /**< nearest pixel sampling */
106 SDL_ScaleModeLinear, /**< linear filtering */
107 SDL_ScaleModeBest /**< anisotropic filtering */
108} SDL_ScaleMode;
109
110/**
111 * The access pattern allowed for a texture.
112 */
113typedef enum SDL_TextureAccess
114{
115 SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */
116 SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
117 SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */
118} SDL_TextureAccess;
119
120/**
121 * The texture channel modulation used in SDL_RenderCopy().
122 */
123typedef enum SDL_TextureModulate
124{
125 SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */
126 SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */
127 SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */
128} SDL_TextureModulate;
129
130/**
131 * Flip constants for SDL_RenderCopyEx
132 */
133typedef enum SDL_RendererFlip
134{
135 SDL_FLIP_NONE = 0x00000000, /**< Do not flip */
136 SDL_FLIP_HORIZONTAL = 0x00000001, /**< flip horizontally */
137 SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */
138} SDL_RendererFlip;
139
140/**
141 * A structure representing rendering state
142 */
143struct SDL_Renderer;
144typedef struct SDL_Renderer SDL_Renderer;
145
146/**
147 * An efficient driver-specific representation of pixel data
148 */
149struct SDL_Texture;
150typedef struct SDL_Texture SDL_Texture;
151
152/* Function prototypes */
153
154/**
155 * Get the number of 2D rendering drivers available for the current display.
156 *
157 * A render driver is a set of code that handles rendering and texture
158 * management on a particular display. Normally there is only one, but some
159 * drivers may have several available with different capabilities.
160 *
161 * There may be none if SDL was compiled without render support.
162 *
163 * \returns a number >= 0 on success or a negative error code on failure; call
164 * SDL_GetError() for more information.
165 *
166 * \since This function is available since SDL 2.0.0.
167 *
168 * \sa SDL_CreateRenderer
169 * \sa SDL_GetRenderDriverInfo
170 */
171extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
172
173/**
174 * Get info about a specific 2D rendering driver for the current display.
175 *
176 * \param index the index of the driver to query information about.
177 * \param info an SDL_RendererInfo structure to be filled with information on
178 * the rendering driver.
179 * \returns 0 on success or a negative error code on failure; call
180 * SDL_GetError() for more information.
181 *
182 * \since This function is available since SDL 2.0.0.
183 *
184 * \sa SDL_CreateRenderer
185 * \sa SDL_GetNumRenderDrivers
186 */
187extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index,
188 SDL_RendererInfo * info);
189
190/**
191 * Create a window and default renderer.
192 *
193 * \param width the width of the window.
194 * \param height the height of the window.
195 * \param window_flags the flags used to create the window (see
196 * SDL_CreateWindow()).
197 * \param window a pointer filled with the window, or NULL on error.
198 * \param renderer a pointer filled with the renderer, or NULL on error.
199 * \returns 0 on success, or -1 on error; call SDL_GetError() for more
200 * information.
201 *
202 * \since This function is available since SDL 2.0.0.
203 *
204 * \sa SDL_CreateRenderer
205 * \sa SDL_CreateWindow
206 */
207extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(
208 int width, int height, Uint32 window_flags,
209 SDL_Window **window, SDL_Renderer **renderer);
210
211
212/**
213 * Create a 2D rendering context for a window.
214 *
215 * \param window the window where rendering is displayed.
216 * \param index the index of the rendering driver to initialize, or -1 to
217 * initialize the first one supporting the requested flags.
218 * \param flags 0, or one or more SDL_RendererFlags OR'd together.
219 * \returns a valid rendering context or NULL if there was an error; call
220 * SDL_GetError() for more information.
221 *
222 * \since This function is available since SDL 2.0.0.
223 *
224 * \sa SDL_CreateSoftwareRenderer
225 * \sa SDL_DestroyRenderer
226 * \sa SDL_GetNumRenderDrivers
227 * \sa SDL_GetRendererInfo
228 */
229extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window,
230 int index, Uint32 flags);
231
232/**
233 * Create a 2D software rendering context for a surface.
234 *
235 * Two other API which can be used to create SDL_Renderer:
236 * SDL_CreateRenderer() and SDL_CreateWindowAndRenderer(). These can _also_
237 * create a software renderer, but they are intended to be used with an
238 * SDL_Window as the final destination and not an SDL_Surface.
239 *
240 * \param surface the SDL_Surface structure representing the surface where
241 * rendering is done.
242 * \returns a valid rendering context or NULL if there was an error; call
243 * SDL_GetError() for more information.
244 *
245 * \since This function is available since SDL 2.0.0.
246 *
247 * \sa SDL_CreateRenderer
248 * \sa SDL_CreateWindowAndRenderer
249 * \sa SDL_DestroyRenderer
250 */
251extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface);
252
253/**
254 * Get the renderer associated with a window.
255 *
256 * \param window the window to query.
257 * \returns the rendering context on success or NULL on failure; call
258 * SDL_GetError() for more information.
259 *
260 * \since This function is available since SDL 2.0.0.
261 *
262 * \sa SDL_CreateRenderer
263 */
264extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window);
265
266/**
267 * Get the window associated with a renderer.
268 *
269 * \param renderer the renderer to query.
270 * \returns the window on success or NULL on failure; call SDL_GetError() for
271 * more information.
272 *
273 * \since This function is available since SDL 2.0.22.
274 */
275extern DECLSPEC SDL_Window * SDLCALL SDL_RenderGetWindow(SDL_Renderer *renderer);
276
277/**
278 * Get information about a rendering context.
279 *
280 * \param renderer the rendering context.
281 * \param info an SDL_RendererInfo structure filled with information about the
282 * current renderer.
283 * \returns 0 on success or a negative error code on failure; call
284 * SDL_GetError() for more information.
285 *
286 * \since This function is available since SDL 2.0.0.
287 *
288 * \sa SDL_CreateRenderer
289 */
290extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer,
291 SDL_RendererInfo * info);
292
293/**
294 * Get the output size in pixels of a rendering context.
295 *
296 * Due to high-dpi displays, you might end up with a rendering context that
297 * has more pixels than the window that contains it, so use this instead of
298 * SDL_GetWindowSize() to decide how much drawing area you have.
299 *
300 * \param renderer the rendering context.
301 * \param w an int filled with the width.
302 * \param h an int filled with the height.
303 * \returns 0 on success or a negative error code on failure; call
304 * SDL_GetError() for more information.
305 *
306 * \since This function is available since SDL 2.0.0.
307 *
308 * \sa SDL_GetRenderer
309 */
310extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer,
311 int *w, int *h);
312
313/**
314 * Create a texture for a rendering context.
315 *
316 * You can set the texture scaling method by setting
317 * `SDL_HINT_RENDER_SCALE_QUALITY` before creating the texture.
318 *
319 * \param renderer the rendering context.
320 * \param format one of the enumerated values in SDL_PixelFormatEnum.
321 * \param access one of the enumerated values in SDL_TextureAccess.
322 * \param w the width of the texture in pixels.
323 * \param h the height of the texture in pixels.
324 * \returns a pointer to the created texture or NULL if no rendering context
325 * was active, the format was unsupported, or the width or height
326 * were out of range; call SDL_GetError() for more information.
327 *
328 * \since This function is available since SDL 2.0.0.
329 *
330 * \sa SDL_CreateTextureFromSurface
331 * \sa SDL_DestroyTexture
332 * \sa SDL_QueryTexture
333 * \sa SDL_UpdateTexture
334 */
335extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer,
336 Uint32 format,
337 int access, int w,
338 int h);
339
340/**
341 * Create a texture from an existing surface.
342 *
343 * The surface is not modified or freed by this function.
344 *
345 * The SDL_TextureAccess hint for the created texture is
346 * `SDL_TEXTUREACCESS_STATIC`.
347 *
348 * The pixel format of the created texture may be different from the pixel
349 * format of the surface. Use SDL_QueryTexture() to query the pixel format of
350 * the texture.
351 *
352 * \param renderer the rendering context.
353 * \param surface the SDL_Surface structure containing pixel data used to fill
354 * the texture.
355 * \returns the created texture or NULL on failure; call SDL_GetError() for
356 * more information.
357 *
358 * \since This function is available since SDL 2.0.0.
359 *
360 * \sa SDL_CreateTexture
361 * \sa SDL_DestroyTexture
362 * \sa SDL_QueryTexture
363 */
364extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface);
365
366/**
367 * Query the attributes of a texture.
368 *
369 * \param texture the texture to query.
370 * \param format a pointer filled in with the raw format of the texture; the
371 * actual format may differ, but pixel transfers will use this
372 * format (one of the SDL_PixelFormatEnum values). This argument
373 * can be NULL if you don't need this information.
374 * \param access a pointer filled in with the actual access to the texture
375 * (one of the SDL_TextureAccess values). This argument can be
376 * NULL if you don't need this information.
377 * \param w a pointer filled in with the width of the texture in pixels. This
378 * argument can be NULL if you don't need this information.
379 * \param h a pointer filled in with the height of the texture in pixels. This
380 * argument can be NULL if you don't need this information.
381 * \returns 0 on success or a negative error code on failure; call
382 * SDL_GetError() for more information.
383 *
384 * \since This function is available since SDL 2.0.0.
385 *
386 * \sa SDL_CreateTexture
387 */
388extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
389 Uint32 * format, int *access,
390 int *w, int *h);
391
392/**
393 * Set an additional color value multiplied into render copy operations.
394 *
395 * When this texture is rendered, during the copy operation each source color
396 * channel is modulated by the appropriate color value according to the
397 * following formula:
398 *
399 * `srcC = srcC * (color / 255)`
400 *
401 * Color modulation is not always supported by the renderer; it will return -1
402 * if color modulation is not supported.
403 *
404 * \param texture the texture to update.
405 * \param r the red color value multiplied into copy operations.
406 * \param g the green color value multiplied into copy operations.
407 * \param b the blue color value multiplied into copy operations.
408 * \returns 0 on success or a negative error code on failure; call
409 * SDL_GetError() for more information.
410 *
411 * \since This function is available since SDL 2.0.0.
412 *
413 * \sa SDL_GetTextureColorMod
414 * \sa SDL_SetTextureAlphaMod
415 */
416extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
417 Uint8 r, Uint8 g, Uint8 b);
418
419
420/**
421 * Get the additional color value multiplied into render copy operations.
422 *
423 * \param texture the texture to query.
424 * \param r a pointer filled in with the current red color value.
425 * \param g a pointer filled in with the current green color value.
426 * \param b a pointer filled in with the current blue color value.
427 * \returns 0 on success or a negative error code on failure; call
428 * SDL_GetError() for more information.
429 *
430 * \since This function is available since SDL 2.0.0.
431 *
432 * \sa SDL_GetTextureAlphaMod
433 * \sa SDL_SetTextureColorMod
434 */
435extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
436 Uint8 * r, Uint8 * g,
437 Uint8 * b);
438
439/**
440 * Set an additional alpha value multiplied into render copy operations.
441 *
442 * When this texture is rendered, during the copy operation the source alpha
443 * value is modulated by this alpha value according to the following formula:
444 *
445 * `srcA = srcA * (alpha / 255)`
446 *
447 * Alpha modulation is not always supported by the renderer; it will return -1
448 * if alpha modulation is not supported.
449 *
450 * \param texture the texture to update.
451 * \param alpha the source alpha value multiplied into copy operations.
452 * \returns 0 on success or a negative error code on failure; call
453 * SDL_GetError() for more information.
454 *
455 * \since This function is available since SDL 2.0.0.
456 *
457 * \sa SDL_GetTextureAlphaMod
458 * \sa SDL_SetTextureColorMod
459 */
460extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
461 Uint8 alpha);
462
463/**
464 * Get the additional alpha value multiplied into render copy operations.
465 *
466 * \param texture the texture to query.
467 * \param alpha a pointer filled in with the current alpha value.
468 * \returns 0 on success or a negative error code on failure; call
469 * SDL_GetError() for more information.
470 *
471 * \since This function is available since SDL 2.0.0.
472 *
473 * \sa SDL_GetTextureColorMod
474 * \sa SDL_SetTextureAlphaMod
475 */
476extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
477 Uint8 * alpha);
478
479/**
480 * Set the blend mode for a texture, used by SDL_RenderCopy().
481 *
482 * If the blend mode is not supported, the closest supported mode is chosen
483 * and this function returns -1.
484 *
485 * \param texture the texture to update.
486 * \param blendMode the SDL_BlendMode to use for texture blending.
487 * \returns 0 on success or a negative error code on failure; call
488 * SDL_GetError() for more information.
489 *
490 * \since This function is available since SDL 2.0.0.
491 *
492 * \sa SDL_GetTextureBlendMode
493 * \sa SDL_RenderCopy
494 */
495extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
496 SDL_BlendMode blendMode);
497
498/**
499 * Get the blend mode used for texture copy operations.
500 *
501 * \param texture the texture to query.
502 * \param blendMode a pointer filled in with the current SDL_BlendMode.
503 * \returns 0 on success or a negative error code on failure; call
504 * SDL_GetError() for more information.
505 *
506 * \since This function is available since SDL 2.0.0.
507 *
508 * \sa SDL_SetTextureBlendMode
509 */
510extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
511 SDL_BlendMode *blendMode);
512
513/**
514 * Set the scale mode used for texture scale operations.
515 *
516 * If the scale mode is not supported, the closest supported mode is chosen.
517 *
518 * \param texture The texture to update.
519 * \param scaleMode the SDL_ScaleMode to use for texture scaling.
520 * \returns 0 on success, or -1 if the texture is not valid.
521 *
522 * \since This function is available since SDL 2.0.12.
523 *
524 * \sa SDL_GetTextureScaleMode
525 */
526extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture,
527 SDL_ScaleMode scaleMode);
528
529/**
530 * Get the scale mode used for texture scale operations.
531 *
532 * \param texture the texture to query.
533 * \param scaleMode a pointer filled in with the current scale mode.
534 * \return 0 on success, or -1 if the texture is not valid.
535 *
536 * \since This function is available since SDL 2.0.12.
537 *
538 * \sa SDL_SetTextureScaleMode
539 */
540extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture,
541 SDL_ScaleMode *scaleMode);
542
543/**
544 * Associate a user-specified pointer with a texture.
545 *
546 * \param texture the texture to update.
547 * \param userdata the pointer to associate with the texture.
548 * \returns 0 on success, or -1 if the texture is not valid.
549 *
550 * \since This function is available since SDL 2.0.18.
551 *
552 * \sa SDL_GetTextureUserData
553 */
554extern DECLSPEC int SDLCALL SDL_SetTextureUserData(SDL_Texture * texture,
555 void *userdata);
556
557/**
558 * Get the user-specified pointer associated with a texture
559 *
560 * \param texture the texture to query.
561 * \return the pointer associated with the texture, or NULL if the texture is
562 * not valid.
563 *
564 * \since This function is available since SDL 2.0.18.
565 *
566 * \sa SDL_SetTextureUserData
567 */
568extern DECLSPEC void * SDLCALL SDL_GetTextureUserData(SDL_Texture * texture);
569
570/**
571 * Update the given texture rectangle with new pixel data.
572 *
573 * The pixel data must be in the pixel format of the texture. Use
574 * SDL_QueryTexture() to query the pixel format of the texture.
575 *
576 * This is a fairly slow function, intended for use with static textures that
577 * do not change often.
578 *
579 * If the texture is intended to be updated often, it is preferred to create
580 * the texture as streaming and use the locking functions referenced below.
581 * While this function will work with streaming textures, for optimization
582 * reasons you may not get the pixels back if you lock the texture afterward.
583 *
584 * \param texture the texture to update.
585 * \param rect an SDL_Rect structure representing the area to update, or NULL
586 * to update the entire texture.
587 * \param pixels the raw pixel data in the format of the texture.
588 * \param pitch the number of bytes in a row of pixel data, including padding
589 * between lines.
590 * \returns 0 on success or a negative error code on failure; call
591 * SDL_GetError() for more information.
592 *
593 * \since This function is available since SDL 2.0.0.
594 *
595 * \sa SDL_CreateTexture
596 * \sa SDL_LockTexture
597 * \sa SDL_UnlockTexture
598 */
599extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
600 const SDL_Rect * rect,
601 const void *pixels, int pitch);
602
603/**
604 * Update a rectangle within a planar YV12 or IYUV texture with new pixel
605 * data.
606 *
607 * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
608 * block of Y and U/V planes in the proper order, but this function is
609 * available if your pixel data is not contiguous.
610 *
611 * \param texture the texture to update.
612 * \param rect a pointer to the rectangle of pixels to update, or NULL to
613 * update the entire texture.
614 * \param Yplane the raw pixel data for the Y plane.
615 * \param Ypitch the number of bytes between rows of pixel data for the Y
616 * plane.
617 * \param Uplane the raw pixel data for the U plane.
618 * \param Upitch the number of bytes between rows of pixel data for the U
619 * plane.
620 * \param Vplane the raw pixel data for the V plane.
621 * \param Vpitch the number of bytes between rows of pixel data for the V
622 * plane.
623 * \returns 0 on success or -1 if the texture is not valid; call
624 * SDL_GetError() for more information.
625 *
626 * \since This function is available since SDL 2.0.1.
627 *
628 * \sa SDL_UpdateTexture
629 */
630extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture,
631 const SDL_Rect * rect,
632 const Uint8 *Yplane, int Ypitch,
633 const Uint8 *Uplane, int Upitch,
634 const Uint8 *Vplane, int Vpitch);
635
636/**
637 * Update a rectangle within a planar NV12 or NV21 texture with new pixels.
638 *
639 * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
640 * block of NV12/21 planes in the proper order, but this function is available
641 * if your pixel data is not contiguous.
642 *
643 * \param texture the texture to update.
644 * \param rect a pointer to the rectangle of pixels to update, or NULL to
645 * update the entire texture.
646 * \param Yplane the raw pixel data for the Y plane.
647 * \param Ypitch the number of bytes between rows of pixel data for the Y
648 * plane.
649 * \param UVplane the raw pixel data for the UV plane.
650 * \param UVpitch the number of bytes between rows of pixel data for the UV
651 * plane.
652 * \return 0 on success, or -1 if the texture is not valid.
653 *
654 * \since This function is available since SDL 2.0.16.
655 */
656extern DECLSPEC int SDLCALL SDL_UpdateNVTexture(SDL_Texture * texture,
657 const SDL_Rect * rect,
658 const Uint8 *Yplane, int Ypitch,
659 const Uint8 *UVplane, int UVpitch);
660
661/**
662 * Lock a portion of the texture for **write-only** pixel access.
663 *
664 * As an optimization, the pixels made available for editing don't necessarily
665 * contain the old texture data. This is a write-only operation, and if you
666 * need to keep a copy of the texture data you should do that at the
667 * application level.
668 *
669 * You must use SDL_UnlockTexture() to unlock the pixels and apply any
670 * changes.
671 *
672 * \param texture the texture to lock for access, which was created with
673 * `SDL_TEXTUREACCESS_STREAMING`.
674 * \param rect an SDL_Rect structure representing the area to lock for access;
675 * NULL to lock the entire texture.
676 * \param pixels this is filled in with a pointer to the locked pixels,
677 * appropriately offset by the locked area.
678 * \param pitch this is filled in with the pitch of the locked pixels; the
679 * pitch is the length of one row in bytes.
680 * \returns 0 on success or a negative error code if the texture is not valid
681 * or was not created with `SDL_TEXTUREACCESS_STREAMING`; call
682 * SDL_GetError() for more information.
683 *
684 * \since This function is available since SDL 2.0.0.
685 *
686 * \sa SDL_UnlockTexture
687 */
688extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
689 const SDL_Rect * rect,
690 void **pixels, int *pitch);
691
692/**
693 * Lock a portion of the texture for **write-only** pixel access, and expose
694 * it as a SDL surface.
695 *
696 * Besides providing an SDL_Surface instead of raw pixel data, this function
697 * operates like SDL_LockTexture.
698 *
699 * As an optimization, the pixels made available for editing don't necessarily
700 * contain the old texture data. This is a write-only operation, and if you
701 * need to keep a copy of the texture data you should do that at the
702 * application level.
703 *
704 * You must use SDL_UnlockTexture() to unlock the pixels and apply any
705 * changes.
706 *
707 * The returned surface is freed internally after calling SDL_UnlockTexture()
708 * or SDL_DestroyTexture(). The caller should not free it.
709 *
710 * \param texture the texture to lock for access, which was created with
711 * `SDL_TEXTUREACCESS_STREAMING`.
712 * \param rect a pointer to the rectangle to lock for access. If the rect is
713 * NULL, the entire texture will be locked.
714 * \param surface this is filled in with an SDL surface representing the
715 * locked area.
716 * \returns 0 on success, or -1 if the texture is not valid or was not created
717 * with `SDL_TEXTUREACCESS_STREAMING`.
718 *
719 * \since This function is available since SDL 2.0.12.
720 *
721 * \sa SDL_LockTexture
722 * \sa SDL_UnlockTexture
723 */
724extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
725 const SDL_Rect *rect,
726 SDL_Surface **surface);
727
728/**
729 * Unlock a texture, uploading the changes to video memory, if needed.
730 *
731 * **Warning**: Please note that SDL_LockTexture() is intended to be
732 * write-only; it will not guarantee the previous contents of the texture will
733 * be provided. You must fully initialize any area of a texture that you lock
734 * before unlocking it, as the pixels might otherwise be uninitialized memory.
735 *
736 * Which is to say: locking and immediately unlocking a texture can result in
737 * corrupted textures, depending on the renderer in use.
738 *
739 * \param texture a texture locked by SDL_LockTexture().
740 *
741 * \since This function is available since SDL 2.0.0.
742 *
743 * \sa SDL_LockTexture
744 */
745extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
746
747/**
748 * Determine whether a renderer supports the use of render targets.
749 *
750 * \param renderer the renderer that will be checked.
751 * \returns SDL_TRUE if supported or SDL_FALSE if not.
752 *
753 * \since This function is available since SDL 2.0.0.
754 *
755 * \sa SDL_SetRenderTarget
756 */
757extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer);
758
759/**
760 * Set a texture as the current rendering target.
761 *
762 * Before using this function, you should check the
763 * `SDL_RENDERER_TARGETTEXTURE` bit in the flags of SDL_RendererInfo to see if
764 * render targets are supported.
765 *
766 * The default render target is the window for which the renderer was created.
767 * To stop rendering to a texture and render to the window again, call this
768 * function with a NULL `texture`. This will reset the renderer's viewport,
769 * clipping rectangle, and scaling settings to the state they were in before
770 * setting a non-NULL `texture` target, losing any changes made in the
771 * meantime.
772 *
773 * \param renderer the rendering context.
774 * \param texture the targeted texture, which must be created with the
775 * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the
776 * window instead of a texture.
777 * \returns 0 on success or a negative error code on failure; call
778 * SDL_GetError() for more information.
779 *
780 * \since This function is available since SDL 2.0.0.
781 *
782 * \sa SDL_GetRenderTarget
783 */
784extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
785 SDL_Texture *texture);
786
787/**
788 * Get the current render target.
789 *
790 * The default render target is the window for which the renderer was created,
791 * and is reported as NULL here.
792 *
793 * \param renderer the rendering context.
794 * \returns the current render target or NULL for the default render target.
795 *
796 * \since This function is available since SDL 2.0.0.
797 *
798 * \sa SDL_SetRenderTarget
799 */
800extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
801
802/**
803 * Set a device independent resolution for rendering.
804 *
805 * This function uses the viewport and scaling functionality to allow a fixed
806 * logical resolution for rendering, regardless of the actual output
807 * resolution. If the actual output resolution doesn't have the same aspect
808 * ratio the output rendering will be centered within the output display.
809 *
810 * If the output display is a window, mouse and touch events in the window
811 * will be filtered and scaled so they seem to arrive within the logical
812 * resolution. The SDL_HINT_MOUSE_RELATIVE_SCALING hint controls whether
813 * relative motion events are also scaled.
814 *
815 * If this function results in scaling or subpixel drawing by the rendering
816 * backend, it will be handled using the appropriate quality hints.
817 *
818 * \param renderer the renderer for which resolution should be set.
819 * \param w the width of the logical resolution.
820 * \param h the height of the logical resolution.
821 * \returns 0 on success or a negative error code on failure; call
822 * SDL_GetError() for more information.
823 *
824 * \since This function is available since SDL 2.0.0.
825 *
826 * \sa SDL_RenderGetLogicalSize
827 */
828extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h);
829
830/**
831 * Get device independent resolution for rendering.
832 *
833 * When using the main rendering target (eg no target texture is set): this
834 * may return 0 for `w` and `h` if the SDL_Renderer has never had its logical
835 * size set by SDL_RenderSetLogicalSize(). Otherwise it returns the logical
836 * width and height.
837 *
838 * When using a target texture: Never return 0 for `w` and `h` at first. Then
839 * it returns the logical width and height that are set.
840 *
841 * \param renderer a rendering context.
842 * \param w an int to be filled with the width.
843 * \param h an int to be filled with the height.
844 *
845 * \since This function is available since SDL 2.0.0.
846 *
847 * \sa SDL_RenderSetLogicalSize
848 */
849extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h);
850
851/**
852 * Set whether to force integer scales for resolution-independent rendering.
853 *
854 * This function restricts the logical viewport to integer values - that is,
855 * when a resolution is between two multiples of a logical size, the viewport
856 * size is rounded down to the lower multiple.
857 *
858 * \param renderer the renderer for which integer scaling should be set.
859 * \param enable enable or disable the integer scaling for rendering.
860 * \returns 0 on success or a negative error code on failure; call
861 * SDL_GetError() for more information.
862 *
863 * \since This function is available since SDL 2.0.5.
864 *
865 * \sa SDL_RenderGetIntegerScale
866 * \sa SDL_RenderSetLogicalSize
867 */
868extern DECLSPEC int SDLCALL SDL_RenderSetIntegerScale(SDL_Renderer * renderer,
869 SDL_bool enable);
870
871/**
872 * Get whether integer scales are forced for resolution-independent rendering.
873 *
874 * \param renderer the renderer from which integer scaling should be queried.
875 * \returns SDL_TRUE if integer scales are forced or SDL_FALSE if not and on
876 * failure; call SDL_GetError() for more information.
877 *
878 * \since This function is available since SDL 2.0.5.
879 *
880 * \sa SDL_RenderSetIntegerScale
881 */
882extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer);
883
884/**
885 * Set the drawing area for rendering on the current target.
886 *
887 * When the window is resized, the viewport is reset to fill the entire new
888 * window size.
889 *
890 * \param renderer the rendering context.
891 * \param rect the SDL_Rect structure representing the drawing area, or NULL
892 * to set the viewport to the entire target.
893 * \returns 0 on success or a negative error code on failure; call
894 * SDL_GetError() for more information.
895 *
896 * \since This function is available since SDL 2.0.0.
897 *
898 * \sa SDL_RenderGetViewport
899 */
900extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
901 const SDL_Rect * rect);
902
903/**
904 * Get the drawing area for the current target.
905 *
906 * \param renderer the rendering context.
907 * \param rect an SDL_Rect structure filled in with the current drawing area.
908 *
909 * \since This function is available since SDL 2.0.0.
910 *
911 * \sa SDL_RenderSetViewport
912 */
913extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
914 SDL_Rect * rect);
915
916/**
917 * Set the clip rectangle for rendering on the specified target.
918 *
919 * \param renderer the rendering context for which clip rectangle should be
920 * set.
921 * \param rect an SDL_Rect structure representing the clip area, relative to
922 * the viewport, or NULL to disable clipping.
923 * \returns 0 on success or a negative error code on failure; call
924 * SDL_GetError() for more information.
925 *
926 * \since This function is available since SDL 2.0.0.
927 *
928 * \sa SDL_RenderGetClipRect
929 * \sa SDL_RenderIsClipEnabled
930 */
931extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer,
932 const SDL_Rect * rect);
933
934/**
935 * Get the clip rectangle for the current target.
936 *
937 * \param renderer the rendering context from which clip rectangle should be
938 * queried.
939 * \param rect an SDL_Rect structure filled in with the current clipping area
940 * or an empty rectangle if clipping is disabled.
941 *
942 * \since This function is available since SDL 2.0.0.
943 *
944 * \sa SDL_RenderIsClipEnabled
945 * \sa SDL_RenderSetClipRect
946 */
947extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer,
948 SDL_Rect * rect);
949
950/**
951 * Get whether clipping is enabled on the given renderer.
952 *
953 * \param renderer the renderer from which clip state should be queried.
954 * \returns SDL_TRUE if clipping is enabled or SDL_FALSE if not; call
955 * SDL_GetError() for more information.
956 *
957 * \since This function is available since SDL 2.0.4.
958 *
959 * \sa SDL_RenderGetClipRect
960 * \sa SDL_RenderSetClipRect
961 */
962extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer);
963
964
965/**
966 * Set the drawing scale for rendering on the current target.
967 *
968 * The drawing coordinates are scaled by the x/y scaling factors before they
969 * are used by the renderer. This allows resolution independent drawing with a
970 * single coordinate system.
971 *
972 * If this results in scaling or subpixel drawing by the rendering backend, it
973 * will be handled using the appropriate quality hints. For best results use
974 * integer scaling factors.
975 *
976 * \param renderer a rendering context.
977 * \param scaleX the horizontal scaling factor.
978 * \param scaleY the vertical scaling factor.
979 * \returns 0 on success or a negative error code on failure; call
980 * SDL_GetError() for more information.
981 *
982 * \since This function is available since SDL 2.0.0.
983 *
984 * \sa SDL_RenderGetScale
985 * \sa SDL_RenderSetLogicalSize
986 */
987extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
988 float scaleX, float scaleY);
989
990/**
991 * Get the drawing scale for the current target.
992 *
993 * \param renderer the renderer from which drawing scale should be queried.
994 * \param scaleX a pointer filled in with the horizontal scaling factor.
995 * \param scaleY a pointer filled in with the vertical scaling factor.
996 *
997 * \since This function is available since SDL 2.0.0.
998 *
999 * \sa SDL_RenderSetScale
1000 */
1001extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
1002 float *scaleX, float *scaleY);
1003
1004/**
1005 * Get logical coordinates of point in renderer when given real coordinates of
1006 * point in window.
1007 *
1008 * Logical coordinates will differ from real coordinates when render is scaled
1009 * and logical renderer size set
1010 *
1011 * \param renderer the renderer from which the logical coordinates should be
1012 * calculated.
1013 * \param windowX the real X coordinate in the window.
1014 * \param windowY the real Y coordinate in the window.
1015 * \param logicalX the pointer filled with the logical x coordinate.
1016 * \param logicalY the pointer filled with the logical y coordinate.
1017 *
1018 * \since This function is available since SDL 2.0.18.
1019 *
1020 * \sa SDL_RenderGetScale
1021 * \sa SDL_RenderSetScale
1022 * \sa SDL_RenderGetLogicalSize
1023 * \sa SDL_RenderSetLogicalSize
1024 */
1025extern DECLSPEC void SDLCALL SDL_RenderWindowToLogical(SDL_Renderer * renderer,
1026 int windowX, int windowY,
1027 float *logicalX, float *logicalY);
1028
1029
1030/**
1031 * Get real coordinates of point in window when given logical coordinates of
1032 * point in renderer.
1033 *
1034 * Logical coordinates will differ from real coordinates when render is scaled
1035 * and logical renderer size set
1036 *
1037 * \param renderer the renderer from which the window coordinates should be
1038 * calculated.
1039 * \param logicalX the logical x coordinate.
1040 * \param logicalY the logical y coordinate.
1041 * \param windowX the pointer filled with the real X coordinate in the window.
1042 * \param windowY the pointer filled with the real Y coordinate in the window.
1043 *
1044 * \since This function is available since SDL 2.0.18.
1045 *
1046 * \sa SDL_RenderGetScale
1047 * \sa SDL_RenderSetScale
1048 * \sa SDL_RenderGetLogicalSize
1049 * \sa SDL_RenderSetLogicalSize
1050 */
1051extern DECLSPEC void SDLCALL SDL_RenderLogicalToWindow(SDL_Renderer * renderer,
1052 float logicalX, float logicalY,
1053 int *windowX, int *windowY);
1054
1055/**
1056 * Set the color used for drawing operations (Rect, Line and Clear).
1057 *
1058 * Set the color for drawing or filling rectangles, lines, and points, and for
1059 * SDL_RenderClear().
1060 *
1061 * \param renderer the rendering context.
1062 * \param r the red value used to draw on the rendering target.
1063 * \param g the green value used to draw on the rendering target.
1064 * \param b the blue value used to draw on the rendering target.
1065 * \param a the alpha value used to draw on the rendering target; usually
1066 * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
1067 * specify how the alpha channel is used.
1068 * \returns 0 on success or a negative error code on failure; call
1069 * SDL_GetError() for more information.
1070 *
1071 * \since This function is available since SDL 2.0.0.
1072 *
1073 * \sa SDL_GetRenderDrawColor
1074 * \sa SDL_RenderClear
1075 * \sa SDL_RenderDrawLine
1076 * \sa SDL_RenderDrawLines
1077 * \sa SDL_RenderDrawPoint
1078 * \sa SDL_RenderDrawPoints
1079 * \sa SDL_RenderDrawRect
1080 * \sa SDL_RenderDrawRects
1081 * \sa SDL_RenderFillRect
1082 * \sa SDL_RenderFillRects
1083 */
1084extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer,
1085 Uint8 r, Uint8 g, Uint8 b,
1086 Uint8 a);
1087
1088/**
1089 * Get the color used for drawing operations (Rect, Line and Clear).
1090 *
1091 * \param renderer the rendering context.
1092 * \param r a pointer filled in with the red value used to draw on the
1093 * rendering target.
1094 * \param g a pointer filled in with the green value used to draw on the
1095 * rendering target.
1096 * \param b a pointer filled in with the blue value used to draw on the
1097 * rendering target.
1098 * \param a a pointer filled in with the alpha value used to draw on the
1099 * rendering target; usually `SDL_ALPHA_OPAQUE` (255).
1100 * \returns 0 on success or a negative error code on failure; call
1101 * SDL_GetError() for more information.
1102 *
1103 * \since This function is available since SDL 2.0.0.
1104 *
1105 * \sa SDL_SetRenderDrawColor
1106 */
1107extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer,
1108 Uint8 * r, Uint8 * g, Uint8 * b,
1109 Uint8 * a);
1110
1111/**
1112 * Set the blend mode used for drawing operations (Fill and Line).
1113 *
1114 * If the blend mode is not supported, the closest supported mode is chosen.
1115 *
1116 * \param renderer the rendering context.
1117 * \param blendMode the SDL_BlendMode to use for blending.
1118 * \returns 0 on success or a negative error code on failure; call
1119 * SDL_GetError() for more information.
1120 *
1121 * \since This function is available since SDL 2.0.0.
1122 *
1123 * \sa SDL_GetRenderDrawBlendMode
1124 * \sa SDL_RenderDrawLine
1125 * \sa SDL_RenderDrawLines
1126 * \sa SDL_RenderDrawPoint
1127 * \sa SDL_RenderDrawPoints
1128 * \sa SDL_RenderDrawRect
1129 * \sa SDL_RenderDrawRects
1130 * \sa SDL_RenderFillRect
1131 * \sa SDL_RenderFillRects
1132 */
1133extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
1134 SDL_BlendMode blendMode);
1135
1136/**
1137 * Get the blend mode used for drawing operations.
1138 *
1139 * \param renderer the rendering context.
1140 * \param blendMode a pointer filled in with the current SDL_BlendMode.
1141 * \returns 0 on success or a negative error code on failure; call
1142 * SDL_GetError() for more information.
1143 *
1144 * \since This function is available since SDL 2.0.0.
1145 *
1146 * \sa SDL_SetRenderDrawBlendMode
1147 */
1148extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
1149 SDL_BlendMode *blendMode);
1150
1151/**
1152 * Clear the current rendering target with the drawing color.
1153 *
1154 * This function clears the entire rendering target, ignoring the viewport and
1155 * the clip rectangle.
1156 *
1157 * \param renderer the rendering context.
1158 * \returns 0 on success or a negative error code on failure; call
1159 * SDL_GetError() for more information.
1160 *
1161 * \since This function is available since SDL 2.0.0.
1162 *
1163 * \sa SDL_SetRenderDrawColor
1164 */
1165extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
1166
1167/**
1168 * Draw a point on the current rendering target.
1169 *
1170 * SDL_RenderDrawPoint() draws a single point. If you want to draw multiple,
1171 * use SDL_RenderDrawPoints() instead.
1172 *
1173 * \param renderer the rendering context.
1174 * \param x the x coordinate of the point.
1175 * \param y the y coordinate of the point.
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 2.0.0.
1180 *
1181 * \sa SDL_RenderDrawLine
1182 * \sa SDL_RenderDrawLines
1183 * \sa SDL_RenderDrawPoints
1184 * \sa SDL_RenderDrawRect
1185 * \sa SDL_RenderDrawRects
1186 * \sa SDL_RenderFillRect
1187 * \sa SDL_RenderFillRects
1188 * \sa SDL_RenderPresent
1189 * \sa SDL_SetRenderDrawBlendMode
1190 * \sa SDL_SetRenderDrawColor
1191 */
1192extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
1193 int x, int y);
1194
1195/**
1196 * Draw multiple points on the current rendering target.
1197 *
1198 * \param renderer the rendering context.
1199 * \param points an array of SDL_Point structures that represent the points to
1200 * draw.
1201 * \param count the number of points to draw.
1202 * \returns 0 on success or a negative error code on failure; call
1203 * SDL_GetError() for more information.
1204 *
1205 * \since This function is available since SDL 2.0.0.
1206 *
1207 * \sa SDL_RenderDrawLine
1208 * \sa SDL_RenderDrawLines
1209 * \sa SDL_RenderDrawPoint
1210 * \sa SDL_RenderDrawRect
1211 * \sa SDL_RenderDrawRects
1212 * \sa SDL_RenderFillRect
1213 * \sa SDL_RenderFillRects
1214 * \sa SDL_RenderPresent
1215 * \sa SDL_SetRenderDrawBlendMode
1216 * \sa SDL_SetRenderDrawColor
1217 */
1218extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
1219 const SDL_Point * points,
1220 int count);
1221
1222/**
1223 * Draw a line on the current rendering target.
1224 *
1225 * SDL_RenderDrawLine() draws the line to include both end points. If you want
1226 * to draw multiple, connecting lines use SDL_RenderDrawLines() instead.
1227 *
1228 * \param renderer the rendering context.
1229 * \param x1 the x coordinate of the start point.
1230 * \param y1 the y coordinate of the start point.
1231 * \param x2 the x coordinate of the end point.
1232 * \param y2 the y coordinate of the end point.
1233 * \returns 0 on success or a negative error code on failure; call
1234 * SDL_GetError() for more information.
1235 *
1236 * \since This function is available since SDL 2.0.0.
1237 *
1238 * \sa SDL_RenderDrawLines
1239 * \sa SDL_RenderDrawPoint
1240 * \sa SDL_RenderDrawPoints
1241 * \sa SDL_RenderDrawRect
1242 * \sa SDL_RenderDrawRects
1243 * \sa SDL_RenderFillRect
1244 * \sa SDL_RenderFillRects
1245 * \sa SDL_RenderPresent
1246 * \sa SDL_SetRenderDrawBlendMode
1247 * \sa SDL_SetRenderDrawColor
1248 */
1249extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
1250 int x1, int y1, int x2, int y2);
1251
1252/**
1253 * Draw a series of connected lines on the current rendering target.
1254 *
1255 * \param renderer the rendering context.
1256 * \param points an array of SDL_Point structures representing points along
1257 * the lines.
1258 * \param count the number of points, drawing count-1 lines.
1259 * \returns 0 on success or a negative error code on failure; call
1260 * SDL_GetError() for more information.
1261 *
1262 * \since This function is available since SDL 2.0.0.
1263 *
1264 * \sa SDL_RenderDrawLine
1265 * \sa SDL_RenderDrawPoint
1266 * \sa SDL_RenderDrawPoints
1267 * \sa SDL_RenderDrawRect
1268 * \sa SDL_RenderDrawRects
1269 * \sa SDL_RenderFillRect
1270 * \sa SDL_RenderFillRects
1271 * \sa SDL_RenderPresent
1272 * \sa SDL_SetRenderDrawBlendMode
1273 * \sa SDL_SetRenderDrawColor
1274 */
1275extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
1276 const SDL_Point * points,
1277 int count);
1278
1279/**
1280 * Draw a rectangle on the current rendering target.
1281 *
1282 * \param renderer the rendering context.
1283 * \param rect an SDL_Rect structure representing the rectangle to draw, or
1284 * NULL to outline the entire rendering target.
1285 * \returns 0 on success or a negative error code on failure; call
1286 * SDL_GetError() for more information.
1287 *
1288 * \since This function is available since SDL 2.0.0.
1289 *
1290 * \sa SDL_RenderDrawLine
1291 * \sa SDL_RenderDrawLines
1292 * \sa SDL_RenderDrawPoint
1293 * \sa SDL_RenderDrawPoints
1294 * \sa SDL_RenderDrawRects
1295 * \sa SDL_RenderFillRect
1296 * \sa SDL_RenderFillRects
1297 * \sa SDL_RenderPresent
1298 * \sa SDL_SetRenderDrawBlendMode
1299 * \sa SDL_SetRenderDrawColor
1300 */
1301extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
1302 const SDL_Rect * rect);
1303
1304/**
1305 * Draw some number of rectangles on the current rendering target.
1306 *
1307 * \param renderer the rendering context.
1308 * \param rects an array of SDL_Rect structures representing the rectangles to
1309 * be drawn.
1310 * \param count the number of rectangles.
1311 * \returns 0 on success or a negative error code on failure; call
1312 * SDL_GetError() for more information.
1313 *
1314 * \since This function is available since SDL 2.0.0.
1315 *
1316 * \sa SDL_RenderDrawLine
1317 * \sa SDL_RenderDrawLines
1318 * \sa SDL_RenderDrawPoint
1319 * \sa SDL_RenderDrawPoints
1320 * \sa SDL_RenderDrawRect
1321 * \sa SDL_RenderFillRect
1322 * \sa SDL_RenderFillRects
1323 * \sa SDL_RenderPresent
1324 * \sa SDL_SetRenderDrawBlendMode
1325 * \sa SDL_SetRenderDrawColor
1326 */
1327extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
1328 const SDL_Rect * rects,
1329 int count);
1330
1331/**
1332 * Fill a rectangle on the current rendering target with the drawing color.
1333 *
1334 * The current drawing color is set by SDL_SetRenderDrawColor(), and the
1335 * color's alpha value is ignored unless blending is enabled with the
1336 * appropriate call to SDL_SetRenderDrawBlendMode().
1337 *
1338 * \param renderer the rendering context.
1339 * \param rect the SDL_Rect structure representing the rectangle to fill, or
1340 * NULL for the entire rendering target.
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 2.0.0.
1345 *
1346 * \sa SDL_RenderDrawLine
1347 * \sa SDL_RenderDrawLines
1348 * \sa SDL_RenderDrawPoint
1349 * \sa SDL_RenderDrawPoints
1350 * \sa SDL_RenderDrawRect
1351 * \sa SDL_RenderDrawRects
1352 * \sa SDL_RenderFillRects
1353 * \sa SDL_RenderPresent
1354 * \sa SDL_SetRenderDrawBlendMode
1355 * \sa SDL_SetRenderDrawColor
1356 */
1357extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
1358 const SDL_Rect * rect);
1359
1360/**
1361 * Fill some number of rectangles on the current rendering target with the
1362 * drawing color.
1363 *
1364 * \param renderer the rendering context.
1365 * \param rects an array of SDL_Rect structures representing the rectangles to
1366 * be filled.
1367 * \param count the number of rectangles.
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 2.0.0.
1372 *
1373 * \sa SDL_RenderDrawLine
1374 * \sa SDL_RenderDrawLines
1375 * \sa SDL_RenderDrawPoint
1376 * \sa SDL_RenderDrawPoints
1377 * \sa SDL_RenderDrawRect
1378 * \sa SDL_RenderDrawRects
1379 * \sa SDL_RenderFillRect
1380 * \sa SDL_RenderPresent
1381 */
1382extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
1383 const SDL_Rect * rects,
1384 int count);
1385
1386/**
1387 * Copy a portion of the texture to the current rendering target.
1388 *
1389 * The texture is blended with the destination based on its blend mode set
1390 * with SDL_SetTextureBlendMode().
1391 *
1392 * The texture color is affected based on its color modulation set by
1393 * SDL_SetTextureColorMod().
1394 *
1395 * The texture alpha is affected based on its alpha modulation set by
1396 * SDL_SetTextureAlphaMod().
1397 *
1398 * \param renderer the rendering context.
1399 * \param texture the source texture.
1400 * \param srcrect the source SDL_Rect structure or NULL for the entire
1401 * texture.
1402 * \param dstrect the destination SDL_Rect structure or NULL for the entire
1403 * rendering target; the texture will be stretched to fill the
1404 * given rectangle.
1405 * \returns 0 on success or a negative error code on failure; call
1406 * SDL_GetError() for more information.
1407 *
1408 * \since This function is available since SDL 2.0.0.
1409 *
1410 * \sa SDL_RenderCopyEx
1411 * \sa SDL_SetTextureAlphaMod
1412 * \sa SDL_SetTextureBlendMode
1413 * \sa SDL_SetTextureColorMod
1414 */
1415extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
1416 SDL_Texture * texture,
1417 const SDL_Rect * srcrect,
1418 const SDL_Rect * dstrect);
1419
1420/**
1421 * Copy a portion of the texture to the current rendering, with optional
1422 * rotation and flipping.
1423 *
1424 * Copy a portion of the texture to the current rendering target, optionally
1425 * rotating it by angle around the given center and also flipping it
1426 * top-bottom and/or left-right.
1427 *
1428 * The texture is blended with the destination based on its blend mode set
1429 * with SDL_SetTextureBlendMode().
1430 *
1431 * The texture color is affected based on its color modulation set by
1432 * SDL_SetTextureColorMod().
1433 *
1434 * The texture alpha is affected based on its alpha modulation set by
1435 * SDL_SetTextureAlphaMod().
1436 *
1437 * \param renderer the rendering context.
1438 * \param texture the source texture.
1439 * \param srcrect the source SDL_Rect structure or NULL for the entire
1440 * texture.
1441 * \param dstrect the destination SDL_Rect structure or NULL for the entire
1442 * rendering target.
1443 * \param angle an angle in degrees that indicates the rotation that will be
1444 * applied to dstrect, rotating it in a clockwise direction.
1445 * \param center a pointer to a point indicating the point around which
1446 * dstrect will be rotated (if NULL, rotation will be done
1447 * around `dstrect.w / 2`, `dstrect.h / 2`).
1448 * \param flip a SDL_RendererFlip value stating which flipping actions should
1449 * be performed on the texture.
1450 * \returns 0 on success or a negative error code on failure; call
1451 * SDL_GetError() for more information.
1452 *
1453 * \since This function is available since SDL 2.0.0.
1454 *
1455 * \sa SDL_RenderCopy
1456 * \sa SDL_SetTextureAlphaMod
1457 * \sa SDL_SetTextureBlendMode
1458 * \sa SDL_SetTextureColorMod
1459 */
1460extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
1461 SDL_Texture * texture,
1462 const SDL_Rect * srcrect,
1463 const SDL_Rect * dstrect,
1464 const double angle,
1465 const SDL_Point *center,
1466 const SDL_RendererFlip flip);
1467
1468
1469/**
1470 * Draw a point on the current rendering target at subpixel precision.
1471 *
1472 * \param renderer The renderer which should draw a point.
1473 * \param x The x coordinate of the point.
1474 * \param y The y coordinate of the point.
1475 * \return 0 on success, or -1 on error.
1476 *
1477 * \since This function is available since SDL 2.0.10.
1478 */
1479extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer,
1480 float x, float y);
1481
1482/**
1483 * Draw multiple points on the current rendering target at subpixel precision.
1484 *
1485 * \param renderer The renderer which should draw multiple points.
1486 * \param points The points to draw.
1487 * \param count The number of points to draw.
1488 * \return 0 on success, or -1 on error.
1489 *
1490 * \since This function is available since SDL 2.0.10.
1491 */
1492extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer,
1493 const SDL_FPoint * points,
1494 int count);
1495
1496/**
1497 * Draw a line on the current rendering target at subpixel precision.
1498 *
1499 * \param renderer The renderer which should draw a line.
1500 * \param x1 The x coordinate of the start point.
1501 * \param y1 The y coordinate of the start point.
1502 * \param x2 The x coordinate of the end point.
1503 * \param y2 The y coordinate of the end point.
1504 * \return 0 on success, or -1 on error.
1505 *
1506 * \since This function is available since SDL 2.0.10.
1507 */
1508extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer,
1509 float x1, float y1, float x2, float y2);
1510
1511/**
1512 * Draw a series of connected lines on the current rendering target at
1513 * subpixel precision.
1514 *
1515 * \param renderer The renderer which should draw multiple lines.
1516 * \param points The points along the lines.
1517 * \param count The number of points, drawing count-1 lines.
1518 * \return 0 on success, or -1 on error.
1519 *
1520 * \since This function is available since SDL 2.0.10.
1521 */
1522extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer,
1523 const SDL_FPoint * points,
1524 int count);
1525
1526/**
1527 * Draw a rectangle on the current rendering target at subpixel precision.
1528 *
1529 * \param renderer The renderer which should draw a rectangle.
1530 * \param rect A pointer to the destination rectangle, or NULL to outline the
1531 * entire rendering target.
1532 * \return 0 on success, or -1 on error.
1533 *
1534 * \since This function is available since SDL 2.0.10.
1535 */
1536extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer,
1537 const SDL_FRect * rect);
1538
1539/**
1540 * Draw some number of rectangles on the current rendering target at subpixel
1541 * precision.
1542 *
1543 * \param renderer The renderer which should draw multiple rectangles.
1544 * \param rects A pointer to an array of destination rectangles.
1545 * \param count The number of rectangles.
1546 * \return 0 on success, or -1 on error.
1547 *
1548 * \since This function is available since SDL 2.0.10.
1549 */
1550extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer,
1551 const SDL_FRect * rects,
1552 int count);
1553
1554/**
1555 * Fill a rectangle on the current rendering target with the drawing color at
1556 * subpixel precision.
1557 *
1558 * \param renderer The renderer which should fill a rectangle.
1559 * \param rect A pointer to the destination rectangle, or NULL for the entire
1560 * rendering target.
1561 * \return 0 on success, or -1 on error.
1562 *
1563 * \since This function is available since SDL 2.0.10.
1564 */
1565extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer,
1566 const SDL_FRect * rect);
1567
1568/**
1569 * Fill some number of rectangles on the current rendering target with the
1570 * drawing color at subpixel precision.
1571 *
1572 * \param renderer The renderer which should fill multiple rectangles.
1573 * \param rects A pointer to an array of destination rectangles.
1574 * \param count The number of rectangles.
1575 * \return 0 on success, or -1 on error.
1576 *
1577 * \since This function is available since SDL 2.0.10.
1578 */
1579extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer,
1580 const SDL_FRect * rects,
1581 int count);
1582
1583/**
1584 * Copy a portion of the texture to the current rendering target at subpixel
1585 * precision.
1586 *
1587 * \param renderer The renderer which should copy parts of a texture.
1588 * \param texture The source texture.
1589 * \param srcrect A pointer to the source rectangle, or NULL for the entire
1590 * texture.
1591 * \param dstrect A pointer to the destination rectangle, or NULL for the
1592 * entire rendering target.
1593 * \return 0 on success, or -1 on error.
1594 *
1595 * \since This function is available since SDL 2.0.10.
1596 */
1597extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer,
1598 SDL_Texture * texture,
1599 const SDL_Rect * srcrect,
1600 const SDL_FRect * dstrect);
1601
1602/**
1603 * Copy a portion of the source texture to the current rendering target, with
1604 * rotation and flipping, at subpixel precision.
1605 *
1606 * \param renderer The renderer which should copy parts of a texture.
1607 * \param texture The source texture.
1608 * \param srcrect A pointer to the source rectangle, or NULL for the entire
1609 * texture.
1610 * \param dstrect A pointer to the destination rectangle, or NULL for the
1611 * entire rendering target.
1612 * \param angle An angle in degrees that indicates the rotation that will be
1613 * applied to dstrect, rotating it in a clockwise direction.
1614 * \param center A pointer to a point indicating the point around which
1615 * dstrect will be rotated (if NULL, rotation will be done
1616 * around dstrect.w/2, dstrect.h/2).
1617 * \param flip An SDL_RendererFlip value stating which flipping actions should
1618 * be performed on the texture.
1619 * \return 0 on success, or -1 on error.
1620 *
1621 * \since This function is available since SDL 2.0.10.
1622 */
1623extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer,
1624 SDL_Texture * texture,
1625 const SDL_Rect * srcrect,
1626 const SDL_FRect * dstrect,
1627 const double angle,
1628 const SDL_FPoint *center,
1629 const SDL_RendererFlip flip);
1630
1631/**
1632 * Render a list of triangles, optionally using a texture and indices into the
1633 * vertex array Color and alpha modulation is done per vertex
1634 * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
1635 *
1636 * \param renderer The rendering context.
1637 * \param texture (optional) The SDL texture to use.
1638 * \param vertices Vertices.
1639 * \param num_vertices Number of vertices.
1640 * \param indices (optional) An array of integer indices into the 'vertices'
1641 * array, if NULL all vertices will be rendered in sequential
1642 * order.
1643 * \param num_indices Number of indices.
1644 * \return 0 on success, or -1 if the operation is not supported.
1645 *
1646 * \since This function is available since SDL 2.0.18.
1647 *
1648 * \sa SDL_RenderGeometryRaw
1649 * \sa SDL_Vertex
1650 */
1651extern DECLSPEC int SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
1652 SDL_Texture *texture,
1653 const SDL_Vertex *vertices, int num_vertices,
1654 const int *indices, int num_indices);
1655
1656/**
1657 * Render a list of triangles, optionally using a texture and indices into the
1658 * vertex arrays Color and alpha modulation is done per vertex
1659 * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
1660 *
1661 * \param renderer The rendering context.
1662 * \param texture (optional) The SDL texture to use.
1663 * \param xy Vertex positions.
1664 * \param xy_stride Byte size to move from one element to the next element.
1665 * \param color Vertex colors (as SDL_Color).
1666 * \param color_stride Byte size to move from one element to the next element.
1667 * \param uv Vertex normalized texture coordinates.
1668 * \param uv_stride Byte size to move from one element to the next element.
1669 * \param num_vertices Number of vertices.
1670 * \param indices (optional) An array of indices into the 'vertices' arrays,
1671 * if NULL all vertices will be rendered in sequential order.
1672 * \param num_indices Number of indices.
1673 * \param size_indices Index size: 1 (byte), 2 (short), 4 (int).
1674 * \return 0 on success, or -1 if the operation is not supported.
1675 *
1676 * \since This function is available since SDL 2.0.18.
1677 *
1678 * \sa SDL_RenderGeometry
1679 * \sa SDL_Vertex
1680 */
1681extern DECLSPEC int SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
1682 SDL_Texture *texture,
1683 const float *xy, int xy_stride,
1684 const SDL_Color *color, int color_stride,
1685 const float *uv, int uv_stride,
1686 int num_vertices,
1687 const void *indices, int num_indices, int size_indices);
1688
1689/**
1690 * Read pixels from the current rendering target to an array of pixels.
1691 *
1692 * **WARNING**: This is a very slow operation, and should not be used
1693 * frequently. If you're using this on the main rendering target, it should be
1694 * called after rendering and before SDL_RenderPresent().
1695 *
1696 * `pitch` specifies the number of bytes between rows in the destination
1697 * `pixels` data. This allows you to write to a subrectangle or have padded
1698 * rows in the destination. Generally, `pitch` should equal the number of
1699 * pixels per row in the `pixels` data times the number of bytes per pixel,
1700 * but it might contain additional padding (for example, 24bit RGB Windows
1701 * Bitmap data pads all rows to multiples of 4 bytes).
1702 *
1703 * \param renderer the rendering context.
1704 * \param rect an SDL_Rect structure representing the area to read, or NULL
1705 * for the entire render target.
1706 * \param format an SDL_PixelFormatEnum value of the desired format of the
1707 * pixel data, or 0 to use the format of the rendering target.
1708 * \param pixels a pointer to the pixel data to copy into.
1709 * \param pitch the pitch of the `pixels` parameter.
1710 * \returns 0 on success or a negative error code on failure; call
1711 * SDL_GetError() for more information.
1712 *
1713 * \since This function is available since SDL 2.0.0.
1714 */
1715extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
1716 const SDL_Rect * rect,
1717 Uint32 format,
1718 void *pixels, int pitch);
1719
1720/**
1721 * Update the screen with any rendering performed since the previous call.
1722 *
1723 * SDL's rendering functions operate on a backbuffer; that is, calling a
1724 * rendering function such as SDL_RenderDrawLine() does not directly put a
1725 * line on the screen, but rather updates the backbuffer. As such, you compose
1726 * your entire scene and *present* the composed backbuffer to the screen as a
1727 * complete picture.
1728 *
1729 * Therefore, when using SDL's rendering API, one does all drawing intended
1730 * for the frame, and then calls this function once per frame to present the
1731 * final drawing to the user.
1732 *
1733 * The backbuffer should be considered invalidated after each present; do not
1734 * assume that previous contents will exist between frames. You are strongly
1735 * encouraged to call SDL_RenderClear() to initialize the backbuffer before
1736 * starting each new frame's drawing, even if you plan to overwrite every
1737 * pixel.
1738 *
1739 * \param renderer the rendering context.
1740 *
1741 * \threadsafety You may only call this function on the main thread. If this
1742 * happens to work on a background thread on any given platform
1743 * or backend, it's purely by luck and you should not rely on it
1744 * to work next time.
1745 *
1746 * \since This function is available since SDL 2.0.0.
1747 *
1748 * \sa SDL_CreateRenderer
1749 * \sa SDL_RenderClear
1750 * \sa SDL_RenderDrawLine
1751 * \sa SDL_RenderDrawLines
1752 * \sa SDL_RenderDrawPoint
1753 * \sa SDL_RenderDrawPoints
1754 * \sa SDL_RenderDrawRect
1755 * \sa SDL_RenderDrawRects
1756 * \sa SDL_RenderFillRect
1757 * \sa SDL_RenderFillRects
1758 * \sa SDL_SetRenderDrawBlendMode
1759 * \sa SDL_SetRenderDrawColor
1760 */
1761extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
1762
1763/**
1764 * Destroy the specified texture.
1765 *
1766 * Passing NULL or an otherwise invalid texture will set the SDL error message
1767 * to "Invalid texture".
1768 *
1769 * \param texture the texture to destroy.
1770 *
1771 * \since This function is available since SDL 2.0.0.
1772 *
1773 * \sa SDL_CreateTexture
1774 * \sa SDL_CreateTextureFromSurface
1775 */
1776extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
1777
1778/**
1779 * Destroy the rendering context for a window and free associated textures.
1780 *
1781 * If `renderer` is NULL, this function will return immediately after setting
1782 * the SDL error message to "Invalid renderer". See SDL_GetError().
1783 *
1784 * \param renderer the rendering context.
1785 *
1786 * \since This function is available since SDL 2.0.0.
1787 *
1788 * \sa SDL_CreateRenderer
1789 */
1790extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
1791
1792/**
1793 * Force the rendering context to flush any pending commands to the underlying
1794 * rendering API.
1795 *
1796 * You do not need to (and in fact, shouldn't) call this function unless you
1797 * are planning to call into OpenGL/Direct3D/Metal/whatever directly in
1798 * addition to using an SDL_Renderer.
1799 *
1800 * This is for a very-specific case: if you are using SDL's render API, you
1801 * asked for a specific renderer backend (OpenGL, Direct3D, etc), you set
1802 * SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever
1803 * calls in addition to SDL render API calls. If all of this applies, you
1804 * should call SDL_RenderFlush() between calls to SDL's render API and the
1805 * low-level API you're using in cooperation.
1806 *
1807 * In all other cases, you can ignore this function. This is only here to get
1808 * maximum performance out of a specific situation. In all other cases, SDL
1809 * will do the right thing, perhaps at a performance loss.
1810 *
1811 * This function is first available in SDL 2.0.10, and is not needed in 2.0.9
1812 * and earlier, as earlier versions did not queue rendering commands at all,
1813 * instead flushing them to the OS immediately.
1814 *
1815 * \param renderer the rendering context.
1816 * \returns 0 on success or a negative error code on failure; call
1817 * SDL_GetError() for more information.
1818 *
1819 * \since This function is available since SDL 2.0.10.
1820 */
1821extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer);
1822
1823
1824/**
1825 * Bind an OpenGL/ES/ES2 texture to the current context.
1826 *
1827 * This is for use with OpenGL instructions when rendering OpenGL primitives
1828 * directly.
1829 *
1830 * If not NULL, `texw` and `texh` will be filled with the width and height
1831 * values suitable for the provided texture. In most cases, both will be 1.0,
1832 * however, on systems that support the GL_ARB_texture_rectangle extension,
1833 * these values will actually be the pixel width and height used to create the
1834 * texture, so this factor needs to be taken into account when providing
1835 * texture coordinates to OpenGL.
1836 *
1837 * You need a renderer to create an SDL_Texture, therefore you can only use
1838 * this function with an implicit OpenGL context from SDL_CreateRenderer(),
1839 * not with your own OpenGL context. If you need control over your OpenGL
1840 * context, you need to write your own texture-loading methods.
1841 *
1842 * Also note that SDL may upload RGB textures as BGR (or vice-versa), and
1843 * re-order the color channels in the shaders phase, so the uploaded texture
1844 * may have swapped color channels.
1845 *
1846 * \param texture the texture to bind to the current OpenGL/ES/ES2 context.
1847 * \param texw a pointer to a float value which will be filled with the
1848 * texture width or NULL if you don't need that value.
1849 * \param texh a pointer to a float value which will be filled with the
1850 * texture height or NULL if you don't need that value.
1851 * \returns 0 on success, or -1 if the operation is not supported; call
1852 * SDL_GetError() for more information.
1853 *
1854 * \since This function is available since SDL 2.0.0.
1855 *
1856 * \sa SDL_GL_MakeCurrent
1857 * \sa SDL_GL_UnbindTexture
1858 */
1859extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);
1860
1861/**
1862 * Unbind an OpenGL/ES/ES2 texture from the current context.
1863 *
1864 * See SDL_GL_BindTexture() for examples on how to use these functions
1865 *
1866 * \param texture the texture to unbind from the current OpenGL/ES/ES2
1867 * context.
1868 * \returns 0 on success, or -1 if the operation is not supported.
1869 *
1870 * \since This function is available since SDL 2.0.0.
1871 *
1872 * \sa SDL_GL_BindTexture
1873 * \sa SDL_GL_MakeCurrent
1874 */
1875extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture);
1876
1877/**
1878 * Get the CAMetalLayer associated with the given Metal renderer.
1879 *
1880 * This function returns `void *`, so SDL doesn't have to include Metal's
1881 * headers, but it can be safely cast to a `CAMetalLayer *`.
1882 *
1883 * \param renderer The renderer to query.
1884 * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
1885 * Metal renderer.
1886 *
1887 * \since This function is available since SDL 2.0.8.
1888 *
1889 * \sa SDL_RenderGetMetalCommandEncoder
1890 */
1891extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer);
1892
1893/**
1894 * Get the Metal command encoder for the current frame
1895 *
1896 * This function returns `void *`, so SDL doesn't have to include Metal's
1897 * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
1898 *
1899 * Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give
1900 * SDL a drawable to render to, which might happen if the window is
1901 * hidden/minimized/offscreen. This doesn't apply to command encoders for
1902 * render targets, just the window's backbuffer. Check your return values!
1903 *
1904 * \param renderer The renderer to query.
1905 * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
1906 * renderer isn't a Metal renderer or there was an error.
1907 *
1908 * \since This function is available since SDL 2.0.8.
1909 *
1910 * \sa SDL_RenderGetMetalLayer
1911 */
1912extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer);
1913
1914/**
1915 * Toggle VSync of the given renderer.
1916 *
1917 * \param renderer The renderer to toggle.
1918 * \param vsync 1 for on, 0 for off. All other values are reserved.
1919 * \returns a 0 int on success, or non-zero on failure.
1920 *
1921 * \since This function is available since SDL 2.0.18.
1922 */
1923extern DECLSPEC int SDLCALL SDL_RenderSetVSync(SDL_Renderer* renderer, int vsync);
1924
1925/* Ends C function definitions when using C++ */
1926#ifdef __cplusplus
1927}
1928#endif
1929#include "close_code.h"
1930
1931#endif /* SDL_render_h_ */
1932
1933/* vi: set ts=4 sw=4 expandtab: */
1934