1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2026 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. If the existing texture contents happen to be in the
668 * locked buffer, it is purely coincidental.
669 *
670 * You must use SDL_UnlockTexture() to unlock the pixels and apply any
671 * changes.
672 *
673 * Every pixel must be initialized by the caller, or uninitialized data will
674 * be uploaded to the texture during unlock.
675 *
676 * `pitch` may be larger than the bytes needed for a row of pixels, as there
677 * might be padding included. Use `(y * pitch) + (x * pixel_size_in_bytes)` to
678 * write to the first byte of the pixel at `(x, y)` in the locked texture
679 * area, where `(0, 0)` is the top-left corner of the area.
680 *
681 * \param texture the texture to lock for access, which was created with
682 * `SDL_TEXTUREACCESS_STREAMING`.
683 * \param rect an SDL_Rect structure representing the area to lock for access;
684 * NULL to lock the entire texture.
685 * \param pixels this is filled in with a pointer to the locked pixels,
686 * appropriately offset by the locked area.
687 * \param pitch this is filled in with the pitch of the locked pixels; the
688 * pitch is the length of one row in bytes.
689 * \returns 0 on success or a negative error code if the texture is not valid
690 * or was not created with `SDL_TEXTUREACCESS_STREAMING`; call
691 * SDL_GetError() for more information.
692 *
693 * \since This function is available since SDL 2.0.0.
694 *
695 * \sa SDL_UnlockTexture
696 */
697extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
698 const SDL_Rect * rect,
699 void **pixels, int *pitch);
700
701/**
702 * Lock a portion of the texture for **write-only** pixel access, and expose
703 * it as a SDL surface.
704 *
705 * Besides providing an SDL_Surface instead of raw pixel data, this function
706 * operates like SDL_LockTexture.
707 *
708 * As an optimization, the pixels made available for editing don't necessarily
709 * contain the old texture data. This is a write-only operation, and if you
710 * need to keep a copy of the texture data you should do that at the
711 * application level.
712 *
713 * You must use SDL_UnlockTexture() to unlock the pixels and apply any
714 * changes.
715 *
716 * The returned surface is freed internally after calling SDL_UnlockTexture()
717 * or SDL_DestroyTexture(). The caller should not free it.
718 *
719 * \param texture the texture to lock for access, which was created with
720 * `SDL_TEXTUREACCESS_STREAMING`.
721 * \param rect a pointer to the rectangle to lock for access. If the rect is
722 * NULL, the entire texture will be locked.
723 * \param surface this is filled in with an SDL surface representing the
724 * locked area.
725 * \returns 0 on success, or -1 if the texture is not valid or was not created
726 * with `SDL_TEXTUREACCESS_STREAMING`.
727 *
728 * \since This function is available since SDL 2.0.12.
729 *
730 * \sa SDL_LockTexture
731 * \sa SDL_UnlockTexture
732 */
733extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
734 const SDL_Rect *rect,
735 SDL_Surface **surface);
736
737/**
738 * Unlock a texture, uploading the changes to video memory, if needed.
739 *
740 * **Warning**: Please note that SDL_LockTexture() is intended to be
741 * write-only; it will not guarantee the previous contents of the texture will
742 * be provided. You must fully initialize any area of a texture that you lock
743 * before unlocking it, as the pixels might otherwise be uninitialized memory.
744 *
745 * Which is to say: locking and immediately unlocking a texture can result in
746 * corrupted textures, depending on the renderer in use.
747 *
748 * \param texture a texture locked by SDL_LockTexture().
749 *
750 * \since This function is available since SDL 2.0.0.
751 *
752 * \sa SDL_LockTexture
753 */
754extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
755
756/**
757 * Determine whether a renderer supports the use of render targets.
758 *
759 * \param renderer the renderer that will be checked.
760 * \returns SDL_TRUE if supported or SDL_FALSE if not.
761 *
762 * \since This function is available since SDL 2.0.0.
763 *
764 * \sa SDL_SetRenderTarget
765 */
766extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer);
767
768/**
769 * Set a texture as the current rendering target.
770 *
771 * Before using this function, you should check the
772 * `SDL_RENDERER_TARGETTEXTURE` bit in the flags of SDL_RendererInfo to see if
773 * render targets are supported.
774 *
775 * The default render target is the window for which the renderer was created.
776 * To stop rendering to a texture and render to the window again, call this
777 * function with a NULL `texture`. This will reset the renderer's viewport,
778 * clipping rectangle, and scaling settings to the state they were in before
779 * setting a non-NULL `texture` target, losing any changes made in the
780 * meantime.
781 *
782 * \param renderer the rendering context.
783 * \param texture the targeted texture, which must be created with the
784 * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the
785 * window instead of a texture.
786 * \returns 0 on success or a negative error code on failure; call
787 * SDL_GetError() for more information.
788 *
789 * \since This function is available since SDL 2.0.0.
790 *
791 * \sa SDL_GetRenderTarget
792 */
793extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
794 SDL_Texture *texture);
795
796/**
797 * Get the current render target.
798 *
799 * The default render target is the window for which the renderer was created,
800 * and is reported as NULL here.
801 *
802 * \param renderer the rendering context.
803 * \returns the current render target or NULL for the default render target.
804 *
805 * \since This function is available since SDL 2.0.0.
806 *
807 * \sa SDL_SetRenderTarget
808 */
809extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
810
811/**
812 * Set a device independent resolution for rendering.
813 *
814 * This function uses the viewport and scaling functionality to allow a fixed
815 * logical resolution for rendering, regardless of the actual output
816 * resolution. If the actual output resolution doesn't have the same aspect
817 * ratio the output rendering will be centered within the output display.
818 *
819 * If the output display is a window, mouse and touch events in the window
820 * will be filtered and scaled so they seem to arrive within the logical
821 * resolution. The SDL_HINT_MOUSE_RELATIVE_SCALING hint controls whether
822 * relative motion events are also scaled.
823 *
824 * If this function results in scaling or subpixel drawing by the rendering
825 * backend, it will be handled using the appropriate quality hints.
826 *
827 * \param renderer the renderer for which resolution should be set.
828 * \param w the width of the logical resolution.
829 * \param h the height of the logical resolution.
830 * \returns 0 on success or a negative error code on failure; call
831 * SDL_GetError() for more information.
832 *
833 * \since This function is available since SDL 2.0.0.
834 *
835 * \sa SDL_RenderGetLogicalSize
836 */
837extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h);
838
839/**
840 * Get device independent resolution for rendering.
841 *
842 * When using the main rendering target (eg no target texture is set): this
843 * may return 0 for `w` and `h` if the SDL_Renderer has never had its logical
844 * size set by SDL_RenderSetLogicalSize(). Otherwise it returns the logical
845 * width and height.
846 *
847 * When using a target texture: Never return 0 for `w` and `h` at first. Then
848 * it returns the logical width and height that are set.
849 *
850 * \param renderer a rendering context.
851 * \param w an int to be filled with the width.
852 * \param h an int to be filled with the height.
853 *
854 * \since This function is available since SDL 2.0.0.
855 *
856 * \sa SDL_RenderSetLogicalSize
857 */
858extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h);
859
860/**
861 * Set whether to force integer scales for resolution-independent rendering.
862 *
863 * This function restricts the logical viewport to integer values - that is,
864 * when a resolution is between two multiples of a logical size, the viewport
865 * size is rounded down to the lower multiple.
866 *
867 * \param renderer the renderer for which integer scaling should be set.
868 * \param enable enable or disable the integer scaling for rendering.
869 * \returns 0 on success or a negative error code on failure; call
870 * SDL_GetError() for more information.
871 *
872 * \since This function is available since SDL 2.0.5.
873 *
874 * \sa SDL_RenderGetIntegerScale
875 * \sa SDL_RenderSetLogicalSize
876 */
877extern DECLSPEC int SDLCALL SDL_RenderSetIntegerScale(SDL_Renderer * renderer,
878 SDL_bool enable);
879
880/**
881 * Get whether integer scales are forced for resolution-independent rendering.
882 *
883 * \param renderer the renderer from which integer scaling should be queried.
884 * \returns SDL_TRUE if integer scales are forced or SDL_FALSE if not and on
885 * failure; call SDL_GetError() for more information.
886 *
887 * \since This function is available since SDL 2.0.5.
888 *
889 * \sa SDL_RenderSetIntegerScale
890 */
891extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer);
892
893/**
894 * Set the drawing area for rendering on the current target.
895 *
896 * When the window is resized, the viewport is reset to fill the entire new
897 * window size.
898 *
899 * \param renderer the rendering context.
900 * \param rect the SDL_Rect structure representing the drawing area, or NULL
901 * to set the viewport to the entire target.
902 * \returns 0 on success or a negative error code on failure; call
903 * SDL_GetError() for more information.
904 *
905 * \since This function is available since SDL 2.0.0.
906 *
907 * \sa SDL_RenderGetViewport
908 */
909extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
910 const SDL_Rect * rect);
911
912/**
913 * Get the drawing area for the current target.
914 *
915 * \param renderer the rendering context.
916 * \param rect an SDL_Rect structure filled in with the current drawing area.
917 *
918 * \since This function is available since SDL 2.0.0.
919 *
920 * \sa SDL_RenderSetViewport
921 */
922extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
923 SDL_Rect * rect);
924
925/**
926 * Set the clip rectangle for rendering on the specified target.
927 *
928 * \param renderer the rendering context for which clip rectangle should be
929 * set.
930 * \param rect an SDL_Rect structure representing the clip area, relative to
931 * the viewport, or NULL to disable clipping.
932 * \returns 0 on success or a negative error code on failure; call
933 * SDL_GetError() for more information.
934 *
935 * \since This function is available since SDL 2.0.0.
936 *
937 * \sa SDL_RenderGetClipRect
938 * \sa SDL_RenderIsClipEnabled
939 */
940extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer,
941 const SDL_Rect * rect);
942
943/**
944 * Get the clip rectangle for the current target.
945 *
946 * \param renderer the rendering context from which clip rectangle should be
947 * queried.
948 * \param rect an SDL_Rect structure filled in with the current clipping area
949 * or an empty rectangle if clipping is disabled.
950 *
951 * \since This function is available since SDL 2.0.0.
952 *
953 * \sa SDL_RenderIsClipEnabled
954 * \sa SDL_RenderSetClipRect
955 */
956extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer,
957 SDL_Rect * rect);
958
959/**
960 * Get whether clipping is enabled on the given renderer.
961 *
962 * \param renderer the renderer from which clip state should be queried.
963 * \returns SDL_TRUE if clipping is enabled or SDL_FALSE if not; call
964 * SDL_GetError() for more information.
965 *
966 * \since This function is available since SDL 2.0.4.
967 *
968 * \sa SDL_RenderGetClipRect
969 * \sa SDL_RenderSetClipRect
970 */
971extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer);
972
973
974/**
975 * Set the drawing scale for rendering on the current target.
976 *
977 * The drawing coordinates are scaled by the x/y scaling factors before they
978 * are used by the renderer. This allows resolution independent drawing with a
979 * single coordinate system.
980 *
981 * If this results in scaling or subpixel drawing by the rendering backend, it
982 * will be handled using the appropriate quality hints. For best results use
983 * integer scaling factors.
984 *
985 * \param renderer a rendering context.
986 * \param scaleX the horizontal scaling factor.
987 * \param scaleY the vertical scaling factor.
988 * \returns 0 on success or a negative error code on failure; call
989 * SDL_GetError() for more information.
990 *
991 * \since This function is available since SDL 2.0.0.
992 *
993 * \sa SDL_RenderGetScale
994 * \sa SDL_RenderSetLogicalSize
995 */
996extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
997 float scaleX, float scaleY);
998
999/**
1000 * Get the drawing scale for the current target.
1001 *
1002 * \param renderer the renderer from which drawing scale should be queried.
1003 * \param scaleX a pointer filled in with the horizontal scaling factor.
1004 * \param scaleY a pointer filled in with the vertical scaling factor.
1005 *
1006 * \since This function is available since SDL 2.0.0.
1007 *
1008 * \sa SDL_RenderSetScale
1009 */
1010extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
1011 float *scaleX, float *scaleY);
1012
1013/**
1014 * Get logical coordinates of point in renderer when given real coordinates of
1015 * point in window.
1016 *
1017 * Logical coordinates will differ from real coordinates when render is scaled
1018 * and logical renderer size set
1019 *
1020 * \param renderer the renderer from which the logical coordinates should be
1021 * calculated.
1022 * \param windowX the real X coordinate in the window.
1023 * \param windowY the real Y coordinate in the window.
1024 * \param logicalX the pointer filled with the logical x coordinate.
1025 * \param logicalY the pointer filled with the logical y coordinate.
1026 *
1027 * \since This function is available since SDL 2.0.18.
1028 *
1029 * \sa SDL_RenderGetScale
1030 * \sa SDL_RenderSetScale
1031 * \sa SDL_RenderGetLogicalSize
1032 * \sa SDL_RenderSetLogicalSize
1033 */
1034extern DECLSPEC void SDLCALL SDL_RenderWindowToLogical(SDL_Renderer * renderer,
1035 int windowX, int windowY,
1036 float *logicalX, float *logicalY);
1037
1038
1039/**
1040 * Get real coordinates of point in window when given logical coordinates of
1041 * point in renderer.
1042 *
1043 * Logical coordinates will differ from real coordinates when render is scaled
1044 * and logical renderer size set
1045 *
1046 * \param renderer the renderer from which the window coordinates should be
1047 * calculated.
1048 * \param logicalX the logical x coordinate.
1049 * \param logicalY the logical y coordinate.
1050 * \param windowX the pointer filled with the real X coordinate in the window.
1051 * \param windowY the pointer filled with the real Y coordinate in the window.
1052 *
1053 * \since This function is available since SDL 2.0.18.
1054 *
1055 * \sa SDL_RenderGetScale
1056 * \sa SDL_RenderSetScale
1057 * \sa SDL_RenderGetLogicalSize
1058 * \sa SDL_RenderSetLogicalSize
1059 */
1060extern DECLSPEC void SDLCALL SDL_RenderLogicalToWindow(SDL_Renderer * renderer,
1061 float logicalX, float logicalY,
1062 int *windowX, int *windowY);
1063
1064/**
1065 * Set the color used for drawing operations (Rect, Line and Clear).
1066 *
1067 * Set the color for drawing or filling rectangles, lines, and points, and for
1068 * SDL_RenderClear().
1069 *
1070 * \param renderer the rendering context.
1071 * \param r the red value used to draw on the rendering target.
1072 * \param g the green value used to draw on the rendering target.
1073 * \param b the blue value used to draw on the rendering target.
1074 * \param a the alpha value used to draw on the rendering target; usually
1075 * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
1076 * specify how the alpha channel is used.
1077 * \returns 0 on success or a negative error code on failure; call
1078 * SDL_GetError() for more information.
1079 *
1080 * \since This function is available since SDL 2.0.0.
1081 *
1082 * \sa SDL_GetRenderDrawColor
1083 * \sa SDL_RenderClear
1084 * \sa SDL_RenderDrawLine
1085 * \sa SDL_RenderDrawLines
1086 * \sa SDL_RenderDrawPoint
1087 * \sa SDL_RenderDrawPoints
1088 * \sa SDL_RenderDrawRect
1089 * \sa SDL_RenderDrawRects
1090 * \sa SDL_RenderFillRect
1091 * \sa SDL_RenderFillRects
1092 */
1093extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer,
1094 Uint8 r, Uint8 g, Uint8 b,
1095 Uint8 a);
1096
1097/**
1098 * Get the color used for drawing operations (Rect, Line and Clear).
1099 *
1100 * \param renderer the rendering context.
1101 * \param r a pointer filled in with the red value used to draw on the
1102 * rendering target.
1103 * \param g a pointer filled in with the green value used to draw on the
1104 * rendering target.
1105 * \param b a pointer filled in with the blue value used to draw on the
1106 * rendering target.
1107 * \param a a pointer filled in with the alpha value used to draw on the
1108 * rendering target; usually `SDL_ALPHA_OPAQUE` (255).
1109 * \returns 0 on success or a negative error code on failure; call
1110 * SDL_GetError() for more information.
1111 *
1112 * \since This function is available since SDL 2.0.0.
1113 *
1114 * \sa SDL_SetRenderDrawColor
1115 */
1116extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer,
1117 Uint8 * r, Uint8 * g, Uint8 * b,
1118 Uint8 * a);
1119
1120/**
1121 * Set the blend mode used for drawing operations (Fill and Line).
1122 *
1123 * If the blend mode is not supported, the closest supported mode is chosen.
1124 *
1125 * \param renderer the rendering context.
1126 * \param blendMode the SDL_BlendMode to use for blending.
1127 * \returns 0 on success or a negative error code on failure; call
1128 * SDL_GetError() for more information.
1129 *
1130 * \since This function is available since SDL 2.0.0.
1131 *
1132 * \sa SDL_GetRenderDrawBlendMode
1133 * \sa SDL_RenderDrawLine
1134 * \sa SDL_RenderDrawLines
1135 * \sa SDL_RenderDrawPoint
1136 * \sa SDL_RenderDrawPoints
1137 * \sa SDL_RenderDrawRect
1138 * \sa SDL_RenderDrawRects
1139 * \sa SDL_RenderFillRect
1140 * \sa SDL_RenderFillRects
1141 */
1142extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
1143 SDL_BlendMode blendMode);
1144
1145/**
1146 * Get the blend mode used for drawing operations.
1147 *
1148 * \param renderer the rendering context.
1149 * \param blendMode a pointer filled in with the current SDL_BlendMode.
1150 * \returns 0 on success or a negative error code on failure; call
1151 * SDL_GetError() for more information.
1152 *
1153 * \since This function is available since SDL 2.0.0.
1154 *
1155 * \sa SDL_SetRenderDrawBlendMode
1156 */
1157extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
1158 SDL_BlendMode *blendMode);
1159
1160/**
1161 * Clear the current rendering target with the drawing color.
1162 *
1163 * This function clears the entire rendering target, ignoring the viewport and
1164 * the clip rectangle.
1165 *
1166 * \param renderer the rendering context.
1167 * \returns 0 on success or a negative error code on failure; call
1168 * SDL_GetError() for more information.
1169 *
1170 * \since This function is available since SDL 2.0.0.
1171 *
1172 * \sa SDL_SetRenderDrawColor
1173 */
1174extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
1175
1176/**
1177 * Draw a point on the current rendering target.
1178 *
1179 * SDL_RenderDrawPoint() draws a single point. If you want to draw multiple,
1180 * use SDL_RenderDrawPoints() instead.
1181 *
1182 * \param renderer the rendering context.
1183 * \param x the x coordinate of the point.
1184 * \param y the y coordinate of the point.
1185 * \returns 0 on success or a negative error code on failure; call
1186 * SDL_GetError() for more information.
1187 *
1188 * \since This function is available since SDL 2.0.0.
1189 *
1190 * \sa SDL_RenderDrawLine
1191 * \sa SDL_RenderDrawLines
1192 * \sa SDL_RenderDrawPoints
1193 * \sa SDL_RenderDrawRect
1194 * \sa SDL_RenderDrawRects
1195 * \sa SDL_RenderFillRect
1196 * \sa SDL_RenderFillRects
1197 * \sa SDL_RenderPresent
1198 * \sa SDL_SetRenderDrawBlendMode
1199 * \sa SDL_SetRenderDrawColor
1200 */
1201extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
1202 int x, int y);
1203
1204/**
1205 * Draw multiple points on the current rendering target.
1206 *
1207 * \param renderer the rendering context.
1208 * \param points an array of SDL_Point structures that represent the points to
1209 * draw.
1210 * \param count the number of points to draw.
1211 * \returns 0 on success or a negative error code on failure; call
1212 * SDL_GetError() for more information.
1213 *
1214 * \since This function is available since SDL 2.0.0.
1215 *
1216 * \sa SDL_RenderDrawLine
1217 * \sa SDL_RenderDrawLines
1218 * \sa SDL_RenderDrawPoint
1219 * \sa SDL_RenderDrawRect
1220 * \sa SDL_RenderDrawRects
1221 * \sa SDL_RenderFillRect
1222 * \sa SDL_RenderFillRects
1223 * \sa SDL_RenderPresent
1224 * \sa SDL_SetRenderDrawBlendMode
1225 * \sa SDL_SetRenderDrawColor
1226 */
1227extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
1228 const SDL_Point * points,
1229 int count);
1230
1231/**
1232 * Draw a line on the current rendering target.
1233 *
1234 * SDL_RenderDrawLine() draws the line to include both end points. If you want
1235 * to draw multiple, connecting lines use SDL_RenderDrawLines() instead.
1236 *
1237 * \param renderer the rendering context.
1238 * \param x1 the x coordinate of the start point.
1239 * \param y1 the y coordinate of the start point.
1240 * \param x2 the x coordinate of the end point.
1241 * \param y2 the y coordinate of the end point.
1242 * \returns 0 on success or a negative error code on failure; call
1243 * SDL_GetError() for more information.
1244 *
1245 * \since This function is available since SDL 2.0.0.
1246 *
1247 * \sa SDL_RenderDrawLines
1248 * \sa SDL_RenderDrawPoint
1249 * \sa SDL_RenderDrawPoints
1250 * \sa SDL_RenderDrawRect
1251 * \sa SDL_RenderDrawRects
1252 * \sa SDL_RenderFillRect
1253 * \sa SDL_RenderFillRects
1254 * \sa SDL_RenderPresent
1255 * \sa SDL_SetRenderDrawBlendMode
1256 * \sa SDL_SetRenderDrawColor
1257 */
1258extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
1259 int x1, int y1, int x2, int y2);
1260
1261/**
1262 * Draw a series of connected lines on the current rendering target.
1263 *
1264 * \param renderer the rendering context.
1265 * \param points an array of SDL_Point structures representing points along
1266 * the lines.
1267 * \param count the number of points, drawing count-1 lines.
1268 * \returns 0 on success or a negative error code on failure; call
1269 * SDL_GetError() for more information.
1270 *
1271 * \since This function is available since SDL 2.0.0.
1272 *
1273 * \sa SDL_RenderDrawLine
1274 * \sa SDL_RenderDrawPoint
1275 * \sa SDL_RenderDrawPoints
1276 * \sa SDL_RenderDrawRect
1277 * \sa SDL_RenderDrawRects
1278 * \sa SDL_RenderFillRect
1279 * \sa SDL_RenderFillRects
1280 * \sa SDL_RenderPresent
1281 * \sa SDL_SetRenderDrawBlendMode
1282 * \sa SDL_SetRenderDrawColor
1283 */
1284extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
1285 const SDL_Point * points,
1286 int count);
1287
1288/**
1289 * Draw a rectangle on the current rendering target.
1290 *
1291 * \param renderer the rendering context.
1292 * \param rect an SDL_Rect structure representing the rectangle to draw, or
1293 * NULL to outline the entire rendering target.
1294 * \returns 0 on success or a negative error code on failure; call
1295 * SDL_GetError() for more information.
1296 *
1297 * \since This function is available since SDL 2.0.0.
1298 *
1299 * \sa SDL_RenderDrawLine
1300 * \sa SDL_RenderDrawLines
1301 * \sa SDL_RenderDrawPoint
1302 * \sa SDL_RenderDrawPoints
1303 * \sa SDL_RenderDrawRects
1304 * \sa SDL_RenderFillRect
1305 * \sa SDL_RenderFillRects
1306 * \sa SDL_RenderPresent
1307 * \sa SDL_SetRenderDrawBlendMode
1308 * \sa SDL_SetRenderDrawColor
1309 */
1310extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
1311 const SDL_Rect * rect);
1312
1313/**
1314 * Draw some number of rectangles on the current rendering target.
1315 *
1316 * \param renderer the rendering context.
1317 * \param rects an array of SDL_Rect structures representing the rectangles to
1318 * be drawn.
1319 * \param count the number of rectangles.
1320 * \returns 0 on success or a negative error code on failure; call
1321 * SDL_GetError() for more information.
1322 *
1323 * \since This function is available since SDL 2.0.0.
1324 *
1325 * \sa SDL_RenderDrawLine
1326 * \sa SDL_RenderDrawLines
1327 * \sa SDL_RenderDrawPoint
1328 * \sa SDL_RenderDrawPoints
1329 * \sa SDL_RenderDrawRect
1330 * \sa SDL_RenderFillRect
1331 * \sa SDL_RenderFillRects
1332 * \sa SDL_RenderPresent
1333 * \sa SDL_SetRenderDrawBlendMode
1334 * \sa SDL_SetRenderDrawColor
1335 */
1336extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
1337 const SDL_Rect * rects,
1338 int count);
1339
1340/**
1341 * Fill a rectangle on the current rendering target with the drawing color.
1342 *
1343 * The current drawing color is set by SDL_SetRenderDrawColor(), and the
1344 * color's alpha value is ignored unless blending is enabled with the
1345 * appropriate call to SDL_SetRenderDrawBlendMode().
1346 *
1347 * \param renderer the rendering context.
1348 * \param rect the SDL_Rect structure representing the rectangle to fill, or
1349 * NULL for the entire rendering target.
1350 * \returns 0 on success or a negative error code on failure; call
1351 * SDL_GetError() for more information.
1352 *
1353 * \since This function is available since SDL 2.0.0.
1354 *
1355 * \sa SDL_RenderDrawLine
1356 * \sa SDL_RenderDrawLines
1357 * \sa SDL_RenderDrawPoint
1358 * \sa SDL_RenderDrawPoints
1359 * \sa SDL_RenderDrawRect
1360 * \sa SDL_RenderDrawRects
1361 * \sa SDL_RenderFillRects
1362 * \sa SDL_RenderPresent
1363 * \sa SDL_SetRenderDrawBlendMode
1364 * \sa SDL_SetRenderDrawColor
1365 */
1366extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
1367 const SDL_Rect * rect);
1368
1369/**
1370 * Fill some number of rectangles on the current rendering target with the
1371 * drawing color.
1372 *
1373 * \param renderer the rendering context.
1374 * \param rects an array of SDL_Rect structures representing the rectangles to
1375 * be filled.
1376 * \param count the number of rectangles.
1377 * \returns 0 on success or a negative error code on failure; call
1378 * SDL_GetError() for more information.
1379 *
1380 * \since This function is available since SDL 2.0.0.
1381 *
1382 * \sa SDL_RenderDrawLine
1383 * \sa SDL_RenderDrawLines
1384 * \sa SDL_RenderDrawPoint
1385 * \sa SDL_RenderDrawPoints
1386 * \sa SDL_RenderDrawRect
1387 * \sa SDL_RenderDrawRects
1388 * \sa SDL_RenderFillRect
1389 * \sa SDL_RenderPresent
1390 */
1391extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
1392 const SDL_Rect * rects,
1393 int count);
1394
1395/**
1396 * Copy a portion of the texture to the current rendering target.
1397 *
1398 * The texture is blended with the destination based on its blend mode set
1399 * with SDL_SetTextureBlendMode().
1400 *
1401 * The texture color is affected based on its color modulation set by
1402 * SDL_SetTextureColorMod().
1403 *
1404 * The texture alpha is affected based on its alpha modulation set by
1405 * SDL_SetTextureAlphaMod().
1406 *
1407 * \param renderer the rendering context.
1408 * \param texture the source texture.
1409 * \param srcrect the source SDL_Rect structure or NULL for the entire
1410 * texture.
1411 * \param dstrect the destination SDL_Rect structure or NULL for the entire
1412 * rendering target; the texture will be stretched to fill the
1413 * given rectangle.
1414 * \returns 0 on success or a negative error code on failure; call
1415 * SDL_GetError() for more information.
1416 *
1417 * \since This function is available since SDL 2.0.0.
1418 *
1419 * \sa SDL_RenderCopyEx
1420 * \sa SDL_SetTextureAlphaMod
1421 * \sa SDL_SetTextureBlendMode
1422 * \sa SDL_SetTextureColorMod
1423 */
1424extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
1425 SDL_Texture * texture,
1426 const SDL_Rect * srcrect,
1427 const SDL_Rect * dstrect);
1428
1429/**
1430 * Copy a portion of the texture to the current rendering, with optional
1431 * rotation and flipping.
1432 *
1433 * Copy a portion of the texture to the current rendering target, optionally
1434 * rotating it by angle around the given center and also flipping it
1435 * top-bottom and/or left-right.
1436 *
1437 * The texture is blended with the destination based on its blend mode set
1438 * with SDL_SetTextureBlendMode().
1439 *
1440 * The texture color is affected based on its color modulation set by
1441 * SDL_SetTextureColorMod().
1442 *
1443 * The texture alpha is affected based on its alpha modulation set by
1444 * SDL_SetTextureAlphaMod().
1445 *
1446 * \param renderer the rendering context.
1447 * \param texture the source texture.
1448 * \param srcrect the source SDL_Rect structure or NULL for the entire
1449 * texture.
1450 * \param dstrect the destination SDL_Rect structure or NULL for the entire
1451 * rendering target.
1452 * \param angle an angle in degrees that indicates the rotation that will be
1453 * applied to dstrect, rotating it in a clockwise direction.
1454 * \param center a pointer to a point indicating the point around which
1455 * dstrect will be rotated (if NULL, rotation will be done
1456 * around `dstrect.w / 2`, `dstrect.h / 2`).
1457 * \param flip a SDL_RendererFlip value stating which flipping actions should
1458 * be performed on the texture.
1459 * \returns 0 on success or a negative error code on failure; call
1460 * SDL_GetError() for more information.
1461 *
1462 * \since This function is available since SDL 2.0.0.
1463 *
1464 * \sa SDL_RenderCopy
1465 * \sa SDL_SetTextureAlphaMod
1466 * \sa SDL_SetTextureBlendMode
1467 * \sa SDL_SetTextureColorMod
1468 */
1469extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
1470 SDL_Texture * texture,
1471 const SDL_Rect * srcrect,
1472 const SDL_Rect * dstrect,
1473 const double angle,
1474 const SDL_Point *center,
1475 const SDL_RendererFlip flip);
1476
1477
1478/**
1479 * Draw a point on the current rendering target at subpixel precision.
1480 *
1481 * \param renderer The renderer which should draw a point.
1482 * \param x The x coordinate of the point.
1483 * \param y The y coordinate of the point.
1484 * \return 0 on success, or -1 on error.
1485 *
1486 * \since This function is available since SDL 2.0.10.
1487 */
1488extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer,
1489 float x, float y);
1490
1491/**
1492 * Draw multiple points on the current rendering target at subpixel precision.
1493 *
1494 * \param renderer The renderer which should draw multiple points.
1495 * \param points The points to draw.
1496 * \param count The number of points to draw.
1497 * \return 0 on success, or -1 on error.
1498 *
1499 * \since This function is available since SDL 2.0.10.
1500 */
1501extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer,
1502 const SDL_FPoint * points,
1503 int count);
1504
1505/**
1506 * Draw a line on the current rendering target at subpixel precision.
1507 *
1508 * \param renderer The renderer which should draw a line.
1509 * \param x1 The x coordinate of the start point.
1510 * \param y1 The y coordinate of the start point.
1511 * \param x2 The x coordinate of the end point.
1512 * \param y2 The y coordinate of the end point.
1513 * \return 0 on success, or -1 on error.
1514 *
1515 * \since This function is available since SDL 2.0.10.
1516 */
1517extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer,
1518 float x1, float y1, float x2, float y2);
1519
1520/**
1521 * Draw a series of connected lines on the current rendering target at
1522 * subpixel precision.
1523 *
1524 * \param renderer The renderer which should draw multiple lines.
1525 * \param points The points along the lines.
1526 * \param count The number of points, drawing count-1 lines.
1527 * \return 0 on success, or -1 on error.
1528 *
1529 * \since This function is available since SDL 2.0.10.
1530 */
1531extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer,
1532 const SDL_FPoint * points,
1533 int count);
1534
1535/**
1536 * Draw a rectangle on the current rendering target at subpixel precision.
1537 *
1538 * \param renderer The renderer which should draw a rectangle.
1539 * \param rect A pointer to the destination rectangle, or NULL to outline the
1540 * entire rendering target.
1541 * \return 0 on success, or -1 on error.
1542 *
1543 * \since This function is available since SDL 2.0.10.
1544 */
1545extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer,
1546 const SDL_FRect * rect);
1547
1548/**
1549 * Draw some number of rectangles on the current rendering target at subpixel
1550 * precision.
1551 *
1552 * \param renderer The renderer which should draw multiple rectangles.
1553 * \param rects A pointer to an array of destination rectangles.
1554 * \param count The number of rectangles.
1555 * \return 0 on success, or -1 on error.
1556 *
1557 * \since This function is available since SDL 2.0.10.
1558 */
1559extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer,
1560 const SDL_FRect * rects,
1561 int count);
1562
1563/**
1564 * Fill a rectangle on the current rendering target with the drawing color at
1565 * subpixel precision.
1566 *
1567 * \param renderer The renderer which should fill a rectangle.
1568 * \param rect A pointer to the destination rectangle, or NULL for the entire
1569 * rendering target.
1570 * \return 0 on success, or -1 on error.
1571 *
1572 * \since This function is available since SDL 2.0.10.
1573 */
1574extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer,
1575 const SDL_FRect * rect);
1576
1577/**
1578 * Fill some number of rectangles on the current rendering target with the
1579 * drawing color at subpixel precision.
1580 *
1581 * \param renderer The renderer which should fill multiple rectangles.
1582 * \param rects A pointer to an array of destination rectangles.
1583 * \param count The number of rectangles.
1584 * \return 0 on success, or -1 on error.
1585 *
1586 * \since This function is available since SDL 2.0.10.
1587 */
1588extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer,
1589 const SDL_FRect * rects,
1590 int count);
1591
1592/**
1593 * Copy a portion of the texture to the current rendering target at subpixel
1594 * precision.
1595 *
1596 * \param renderer The renderer which should copy parts of a texture.
1597 * \param texture The source texture.
1598 * \param srcrect A pointer to the source rectangle, or NULL for the entire
1599 * texture.
1600 * \param dstrect A pointer to the destination rectangle, or NULL for the
1601 * entire rendering target.
1602 * \return 0 on success, or -1 on error.
1603 *
1604 * \since This function is available since SDL 2.0.10.
1605 */
1606extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer,
1607 SDL_Texture * texture,
1608 const SDL_Rect * srcrect,
1609 const SDL_FRect * dstrect);
1610
1611/**
1612 * Copy a portion of the source texture to the current rendering target, with
1613 * rotation and flipping, at subpixel precision.
1614 *
1615 * \param renderer The renderer which should copy parts of a texture.
1616 * \param texture The source texture.
1617 * \param srcrect A pointer to the source rectangle, or NULL for the entire
1618 * texture.
1619 * \param dstrect A pointer to the destination rectangle, or NULL for the
1620 * entire rendering target.
1621 * \param angle An angle in degrees that indicates the rotation that will be
1622 * applied to dstrect, rotating it in a clockwise direction.
1623 * \param center A pointer to a point indicating the point around which
1624 * dstrect will be rotated (if NULL, rotation will be done
1625 * around dstrect.w/2, dstrect.h/2).
1626 * \param flip An SDL_RendererFlip value stating which flipping actions should
1627 * be performed on the texture.
1628 * \return 0 on success, or -1 on error.
1629 *
1630 * \since This function is available since SDL 2.0.10.
1631 */
1632extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer,
1633 SDL_Texture * texture,
1634 const SDL_Rect * srcrect,
1635 const SDL_FRect * dstrect,
1636 const double angle,
1637 const SDL_FPoint *center,
1638 const SDL_RendererFlip flip);
1639
1640/**
1641 * Render a list of triangles, optionally using a texture and indices into the
1642 * vertex array Color and alpha modulation is done per vertex
1643 * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
1644 *
1645 * \param renderer The rendering context.
1646 * \param texture (optional) The SDL texture to use.
1647 * \param vertices Vertices.
1648 * \param num_vertices Number of vertices.
1649 * \param indices (optional) An array of integer indices into the 'vertices'
1650 * array, if NULL all vertices will be rendered in sequential
1651 * order.
1652 * \param num_indices Number of indices.
1653 * \return 0 on success, or -1 if the operation is not supported.
1654 *
1655 * \since This function is available since SDL 2.0.18.
1656 *
1657 * \sa SDL_RenderGeometryRaw
1658 * \sa SDL_Vertex
1659 */
1660extern DECLSPEC int SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
1661 SDL_Texture *texture,
1662 const SDL_Vertex *vertices, int num_vertices,
1663 const int *indices, int num_indices);
1664
1665/**
1666 * Render a list of triangles, optionally using a texture and indices into the
1667 * vertex arrays Color and alpha modulation is done per vertex
1668 * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
1669 *
1670 * \param renderer The rendering context.
1671 * \param texture (optional) The SDL texture to use.
1672 * \param xy Vertex positions.
1673 * \param xy_stride Byte size to move from one element to the next element.
1674 * \param color Vertex colors (as SDL_Color).
1675 * \param color_stride Byte size to move from one element to the next element.
1676 * \param uv Vertex normalized texture coordinates.
1677 * \param uv_stride Byte size to move from one element to the next element.
1678 * \param num_vertices Number of vertices.
1679 * \param indices (optional) An array of indices into the 'vertices' arrays,
1680 * if NULL all vertices will be rendered in sequential order.
1681 * \param num_indices Number of indices.
1682 * \param size_indices Index size: 1 (byte), 2 (short), 4 (int).
1683 * \return 0 on success, or -1 if the operation is not supported.
1684 *
1685 * \since This function is available since SDL 2.0.18.
1686 *
1687 * \sa SDL_RenderGeometry
1688 * \sa SDL_Vertex
1689 */
1690extern DECLSPEC int SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
1691 SDL_Texture *texture,
1692 const float *xy, int xy_stride,
1693 const SDL_Color *color, int color_stride,
1694 const float *uv, int uv_stride,
1695 int num_vertices,
1696 const void *indices, int num_indices, int size_indices);
1697
1698/**
1699 * Read pixels from the current rendering target to an array of pixels.
1700 *
1701 * **WARNING**: This is a very slow operation, and should not be used
1702 * frequently. If you're using this on the main rendering target, it should be
1703 * called after rendering and before SDL_RenderPresent().
1704 *
1705 * `pitch` specifies the number of bytes between rows in the destination
1706 * `pixels` data. This allows you to write to a subrectangle or have padded
1707 * rows in the destination. Generally, `pitch` should equal the number of
1708 * pixels per row in the `pixels` data times the number of bytes per pixel,
1709 * but it might contain additional padding (for example, 24bit RGB Windows
1710 * Bitmap data pads all rows to multiples of 4 bytes).
1711 *
1712 * \param renderer the rendering context.
1713 * \param rect an SDL_Rect structure representing the area to read, or NULL
1714 * for the entire render target.
1715 * \param format an SDL_PixelFormatEnum value of the desired format of the
1716 * pixel data, or 0 to use the format of the rendering target.
1717 * \param pixels a pointer to the pixel data to copy into.
1718 * \param pitch the pitch of the `pixels` parameter.
1719 * \returns 0 on success or a negative error code on failure; call
1720 * SDL_GetError() for more information.
1721 *
1722 * \since This function is available since SDL 2.0.0.
1723 */
1724extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
1725 const SDL_Rect * rect,
1726 Uint32 format,
1727 void *pixels, int pitch);
1728
1729/**
1730 * Update the screen with any rendering performed since the previous call.
1731 *
1732 * SDL's rendering functions operate on a backbuffer; that is, calling a
1733 * rendering function such as SDL_RenderDrawLine() does not directly put a
1734 * line on the screen, but rather updates the backbuffer. As such, you compose
1735 * your entire scene and *present* the composed backbuffer to the screen as a
1736 * complete picture.
1737 *
1738 * Therefore, when using SDL's rendering API, one does all drawing intended
1739 * for the frame, and then calls this function once per frame to present the
1740 * final drawing to the user.
1741 *
1742 * The backbuffer should be considered invalidated after each present; do not
1743 * assume that previous contents will exist between frames. You are strongly
1744 * encouraged to call SDL_RenderClear() to initialize the backbuffer before
1745 * starting each new frame's drawing, even if you plan to overwrite every
1746 * pixel.
1747 *
1748 * \param renderer the rendering context.
1749 *
1750 * \threadsafety You may only call this function on the main thread. If this
1751 * happens to work on a background thread on any given platform
1752 * or backend, it's purely by luck and you should not rely on it
1753 * to work next time.
1754 *
1755 * \since This function is available since SDL 2.0.0.
1756 *
1757 * \sa SDL_CreateRenderer
1758 * \sa SDL_RenderClear
1759 * \sa SDL_RenderDrawLine
1760 * \sa SDL_RenderDrawLines
1761 * \sa SDL_RenderDrawPoint
1762 * \sa SDL_RenderDrawPoints
1763 * \sa SDL_RenderDrawRect
1764 * \sa SDL_RenderDrawRects
1765 * \sa SDL_RenderFillRect
1766 * \sa SDL_RenderFillRects
1767 * \sa SDL_SetRenderDrawBlendMode
1768 * \sa SDL_SetRenderDrawColor
1769 */
1770extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
1771
1772/**
1773 * Destroy the specified texture.
1774 *
1775 * Passing NULL or an otherwise invalid texture will set the SDL error message
1776 * to "Invalid texture".
1777 *
1778 * \param texture the texture to destroy.
1779 *
1780 * \since This function is available since SDL 2.0.0.
1781 *
1782 * \sa SDL_CreateTexture
1783 * \sa SDL_CreateTextureFromSurface
1784 */
1785extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
1786
1787/**
1788 * Destroy the rendering context for a window and free associated textures.
1789 *
1790 * If `renderer` is NULL, this function will return immediately after setting
1791 * the SDL error message to "Invalid renderer". See SDL_GetError().
1792 *
1793 * \param renderer the rendering context.
1794 *
1795 * \since This function is available since SDL 2.0.0.
1796 *
1797 * \sa SDL_CreateRenderer
1798 */
1799extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
1800
1801/**
1802 * Force the rendering context to flush any pending commands to the underlying
1803 * rendering API.
1804 *
1805 * You do not need to (and in fact, shouldn't) call this function unless you
1806 * are planning to call into OpenGL/Direct3D/Metal/whatever directly in
1807 * addition to using an SDL_Renderer.
1808 *
1809 * This is for a very-specific case: if you are using SDL's render API, you
1810 * asked for a specific renderer backend (OpenGL, Direct3D, etc), you set
1811 * SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever
1812 * calls in addition to SDL render API calls. If all of this applies, you
1813 * should call SDL_RenderFlush() between calls to SDL's render API and the
1814 * low-level API you're using in cooperation.
1815 *
1816 * In all other cases, you can ignore this function. This is only here to get
1817 * maximum performance out of a specific situation. In all other cases, SDL
1818 * will do the right thing, perhaps at a performance loss.
1819 *
1820 * This function is first available in SDL 2.0.10, and is not needed in 2.0.9
1821 * and earlier, as earlier versions did not queue rendering commands at all,
1822 * instead flushing them to the OS immediately.
1823 *
1824 * \param renderer the rendering context.
1825 * \returns 0 on success or a negative error code on failure; call
1826 * SDL_GetError() for more information.
1827 *
1828 * \since This function is available since SDL 2.0.10.
1829 */
1830extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer);
1831
1832
1833/**
1834 * Bind an OpenGL/ES/ES2 texture to the current context.
1835 *
1836 * This is for use with OpenGL instructions when rendering OpenGL primitives
1837 * directly.
1838 *
1839 * If not NULL, `texw` and `texh` will be filled with the width and height
1840 * values suitable for the provided texture. In most cases, both will be 1.0,
1841 * however, on systems that support the GL_ARB_texture_rectangle extension,
1842 * these values will actually be the pixel width and height used to create the
1843 * texture, so this factor needs to be taken into account when providing
1844 * texture coordinates to OpenGL.
1845 *
1846 * You need a renderer to create an SDL_Texture, therefore you can only use
1847 * this function with an implicit OpenGL context from SDL_CreateRenderer(),
1848 * not with your own OpenGL context. If you need control over your OpenGL
1849 * context, you need to write your own texture-loading methods.
1850 *
1851 * Also note that SDL may upload RGB textures as BGR (or vice-versa), and
1852 * re-order the color channels in the shaders phase, so the uploaded texture
1853 * may have swapped color channels.
1854 *
1855 * \param texture the texture to bind to the current OpenGL/ES/ES2 context.
1856 * \param texw a pointer to a float value which will be filled with the
1857 * texture width or NULL if you don't need that value.
1858 * \param texh a pointer to a float value which will be filled with the
1859 * texture height or NULL if you don't need that value.
1860 * \returns 0 on success, or -1 if the operation is not supported; call
1861 * SDL_GetError() for more information.
1862 *
1863 * \since This function is available since SDL 2.0.0.
1864 *
1865 * \sa SDL_GL_MakeCurrent
1866 * \sa SDL_GL_UnbindTexture
1867 */
1868extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);
1869
1870/**
1871 * Unbind an OpenGL/ES/ES2 texture from the current context.
1872 *
1873 * See SDL_GL_BindTexture() for examples on how to use these functions
1874 *
1875 * \param texture the texture to unbind from the current OpenGL/ES/ES2
1876 * context.
1877 * \returns 0 on success, or -1 if the operation is not supported.
1878 *
1879 * \since This function is available since SDL 2.0.0.
1880 *
1881 * \sa SDL_GL_BindTexture
1882 * \sa SDL_GL_MakeCurrent
1883 */
1884extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture);
1885
1886/**
1887 * Get the CAMetalLayer associated with the given Metal renderer.
1888 *
1889 * This function returns `void *`, so SDL doesn't have to include Metal's
1890 * headers, but it can be safely cast to a `CAMetalLayer *`.
1891 *
1892 * \param renderer The renderer to query.
1893 * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
1894 * Metal renderer.
1895 *
1896 * \since This function is available since SDL 2.0.8.
1897 *
1898 * \sa SDL_RenderGetMetalCommandEncoder
1899 */
1900extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer);
1901
1902/**
1903 * Get the Metal command encoder for the current frame
1904 *
1905 * This function returns `void *`, so SDL doesn't have to include Metal's
1906 * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
1907 *
1908 * Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give
1909 * SDL a drawable to render to, which might happen if the window is
1910 * hidden/minimized/offscreen. This doesn't apply to command encoders for
1911 * render targets, just the window's backbuffer. Check your return values!
1912 *
1913 * \param renderer The renderer to query.
1914 * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
1915 * renderer isn't a Metal renderer or there was an error.
1916 *
1917 * \since This function is available since SDL 2.0.8.
1918 *
1919 * \sa SDL_RenderGetMetalLayer
1920 */
1921extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer);
1922
1923/**
1924 * Toggle VSync of the given renderer.
1925 *
1926 * \param renderer The renderer to toggle.
1927 * \param vsync 1 for on, 0 for off. All other values are reserved.
1928 * \returns a 0 int on success, or non-zero on failure.
1929 *
1930 * \since This function is available since SDL 2.0.18.
1931 */
1932extern DECLSPEC int SDLCALL SDL_RenderSetVSync(SDL_Renderer* renderer, int vsync);
1933
1934/* Ends C function definitions when using C++ */
1935#ifdef __cplusplus
1936}
1937#endif
1938#include "close_code.h"
1939
1940#endif /* SDL_render_h_ */
1941
1942/* vi: set ts=4 sw=4 expandtab: */
1943