src/render/SDL_sysrender.h
author Gabriel Jacobo <gabomdq@gmail.com>
Fri, 01 Jun 2012 19:51:08 -0300
changeset 6320 6077a1310907
parent 6260 fd494c5f305b
child 6414 df50b0d6c1c3
permissions -rwxr-xr-x
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
slouken@5154
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6138
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
slouken@5154
     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@5154
     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@5154
    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@5154
    20
*/
slouken@5154
    21
#include "SDL_config.h"
slouken@5154
    22
slouken@5154
    23
#ifndef _SDL_sysrender_h
slouken@5154
    24
#define _SDL_sysrender_h
slouken@5154
    25
slouken@5154
    26
#include "SDL_render.h"
slouken@5154
    27
#include "SDL_events.h"
slouken@5156
    28
#include "SDL_yuv_sw_c.h"
slouken@5154
    29
slouken@5154
    30
/* The SDL 2D rendering system */
slouken@5154
    31
slouken@5154
    32
typedef struct SDL_RenderDriver SDL_RenderDriver;
slouken@5154
    33
slouken@5154
    34
/* Define the SDL texture structure */
slouken@5154
    35
struct SDL_Texture
slouken@5154
    36
{
slouken@5154
    37
    const void *magic;
slouken@5154
    38
    Uint32 format;              /**< The pixel format of the texture */
slouken@5154
    39
    int access;                 /**< SDL_TextureAccess */
slouken@5154
    40
    int w;                      /**< The width of the texture */
slouken@5154
    41
    int h;                      /**< The height of the texture */
slouken@5154
    42
    int modMode;                /**< The texture modulation mode */
slouken@5154
    43
    SDL_BlendMode blendMode;    /**< The texture blend mode */
slouken@5154
    44
    Uint8 r, g, b, a;           /**< Texture modulation values */
slouken@5154
    45
slouken@5154
    46
    SDL_Renderer *renderer;
slouken@5154
    47
slouken@5156
    48
    /* Support for formats not supported directly by the renderer */
slouken@5156
    49
    SDL_Texture *native;
slouken@5156
    50
    SDL_SW_YUVTexture *yuv;
slouken@5156
    51
    void *pixels;
slouken@5156
    52
    int pitch;
slouken@5156
    53
    SDL_Rect locked_rect;
slouken@5156
    54
slouken@5154
    55
    void *driverdata;           /**< Driver specific texture representation */
slouken@5154
    56
slouken@5154
    57
    SDL_Texture *prev;
slouken@5154
    58
    SDL_Texture *next;
slouken@5154
    59
};
slouken@5154
    60
slouken@5154
    61
/* Define the SDL renderer structure */
slouken@5154
    62
struct SDL_Renderer
slouken@5154
    63
{
slouken@5154
    64
    const void *magic;
slouken@5154
    65
slouken@5154
    66
    void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
slouken@5154
    67
    int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
slouken@5154
    68
    int (*SetTextureColorMod) (SDL_Renderer * renderer,
slouken@5154
    69
                               SDL_Texture * texture);
slouken@5154
    70
    int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
slouken@5154
    71
                               SDL_Texture * texture);
slouken@5154
    72
    int (*SetTextureBlendMode) (SDL_Renderer * renderer,
slouken@5154
    73
                                SDL_Texture * texture);
slouken@5154
    74
    int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@5154
    75
                          const SDL_Rect * rect, const void *pixels,
slouken@5154
    76
                          int pitch);
slouken@5154
    77
    int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@5156
    78
                        const SDL_Rect * rect, void **pixels, int *pitch);
slouken@5154
    79
    void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
slouken@6247
    80
    int (*SetRenderTarget) (SDL_Renderer * renderer, SDL_Texture * texture);
slouken@5297
    81
    int (*UpdateViewport) (SDL_Renderer * renderer);
slouken@5154
    82
    int (*RenderClear) (SDL_Renderer * renderer);
slouken@5154
    83
    int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
slouken@5154
    84
                             int count);
slouken@5154
    85
    int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points,
slouken@5154
    86
                            int count);
slouken@5297
    87
    int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect * rects,
