src/render/SDL_sysrender.h
author Captain Lex <kimonline@126.com>
Sun, 17 Mar 2013 20:07:02 +0800
changeset 7009 161b7b6a5303
parent 6885 700f1b25f77f
child 7011 82bbfbbc720e
permissions -rw-r--r--
Add PSP support
     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 #include "SDL_config.h"
    22 
    23 #ifndef _SDL_sysrender_h
    24 #define _SDL_sysrender_h
    25 
    26 #include "SDL_render.h"
    27 #include "SDL_events.h"
    28 #include "SDL_yuv_sw_c.h"
    29 
    30 /* The SDL 2D rendering system */
    31 
    32 typedef struct SDL_RenderDriver SDL_RenderDriver;
    33 
    34 typedef struct
    35 {
    36     float x;
    37     float y;
    38 } SDL_FPoint;
    39 
    40 typedef struct
    41 {
    42     float x;
    43     float y;
    44     float w;
    45     float h;
    46 } SDL_FRect;
    47 
    48 /* Define the SDL texture structure */
    49 struct SDL_Texture
    50 {
    51     const void *magic;
    52     Uint32 format;              /**< The pixel format of the texture */
    53     int access;                 /**< SDL_TextureAccess */
    54     int w;                      /**< The width of the texture */
    55     int h;                      /**< The height of the texture */
    56     int modMode;                /**< The texture modulation mode */
    57     SDL_BlendMode blendMode;    /**< The texture blend mode */
    58     Uint8 r, g, b, a;           /**< Texture modulation values */
    59 
    60     SDL_Renderer *renderer;
    61 
    62     /* Support for formats not supported directly by the renderer */
    63     SDL_Texture *native;
    64     SDL_SW_YUVTexture *yuv;
    65     void *pixels;
    66     int pitch;
    67     SDL_Rect locked_rect;
    68 
    69     void *driverdata;           /**< Driver specific texture representation */
    70 
    71     SDL_Texture *prev;
    72     SDL_Texture *next;
    73 };
    74 
    75 /* Define the SDL renderer structure */
    76 struct SDL_Renderer
    77 {
    78     const void *magic;
    79 
    80     void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
    81     int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
    82     int (*SetTextureColorMod) (SDL_Renderer * renderer,
    83                                SDL_Texture * texture);
    84     int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
    85                                SDL_Texture * texture);
    86     int (*SetTextureBlendMode) (SDL_Renderer * renderer,
    87                                 SDL_Texture * texture);
    88     int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
    89                           const SDL_Rect * rect, const void *pixels,
    90                           int pitch);
    91     int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
    92                         const SDL_Rect * rect, void **pixels, int *pitch);
    93     void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
    94     int (*SetRenderTarget) (SDL_Renderer * renderer, SDL_Texture * texture);
    95     int (*UpdateViewport) (SDL_Renderer * renderer);
    96     int (*RenderClear) (SDL_Renderer * renderer);
    97     int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_FPoint * points,
    98                              int count);
    99     int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_FPoint * points,
   100                             int count);
   101     int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_FRect * rects,
   102                             int count);
   103     int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
   104                        const SDL_Rect * srcrect, const SDL_FRect * dstrect);
   105     int (*RenderCopyEx) (SDL_Renderer * renderer, SDL_Texture * texture,
   106                        const SDL_Rect * srcquad, const SDL_FRect * dstrect,
   107                        const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
   108     int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
   109                              Uint32 format, void * pixels, int pitch);
   110     void (*RenderPresent) (SDL_Renderer * renderer);
   111     void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
   112 
   113     void (*DestroyRenderer) (SDL_Renderer * renderer);
   114 
   115     int (*GL_BindTexture) (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh);
   116     int (*GL_UnbindTexture) (SDL_Renderer * renderer, SDL_Texture *texture);
   117 
   118     /* The current renderer info */
   119     SDL_RendererInfo info;
   120 
   121     /* The window associated with the renderer */
   122     SDL_Window *window;
   123     SDL_bool hidden;
   124     SDL_bool resized;
   125 
   126     /* The logical resolution for rendering */
   127     int logical_w;
   128     int logical_h;
   129     int logical_w_backup;
   130     int logical_h_backup;
   131 
   132     /* The drawable area within the window */
   133     SDL_Rect viewport;
   134     SDL_Rect viewport_backup;
   135 
   136     /* The render output coordinate scale */
   137     SDL_FPoint scale;
   138     SDL_FPoint scale_backup;
   139 
   140     /* The list of textures */
   141     SDL_Texture *textures;
   142     SDL_Texture *target;
   143 
   144     Uint8 r, g, b, a;                   /**< Color for drawing operations values */
   145     SDL_BlendMode blendMode;            /**< The drawing blend mode */
   146 
   147     void *driverdata;
   148 };
   149 
   150 /* Define the SDL render driver structure */
   151 struct SDL_RenderDriver
   152 {
   153     SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
   154 
   155     /* Info about the renderer capabilities */
   156     SDL_RendererInfo info;
   157 };
   158 
   159 #if !SDL_RENDER_DISABLED
   160 
   161 #if SDL_VIDEO_RENDER_D3D
   162 extern SDL_RenderDriver D3D_RenderDriver;
   163 #endif
   164 #if SDL_VIDEO_RENDER_OGL
   165 extern SDL_RenderDriver GL_RenderDriver;
   166 #endif
   167 #if SDL_VIDEO_RENDER_OGL_ES2
   168 extern SDL_RenderDriver GLES2_RenderDriver;
   169 #endif
   170 #if SDL_VIDEO_RENDER_OGL_ES
   171 extern SDL_RenderDriver GLES_RenderDriver;
   172 #endif
   173 #if SDL_VIDEO_RENDER_DIRECTFB
   174 extern SDL_RenderDriver DirectFB_RenderDriver;
   175 #endif
   176 #if SDL_VIDEO_RENDER_NDS
   177 extern SDL_RenderDriver NDS_RenderDriver;
   178 #endif
   179 #if SDL_VIDEO_RENDER_PSP
   180 extern SDL_RenderDriver PSP_RenderDriver;
   181 #endif
   182 extern SDL_RenderDriver SW_RenderDriver;
   183 
   184 #endif /* !SDL_RENDER_DISABLED */
   185 
   186 #endif /* _SDL_sysrender_h */
   187 
   188 /* vi: set ts=4 sw=4 expandtab: */