Imported Upstream version 2.0.14
[platform/upstream/SDL.git] / include / SDL_render.h
1 /*
2   Simple DirectMedia Layer
3   Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
5   This software is provided 'as-is', without any express or implied
6   warranty.  In no event will the authors be held liable for any damages
7   arising from the use of this software.
8
9   Permission is granted to anyone to use this software for any purpose,
10   including commercial applications, and to alter it and redistribute it
11   freely, subject to the following restrictions:
12
13   1. The origin of this software must not be misrepresented; you must not
14      claim that you wrote the original software. If you use this software
15      in a product, an acknowledgment in the product documentation would be
16      appreciated but is not required.
17   2. Altered source versions must be plainly marked as such, and must not be
18      misrepresented as being the original software.
19   3. This notice may not be removed or altered from any source distribution.
20 */
21
22 /**
23  *  \file SDL_render.h
24  *
25  *  Header file for SDL 2D rendering functions.
26  *
27  *  This API supports the following features:
28  *      * single pixel points
29  *      * single pixel lines
30  *      * filled rectangles
31  *      * texture images
32  *
33  *  The primitives may be drawn in opaque, blended, or additive modes.
34  *
35  *  The texture images may be drawn in opaque, blended, or additive modes.
36  *  They can have an additional color tint or alpha modulation applied to
37  *  them, and may also be stretched with linear interpolation.
38  *
39  *  This API is designed to accelerate simple 2D operations. You may
40  *  want more functionality such as polygons and particle effects and
41  *  in that case you should use SDL's OpenGL/Direct3D support or one
42  *  of the many good 3D engines.
43  *
44  *  These functions must be called from the main thread.
45  *  See this bug for details: http://bugzilla.libsdl.org/show_bug.cgi?id=1995
46  */
47
48 #ifndef SDL_render_h_
49 #define SDL_render_h_
50
51 #include "SDL_stdinc.h"
52 #include "SDL_rect.h"
53 #include "SDL_video.h"
54
55 #include "begin_code.h"
56 /* Set up for C function definitions, even when using C++ */
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60
61 /**
62  *  \brief Flags used when creating a rendering context
63  */
64 typedef enum
65 {
66     SDL_RENDERER_SOFTWARE = 0x00000001,         /**< The renderer is a software fallback */
67     SDL_RENDERER_ACCELERATED = 0x00000002,      /**< The renderer uses hardware
68                                                      acceleration */
69     SDL_RENDERER_PRESENTVSYNC = 0x00000004,     /**< Present is synchronized
70                                                      with the refresh rate */
71     SDL_RENDERER_TARGETTEXTURE = 0x00000008     /**< The renderer supports
72                                                      rendering to texture */
73 } SDL_RendererFlags;
74
75 /**
76  *  \brief Information on the capabilities of a render driver or context.
77  */
78 typedef struct SDL_RendererInfo
79 {
80     const char *name;           /**< The name of the renderer */
81     Uint32 flags;               /**< Supported ::SDL_RendererFlags */
82     Uint32 num_texture_formats; /**< The number of available texture formats */
83     Uint32 texture_formats[16]; /**< The available texture formats */
84     int max_texture_width;      /**< The maximum texture width */
85     int max_texture_height;     /**< The maximum texture height */
86 } SDL_RendererInfo;
87
88 /**
89  *  \brief The scaling mode for a texture.
90  */
91 typedef enum
92 {
93     SDL_ScaleModeNearest, /**< nearest pixel sampling */
94     SDL_ScaleModeLinear,  /**< linear filtering */
95     SDL_ScaleModeBest     /**< anisotropic filtering */
96 } SDL_ScaleMode;
97
98 /**
99  *  \brief The access pattern allowed for a texture.
100  */
101 typedef enum
102 {
103     SDL_TEXTUREACCESS_STATIC,    /**< Changes rarely, not lockable */
104     SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
105     SDL_TEXTUREACCESS_TARGET     /**< Texture can be used as a render target */
106 } SDL_TextureAccess;
107
108 /**
109  *  \brief The texture channel modulation used in SDL_RenderCopy().
110  */
111 typedef enum
112 {
113     SDL_TEXTUREMODULATE_NONE = 0x00000000,     /**< No modulation */
114     SDL_TEXTUREMODULATE_COLOR = 0x00000001,    /**< srcC = srcC * color */
115     SDL_TEXTUREMODULATE_ALPHA = 0x00000002     /**< srcA = srcA * alpha */
116 } SDL_TextureModulate;
117
118 /**
119  *  \brief Flip constants for SDL_RenderCopyEx
120  */
121 typedef enum
122 {
123     SDL_FLIP_NONE = 0x00000000,     /**< Do not flip */
124     SDL_FLIP_HORIZONTAL = 0x00000001,    /**< flip horizontally */
125     SDL_FLIP_VERTICAL = 0x00000002     /**< flip vertically */
126 } SDL_RendererFlip;
127
128 /**
129  *  \brief A structure representing rendering state
130  */
131 struct SDL_Renderer;
132 typedef struct SDL_Renderer SDL_Renderer;
133
134 /**
135  *  \brief An efficient driver-specific representation of pixel data
136  */
137 struct SDL_Texture;
138 typedef struct SDL_Texture SDL_Texture;
139
140
141 /* Function prototypes */
142
143 /**
144  *  \brief Get the number of 2D rendering drivers available for the current
145  *         display.
146  *
147  *  A render driver is a set of code that handles rendering and texture
148  *  management on a particular display.  Normally there is only one, but
149  *  some drivers may have several available with different capabilities.
150  *
151  *  \sa SDL_GetRenderDriverInfo()
152  *  \sa SDL_CreateRenderer()
153  */
154 extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
155
156 /**
157  *  \brief Get information about a specific 2D rendering driver for the current
158  *         display.
159  *
160  *  \param index The index of the driver to query information about.
161  *  \param info  A pointer to an SDL_RendererInfo struct to be filled with
162  *               information on the rendering driver.
163  *
164  *  \return 0 on success, -1 if the index was out of range.
165  *
166  *  \sa SDL_CreateRenderer()
167  */
168 extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index,
169                                                     SDL_RendererInfo * info);
170
171 /**
172  *  \brief Create a window and default renderer
173  *
174  *  \param width    The width of the window
175  *  \param height   The height of the window
176  *  \param window_flags The flags used to create the window
177  *  \param window   A pointer filled with the window, or NULL on error
178  *  \param renderer A pointer filled with the renderer, or NULL on error
179  *
180  *  \return 0 on success, or -1 on error
181  */
182 extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(
183                                 int width, int height, Uint32 window_flags,
184                                 SDL_Window **window, SDL_Renderer **renderer);
185
186
187 /**
188  *  \brief Create a 2D rendering context for a window.
189  *
190  *  \param window The window where rendering is displayed.
191  *  \param index    The index of the rendering driver to initialize, or -1 to
192  *                  initialize the first one supporting the requested flags.
193  *  \param flags    ::SDL_RendererFlags.
194  *
195  *  \return A valid rendering context or NULL if there was an error.
196  *
197  *  \sa SDL_CreateSoftwareRenderer()
198  *  \sa SDL_GetRendererInfo()
199  *  \sa SDL_DestroyRenderer()
200  */
201 extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window,
202                                                int index, Uint32 flags);
203
204 /**
205  *  \brief Create a 2D software rendering context for a surface.
206  *
207  *  \param surface The surface where rendering is done.
208  *
209  *  \return A valid rendering context or NULL if there was an error.
210  *
211  *  \sa SDL_CreateRenderer()
212  *  \sa SDL_DestroyRenderer()
213  */
214 extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface);
215
216 /**
217  *  \brief Get the renderer associated with a window.
218  */
219 extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window);
220
221 /**
222  *  \brief Get information about a rendering context.
223  */
224 extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer,
225                                                 SDL_RendererInfo * info);
226
227 /**
228  *  \brief Get the output size in pixels of a rendering context.
229  */
230 extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer,
231                                                       int *w, int *h);
232
233 /**
234  *  \brief Create a texture for a rendering context.
235  *
236  *  \param renderer The renderer.
237  *  \param format The format of the texture.
238  *  \param access One of the enumerated values in ::SDL_TextureAccess.
239  *  \param w      The width of the texture in pixels.
240  *  \param h      The height of the texture in pixels.
241  *
242  *  \return The created texture is returned, or NULL if no rendering context was
243  *          active,  the format was unsupported, or the width or height were out
244  *          of range.
245  *
246  *  \note The contents of the texture are not defined at creation.
247  *
248  *  \sa SDL_QueryTexture()
249  *  \sa SDL_UpdateTexture()
250  *  \sa SDL_DestroyTexture()
251  */
252 extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer,
253                                                         Uint32 format,
254                                                         int access, int w,
255                                                         int h);
256
257 /**
258  *  \brief Create a texture from an existing surface.
259  *
260  *  \param renderer The renderer.
261  *  \param surface The surface containing pixel data used to fill the texture.
262  *
263  *  \return The created texture is returned, or NULL on error.
264  *
265  *  \note The surface is not modified or freed by this function.
266  *
267  *  \sa SDL_QueryTexture()
268  *  \sa SDL_DestroyTexture()
269  */
270 extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface);
271
272 /**
273  *  \brief Query the attributes of a texture
274  *
275  *  \param texture A texture to be queried.
276  *  \param format  A pointer filled in with the raw format of the texture.  The
277  *                 actual format may differ, but pixel transfers will use this
278  *                 format.
279  *  \param access  A pointer filled in with the actual access to the texture.
280  *  \param w       A pointer filled in with the width of the texture in pixels.
281  *  \param h       A pointer filled in with the height of the texture in pixels.
282  *
283  *  \return 0 on success, or -1 if the texture is not valid.
284  */
285 extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
286                                              Uint32 * format, int *access,
287                                              int *w, int *h);
288
289 /**
290  *  \brief Set an additional color value used in render copy operations.
291  *
292  *  \param texture The texture to update.
293  *  \param r       The red color value multiplied into copy operations.
294  *  \param g       The green color value multiplied into copy operations.
295  *  \param b       The blue color value multiplied into copy operations.
296  *
297  *  \return 0 on success, or -1 if the texture is not valid or color modulation
298  *          is not supported.
299  *
300  *  \sa SDL_GetTextureColorMod()
301  */
302 extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
303                                                    Uint8 r, Uint8 g, Uint8 b);
304
305
306 /**
307  *  \brief Get the additional color value used in render copy operations.
308  *
309  *  \param texture The texture to query.
310  *  \param r         A pointer filled in with the current red color value.
311  *  \param g         A pointer filled in with the current green color value.
312  *  \param b         A pointer filled in with the current blue color value.
313  *
314  *  \return 0 on success, or -1 if the texture is not valid.
315  *
316  *  \sa SDL_SetTextureColorMod()
317  */
318 extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
319                                                    Uint8 * r, Uint8 * g,
320                                                    Uint8 * b);
321
322 /**
323  *  \brief Set an additional alpha value used in render copy operations.
324  *
325  *  \param texture The texture to update.
326  *  \param alpha     The alpha value multiplied into copy operations.
327  *
328  *  \return 0 on success, or -1 if the texture is not valid or alpha modulation
329  *          is not supported.
330  *
331  *  \sa SDL_GetTextureAlphaMod()
332  */
333 extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
334                                                    Uint8 alpha);
335
336 /**
337  *  \brief Get the additional alpha value used in render copy operations.
338  *
339  *  \param texture The texture to query.
340  *  \param alpha     A pointer filled in with the current alpha value.
341  *
342  *  \return 0 on success, or -1 if the texture is not valid.
343  *
344  *  \sa SDL_SetTextureAlphaMod()
345  */
346 extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
347                                                    Uint8 * alpha);
348
349 /**
350  *  \brief Set the blend mode used for texture copy operations.
351  *
352  *  \param texture The texture to update.
353  *  \param blendMode ::SDL_BlendMode to use for texture blending.
354  *
355  *  \return 0 on success, or -1 if the texture is not valid or the blend mode is
356  *          not supported.
357  *
358  *  \note If the blend mode is not supported, the closest supported mode is
359  *        chosen.
360  *
361  *  \sa SDL_GetTextureBlendMode()
362  */
363 extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
364                                                     SDL_BlendMode blendMode);
365
366 /**
367  *  \brief Get the blend mode used for texture copy operations.
368  *
369  *  \param texture   The texture to query.
370  *  \param blendMode A pointer filled in with the current blend mode.
371  *
372  *  \return 0 on success, or -1 if the texture is not valid.
373  *
374  *  \sa SDL_SetTextureBlendMode()
375  */
376 extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
377                                                     SDL_BlendMode *blendMode);
378
379 /**
380  *  \brief Set the scale mode used for texture scale operations.
381  *
382  *  \param texture The texture to update.
383  *  \param scaleMode ::SDL_ScaleMode to use for texture scaling.
384  *
385  *  \return 0 on success, or -1 if the texture is not valid.
386  *
387  *  \note If the scale mode is not supported, the closest supported mode is
388  *        chosen.
389  *
390  *  \sa SDL_GetTextureScaleMode()
391  */
392 extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture,
393                                                     SDL_ScaleMode scaleMode);
394
395 /**
396  *  \brief Get the scale mode used for texture scale operations.
397  *
398  *  \param texture   The texture to query.
399  *  \param scaleMode A pointer filled in with the current scale mode.
400  *
401  *  \return 0 on success, or -1 if the texture is not valid.
402  *
403  *  \sa SDL_SetTextureScaleMode()
404  */
405 extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture,
406                                                     SDL_ScaleMode *scaleMode);
407
408 /**
409  *  \brief Update the given texture rectangle with new pixel data.
410  *
411  *  \param texture   The texture to update
412  *  \param rect      A pointer to the rectangle of pixels to update, or NULL to
413  *                   update the entire texture.
414  *  \param pixels    The raw pixel data in the format of the texture.
415  *  \param pitch     The number of bytes in a row of pixel data, including padding between lines.
416  *
417  *  The pixel data must be in the format of the texture. The pixel format can be
418  *  queried with SDL_QueryTexture.
419  *
420  *  \return 0 on success, or -1 if the texture is not valid.
421  *
422  *  \note This is a fairly slow function.
423  */
424 extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
425                                               const SDL_Rect * rect,
426                                               const void *pixels, int pitch);
427
428 /**
429  *  \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data.
430  *
431  *  \param texture   The texture to update
432  *  \param rect      A pointer to the rectangle of pixels to update, or NULL to
433  *                   update the entire texture.
434  *  \param Yplane    The raw pixel data for the Y plane.
435  *  \param Ypitch    The number of bytes between rows of pixel data for the Y plane.
436  *  \param Uplane    The raw pixel data for the U plane.
437  *  \param Upitch    The number of bytes between rows of pixel data for the U plane.
438  *  \param Vplane    The raw pixel data for the V plane.
439  *  \param Vpitch    The number of bytes between rows of pixel data for the V plane.
440  *
441  *  \return 0 on success, or -1 if the texture is not valid.
442  *
443  *  \note You can use SDL_UpdateTexture() as long as your pixel data is
444  *        a contiguous block of Y and U/V planes in the proper order, but
445  *        this function is available if your pixel data is not contiguous.
446  */
447 extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture,
448                                                  const SDL_Rect * rect,
449                                                  const Uint8 *Yplane, int Ypitch,
450                                                  const Uint8 *Uplane, int Upitch,
451                                                  const Uint8 *Vplane, int Vpitch);
452
453 /**
454  *  \brief Lock a portion of the texture for write-only pixel access.
455  *
456  *  \param texture   The texture to lock for access, which was created with
457  *                   ::SDL_TEXTUREACCESS_STREAMING.
458  *  \param rect      A pointer to the rectangle to lock for access. If the rect
459  *                   is NULL, the entire texture will be locked.
460  *  \param pixels    This is filled in with a pointer to the locked pixels,
461  *                   appropriately offset by the locked area.
462  *  \param pitch     This is filled in with the pitch of the locked pixels.
463  *
464  *  \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING.
465  *
466  *  \sa SDL_UnlockTexture()
467  */
468 extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
469                                             const SDL_Rect * rect,
470                                             void **pixels, int *pitch);
471
472 /**
473  *  \brief Lock a portion of the texture for write-only pixel access.
474  *         Expose it as a SDL surface.
475  *
476  *  \param texture   The texture to lock for access, which was created with
477  *                   ::SDL_TEXTUREACCESS_STREAMING.
478  *  \param rect      A pointer to the rectangle to lock for access. If the rect
479  *                   is NULL, the entire texture will be locked.
480  *  \param surface   This is filled in with a SDL surface representing the locked area
481  *                   Surface is freed internally after calling SDL_UnlockTexture or SDL_DestroyTexture.
482  *
483  *  \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING.
484  *
485  *  \sa SDL_UnlockTexture()
486  */
487 extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
488                                             const SDL_Rect *rect,
489                                             SDL_Surface **surface);
490
491 /**
492  *  \brief Unlock a texture, uploading the changes to video memory, if needed.
493  *         If SDL_LockTextureToSurface() was called for locking, the SDL surface is freed.
494  *
495  *  \sa SDL_LockTexture()
496  *  \sa SDL_LockTextureToSurface()
497  */
498 extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
499
500 /**
501  * \brief Determines whether a window supports the use of render targets
502  *
503  * \param renderer The renderer that will be checked
504  *
505  * \return SDL_TRUE if supported, SDL_FALSE if not.
506  */
507 extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer);
508
509 /**
510  * \brief Set a texture as the current rendering target.
511  *
512  * \param renderer The renderer.
513  * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target
514  *
515  * \return 0 on success, or -1 on error
516  *
517  *  \sa SDL_GetRenderTarget()
518  */
519 extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
520                                                 SDL_Texture *texture);
521
522 /**
523  * \brief Get the current render target or NULL for the default render target.
524  *
525  * \return The current render target
526  *
527  *  \sa SDL_SetRenderTarget()
528  */
529 extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
530
531 /**
532  *  \brief Set device independent resolution for rendering
533  *
534  *  \param renderer The renderer for which resolution should be set.
535  *  \param w      The width of the logical resolution
536  *  \param h      The height of the logical resolution
537  *
538  *  This function uses the viewport and scaling functionality to allow a fixed logical
539  *  resolution for rendering, regardless of the actual output resolution.  If the actual
540  *  output resolution doesn't have the same aspect ratio the output rendering will be
541  *  centered within the output display.
542  *
543  *  If the output display is a window, mouse events in the window will be filtered
544  *  and scaled so they seem to arrive within the logical resolution.
545  *
546  *  \note If this function results in scaling or subpixel drawing by the
547  *        rendering backend, it will be handled using the appropriate
548  *        quality hints.
549  *
550  *  \sa SDL_RenderGetLogicalSize()
551  *  \sa SDL_RenderSetScale()
552  *  \sa SDL_RenderSetViewport()
553  */
554 extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h);
555
556 /**
557  *  \brief Get device independent resolution for rendering
558  *
559  *  \param renderer The renderer from which resolution should be queried.
560  *  \param w      A pointer filled with the width of the logical resolution
561  *  \param h      A pointer filled with the height of the logical resolution
562  *
563  *  \sa SDL_RenderSetLogicalSize()
564  */
565 extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h);
566
567 /**
568  *  \brief Set whether to force integer scales for resolution-independent rendering
569  *
570  *  \param renderer The renderer for which integer scaling should be set.
571  *  \param enable   Enable or disable integer scaling
572  *
573  *  This function restricts the logical viewport to integer values - that is, when
574  *  a resolution is between two multiples of a logical size, the viewport size is
575  *  rounded down to the lower multiple.
576  *
577  *  \sa SDL_RenderSetLogicalSize()
578  */
579 extern DECLSPEC int SDLCALL SDL_RenderSetIntegerScale(SDL_Renderer * renderer,
580                                                       SDL_bool enable);
581
582 /**
583  *  \brief Get whether integer scales are forced for resolution-independent rendering
584  *
585  *  \param renderer The renderer from which integer scaling should be queried.
586  *
587  *  \sa SDL_RenderSetIntegerScale()
588  */
589 extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer);
590
591 /**
592  *  \brief Set the drawing area for rendering on the current target.
593  *
594  *  \param renderer The renderer for which the drawing area should be set.
595  *  \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target.
596  *
597  *  The x,y of the viewport rect represents the origin for rendering.
598  *
599  *  \return 0 on success, or -1 on error
600  *
601  *  \note If the window associated with the renderer is resized, the viewport is automatically reset.
602  *
603  *  \sa SDL_RenderGetViewport()
604  *  \sa SDL_RenderSetLogicalSize()
605  */
606 extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
607                                                   const SDL_Rect * rect);
608
609 /**
610  *  \brief Get the drawing area for the current target.
611  *
612  *  \sa SDL_RenderSetViewport()
613  */
614 extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
615                                                    SDL_Rect * rect);
616
617 /**
618  *  \brief Set the clip rectangle for the current target.
619  *
620  *  \param renderer The renderer for which clip rectangle should be set.
621  *  \param rect   A pointer to the rectangle to set as the clip rectangle,
622  *                relative to the viewport, or NULL to disable clipping.
623  *
624  *  \return 0 on success, or -1 on error
625  *
626  *  \sa SDL_RenderGetClipRect()
627  */
628 extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer,
629                                                   const SDL_Rect * rect);
630
631 /**
632  *  \brief Get the clip rectangle for the current target.
633  *
634  *  \param renderer The renderer from which clip rectangle should be queried.
635  *  \param rect   A pointer filled in with the current clip rectangle, or
636  *                an empty rectangle if clipping is disabled.
637  *
638  *  \sa SDL_RenderSetClipRect()
639  */
640 extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer,
641                                                    SDL_Rect * rect);
642
643 /**
644  *  \brief Get whether clipping is enabled on the given renderer.
645  *
646  *  \param renderer The renderer from which clip state should be queried.
647  *
648  *  \sa SDL_RenderGetClipRect()
649  */
650 extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer);
651
652
653 /**
654  *  \brief Set the drawing scale for rendering on the current target.
655  *
656  *  \param renderer The renderer for which the drawing scale should be set.
657  *  \param scaleX The horizontal scaling factor
658  *  \param scaleY The vertical scaling factor
659  *
660  *  The drawing coordinates are scaled by the x/y scaling factors
661  *  before they are used by the renderer.  This allows resolution
662  *  independent drawing with a single coordinate system.
663  *
664  *  \note If this results in scaling or subpixel drawing by the
665  *        rendering backend, it will be handled using the appropriate
666  *        quality hints.  For best results use integer scaling factors.
667  *
668  *  \sa SDL_RenderGetScale()
669  *  \sa SDL_RenderSetLogicalSize()
670  */
671 extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
672                                                float scaleX, float scaleY);
673
674 /**
675  *  \brief Get the drawing scale for the current target.
676  *
677  *  \param renderer The renderer from which drawing scale should be queried.
678  *  \param scaleX A pointer filled in with the horizontal scaling factor
679  *  \param scaleY A pointer filled in with the vertical scaling factor
680  *
681  *  \sa SDL_RenderSetScale()
682  */
683 extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
684                                                float *scaleX, float *scaleY);
685
686 /**
687  *  \brief Set the color used for drawing operations (Rect, Line and Clear).
688  *
689  *  \param renderer The renderer for which drawing color should be set.
690  *  \param r The red value used to draw on the rendering target.
691  *  \param g The green value used to draw on the rendering target.
692  *  \param b The blue value used to draw on the rendering target.
693  *  \param a The alpha value used to draw on the rendering target, usually
694  *           ::SDL_ALPHA_OPAQUE (255).
695  *
696  *  \return 0 on success, or -1 on error
697  */
698 extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer,
699                                            Uint8 r, Uint8 g, Uint8 b,
700                                            Uint8 a);
701
702 /**
703  *  \brief Get the color used for drawing operations (Rect, Line and Clear).
704  *
705  *  \param renderer The renderer from which drawing color should be queried.
706  *  \param r A pointer to the red value used to draw on the rendering target.
707  *  \param g A pointer to the green value used to draw on the rendering target.
708  *  \param b A pointer to the blue value used to draw on the rendering target.
709  *  \param a A pointer to the alpha value used to draw on the rendering target,
710  *           usually ::SDL_ALPHA_OPAQUE (255).
711  *
712  *  \return 0 on success, or -1 on error
713  */
714 extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer,
715                                            Uint8 * r, Uint8 * g, Uint8 * b,
716                                            Uint8 * a);
717
718 /**
719  *  \brief Set the blend mode used for drawing operations (Fill and Line).
720  *
721  *  \param renderer The renderer for which blend mode should be set.
722  *  \param blendMode ::SDL_BlendMode to use for blending.
723  *
724  *  \return 0 on success, or -1 on error
725  *
726  *  \note If the blend mode is not supported, the closest supported mode is
727  *        chosen.
728  *
729  *  \sa SDL_GetRenderDrawBlendMode()
730  */
731 extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
732                                                        SDL_BlendMode blendMode);
733
734 /**
735  *  \brief Get the blend mode used for drawing operations.
736  *
737  *  \param renderer The renderer from which blend mode should be queried.
738  *  \param blendMode A pointer filled in with the current blend mode.
739  *
740  *  \return 0 on success, or -1 on error
741  *
742  *  \sa SDL_SetRenderDrawBlendMode()
743  */
744 extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
745                                                        SDL_BlendMode *blendMode);
746
747 /**
748  *  \brief Clear the current rendering target with the drawing color
749  *
750  *  This function clears the entire rendering target, ignoring the viewport and
751  *  the clip rectangle.
752  *
753  *  \return 0 on success, or -1 on error
754  */
755 extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
756
757 /**
758  *  \brief Draw a point on the current rendering target.
759  *
760  *  \param renderer The renderer which should draw a point.
761  *  \param x The x coordinate of the point.
762  *  \param y The y coordinate of the point.
763  *
764  *  \return 0 on success, or -1 on error
765  */
766 extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
767                                                 int x, int y);
768
769 /**
770  *  \brief Draw multiple points on the current rendering target.
771  *
772  *  \param renderer The renderer which should draw multiple points.
773  *  \param points The points to draw
774  *  \param count The number of points to draw
775  *
776  *  \return 0 on success, or -1 on error
777  */
778 extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
779                                                  const SDL_Point * points,
780                                                  int count);
781
782 /**
783  *  \brief Draw a line on the current rendering target.
784  *
785  *  \param renderer The renderer which should draw a line.
786  *  \param x1 The x coordinate of the start point.
787  *  \param y1 The y coordinate of the start point.
788  *  \param x2 The x coordinate of the end point.
789  *  \param y2 The y coordinate of the end point.
790  *
791  *  \return 0 on success, or -1 on error
792  */
793 extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
794                                                int x1, int y1, int x2, int y2);
795
796 /**
797  *  \brief Draw a series of connected lines on the current rendering target.
798  *
799  *  \param renderer The renderer which should draw multiple lines.
800  *  \param points The points along the lines
801  *  \param count The number of points, drawing count-1 lines
802  *
803  *  \return 0 on success, or -1 on error
804  */
805 extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
806                                                 const SDL_Point * points,
807                                                 int count);
808
809 /**
810  *  \brief Draw a rectangle on the current rendering target.
811  *
812  *  \param renderer The renderer which should draw a rectangle.
813  *  \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
814  *
815  *  \return 0 on success, or -1 on error
816  */
817 extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
818                                                const SDL_Rect * rect);
819
820 /**
821  *  \brief Draw some number of rectangles on the current rendering target.
822  *
823  *  \param renderer The renderer which should draw multiple rectangles.
824  *  \param rects A pointer to an array of destination rectangles.
825  *  \param count The number of rectangles.
826  *
827  *  \return 0 on success, or -1 on error
828  */
829 extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
830                                                 const SDL_Rect * rects,
831                                                 int count);
832
833 /**
834  *  \brief Fill a rectangle on the current rendering target with the drawing color.
835  *
836  *  \param renderer The renderer which should fill a rectangle.
837  *  \param rect A pointer to the destination rectangle, or NULL for the entire
838  *              rendering target.
839  *
840  *  \return 0 on success, or -1 on error
841  */
842 extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
843                                                const SDL_Rect * rect);
844
845 /**
846  *  \brief Fill some number of rectangles on the current rendering target with the drawing color.
847  *
848  *  \param renderer The renderer which should fill multiple rectangles.
849  *  \param rects A pointer to an array of destination rectangles.
850  *  \param count The number of rectangles.
851  *
852  *  \return 0 on success, or -1 on error
853  */
854 extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
855                                                 const SDL_Rect * rects,
856                                                 int count);
857
858 /**
859  *  \brief Copy a portion of the texture to the current rendering target.
860  *
861  *  \param renderer The renderer which should copy parts of a texture.
862  *  \param texture The source texture.
863  *  \param srcrect   A pointer to the source rectangle, or NULL for the entire
864  *                   texture.
865  *  \param dstrect   A pointer to the destination rectangle, or NULL for the
866  *                   entire rendering target.
867  *
868  *  \return 0 on success, or -1 on error
869  */
870 extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
871                                            SDL_Texture * texture,
872                                            const SDL_Rect * srcrect,
873                                            const SDL_Rect * dstrect);
874
875 /**
876  *  \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center
877  *
878  *  \param renderer The renderer which should copy parts of a texture.
879  *  \param texture The source texture.
880  *  \param srcrect   A pointer to the source rectangle, or NULL for the entire
881  *                   texture.
882  *  \param dstrect   A pointer to the destination rectangle, or NULL for the
883  *                   entire rendering target.
884  *  \param angle    An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction
885  *  \param center   A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2).
886  *  \param flip     An SDL_RendererFlip value stating which flipping actions should be performed on the texture
887  *
888  *  \return 0 on success, or -1 on error
889  */
890 extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
891                                            SDL_Texture * texture,
892                                            const SDL_Rect * srcrect,
893                                            const SDL_Rect * dstrect,
894                                            const double angle,
895                                            const SDL_Point *center,
896                                            const SDL_RendererFlip flip);
897
898
899 /**
900  *  \brief Draw a point on the current rendering target.
901  *
902  *  \param renderer The renderer which should draw a point.
903  *  \param x The x coordinate of the point.
904  *  \param y The y coordinate of the point.
905  *
906  *  \return 0 on success, or -1 on error
907  */
908 extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer,
909                                                  float x, float y);
910
911 /**
912  *  \brief Draw multiple points on the current rendering target.
913  *
914  *  \param renderer The renderer which should draw multiple points.
915  *  \param points The points to draw
916  *  \param count The number of points to draw
917  *
918  *  \return 0 on success, or -1 on error
919  */
920 extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer,
921                                                   const SDL_FPoint * points,
922                                                   int count);
923
924 /**
925  *  \brief Draw a line on the current rendering target.
926  *
927  *  \param renderer The renderer which should draw a line.
928  *  \param x1 The x coordinate of the start point.
929  *  \param y1 The y coordinate of the start point.
930  *  \param x2 The x coordinate of the end point.
931  *  \param y2 The y coordinate of the end point.
932  *
933  *  \return 0 on success, or -1 on error
934  */
935 extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer,
936                                                 float x1, float y1, float x2, float y2);
937
938 /**
939  *  \brief Draw a series of connected lines on the current rendering target.
940  *
941  *  \param renderer The renderer which should draw multiple lines.
942  *  \param points The points along the lines
943  *  \param count The number of points, drawing count-1 lines
944  *
945  *  \return 0 on success, or -1 on error
946  */
947 extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer,
948                                                 const SDL_FPoint * points,
949                                                 int count);
950
951 /**
952  *  \brief Draw a rectangle on the current rendering target.
953  *
954  *  \param renderer The renderer which should draw a rectangle.
955  *  \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
956  *
957  *  \return 0 on success, or -1 on error
958  */
959 extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer,
960                                                const SDL_FRect * rect);
961
962 /**
963  *  \brief Draw some number of rectangles on the current rendering target.
964  *
965  *  \param renderer The renderer which should draw multiple rectangles.
966  *  \param rects A pointer to an array of destination rectangles.
967  *  \param count The number of rectangles.
968  *
969  *  \return 0 on success, or -1 on error
970  */
971 extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer,
972                                                  const SDL_FRect * rects,
973                                                  int count);
974
975 /**
976  *  \brief Fill a rectangle on the current rendering target with the drawing color.
977  *
978  *  \param renderer The renderer which should fill a rectangle.
979  *  \param rect A pointer to the destination rectangle, or NULL for the entire
980  *              rendering target.
981  *
982  *  \return 0 on success, or -1 on error
983  */
984 extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer,
985                                                 const SDL_FRect * rect);
986
987 /**
988  *  \brief Fill some number of rectangles on the current rendering target with the drawing color.
989  *
990  *  \param renderer The renderer which should fill multiple rectangles.
991  *  \param rects A pointer to an array of destination rectangles.
992  *  \param count The number of rectangles.
993  *
994  *  \return 0 on success, or -1 on error
995  */
996 extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer,
997                                                  const SDL_FRect * rects,
998                                                  int count);
999
1000 /**
1001  *  \brief Copy a portion of the texture to the current rendering target.
1002  *
1003  *  \param renderer The renderer which should copy parts of a texture.
1004  *  \param texture The source texture.
1005  *  \param srcrect   A pointer to the source rectangle, or NULL for the entire
1006  *                   texture.
1007  *  \param dstrect   A pointer to the destination rectangle, or NULL for the
1008  *                   entire rendering target.
1009  *
1010  *  \return 0 on success, or -1 on error
1011  */
1012 extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer,
1013                                             SDL_Texture * texture,
1014                                             const SDL_Rect * srcrect,
1015                                             const SDL_FRect * dstrect);
1016
1017 /**
1018  *  \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center
1019  *
1020  *  \param renderer The renderer which should copy parts of a texture.
1021  *  \param texture The source texture.
1022  *  \param srcrect   A pointer to the source rectangle, or NULL for the entire
1023  *                   texture.
1024  *  \param dstrect   A pointer to the destination rectangle, or NULL for the
1025  *                   entire rendering target.
1026  *  \param angle    An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction
1027  *  \param center   A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2).
1028  *  \param flip     An SDL_RendererFlip value stating which flipping actions should be performed on the texture
1029  *
1030  *  \return 0 on success, or -1 on error
1031  */
1032 extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer,
1033                                             SDL_Texture * texture,
1034                                             const SDL_Rect * srcrect,
1035                                             const SDL_FRect * dstrect,
1036                                             const double angle,
1037                                             const SDL_FPoint *center,
1038                                             const SDL_RendererFlip flip);
1039
1040 /**
1041  *  \brief Read pixels from the current rendering target.
1042  *
1043  *  \param renderer The renderer from which pixels should be read.
1044  *  \param rect   A pointer to the rectangle to read, or NULL for the entire
1045  *                render target.
1046  *  \param format The desired format of the pixel data, or 0 to use the format
1047  *                of the rendering target
1048  *  \param pixels A pointer to be filled in with the pixel data
1049  *  \param pitch  The pitch of the pixels parameter.
1050  *
1051  *  \return 0 on success, or -1 if pixel reading is not supported.
1052  *
1053  *  \warning This is a very slow operation, and should not be used frequently.
1054  */
1055 extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
1056                                                  const SDL_Rect * rect,
1057                                                  Uint32 format,
1058                                                  void *pixels, int pitch);
1059
1060 /**
1061  *  \brief Update the screen with rendering performed.
1062  */
1063 extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
1064
1065 /**
1066  *  \brief Destroy the specified texture.
1067  *
1068  *  \sa SDL_CreateTexture()
1069  *  \sa SDL_CreateTextureFromSurface()
1070  */
1071 extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
1072
1073 /**
1074  *  \brief Destroy the rendering context for a window and free associated
1075  *         textures.
1076  *
1077  *  \sa SDL_CreateRenderer()
1078  */
1079 extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
1080
1081 /**
1082  *  \brief Force the rendering context to flush any pending commands to the
1083  *         underlying rendering API.
1084  *
1085  *  You do not need to (and in fact, shouldn't) call this function unless
1086  *  you are planning to call into OpenGL/Direct3D/Metal/whatever directly
1087  *  in addition to using an SDL_Renderer.
1088  *
1089  *  This is for a very-specific case: if you are using SDL's render API,
1090  *  you asked for a specific renderer backend (OpenGL, Direct3D, etc),
1091  *  you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make
1092  *  OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of
1093  *  this applies, you should call SDL_RenderFlush() between calls to SDL's
1094  *  render API and the low-level API you're using in cooperation.
1095  *
1096  *  In all other cases, you can ignore this function. This is only here to
1097  *  get maximum performance out of a specific situation. In all other cases,
1098  *  SDL will do the right thing, perhaps at a performance loss.
1099  *
1100  *  This function is first available in SDL 2.0.10, and is not needed in
1101  *  2.0.9 and earlier, as earlier versions did not queue rendering commands
1102  *  at all, instead flushing them to the OS immediately.
1103  */
1104 extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer);
1105
1106
1107 /**
1108  *  \brief Bind the texture to the current OpenGL/ES/ES2 context for use with
1109  *         OpenGL instructions.
1110  *
1111  *  \param texture  The SDL texture to bind
1112  *  \param texw     A pointer to a float that will be filled with the texture width
1113  *  \param texh     A pointer to a float that will be filled with the texture height
1114  *
1115  *  \return 0 on success, or -1 if the operation is not supported
1116  */
1117 extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);
1118
1119 /**
1120  *  \brief Unbind a texture from the current OpenGL/ES/ES2 context.
1121  *
1122  *  \param texture  The SDL texture to unbind
1123  *
1124  *  \return 0 on success, or -1 if the operation is not supported
1125  */
1126 extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture);
1127
1128 /**
1129  *  \brief Get the CAMetalLayer associated with the given Metal renderer
1130  *
1131  *  \param renderer The renderer to query
1132  *
1133  *  \return CAMetalLayer* on success, or NULL if the renderer isn't a Metal renderer
1134  *
1135  *  \sa SDL_RenderGetMetalCommandEncoder()
1136  */
1137 extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer);
1138
1139 /**
1140  *  \brief Get the Metal command encoder for the current frame
1141  *
1142  *  \param renderer The renderer to query
1143  *
1144  *  \return id<MTLRenderCommandEncoder> on success, or NULL if the renderer isn't a Metal renderer
1145  *
1146  *  \sa SDL_RenderGetMetalLayer()
1147  */
1148 extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer);
1149
1150 /* Ends C function definitions when using C++ */
1151 #ifdef __cplusplus
1152 }
1153 #endif
1154 #include "close_code.h"
1155
1156 #endif /* SDL_render_h_ */
1157
1158 /* vi: set ts=4 sw=4 expandtab: */