src/render/SDL_sysrender.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 03 Feb 2011 00:22:18 -0800
changeset 5157 657543cc92f9
parent 5156 307ccc9c135e
child 5199 164f20ba08eb
permissions -rw-r--r--
Making the API simpler, removed the writepixels interface
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2010 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #ifndef _SDL_sysrender_h
    25 #define _SDL_sysrender_h
    26 
    27 #include "SDL_render.h"
    28 #include "SDL_events.h"
    29 #include "SDL_yuv_sw_c.h"
    30 
    31 /* The SDL 2D rendering system */
    32 
    33 typedef struct SDL_RenderDriver SDL_RenderDriver;
    34 
    35 /* Define the SDL texture structure */
    36 struct SDL_Texture
    37 {
    38     const void *magic;
    39     Uint32 format;              /**< The pixel format of the texture */
    40     int access;                 /**< SDL_TextureAccess */
    41     int w;                      /**< The width of the texture */
    42     int h;                      /**< The height of the texture */
    43     int modMode;                /**< The texture modulation mode */
    44     SDL_BlendMode blendMode;    /**< The texture blend mode */
    45     Uint8 r, g, b, a;           /**< Texture modulation values */
    46 
    47     SDL_Renderer *renderer;
    48 
    49     /* Support for formats not supported directly by the renderer */
    50     SDL_Texture *native;
    51     SDL_SW_YUVTexture *yuv;
    52     void *pixels;
    53     int pitch;
    54     SDL_Rect locked_rect;
    55 
    56     void *driverdata;           /**< Driver specific texture representation */
    57 
    58     SDL_Texture *prev;
    59     SDL_Texture *next;
    60 };
    61 
    62 /* Define the SDL renderer structure */
    63 struct SDL_Renderer
    64 {
    65     const void *magic;
    66 
    67     void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
    68     int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
    69     int (*SetTextureColorMod) (SDL_Renderer * renderer,
    70                                SDL_Texture * texture);
    71     int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
    72                                SDL_Texture * texture);
    73     int (*SetTextureBlendMode) (SDL_Renderer * renderer,
    74                                 SDL_Texture * texture);
    75     int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
    76                           const SDL_Rect * rect, const void *pixels,
    77                           int pitch);
    78     int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
    79                         const SDL_Rect * rect, void **pixels, int *pitch);
    80     void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
    81     int (*RenderClear) (SDL_Renderer * renderer);
    82     int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
    83                              int count);
    84     int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points,
    85                             int count);
    86     int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
    87                             int count);
    88     int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
    89                        const SDL_Rect * srcrect, const SDL_Rect * dstrect);
    90     int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
    91                              Uint32 format, void * pixels, int pitch);
    92     void (*RenderPresent) (SDL_Renderer * renderer);
    93     void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
    94 
    95     void (*DestroyRenderer) (SDL_Renderer * renderer);
    96 
    97     /* The current renderer info */
    98     SDL_RendererInfo info;
    99 
   100     /* The window associated with the renderer */
   101     SDL_Window *window;
   102 
   103     /* The list of textures */
   104     SDL_Texture *textures;
   105 
   106     Uint8 r, g, b, a;                   /**< Color for drawing operations values */
   107     SDL_BlendMode blendMode;            /**< The drawing blend mode */
   108 
   109     void *driverdata;
   110 };
   111 
   112 /* Define the SDL render driver structure */
   113 struct SDL_RenderDriver
   114 {
   115     SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
   116 
   117     /* Info about the renderer capabilities */
   118     SDL_RendererInfo info;
   119 };
   120 
   121 #if SDL_VIDEO_RENDER_D3D
   122 extern SDL_RenderDriver D3D_RenderDriver;
   123 #endif
   124 #if SDL_VIDEO_RENDER_OGL
   125 extern SDL_RenderDriver GL_RenderDriver;
   126 #endif
   127 #if SDL_VIDEO_RENDER_OGL_ES
   128 extern SDL_RenderDriver GL_ES_RenderDriver;
   129 #endif
   130 extern SDL_RenderDriver SW_RenderDriver;
   131 
   132 #endif /* _SDL_sysrender_h */
   133 
   134 /* vi: set ts=4 sw=4 expandtab: */