include/SDL_render.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 29 May 2013 03:22:19 -0700
changeset 7240 39eb4958950a
parent 7239 04dda95ba22c
child 7542 399ff49069a5
permissions -rw-r--r--
When the window is resized, the viewport is automatically reset.
This resolves lots of confusion around resizable windows. Most people don't expect a viewport to be implicitly set when the renderer is created and then not to be reset to the window size if the window is resized.

Added common test command line parameters --logical WxH and --scale N to test the render logical size and scaling APIs.
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2013 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 rotation 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 
    45 #ifndef _SDL_render_h
    46 #define _SDL_render_h
    47 
    48 #include "SDL_stdinc.h"
    49 #include "SDL_rect.h"
    50 #include "SDL_video.h"
    51 
    52 #include "begin_code.h"
    53 /* Set up for C function definitions, even when using C++ */
    54 #ifdef __cplusplus
    55 extern "C" {
    56 #endif
    57 
    58 /**
    59  *  \brief Flags used when creating a rendering context
    60  */
    61 typedef enum
    62 {
    63     SDL_RENDERER_SOFTWARE = 0x00000001,         /**< The renderer is a software fallback */
    64     SDL_RENDERER_ACCELERATED = 0x00000002,      /**< The renderer uses hardware
    65                                                      acceleration */
    66     SDL_RENDERER_PRESENTVSYNC = 0x00000004,     /**< Present is synchronized
    67                                                      with the refresh rate */
    68     SDL_RENDERER_TARGETTEXTURE = 0x00000008     /**< The renderer supports
    69                                                      rendering to texture */
    70 } SDL_RendererFlags;
    71 
    72 /**
    73  *  \brief Information on the capabilities of a render driver or context.
    74  */
    75 typedef struct SDL_RendererInfo
    76 {
    77     const char *name;           /**< The name of the renderer */
    78     Uint32 flags;               /**< Supported ::SDL_RendererFlags */
    79     Uint32 num_texture_formats; /**< The number of available texture formats */
    80     Uint32 texture_formats[16]; /**< The available texture formats */
    81     int max_texture_width;      /**< The maximimum texture width */
    82     int max_texture_height;     /**< The maximimum texture height */
    83 } SDL_RendererInfo;
    84 
    85 /**
    86  *  \brief The access pattern allowed for a texture.
    87  */
    88 typedef enum
    89 {
    90     SDL_TEXTUREACCESS_STATIC,    /**< Changes rarely, not lockable */
    91     SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
    92     SDL_TEXTUREACCESS_TARGET     /**< Texture can be used as a render target */
    93 } SDL_TextureAccess;
    94 
    95 /**
    96  *  \brief The texture channel modulation used in SDL_RenderCopy().
    97  */
    98 typedef enum
    99 {
   100     SDL_TEXTUREMODULATE_NONE = 0x00000000,     /**< No modulation */
   101     SDL_TEXTUREMODULATE_COLOR = 0x00000001,    /**< srcC = srcC * color */
   102     SDL_TEXTUREMODULATE_ALPHA = 0x00000002     /**< srcA = srcA * alpha */
   103 } SDL_TextureModulate;
   104 
   105 /**
   106  *  \brief Flip constants for SDL_RenderCopyEx
   107  */
   108 typedef enum
   109 {
   110     SDL_FLIP_NONE = 0x00000000,     /**< Do not flip */
   111     SDL_FLIP_HORIZONTAL = 0x00000001,    /**< flip horizontally */
   112     SDL_FLIP_VERTICAL = 0x00000002     /**< flip vertically */
   113 } SDL_RendererFlip;
   114 
   115 /**
   116  *  \brief A structure representing rendering state
   117  */
   118 struct SDL_Renderer;
   119 typedef struct SDL_Renderer SDL_Renderer;
   120 
   121 /**
   122  *  \brief An efficient driver-specific representation of pixel data
   123  */
   124 struct SDL_Texture;
   125 typedef struct SDL_Texture SDL_Texture;
   126 
   127 
   128 /* Function prototypes */
   129 
   130 /**
   131  *  \brief Get the number of 2D rendering drivers available for the current
   132  *         display.
   133  *
   134  *  A render driver is a set of code that handles rendering and texture
   135  *  management on a particular display.  Normally there is only one, but
   136  *  some drivers may have several available with different capabilities.
   137  *
   138  *  \sa SDL_GetRenderDriverInfo()
   139  *  \sa SDL_CreateRenderer()
   140  */
   141 extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
   142 
   143 /**
   144  *  \brief Get information about a specific 2D rendering driver for the current
   145  *         display.
   146  *
   147  *  \param index The index of the driver to query information about.
   148  *  \param info  A pointer to an SDL_RendererInfo struct to be filled with
   149  *               information on the rendering driver.
   150  *
   151  *  \return 0 on success, -1 if the index was out of range.
   152  *
   153  *  \sa SDL_CreateRenderer()
   154  */
   155 extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index,
   156                                                     SDL_RendererInfo * info);
   157 
   158 /**
   159  *  \brief Create a window and default renderer
   160  *
   161  *  \param width    The width of the window
   162  *  \param height   The height of the window
   163  *  \param window_flags The flags used to create the window
   164  *  \param window   A pointer filled with the window, or NULL on error
   165  *  \param renderer A pointer filled with the renderer, or NULL on error
   166  *
   167  *  \return 0 on success, or -1 on error
   168  */
   169 extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(
   170                                 int width, int height, Uint32 window_flags,
   171                                 SDL_Window **window, SDL_Renderer **renderer);
   172 
   173 
   174 /**
   175  *  \brief Create a 2D rendering context for a window.
   176  *
   177  *  \param window The window where rendering is displayed.
   178  *  \param index    The index of the rendering driver to initialize, or -1 to
   179  *                  initialize the first one supporting the requested flags.
   180  *  \param flags    ::SDL_RendererFlags.
   181  *
   182  *  \return A valid rendering context or NULL if there was an error.
   183  *
   184  *  \sa SDL_CreateSoftwareRenderer()
   185  *  \sa SDL_GetRendererInfo()
   186  *  \sa SDL_DestroyRenderer()
   187  */
   188 extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window,
   189                                                int index, Uint32 flags);
   190 
   191 /**
   192  *  \brief Create a 2D software rendering context for a surface.
   193  *
   194  *  \param surface The surface where rendering is done.
   195  *
   196  *  \return A valid rendering context or NULL if there was an error.
   197  *
   198  *  \sa SDL_CreateRenderer()
   199  *  \sa SDL_DestroyRenderer()
   200  */
   201 extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface);
   202 
   203 /**
   204  *  \brief Get the renderer associated with a window.
   205  */
   206 extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window);
   207 
   208 /**
   209  *  \brief Get information about a rendering context.
   210  */
   211 extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer,
   212                                                 SDL_RendererInfo * info);
   213 
   214 /**
   215  *  \brief Get the output size of a rendering context.
   216  */
   217 extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer,
   218                                                       int *w, int *h);
   219 
   220 /**
   221  *  \brief Create a texture for a rendering context.
   222  *
   223  *  \param renderer The renderer.
   224  *  \param format The format of the texture.
   225  *  \param access One of the enumerated values in ::SDL_TextureAccess.
   226  *  \param w      The width of the texture in pixels.
   227  *  \param h      The height of the texture in pixels.
   228  *
   229  *  \return The created texture is returned, or 0 if no rendering context was
   230  *          active,  the format was unsupported, or the width or height were out
   231  *          of range.
   232  *
   233  *  \sa SDL_QueryTexture()
   234  *  \sa SDL_UpdateTexture()
   235  *  \sa SDL_DestroyTexture()
   236  */
   237 extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer,
   238                                                         Uint32 format,
   239                                                         int access, int w,
   240                                                         int h);
   241 
   242 /**
   243  *  \brief Create a texture from an existing surface.
   244  *
   245  *  \param renderer The renderer.
   246  *  \param surface The surface containing pixel data used to fill the texture.
   247  *
   248  *  \return The created texture is returned, or 0 on error.
   249  *
   250  *  \note The surface is not modified or freed by this function.
   251  *
   252  *  \sa SDL_QueryTexture()
   253  *  \sa SDL_DestroyTexture()
   254  */
   255 extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface);
   256 
   257 /**
   258  *  \brief Query the attributes of a texture
   259  *
   260  *  \param texture A texture to be queried.
   261  *  \param format  A pointer filled in with the raw format of the texture.  The
   262  *                 actual format may differ, but pixel transfers will use this
   263  *                 format.
   264  *  \param access  A pointer filled in with the actual access to the texture.
   265  *  \param w       A pointer filled in with the width of the texture in pixels.
   266  *  \param h       A pointer filled in with the height of the texture in pixels.
   267  *
   268  *  \return 0 on success, or -1 if the texture is not valid.
   269  */
   270 extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
   271                                              Uint32 * format, int *access,
   272                                              int *w, int *h);
   273 
   274 /**
   275  *  \brief Set an additional color value used in render copy operations.
   276  *
   277  *  \param texture The texture to update.
   278  *  \param r       The red color value multiplied into copy operations.
   279  *  \param g       The green color value multiplied into copy operations.
   280  *  \param b       The blue color value multiplied into copy operations.
   281  *
   282  *  \return 0 on success, or -1 if the texture is not valid or color modulation
   283  *          is not supported.
   284  *
   285  *  \sa SDL_GetTextureColorMod()
   286  */
   287 extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
   288                                                    Uint8 r, Uint8 g, Uint8 b);
   289 
   290 
   291 /**
   292  *  \brief Get the additional color value used in render copy operations.
   293  *
   294  *  \param texture The texture to query.
   295  *  \param r         A pointer filled in with the current red color value.
   296  *  \param g         A pointer filled in with the current green color value.
   297  *  \param b         A pointer filled in with the current blue color value.
   298  *
   299  *  \return 0 on success, or -1 if the texture is not valid.
   300  *
   301  *  \sa SDL_SetTextureColorMod()
   302  */
   303 extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
   304                                                    Uint8 * r, Uint8 * g,
   305                                                    Uint8 * b);
   306 
   307 /**
   308  *  \brief Set an additional alpha value used in render copy operations.
   309  *
   310  *  \param texture The texture to update.
   311  *  \param alpha     The alpha value multiplied into copy operations.
   312  *
   313  *  \return 0 on success, or -1 if the texture is not valid or alpha modulation
   314  *          is not supported.
   315  *
   316  *  \sa SDL_GetTextureAlphaMod()
   317  */
   318 extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
   319                                                    Uint8 alpha);
   320 
   321 /**
   322  *  \brief Get the additional alpha value used in render copy operations.
   323  *
   324  *  \param texture The texture to query.
   325  *  \param alpha     A pointer filled in with the current alpha value.
   326  *
   327  *  \return 0 on success, or -1 if the texture is not valid.
   328  *
   329  *  \sa SDL_SetTextureAlphaMod()
   330  */
   331 extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
   332                                                    Uint8 * alpha);
   333 
   334 /**
   335  *  \brief Set the blend mode used for texture copy operations.
   336  *
   337  *  \param texture The texture to update.
   338  *  \param blendMode ::SDL_BlendMode to use for texture blending.
   339  *
   340  *  \return 0 on success, or -1 if the texture is not valid or the blend mode is
   341  *          not supported.
   342  *
   343  *  \note If the blend mode is not supported, the closest supported mode is
   344  *        chosen.
   345  *
   346  *  \sa SDL_GetTextureBlendMode()
   347  */
   348 extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
   349                                                     SDL_BlendMode blendMode);
   350 
   351 /**
   352  *  \brief Get the blend mode used for texture copy operations.
   353  *
   354  *  \param texture   The texture to query.
   355  *  \param blendMode A pointer filled in with the current blend mode.
   356  *
   357  *  \return 0 on success, or -1 if the texture is not valid.
   358  *
   359  *  \sa SDL_SetTextureBlendMode()
   360  */
   361 extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
   362                                                     SDL_BlendMode *blendMode);
   363 
   364 /**
   365  *  \brief Update the given texture rectangle with new pixel data.
   366  *
   367  *  \param texture   The texture to update
   368  *  \param rect      A pointer to the rectangle of pixels to update, or NULL to
   369  *                   update the entire texture.
   370  *  \param pixels    The raw pixel data.
   371  *  \param pitch     The number of bytes between rows of pixel data.
   372  *
   373  *  \return 0 on success, or -1 if the texture is not valid.
   374  *
   375  *  \note This is a fairly slow function.
   376  */
   377 extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
   378                                               const SDL_Rect * rect,
   379                                               const void *pixels, int pitch);
   380 
   381 /**
   382  *  \brief Lock a portion of the texture for write-only pixel access.
   383  *
   384  *  \param texture   The texture to lock for access, which was created with
   385  *                   ::SDL_TEXTUREACCESS_STREAMING.
   386  *  \param rect      A pointer to the rectangle to lock for access. If the rect
   387  *                   is NULL, the entire texture will be locked.
   388  *  \param pixels    This is filled in with a pointer to the locked pixels,
   389  *                   appropriately offset by the locked area.
   390  *  \param pitch     This is filled in with the pitch of the locked pixels.
   391  *
   392  *  \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING.
   393  *
   394  *  \sa SDL_UnlockTexture()
   395  */
   396 extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
   397                                             const SDL_Rect * rect,
   398                                             void **pixels, int *pitch);
   399 
   400 /**
   401  *  \brief Unlock a texture, uploading the changes to video memory, if needed.
   402  *
   403  *  \sa SDL_LockTexture()
   404  */
   405 extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
   406 
   407 /**
   408  * \brief Determines whether a window supports the use of render targets
   409  *
   410  * \param renderer The renderer that will be checked
   411  *
   412  * \return SDL_TRUE if supported, SDL_FALSE if not.
   413  */
   414 extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer);
   415 
   416 /**
   417  * \brief Set a texture as the current rendering target.
   418  *
   419  * \param renderer The renderer.
   420  * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target
   421  *
   422  * \return 0 on success, or -1 on error
   423  *
   424  *  \sa SDL_GetRenderTarget()
   425  */
   426 extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
   427                                                 SDL_Texture *texture);
   428 
   429 /**
   430  * \brief Get the current render target or NULL for the default render target.
   431  *
   432  * \return The current render target
   433  *
   434  *  \sa SDL_SetRenderTarget()
   435  */
   436 extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
   437 
   438 /**
   439  *  \brief Set device independent resolution for rendering
   440  *
   441  *  \param renderer The renderer for which resolution should be set.
   442  *  \param w      The width of the logical resolution
   443  *  \param h      The height of the logical resolution
   444  *
   445  *  This function uses the viewport and scaling functionality to allow a fixed logical
   446  *  resolution for rendering, regardless of the actual output resolution.  If the actual
   447  *  output resolution doesn't have the same aspect ratio the output rendering will be
   448  *  centered within the output display.
   449  *
   450  *  If the output display is a window, mouse events in the window will be filtered
   451  *  and scaled so they seem to arrive within the logical resolution.
   452  *
   453  *  \note If this function results in scaling or subpixel drawing by the
   454  *        rendering backend, it will be handled using the appropriate
   455  *        quality hints.
   456  *
   457  *  \sa SDL_RenderGetLogicalSize()
   458  *  \sa SDL_RenderSetScale()
   459  *  \sa SDL_RenderSetViewport()
   460  */
   461 extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h);
   462 
   463 /**
   464  *  \brief Get device independent resolution for rendering
   465  *
   466  *  \param renderer The renderer from which resolution should be queried.
   467  *  \param w      A pointer filled with the width of the logical resolution
   468  *  \param h      A pointer filled with the height of the logical resolution
   469  *
   470  *  \sa SDL_RenderSetLogicalSize()
   471  */
   472 extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h);
   473 
   474 /**
   475  *  \brief Set the drawing area for rendering on the current target.
   476  *
   477  *  \param renderer The renderer for which the drawing area should be set.
   478  *  \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target.
   479  *
   480  *  The x,y of the viewport rect represents the origin for rendering.
   481  *
   482  *  \return 0 on success, or -1 on error
   483  *
   484  *  \note If the window associated with the renderer is resized, the viewport is automatically reset.
   485  *
   486  *  \sa SDL_RenderGetViewport()
   487  *  \sa SDL_RenderSetLogicalSize()
   488  */
   489 extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
   490                                                   const SDL_Rect * rect);
   491 
   492 /**
   493  *  \brief Get the drawing area for the current target.
   494  *
   495  *  \sa SDL_RenderSetViewport()
   496  */
   497 extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
   498                                                    SDL_Rect * rect);
   499 
   500 /**
   501  *  \brief Set the clip rectangle for the current target.
   502  *
   503  *  \param renderer The renderer for which clip rectangle should be set.
   504  *  \param rect   A pointer to the rectangle to set as the clip rectangle, or
   505  *                NULL to disable clipping.
   506  *
   507  *  \return 0 on success, or -1 on error
   508  *
   509  *  \sa SDL_RenderGetClipRect()
   510  */
   511 extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer,
   512                                                   const SDL_Rect * rect);
   513 
   514 /**
   515  *  \brief Get the clip rectangle for the current target.
   516  *
   517  *  \param renderer The renderer from which clip rectangle should be queried.
   518  *  \param rect   A pointer filled in with the current clip rectangle, or
   519  *                an empty rectangle if clipping is disabled.
   520  *
   521  *  \sa SDL_RenderSetClipRect()
   522  */
   523 extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer,
   524                                                    SDL_Rect * rect);
   525 
   526 /**
   527  *  \brief Set the drawing scale for rendering on the current target.
   528  *
   529  *  \param renderer The renderer for which the drawing scale should be set.
   530  *  \param scaleX The horizontal scaling factor
   531  *  \param scaleY The vertical scaling factor
   532  *
   533  *  The drawing coordinates are scaled by the x/y scaling factors
   534  *  before they are used by the renderer.  This allows resolution
   535  *  independent drawing with a single coordinate system.
   536  *
   537  *  \note If this results in scaling or subpixel drawing by the
   538  *        rendering backend, it will be handled using the appropriate
   539  *        quality hints.  For best results use integer scaling factors.
   540  *
   541  *  \sa SDL_RenderGetScale()
   542  *  \sa SDL_RenderSetLogicalSize()
   543  */
   544 extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
   545                                                float scaleX, float scaleY);
   546 
   547 /**
   548  *  \brief Get the drawing scale for the current target.
   549  *
   550  *  \param renderer The renderer from which drawing scale should be queried.
   551  *  \param scaleX A pointer filled in with the horizontal scaling factor
   552  *  \param scaleY A pointer filled in with the vertical scaling factor
   553  *
   554  *  \sa SDL_RenderSetScale()
   555  */
   556 extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
   557                                                float *scaleX, float *scaleY);
   558 
   559 /**
   560  *  \brief Set the color used for drawing operations (Rect, Line and Clear).
   561  *
   562  *  \param renderer The renderer for which drawing color should be set.
   563  *  \param r The red value used to draw on the rendering target.
   564  *  \param g The green value used to draw on the rendering target.
   565  *  \param b The blue value used to draw on the rendering target.
   566  *  \param a The alpha value used to draw on the rendering target, usually
   567  *           ::SDL_ALPHA_OPAQUE (255).
   568  *
   569  *  \return 0 on success, or -1 on error
   570  */
   571 extern DECLSPEC int SDL_SetRenderDrawColor(SDL_Renderer * renderer,
   572                                            Uint8 r, Uint8 g, Uint8 b,
   573                                            Uint8 a);
   574 
   575 /**
   576  *  \brief Get the color used for drawing operations (Rect, Line and Clear).
   577  *
   578  *  \param renderer The renderer from which drawing color should be queried.
   579  *  \param r A pointer to the red value used to draw on the rendering target.
   580  *  \param g A pointer to the green value used to draw on the rendering target.
   581  *  \param b A pointer to the blue value used to draw on the rendering target.
   582  *  \param a A pointer to the alpha value used to draw on the rendering target,
   583  *           usually ::SDL_ALPHA_OPAQUE (255).
   584  *
   585  *  \return 0 on success, or -1 on error
   586  */
   587 extern DECLSPEC int SDL_GetRenderDrawColor(SDL_Renderer * renderer,
   588                                            Uint8 * r, Uint8 * g, Uint8 * b,
   589                                            Uint8 * a);
   590 
   591 /**
   592  *  \brief Set the blend mode used for drawing operations (Fill and Line).
   593  *
   594  *  \param renderer The renderer for which blend mode should be set.
   595  *  \param blendMode ::SDL_BlendMode to use for blending.
   596  *
   597  *  \return 0 on success, or -1 on error
   598  *
   599  *  \note If the blend mode is not supported, the closest supported mode is
   600  *        chosen.
   601  *
   602  *  \sa SDL_GetRenderDrawBlendMode()
   603  */
   604 extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
   605                                                        SDL_BlendMode blendMode);
   606 
   607 /**
   608  *  \brief Get the blend mode used for drawing operations.
   609  *
   610  *  \param renderer The renderer from which blend mode should be queried.
   611  *  \param blendMode A pointer filled in with the current blend mode.
   612  *
   613  *  \return 0 on success, or -1 on error
   614  *
   615  *  \sa SDL_SetRenderDrawBlendMode()
   616  */
   617 extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
   618                                                        SDL_BlendMode *blendMode);
   619 
   620 /**
   621  *  \brief Clear the current rendering target with the drawing color
   622  *
   623  *  This function clears the entire rendering target, ignoring the viewport.
   624  *
   625  *  \return 0 on success, or -1 on error
   626  */
   627 extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
   628 
   629 /**
   630  *  \brief Draw a point on the current rendering target.
   631  *
   632  *  \param renderer The renderer which should draw a point.
   633  *  \param x The x coordinate of the point.
   634  *  \param y The y coordinate of the point.
   635  *
   636  *  \return 0 on success, or -1 on error
   637  */
   638 extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
   639                                                 int x, int y);
   640 
   641 /**
   642  *  \brief Draw multiple points on the current rendering target.
   643  *
   644  *  \param renderer The renderer which should draw multiple points.
   645  *  \param points The points to draw
   646  *  \param count The number of points to draw
   647  *
   648  *  \return 0 on success, or -1 on error
   649  */
   650 extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
   651                                                  const SDL_Point * points,
   652                                                  int count);
   653 
   654 /**
   655  *  \brief Draw a line on the current rendering target.
   656  *
   657  *  \param renderer The renderer which should draw a line.
   658  *  \param x1 The x coordinate of the start point.
   659  *  \param y1 The y coordinate of the start point.
   660  *  \param x2 The x coordinate of the end point.
   661  *  \param y2 The y coordinate of the end point.
   662  *
   663  *  \return 0 on success, or -1 on error
   664  */
   665 extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
   666                                                int x1, int y1, int x2, int y2);
   667 
   668 /**
   669  *  \brief Draw a series of connected lines on the current rendering target.
   670  *
   671  *  \param renderer The renderer which should draw multiple lines.
   672  *  \param points The points along the lines
   673  *  \param count The number of points, drawing count-1 lines
   674  *
   675  *  \return 0 on success, or -1 on error
   676  */
   677 extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
   678                                                 const SDL_Point * points,
   679                                                 int count);
   680 
   681 /**
   682  *  \brief Draw a rectangle on the current rendering target.
   683  *
   684  *  \param renderer The renderer which should draw a rectangle.
   685  *  \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
   686  *
   687  *  \return 0 on success, or -1 on error
   688  */
   689 extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
   690                                                const SDL_Rect * rect);
   691 
   692 /**
   693  *  \brief Draw some number of rectangles on the current rendering target.
   694  *
   695  *  \param renderer The renderer which should draw multiple rectangles.
   696  *  \param rects A pointer to an array of destination rectangles.
   697  *  \param count The number of rectangles.
   698  *
   699  *  \return 0 on success, or -1 on error
   700  */
   701 extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
   702                                                 const SDL_Rect * rects,
   703                                                 int count);
   704 
   705 /**
   706  *  \brief Fill a rectangle on the current rendering target with the drawing color.
   707  *
   708  *  \param renderer The renderer which should fill a rectangle.
   709  *  \param rect A pointer to the destination rectangle, or NULL for the entire
   710  *              rendering target.
   711  *
   712  *  \return 0 on success, or -1 on error
   713  */
   714 extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
   715                                                const SDL_Rect * rect);
   716 
   717 /**
   718  *  \brief Fill some number of rectangles on the current rendering target with the drawing color.
   719  *
   720  *  \param renderer The renderer which should fill multiple rectangles.
   721  *  \param rects A pointer to an array of destination rectangles.
   722  *  \param count The number of rectangles.
   723  *
   724  *  \return 0 on success, or -1 on error
   725  */
   726 extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
   727                                                 const SDL_Rect * rects,
   728                                                 int count);
   729 
   730 /**
   731  *  \brief Copy a portion of the texture to the current rendering target.
   732  *
   733  *  \param renderer The renderer which should copy parts of a texture.
   734  *  \param texture The source texture.
   735  *  \param srcrect   A pointer to the source rectangle, or NULL for the entire
   736  *                   texture.
   737  *  \param dstrect   A pointer to the destination rectangle, or NULL for the
   738  *                   entire rendering target.
   739  *
   740  *  \return 0 on success, or -1 on error
   741  */
   742 extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
   743                                            SDL_Texture * texture,
   744                                            const SDL_Rect * srcrect,
   745                                            const SDL_Rect * dstrect);
   746 
   747 /**
   748  *  \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center
   749  *
   750  *  \param renderer The renderer which should copy parts of a texture.
   751  *  \param texture The source texture.
   752  *  \param srcrect   A pointer to the source rectangle, or NULL for the entire
   753  *                   texture.
   754  *  \param dstrect   A pointer to the destination rectangle, or NULL for the
   755  *                   entire rendering target.
   756  *  \param angle    An angle in degrees that indicates the rotation that will be applied to dstrect
   757  *  \param center   A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done aroud dstrect.w/2, dstrect.h/2)
   758  *  \param flip     An SDL_RendererFlip value stating which flipping actions should be performed on the texture
   759  *
   760  *  \return 0 on success, or -1 on error
   761  */
   762 extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
   763                                            SDL_Texture * texture,
   764                                            const SDL_Rect * srcrect,
   765                                            const SDL_Rect * dstrect,
   766                                            const double angle,
   767                                            const SDL_Point *center,
   768                                            const SDL_RendererFlip flip);
   769 
   770 /**
   771  *  \brief Read pixels from the current rendering target.
   772  *
   773  *  \param renderer The renderer from which pixels should be read.
   774  *  \param rect   A pointer to the rectangle to read, or NULL for the entire
   775  *                render target.
   776  *  \param format The desired format of the pixel data, or 0 to use the format
   777  *                of the rendering target
   778  *  \param pixels A pointer to be filled in with the pixel data
   779  *  \param pitch  The pitch of the pixels parameter.
   780  *
   781  *  \return 0 on success, or -1 if pixel reading is not supported.
   782  *
   783  *  \warning This is a very slow operation, and should not be used frequently.
   784  */
   785 extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
   786                                                  const SDL_Rect * rect,
   787                                                  Uint32 format,
   788                                                  void *pixels, int pitch);
   789 
   790 /**
   791  *  \brief Update the screen with rendering performed.
   792  */
   793 extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
   794 
   795 /**
   796  *  \brief Destroy the specified texture.
   797  *
   798  *  \sa SDL_CreateTexture()
   799  *  \sa SDL_CreateTextureFromSurface()
   800  */
   801 extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
   802 
   803 /**
   804  *  \brief Destroy the rendering context for a window and free associated
   805  *         textures.
   806  *
   807  *  \sa SDL_CreateRenderer()
   808  */
   809 extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
   810 
   811 
   812 /**
   813  *  \brief Bind the texture to the current OpenGL/ES/ES2 context for use with
   814  *         OpenGL instructions.
   815  *
   816  *  \param texture  The SDL texture to bind
   817  *  \param texw     A pointer to a float that will be filled with the texture width
   818  *  \param texh     A pointer to a float that will be filled with the texture height
   819  *
   820  *  \return 0 on success, or -1 if the operation is not supported
   821  */
   822 extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);
   823 
   824 /**
   825  *  \brief Unbind a texture from the current OpenGL/ES/ES2 context.
   826  *
   827  *  \param texture  The SDL texture to unbind
   828  *
   829  *  \return 0 on success, or -1 if the operation is not supported
   830  */
   831 extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture);
   832 
   833 
   834 /* Ends C function definitions when using C++ */
   835 #ifdef __cplusplus
   836 }
   837 #endif
   838 #include "close_code.h"
   839 
   840 #endif /* _SDL_render_h */
   841 
   842 /* vi: set ts=4 sw=4 expandtab: */