src/render/SDL_sysrender.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 15 Feb 2011 13:59:59 -0800
changeset 5297 1800dc39b74c
parent 5290 25af68c1901d
child 5423 b69fa50e80d7
permissions -rw-r--r--
Changed the concept of a render clip rect to a render viewport.
The render viewport is automatically re-centered when the window changes size, so applications that don't care will not have to handle recalculating their rendering coordinates.

Fixed API for drawing and filling multiple rectangles - the parameter should be an array of rects, not an array of pointers to rects.

Fixed API for updating window rects for consistency with other APIs - the order is pointer to array followed by count in array.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2011 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 (*UpdateViewport) (SDL_Renderer * renderer);
    82     int (*RenderClear) (SDL_Renderer * renderer);
    83     int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
    84                              int count);
    85     int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points,
    86                             int count);
    87     int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect * rects,
    88                             int count);
    89     int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
    90                        const SDL_Rect * srcrect, const SDL_Rect * dstrect);
    91     int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
    92                              Uint32 format, void * pixels, int pitch);
    93     void (*RenderPresent) (SDL_Renderer * renderer);
    94     void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
    95 
    96     void (*DestroyRenderer) (SDL_Renderer * renderer);
    97 
    98     /* The current renderer info */
    99     SDL_RendererInfo info;
   100 
   101     /* The window associated with the renderer */
   102     SDL_Window *window;
   103 
   104     /* The drawable area within the window */
   105     SDL_Rect viewport;
   106 
   107     /* The list of textures */
   108     SDL_Texture *textures;
   109 
   110     Uint8 r, g, b, a;                   /**< Color for drawing operations values */
   111     SDL_BlendMode blendMode;            /**< The drawing blend mode */
   112 
   113     void *driverdata;
   114 };
   115 
   116 /* Define the SDL render driver structure */
   117 struct SDL_RenderDriver
   118 {
   119     SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
   120 
   121     /* Info about the renderer capabilities */
   122     SDL_RendererInfo info;
   123 };
   124 
   125 #if !SDL_RENDER_DISABLED
   126 
   127 #if SDL_VIDEO_RENDER_D3D
   128 extern SDL_RenderDriver D3D_RenderDriver;
   129 #endif
   130 #if SDL_VIDEO_RENDER_OGL
   131 extern SDL_RenderDriver GL_RenderDriver;
   132 #endif
   133 #if SDL_VIDEO_RENDER_OGL_ES2
   134 extern SDL_RenderDriver GLES2_RenderDriver;
   135 #endif
   136 #if SDL_VIDEO_RENDER_OGL_ES
   137 extern SDL_RenderDriver GLES_RenderDriver;
   138 #endif
   139 #if SDL_VIDEO_RENDER_DIRECTFB
   140 extern SDL_RenderDriver DirectFB_RenderDriver;
   141 #endif
   142 extern SDL_RenderDriver SW_RenderDriver;
   143 
   144 #endif /* !SDL_RENDER_DISABLED */
   145 
   146 #endif /* _SDL_sysrender_h */
   147 
   148 /* vi: set ts=4 sw=4 expandtab: */