include/SDL_render.h
author Ryan C. Gordon <icculus@icculus.org>
Tue, 15 Oct 2019 22:36:08 -0400
changeset 13130 502bb7d04f0a
parent 13099 9599e2bf9e3a
permissions -rw-r--r--
x11: On macOS, look for X11 install in /opt/X11 instead of /usr/X11R6.

This is where Apple installs XQuartz now (and apparently, the compatibility
symlink at /usr/X11R6 can be missing).

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