include/SDL_render.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 19 Jan 2012 21:06:47 -0500
changeset 6237 240f1bced46b
parent 6232 37e8d0736366
child 6247 b6212690f78d
permissions -rw-r--r--
Added a renderer flag to expose whether a renderer supports render to texture.
slouken@5145
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6138
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
slouken@5145
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@5145
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@5145
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@5145
    20
*/
slouken@5145
    21
slouken@5145
    22
/**
slouken@5145
    23
 *  \file SDL_render.h
slouken@5145
    24
 *  
slouken@5145
    25
 *  Header file for SDL 2D rendering functions.
slouken@5164
    26
 *
slouken@5164
    27
 *  This API supports the following features:
slouken@5164
    28
 *      * single pixel points
slouken@5164
    29
 *      * single pixel lines
slouken@5164
    30
 *      * filled rectangles
slouken@5164
    31
 *      * texture images
slouken@5164
    32
 *
slouken@5164
    33
 *  The primitives may be drawn in opaque, blended, or additive modes.
slouken@5164
    34
 *
slouken@5164
    35
 *  The texture images may be drawn in opaque, blended, or additive modes.
slouken@5164
    36
 *  They can have an additional color tint or alpha modulation applied to
slouken@5164
    37
 *  them, and may also be stretched with linear interpolation.
slouken@5164
    38
 *
slouken@5164
    39
 *  This API is designed to accelerate simple 2D operations. You may
slouken@5164
    40
 *  want more functionality such as rotation and particle effects and
slouken@5164
    41
 *  in that case you should use SDL's OpenGL/Direct3D support or one
slouken@5164
    42
 *  of the many good 3D engines.
slouken@5145
    43
 */
slouken@5145
    44
slouken@5145
    45
#ifndef _SDL_render_h
slouken@5145
    46
#define _SDL_render_h
slouken@5145
    47
slouken@5145
    48
#include "SDL_stdinc.h"
slouken@5145
    49
#include "SDL_rect.h"
slouken@5145
    50
#include "SDL_video.h"
slouken@5145
    51
slouken@5145
    52
#include "begin_code.h"
slouken@5145
    53
/* Set up for C function definitions, even when using C++ */
slouken@5145
    54
#ifdef __cplusplus
slouken@5145
    55
/* *INDENT-OFF* */
slouken@5145
    56
