src/render/SDL_sysrender.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 12 Feb 2011 11:36:56 -0800
changeset 5270 7aba0406c273
parent 5262 b530ef003506
child 5290 25af68c1901d
permissions -rw-r--r--
Frank Zago to sdl

The following patch fixes some of the bitrot for the Nintendo DS port.
The support is still basic at the moment, but it allows to run the "general"
test under the current head of tree (parent: 5269:11bd1585efb5 tip).
Most of the patch is mine, but I integrated a couple changes that John
Magnotti posted on Feb 1st.
     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     void (*SetClipRect) (SDL_Renderer * renderer, const SDL_Rect *rect);
    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 list of textures */
   105     SDL_Texture *textures;
   106 
   107     Uint8 r, g, b, a;                   /**< Color for drawing operations values */
   108     SDL_BlendMode blendMode;            /**< The drawing blend mode */
   109 
   110     void *driverdata;
   111 };
   112 
   113 /* Define the SDL render driver structure */
   114 struct SDL_RenderDriver
   115 {
   116     SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
   117 
   118     /* Info about the renderer capabilities */
   119     SDL_RendererInfo info;
   120 };
   121 
   122 #if !SDL_RENDER_DISABLED
   123 
   124 #if SDL_VIDEO_RENDER_D3D
   125 extern SDL_RenderDriver D3D_RenderDriver;
   126 #endif
   127 #if SDL_VIDEO_RENDER_OGL
   128 extern SDL_RenderDriver GL_RenderDriver;
   129 #endif
   130 #if SDL_VIDEO_RENDER_OGL_ES2
   131 extern SDL_RenderDriver GLES2_RenderDriver;
   132 #endif
   133 #if SDL_VIDEO_RENDER_OGL_ES
   134 extern SDL_RenderDriver GLES_RenderDriver;
   135 #endif
   136 #if SDL_VIDEO_RENDER_DIRECTFB
   137 extern SDL_RenderDriver DirectFB_RenderDriver;
   138 #endif
   139 #ifdef SDL_VIDEO_RENDER_NDS
   140 extern SDL_RenderDriver NDS_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: */