slouken@5154
    88
                            int count);
slouken@5154
    89
    int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@5154
    90
                       const SDL_Rect * srcrect, const SDL_Rect * dstrect);
gabomdq@6320
    91
    int (*RenderCopyEx) (SDL_Renderer * renderer, SDL_Texture * texture,
gabomdq@6320
    92
                       const SDL_Rect * srcquad, const SDL_Rect * dstrect,
gabomdq@6320
    93
                       const double angle, const SDL_Point *center, const SDL_RendererFlip flip);
slouken@5154
    94
    int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
slouken@5154
    95
                             Uint32 format, void * pixels, int pitch);
slouken@5154
    96
    void (*RenderPresent) (SDL_Renderer * renderer);
slouken@5154
    97
    void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
slouken@5154
    98
slouken@5154
    99
    void (*DestroyRenderer) (SDL_Renderer * renderer);
slouken@5154
   100
slouken@5154
   101
    /* The current renderer info */
slouken@5154
   102
    SDL_RendererInfo info;
slouken@5154
   103
slouken@5154
   104
    /* The window associated with the renderer */
slouken@5154
   105
    SDL_Window *window;
slouken@6260
   106
    SDL_bool hidden;
slouken@6260
   107
    SDL_bool resized;
slouken@5154
   108
slouken@5297
   109
    /* The drawable area within the window */
slouken@5297
   110
    SDL_Rect viewport;
slouken@6246
   111
    SDL_Rect viewport_backup;
slouken@5297
   112
slouken@5154
   113
    /* The list of textures */
slouken@5154
   114
    SDL_Texture *textures;
slouken@6246
   115
    SDL_Texture *target;
slouken@5154
   116
slouken@5154
   117
    Uint8 r, g, b, a;                   /**< Color for drawing operations values */
slouken@5154
   118
    SDL_BlendMode blendMode;            /**< The drawing blend mode */
slouken@5154
   119
slouken@5154
   120
    void *driverdata;
slouken@5154
   121
};
slouken@5154
   122
slouken@5154
   123
/* Define the SDL render driver structure */
slouken@5154
   124
struct SDL_RenderDriver
slouken@5154
   125
{
slouken@5154
   126
    SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
slouken@5154
   127
slouken@5154
   128
    /* Info about the renderer capabilities */
slouken@5154
   129
    SDL_RendererInfo info;
slouken@5154
   130
};
slouken@5154
   131
slouken@5226
   132
#if !SDL_RENDER_DISABLED
slouken@5226
   133
slouken@5154
   134
#if SDL_VIDEO_RENDER_D3D
slouken@5154
   135
extern SDL_RenderDriver D3D_RenderDriver;
slouken@5154
   136
#endif
slouken@5154
   137
#if SDL_VIDEO_RENDER_OGL
slouken@5154
   138
extern SDL_RenderDriver GL_RenderDriver;
slouken@5154
   139
#endif
slouken@5209
   140
#if SDL_VIDEO_RENDER_OGL_ES2
slouken@5209
   141
extern SDL_RenderDriver GLES2_RenderDriver;
slouken@5209
   142
#endif
slouken@5154
   143
#if SDL_VIDEO_RENDER_OGL_ES
slouken@5201
   144
extern SDL_RenderDriver GLES_RenderDriver;
slouken@5201
   145
#endif
slouken@5199
   146
#if SDL_VIDEO_RENDER_DIRECTFB
slouken@5199
   147
extern SDL_RenderDriver DirectFB_RenderDriver;
slouken@5199
   148
#endif
slouken@5423
   149
#if SDL_VIDEO_RENDER_NDS
slouken@5423
   150
extern SDL_RenderDriver NDS_RenderDriver;
slouken@5423
   151
#endif
slouken@5154
   152
extern SDL_RenderDriver SW_RenderDriver;
slouken@5154
   153
slouken@5226
   154
#endif /* !SDL_RENDER_DISABLED */
slouken@5226
   155
slouken@5154
   156
#endif /* _SDL_sysrender_h */
slouken@5154
   157
slouken@5154
   158
/* vi: set ts=4 sw=4 expandtab: */