extern "C" {
slouken@5145
    57
/* *INDENT-ON* */
slouken@5145
    58
#endif
slouken@5145
    59
slouken@5145
    60
/**
slouken@5145
    61
 *  \brief Flags used when creating a rendering context
slouken@5145
    62
 */
slouken@5145
    63
typedef enum
slouken@5145
    64
{
slouken@5337
    65
    SDL_RENDERER_SOFTWARE = 0x00000001,         /**< The renderer is a software fallback */ 
slouken@5337
    66
    SDL_RENDERER_ACCELERATED = 0x00000002,      /**< The renderer uses hardware 
slouken@5145
    67
                                                     acceleration */
slouken@6237
    68
    SDL_RENDERER_PRESENTVSYNC = 0x00000004,     /**< Present is synchronized 
slouken@5145
    69
                                                     with the refresh rate */
slouken@6237
    70
    SDL_RENDERER_TARGETTEXTURE = 0x00000008     /**< The renderer supports
slouken@6237
    71
                                                     rendering to texture */
slouken@5145
    72
} SDL_RendererFlags;
slouken@5145
    73
slouken@5145
    74
/**
slouken@5145
    75
 *  \brief Information on the capabilities of a render driver or context.
slouken@5145
    76
 */
slouken@5145
    77
typedef struct SDL_RendererInfo
slouken@5145
    78
{
slouken@5145
    79
    const char *name;           /**< The name of the renderer */
slouken@5145
    80
    Uint32 flags;               /**< Supported ::SDL_RendererFlags */
slouken@5145
    81
    Uint32 num_texture_formats; /**< The number of available texture formats */
slouken@5156
    82
    Uint32 texture_formats[16]; /**< The available texture formats */
slouken@5145
    83
    int max_texture_width;      /**< The maximimum texture width */
slouken@5145
    84
    int max_texture_height;     /**< The maximimum texture height */
slouken@5145
    85
} SDL_RendererInfo;
slouken@5145
    86
slouken@5145
    87
/**
slouken@5145
    88
 *  \brief The access pattern allowed for a texture.
slouken@5145
    89
 */
slouken@5145
    90
typedef enum
slouken@5145
    91
{
slouken@5145
    92
    SDL_TEXTUREACCESS_STATIC,    /**< Changes rarely, not lockable */
slouken@6232
    93
    SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
slouken@6232
    94
    SDL_TEXTUREACCESS_TARGET     /**< Texture can be used as a render target */
slouken@5145
    95
} SDL_TextureAccess;
slouken@5145
    96
slouken@5145
    97
/**
slouken@5145
    98
 *  \brief The texture channel modulation used in SDL_RenderCopy().
slouken@5145
    99
 */
slouken@5145
   100
typedef enum
slouken@5145
   101
{
slouken@5145
   102
    SDL_TEXTUREMODULATE_NONE = 0x00000000,     /**< No modulation */
slouken@5145
   103
    SDL_TEXTUREMODULATE_COLOR = 0x00000001,    /**< srcC = srcC * color */
slouken@5145
   104
    SDL_TEXTUREMODULATE_ALPHA = 0x00000002     /**< srcA = srcA * alpha */
slouken@5145
   105
} SDL_TextureModulate;
slouken@5145
   106
slouken@5145
   107
/**
slouken@5147
   108
 *  \brief A structure representing rendering state
slouken@5147
   109
 */
slouken@5147
   110
struct SDL_Renderer;
slouken@5147
   111
typedef struct SDL_Renderer SDL_Renderer;
slouken@5147
   112
slouken@5147
   113
/**
slouken@5145
   114
 *  \brief An efficient driver-specific representation of pixel data
slouken@5145
   115
 */
slouken@5145
   116
struct SDL_Texture;
slouken@5145
   117
typedef struct SDL_Texture SDL_Texture;
slouken@5145
   118
slouken@5145
   119
slouken@5145
   120
/* Function prototypes */
slouken@5145
   121
slouken@5145
   122
/**
slouken@5145
   123
 *  \brief Get the number of 2D rendering drivers available for the current 
slouken@5145
   124
 *         display.
slouken@5145
   125
 *  
slouken@5145
   126
 *  A render driver is a set of code that handles rendering and texture
slouken@5145
   127
 *  management on a particular display.  Normally there is only one, but
slouken@5145
   128
 *  some drivers may have several available with different capabilities.
slouken@5145
   129
 *  
slouken@5145
   130
 *  \sa SDL_GetRenderDriverInfo()
slouken@5145
   131
 *  \sa SDL_CreateRenderer()
slouken@5145
   132
 */
slouken@5145
   133
extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
slouken@5145
   134
slouken@5145
   135
/**
slouken@5145
   136
 *  \brief Get information about a specific 2D rendering driver for the current 
slouken@5145
   137
 *         display.
slouken@5145
   138
 *  
slouken@5145
   139
 *  \param index The index of the driver to query information about.
slouken@5145
   140
 *  \param info  A pointer to an SDL_RendererInfo struct to be filled with 
slouken@5145
   141
 *               information on the rendering driver.
slouken@5145
   142
 *  
slouken@5145
   143
 *  \return 0 on success, -1 if the index was out of range.
slouken@5145
   144
 *  
slouken@5145
   145
 *  \sa SDL_CreateRenderer()
slouken@5145
   146
 */
slouken@5145
   147
extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index,
slouken@5145
   148
                                                    SDL_RendererInfo * info);
slouken@5145
   149
slouken@5145
   150
/**
slouken@5147
   151
 *  \brief Create a 2D rendering context for a window.
slouken@5145
   152
 *  
slouken@5145
   153
 *  \param window The window where rendering is displayed.
slouken@5145
   154
 *  \param index    The index of the rendering driver to initialize, or -1 to 
slouken@5145
   155
 *                  initialize the first one supporting the requested flags.
slouken@5145
   156
 *  \param flags    ::SDL_RendererFlags.
slouken@5145
   157
 *  
slouken@5147
   158
 *  \return A valid rendering context or NULL if there was an error.
slouken@5145
   159
 *  
slouken@5166
   160
 *  \sa SDL_CreateSoftwareRenderer()
slouken@5145
   161
 *  \sa SDL_GetRendererInfo()
slouken@5145
   162
 *  \sa SDL_DestroyRenderer()
slouken@5145
   163
 */
slouken@5147
   164
extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window,
slouken@5145
   165
                                               int index, Uint32 flags);
slouken@5145
   166
slouken@5145
   167
/**
slouken@5166
   168
 *  \brief Create a 2D software rendering context for a surface.
slouken@5166
   169
 *  
slouken@5166
   170
 *  \param surface The surface where rendering is done.
slouken@5166
   171
 *  
slouken@5166
   172
 *  \return A valid rendering context or NULL if there was an error.
slouken@5166
   173
 *  
slouken@5166
   174
 *  \sa SDL_CreateRenderer()
slouken@5166
   175
 *  \sa SDL_DestroyRenderer()
slouken@5166
   176
 */
slouken@5166
   177
extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface);
slouken@5166
   178
slouken@5166
   179
/**
slouken@5528
   180
 *  \brief Get the renderer associated with a window.
slouken@5528
   181
 */
slouken@5528
   182
extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window);
slouken@5528
   183
slouken@5528
   184
/**
slouken@5147
   185
 *  \brief Get information about a rendering context.
slouken@5145
   186
 */
slouken@5147
   187
extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer,
slouken@5147
   188
                                                SDL_RendererInfo * info);
slouken@5145
   189
slouken@5145
   190
/**
slouken@5147
   191
 *  \brief Create a texture for a rendering context.
slouken@5145
   192
 *  
slouken@5145
   193
 *  \param format The format of the texture.
slouken@5145
   194
 *  \param access One of the enumerated values in ::SDL_TextureAccess.
slouken@5145
   195
 *  \param w      The width of the texture in pixels.
slouken@5145
   196
 *  \param h      The height of the texture in pixels.
slouken@5145
   197
 *  
slouken@5145
   198
 *  \return The created texture is returned, or 0 if no rendering context was 
slouken@5145
   199
 *          active,  the format was unsupported, or the width or height were out
slouken@5145
   200
 *          of range.
slouken@5145
   201
 *  
slouken@5145
   202
 *  \sa SDL_QueryTexture()
slouken@5216
   203
 *  \sa SDL_UpdateTexture()
slouken@5145
   204
 *  \sa SDL_DestroyTexture()
slouken@5145
   205
 */
slouken@5344
   206
extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer,
slouken@5344
   207
                                                        Uint32 format,
slouken@5145
   208
                                                        int access, int w,
slouken@5145
   209
                                                        int h);
slouken@5145
   210
slouken@5145
   211
/**
slouken@5145
   212
 *  \brief Create a texture from an existing surface.
slouken@5145
   213
 *  
slouken@5145
   214
 *  \param surface The surface containing pixel data used to fill the texture.
slouken@5145
   215
 *  
slouken@5158
   216
 *  \return The created texture is returned, or 0 on error.
slouken@5145
   217
 *  
slouken@5145
   218
 *  \note The surface is not modified or freed by this function.
slouken@5145
   219
 *  
slouken@5145
   220
 *  \sa SDL_QueryTexture()
slouken@5145
   221
 *  \sa SDL_DestroyTexture()
slouken@5145
   222
 */
slouken@5158
   223
extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface);
slouken@5145
   224
slouken@5145
   225
/**
slouken@5145
   226
 *  \brief Query the attributes of a texture
slouken@5145
   227
 *  
slouken@5145
   228
 *  \param texture A texture to be queried.
slouken@5145
   229
 *  \param format  A pointer filled in with the raw format of the texture.  The 
slouken@5145
   230
 *                 actual format may differ, but pixel transfers will use this 
slouken@5145
   231
 *                 format.
slouken@5145
   232
 *  \param access  A pointer filled in with the actual access to the texture.
slouken@5145
   233
 *  \param w       A pointer filled in with the width of the texture in pixels.
slouken@5145
   234
 *  \param h       A pointer filled in with the height of the texture in pixels.
slouken@5145
   235
 *  
slouken@5145
   236
 *  \return 0 on success, or -1 if the texture is not valid.
slouken@5145
   237
 */
slouken@5145
   238
extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
slouken@5145
   239
                                             Uint32 * format, int *access,
slouken@5145
   240
                                             int *w, int *h);
slouken@5145
   241
slouken@5145
   242
