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