/**
slouken@5145
   243
 *  \brief Set an additional color value used in render copy operations.
slouken@5145
   244
 *  
slouken@5145
   245
 *  \param texture The texture to update.
slouken@5145
   246
 *  \param r       The red color value multiplied into copy operations.
slouken@5145
   247
 *  \param g       The green color value multiplied into copy operations.
slouken@5145
   248
 *  \param b       The blue color value multiplied into copy operations.
slouken@5145
   249
 *  
slouken@5145
   250
 *  \return 0 on success, or -1 if the texture is not valid or color modulation 
slouken@5145
   251
 *          is not supported.
slouken@5145
   252
 *  
slouken@5145
   253
 *  \sa SDL_GetTextureColorMod()
slouken@5145
   254
 */
slouken@5145
   255
extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
slouken@5145
   256
                                                   Uint8 r, Uint8 g, Uint8 b);
slouken@5145
   257
slouken@5145
   258
slouken@5145
   259
/**
slouken@5145
   260
 *  \brief Get the additional color value used in render copy operations.
slouken@5145
   261
 *  
slouken@5145
   262
 *  \param texture The texture to query.
slouken@5145
   263
 *  \param r         A pointer filled in with the current red color value.
slouken@5145
   264
 *  \param g         A pointer filled in with the current green color value.
slouken@5145
   265
 *  \param b         A pointer filled in with the current blue color value.
slouken@5145
   266
 *  
slouken@5145
   267
 *  \return 0 on success, or -1 if the texture is not valid.
slouken@5145
   268
 *  
slouken@5145
   269
 *  \sa SDL_SetTextureColorMod()
slouken@5145
   270
 */
slouken@5145
   271
extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
slouken@5145
   272
                                                   Uint8 * r, Uint8 * g,
slouken@5145
   273
                                                   Uint8 * b);
slouken@5145
   274
slouken@5145
   275
/**
slouken@5145
   276
 *  \brief Set an additional alpha value used in render copy operations.
slouken@5145
   277
 *  
slouken@5145
   278
 *  \param texture The texture to update.
slouken@5145
   279
 *  \param alpha     The alpha value multiplied into copy operations.
slouken@5145
   280
 *  
slouken@5145
   281
 *  \return 0 on success, or -1 if the texture is not valid or alpha modulation 
slouken@5145
   282
 *          is not supported.
slouken@5145
   283
 *  
slouken@5145
   284
 *  \sa SDL_GetTextureAlphaMod()
slouken@5145
   285
 */
slouken@5145
   286
extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
slouken@5145
   287
                                                   Uint8 alpha);
slouken@5145
   288
slouken@5145
   289
/**
slouken@5145
   290
 *  \brief Get the additional alpha value used in render copy operations.
slouken@5145
   291
 *  
slouken@5145
   292
 *  \param texture The texture to query.
slouken@5145
   293
 *  \param alpha     A pointer filled in with the current alpha value.
slouken@5145
   294
 *  
slouken@5145
   295
 *  \return 0 on success, or -1 if the texture is not valid.
slouken@5145
   296
 *  
slouken@5145
   297
 *  \sa SDL_SetTextureAlphaMod()
slouken@5145
   298
 */
slouken@5145
   299
extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
slouken@5145
   300
                                                   Uint8 * alpha);
slouken@5145
   301
slouken@5145
   302
/**
slouken@5145
   303
 *  \brief Set the blend mode used for texture copy operations.
slouken@5145
   304
 *  
slouken@5145
   305
 *  \param texture The texture to update.
slouken@5145
   306
 *  \param blendMode ::SDL_BlendMode to use for texture blending.
slouken@5145
   307
 *  
slouken@5145
   308
 *  \return 0 on success, or -1 if the texture is not valid or the blend mode is
slouken@5145
   309
 *          not supported.
slouken@5145
   310
 *  
slouken@5145
   311
 *  \note If the blend mode is not supported, the closest supported mode is
slouken@5145
   312
 *        chosen.
slouken@5145
   313
 *  
slouken@5145
   314
 *  \sa SDL_GetTextureBlendMode()
slouken@5145
   315
 */
slouken@5145
   316
extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
slouken@5145
   317
                                                    SDL_BlendMode blendMode);
slouken@5145
   318
slouken@5145
   319
/**
slouken@5145
   320
 *  \brief Get the blend mode used for texture copy operations.
slouken@5145
   321
 *  
slouken@5156
   322
 *  \param texture   The texture to query.
slouken@5145
   323
 *  \param blendMode A pointer filled in with the current blend mode.
slouken@5145
   324
 *  
slouken@5145
   325
 *  \return 0 on success, or -1 if the texture is not valid.
slouken@5145
   326
 *  
slouken@5145
   327
 *  \sa SDL_SetTextureBlendMode()
slouken@5145
   328
 */
slouken@5145
   329
extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
slouken@5145
   330
                                                    SDL_BlendMode *blendMode);
slouken@5145
   331
slouken@5145
   332
/**
slouken@5145
   333
 *  \brief Update the given texture rectangle with new pixel data.
slouken@5145
   334
 *  
slouken@5156
   335
 *  \param texture   The texture to update
slouken@5145
   336
 *  \param rect      A pointer to the rectangle of pixels to update, or NULL to 
slouken@5145
   337
 *                   update the entire texture.
slouken@5145
   338
 *  \param pixels    The raw pixel data.
slouken@5145
   339
 *  \param pitch     The number of bytes between rows of pixel data.
slouken@5145
   340
 *  
slouken@5145
   341
 *  \return 0 on success, or -1 if the texture is not valid.
slouken@5145
   342
 *  
slouken@5145
   343
 *  \note This is a fairly slow function.
slouken@5145
   344
 */
slouken@5145
   345
extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
slouken@5145
   346
                                              const SDL_Rect * rect,
slouken@5145
   347
                                              const void *pixels, int pitch);
slouken@5145
   348
slouken@5145
   349
/**
slouken@5145
   350
 *  \brief Lock a portion of the texture for pixel access.
slouken@5145
   351
 *  
slouken@5156
   352
 *  \param texture   The texture to lock for access, which was created with 
slouken@5145
   353
 *                   ::SDL_TEXTUREACCESS_STREAMING.
slouken@5145
   354
 *  \param rect      A pointer to the rectangle to lock for access. If the rect 
slouken@5145
   355
 *                   is NULL, the entire texture will be locked.
slouken@5145
   356
 *  \param pixels    This is filled in with a pointer to the locked pixels, 
slouken@5145
   357
 *                   appropriately offset by the locked area.
slouken@5145
   358
 *  \param pitch     This is filled in with the pitch of the locked pixels.
slouken@5145
   359
 *  
slouken@5156
   360
 *  \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING.
slouken@5145
   361
 *  
slouken@5145
   362
 *  \sa SDL_UnlockTexture()
slouken@5145
   363
 */
slouken@5145
   364
extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
slouken@5145
   365
                                            const SDL_Rect * rect,
slouken@5156
   366
                                            void **pixels, int *pitch);
slouken@5145
   367
slouken@5145
   368
/**
slouken@5156
   369
 *  \brief Unlock a texture, uploading the changes to video memory, if needed.
slouken@5145
   370
 *  
slouken@5145
   371
 *  \sa SDL_LockTexture()
slouken@5145
   372
 */
slouken@5145
   373
extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
slouken@5145
   374
slouken@5145
   375
/**
slouken@5297
   376
 *  \brief Set the drawing area for rendering on the current target.
slouken@5224
   377
 *
slouken@5297
   378
 *  \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target.
slouken@5224
   379
 *
slouken@5297
   380
 *  The x,y of the viewport rect represents the origin for rendering.
slouken@5297
   381
 *
slouken@5297
   382
 *  \note When the window is resized, the current viewport is automatically
slouken@5297
   383
 *        centered within the new window size.
slouken@5224
   384
 */
slouken@5297
   385
extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
slouken@5297
   386
                                                  const SDL_Rect * rect);
slouken@5297
   387
slouken@5297
   388
/**
slouken@5297
   389
 *  \brief Get the drawing area for the current target.
slouken@5297
   390
 */
slouken@5297
   391
extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
slouken@5297
   392
                                                   SDL_Rect * rect);
slouken@5224
   393
slouken@5224
   394
/**
slouken@6039
   395
 *  \brief Set the color used for drawing operations (Rect, Line and Clear).
slouken@5145
   396
 *  
slouken@5145
   397
 *  \param r The red value used to draw on the rendering target.
slouken@5145
   398
 *  \param g The green value used to draw on the rendering target.
slouken@5145
   399
 *  \param b The blue value used to draw on the rendering target.
slouken@5145
   400
 *  \param a The alpha value used to draw on the rendering target, usually 
slouken@5145
   401
 *           ::SDL_ALPHA_OPAQUE (255).
slouken@5145
   402
 *  
slouken@5147
   403
 *  \return 0 on success, or -1 on error
slouken@5145
   404
 */
slouken@5147
   405
extern DECLSPEC int SDL_SetRenderDrawColor(SDL_Renderer * renderer,
slouken@5147
   406
                                           Uint8 r, Uint8 g, Uint8 b,
slouken@5145
   407
                                           Uint8 a);
slouken@5145
   408
slouken@5145
   409
/**
slouken@6039
   410
 *  \brief Get the color used for drawing operations (Rect, Line and Clear).
slouken@5145
   411
 *  
slouken@5145
   412
 *  \param r A pointer to the red value used to draw on the rendering target.
slouken@5145
   413
 *  \param g A pointer to the green value used to draw on the rendering target.
slouken@5145
   414
 *  \param b A pointer to the blue value used to draw on the rendering target.
slouken@5145
   415
 *  \param a A pointer to the alpha value used to draw on the rendering target, 
slouken@5145
   416
 *           usually ::SDL_ALPHA_OPAQUE (255).
slouken@5145
   417
 *  
slouken@5147
   418
 *  \return 0 on success, or -1 on error
slouken@5145
   419
 */
slouken@5147
   420
extern DECLSPEC int SDL_GetRenderDrawColor(SDL_Renderer * renderer,
slouken@5147
   421
                                           Uint8 * r, Uint8 * g, Uint8 * b,
slouken@5145
   422
                                           Uint8 * a);
slouken@5145
   423
slouken@5145
   424
/**
slouken@5145
   425
 *  \brief Set the blend mode used for drawing operations (Fill and Line).
slouken@5145
   426
 *  
slouken@5145
   427
 *  \param blendMode ::SDL_BlendMode to use for blending.
slouken@5145
   428
 *  
slouken@5147
   429
 *  \return 0 on success, or -1 on error
slouken@5145
   430
 *  
slouken@5145
   431
 *  \note If the blend mode is not supported, the closest supported mode is 
slouken@5145
   432
 *        chosen.
slouken@5145
   433
 *  
slouken@5145
   434
 *  \sa SDL_GetRenderDrawBlendMode()
slouken@5145
   435
 */
slouken@5147
   436
extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
slouken@5147
   437
                                                       SDL_BlendMode blendMode);
slouken@5145
   438
slouken@5145
   439
/**
slouken@5145
   440
 *  \brief Get the blend mode used for drawing operations.
slouken@5145
   441
 *  
slouken@5145
   442
 *  \param blendMode A pointer filled in with the current blend mode.
slouken@5145
   443
 *  
slouken@5147
   444
 *  \return 0 on success, or -1 on error
slouken@5145
   445
 *  
slouken@5145
   446
 *  \sa SDL_SetRenderDrawBlendMode()
slouken@5145
   447
 */
slouken@5147
   448
extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
slouken@5147
   449
                                                       SDL_BlendMode *blendMode);
slouken@5145
   450
slouken@5145
   451
/**
slouken@5145
   452
 *  \brief Clear the current rendering target with the drawing color
slouken@5297
   453
 *
slouken@5297
   454
 *  This function clears the entire rendering target, ignoring the viewport.
slouken@5145
   455
 */
slouken@5147
   456
extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
slouken@5145
   457
slouken@5145
   458
/**
slouken@5145
   459
 *  \brief Draw a point on the current rendering target.
slouken@5145
   460
 *  
slouken@5145
   461
 *  \param x The x coordinate of the point.
slouken@5145
   462
 *  \param y The y coordinate of the point.
slouken@5145
   463
 *  
slouken@5147
   464
 *  \return 0 on success, or -1 on error
slouken@5145
   465
 */
slouken@5147
   466
extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
slouken@5147
   467
                                                int x, int y);
slouken@5145
   468
slouken@5145
   469
/**
slouken@5145
   470
 *  \brief Draw multiple points on the current rendering target.
slouken@5145
   471
 *  
slouken@5145
   472
 *  \param points The points to draw
slouken@5145
   473
 *  \param count The number of points to draw
slouken@5145
   474
 *  
slouken@5147
   475
 *  \return 0 on success, or -1 on error
slouken@5145
   476
 */
slouken@5147
   477
extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
slouken@5147
   478
                                                 const SDL_Point * points,
slouken@5145
   479
                                                 int count);
slouken@5145
   480
slouken@5145
   481
/**
slouken@5145
   482
 *  \brief Draw a line on the current rendering target.
slouken@5145
   483
 *  
slouken@5145
   484
 *  \param x1 The x coordinate of the start point.
slouken@5145
   485
 *  \param y1 The y coordinate of the start point.
slouken@5145
   486
 *  \param x2 The x coordinate of the end point.
slouken@5145
   487
 *  \param y2 The y coordinate of the end point.
slouken@5145
   488
 *  
slouken@5147
   489
 *  \return 0 on success, or -1 on error
slouken@5145
   490
 */
slouken@5147
   491
extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
slouken@5147
   492
                                               int x1, int y1, int x2, int y2);
slouken@5145
   493
slouken@5145
   494
/**
slouken@5145
   495
 *  \brief Draw a series of connected lines on the current rendering target.
slouken@5145
   496
 *  
slouken@5145
   497
 *  \param points The points along the lines
slouken@5145
   498
 *  \param count The number of points, drawing count-1 lines
slouken@5145
   499
 *  
slouken@5147
   500
 *  \return 0 on success, or -1 on error
slouken@5145
   501
 */
slouken@5147
   502
extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
slouken@5147
   503
                                                const SDL_Point * points,
slouken@5145
   504
                                                int count);
slouken@5145
   505
slouken@5145
   506
/**
slouken@5145
   507
 *  \brief Draw a rectangle on the current rendering target.
slouken@5145
   508
 *  
slouken@5145
   509
 *  \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
slouken@5145
   510
 *  
slouken@5147
   511
 *  \return 0 on success, or -1 on error
slouken@5145
   512
 */
slouken@5147
   513
extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
slouken@5147
   514
                                               const SDL_Rect * rect);
slouken@5145
   515
slouken@5145
   516
/**
slouken@5145
   517
 *  \brief Draw some number of rectangles on the current rendering target.
slouken@5145
   518
 *  
slouken@5145
   519
 *  \param rects A pointer to an array of destination rectangles.
slouken@5145
   520
 *  \param count The number of rectangles.
slouken@5145
   521
 *  
slouken@5147
   522
 *  \return 0 on success, or -1 on error
slouken@5145
   523
 */
slouken@5147
   524
extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
slouken@5297
   525
                                                const SDL_Rect * rects,
slouken@5147
   526
                                                int count);
slouken@5145
   527
slouken@5145
   528
/**
slouken@5145
   529
 *  \brief Fill a rectangle on the current rendering target with the drawing color.
slouken@5145
   530
 *  
slouken@5145
   531
 *  \param rect A pointer to the destination rectangle, or NULL for the entire 
slouken@5145
   532
 *              rendering target.
slouken@5145
   533
 *  
slouken@5147
   534
 *  \return 0 on success, or -1 on error
slouken@5145
   535
 */
slouken@5147
   536
extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
slouken@5147
   537
                                               const SDL_Rect * rect);
slouken@5145
   538
slouken@5145
   539
/**
slouken@5145
   540
 *  \brief Fill some number of rectangles on the current rendering target with the drawing color.
slouken@5145
   541
 *  
slouken@5145
   542
 *  \param rects A pointer to an array of destination rectangles.
slouken@5145
   543
 *  \param count The number of rectangles.
slouken@5145
   544
 *  
slouken@5147
   545
 *  \return 0 on success, or -1 on error
slouken@5145
   546
 */
slouken@5147
   547
extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
slouken@5486
   548
                                                const SDL_Rect * rects,
slouken@5147
   549
                                                int count);
slouken@5145
   550
slouken@5145
   551
/**
slouken@5145
   552
 *  \brief Copy a portion of the texture to the current rendering target.
slouken@5145
   553
 *  
slouken@5145
   554
 *  \param texture The source texture.
slouken@5145
   555
 *  \param srcrect   A pointer to the source rectangle, or NULL for the entire 
slouken@5145
   556
 *                   texture.
slouken@5145
   557
 *  \param dstrect   A pointer to the destination rectangle, or NULL for the 
slouken@5145
   558
 *                   entire rendering target.
slouken@5145
   559
 *  
slouken@5147
   560
 *  \return 0 on success, or -1 on error
slouken@5145
   561
 */
slouken@5147
   562
extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
slouken@5147
   563
                                           SDL_Texture * texture,
slouken@5145
   564
                                           const SDL_Rect * srcrect,
slouken@5145
   565
                                           const SDL_Rect * dstrect);
slouken@5145
   566
slouken@6232
   567
slouken@6232
   568
/**
slouken@6232
   569
 * \fn SDL_bool SDL_RenderTargetSupported(SDL_Renderer *renderer)
slouken@6232
   570
 *
slouken@6232
   571
 * \brief Determines whether a window supports the use of render targets
slouken@6232
   572
 *
slouken@6232
   573
 * \param renderer The renderer that will be checked
slouken@6232
   574
 *
slouken@6232
   575
 * \return SDL_TRUE if supported, SDL_FALSE if not.
slouken@6232
   576
 */
slouken@6232
   577
extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer);
slouken@6232
   578
slouken@6232
   579
/**
slouken@6232
   580
 * \fn int SDL_SetTargetTexture(SDL_Renderer *renderer, SDL_Texture *texture)
slouken@6232
   581
 *
slouken@6232
   582
 * \brief Set a texture as the current rendering target.
slouken@6232
   583
 *
slouken@6232
   584
 * \param renderer The renderer that will be checked
slouken@6232
   585
 *
slouken@6232
   586
 * \param texture The targeted texture, or NULL for the default render target
slouken@6232
   587
 *
slouken@6232
   588
 * \return 0 on success, or -1 if there is no rendering context current, or the driver doesn't support the requested operation.
slouken@6232
   589
 */
slouken@6232
   590
extern DECLSPEC int SDLCALL SDL_SetTargetTexture(SDL_Renderer *renderer, SDL_Texture *texture);
slouken@6232
   591
slouken@5145
   592
/**
slouken@5145
   593
 *  \brief Read pixels from the current rendering target.
slouken@5145
   594
 *  
slouken@5145
   595
 *  \param rect   A pointer to the rectangle to read, or NULL for the entire 
slouken@5145
   596
 *                render target.
slouken@5145
   597
 *  \param format The desired format of the pixel data, or 0 to use the format
slouken@5145
   598
 *                of the rendering target
slouken@5145
   599
 *  \param pixels A pointer to be filled in with the pixel data
slouken@5145
   600
 *  \param pitch  The pitch of the pixels parameter.
slouken@5145
   601
 *  
slouken@5145
   602
 *  \return 0 on success, or -1 if pixel reading is not supported.
slouken@5145
   603
 *  
slouken@5145
   604
 *  \warning This is a very slow operation, and should not be used frequently.
slouken@5145
   605
 */
slouken@5147
   606
extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
slouken@5147
   607
                                                 const SDL_Rect * rect,
slouken@5145
   608
                                                 Uint32 format,
slouken@5145
   609
                                                 void *pixels, int pitch);
slouken@5145
   610
slouken@5145
   611
/**
slouken@5145
   612
 *  \brief Update the screen with rendering performed.
slouken@5145
   613
 */
slouken@5147
   614
extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
slouken@5145
   615
slouken@5145
   616
/**
slouken@5145
   617
 *  \brief Destroy the specified texture.
slouken@5145
   618
 *  
slouken@5145
   619
 *  \sa SDL_CreateTexture()
slouken@5145
   620
 *  \sa SDL_CreateTextureFromSurface()
slouken@5145
   621
 */
slouken@5145
   622
extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
slouken@5145
   623
slouken@5145
   624
/**
slouken@5145
   625
 *  \brief Destroy the rendering context for a window and free associated
slouken@5145
   626
 *         textures.
slouken@5145
   627
 *  
slouken@5145
   628
 *  \sa SDL_CreateRenderer()
slouken@5145
   629
 */
slouken@5147
   630
extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
slouken@5145
   631
slouken@5145
   632
slouken@5145
   633
/* Ends C function definitions when using C++ */
slouken@5145
   634
#ifdef __cplusplus
slouken@5145
   635
/* *INDENT-OFF* */
slouken@5145
   636
}
slouken@5145
   637
/* *INDENT-ON* */
slouken@5145
   638
#endif
slouken@5145
   639
#include "close_code.h"
slouken@5145
   640
slouken@5145
   641
#endif /* _SDL_render_h */
slouken@5145
   642
slouken@5145
   643
/* vi: set ts=4 sw=4 expandtab: */