src/render/SDL_sysrender.h
author Gabriel Jacobo <gabomdq@gmail.com>
Mon, 03 Sep 2012 11:16:12 -0300
changeset 6414 df50b0d6c1c3
parent 6320 6077a1310907
child 6528 e978048ced60
permissions -rwxr-xr-x
Implements SDL_GL_BindTexture and SDL_GL_UnbindTexture (#1576)
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2012 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 /* Define the SDL texture structure */
    35 struct SDL_Texture
    36 {
    37     const void *magic;
    38     Uint32 format;              /**< The pixel format of the texture */
    39     int access;                 /**< SDL_TextureAccess */
    40     int w;                      /**< The width of the texture */
    41     int h;                      /**< The height of the texture */
    42     int modMode;                /**< The texture modulation mode */
    43     SDL_BlendMode blendMode;    /**< The texture blend mode */
    44     Uint8 r, g, b, a;           /**< Texture modulation values */
    45 
    46     SDL_Renderer *renderer;
    47 
    48     /* Support for formats not supported directly by the renderer */
    49     SDL_Texture *native;
    50     SDL_SW_YUVTexture *yuv;
    51     void *pixels;
    52     int pitch;
    53     SDL_Rect locked_rect;
    54 
    55     void *driverdata;           /**< Driver specific texture representation */
    56 
    57     SDL_Texture *prev;
    58     SDL_Texture *next;
    59 };
    60 
    61 /* Define the SDL renderer structure */
    62 struct SDL_Renderer
    63 {
    64     const void *magic;
    65 
    66     void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
    67     int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
    68     int (*SetTextureColorMod) (SDL_Renderer * renderer,
    69                                SDL_Texture * texture);
    70     int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
    71                                SDL_Texture * texture);
    72     int (*SetTextureBlendMode) (SDL_Renderer * renderer,
    73                                 SDL_Texture * texture);
    74     int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
    75                           const SDL_Rect * rect, const void *pixels,
    76                           int pitch);
    77     int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
    78                         const SDL_Rect * rect, void **pixels, int *pitch);
    79     void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
    80     int (*SetRenderTarget) (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 (*RenderCopyEx) (SDL_Renderer * renderer, SDL_Texture * texture,
    92                        const SDL_Rect * srcquad, const SDL_Rect * dstrect,
    93                        const double angle, const SDL_Point *center, const SDL_RendererFlip flip);
    94     int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
    95                              Uint32 format, void * pixels, int pitch);
    96     void (*RenderPresent) (SDL_Renderer * renderer);
    97     void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
    98 
    99     void (*DestroyRenderer) (SDL_Renderer * renderer);
   100 
   101     int (*GL_BindTexture) (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh);
   102     int (*GL_UnbindTexture) (SDL_Renderer * renderer, SDL_Texture *texture);
   103 
   104     /* The current renderer info */
   105     SDL_RendererInfo info;
   106 
   107     /* The window associated with the renderer */
   108     SDL_Window *window;
   109     SDL_bool hidden;
   110     SDL_bool resized;
   111 
   112     /* The drawable area within the window */
   113     SDL_Rect viewport;
   114     SDL_Rect viewport_backup;
   115 
   116     /* The list of textures */
   117     SDL_Texture *textures;
   118     SDL_Texture *target;
   119 
   120     Uint8 r, g, b, a;                   /**< Color for drawing operations values */
   121     SDL_BlendMode blendMode;            /**< The drawing blend mode */
   122 
   123     void *driverdata;
   124 };
   125 
   126 /* Define the SDL render driver structure */
   127 struct SDL_RenderDriver
   128 {
   129     SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
   130 
   131     /* Info about the renderer capabilities */
   132     SDL_RendererInfo info;
   133 };
   134 
   135 #if !SDL_RENDER_DISABLED
   136 
   137 #if SDL_VIDEO_RENDER_D3D
   138 extern SDL_RenderDriver D3D_RenderDriver;
   139 #endif
   140 #if SDL_VIDEO_RENDER_OGL
   141 extern SDL_RenderDriver GL_RenderDriver;
   142 #endif
   143 #if SDL_VIDEO_RENDER_OGL_ES2
   144 extern SDL_RenderDriver GLES2_RenderDriver;
   145 #endif
   146 #if SDL_VIDEO_RENDER_OGL_ES
   147 extern SDL_RenderDriver GLES_RenderDriver;
   148 #endif
   149 #if SDL_VIDEO_RENDER_DIRECTFB
   150 extern SDL_RenderDriver DirectFB_RenderDriver;
   151 #endif
   152 #if SDL_VIDEO_RENDER_NDS
   153 extern SDL_RenderDriver NDS_RenderDriver;
   154 #endif
   155 extern SDL_RenderDriver SW_RenderDriver;
   156 
   157 #endif /* !SDL_RENDER_DISABLED */
   158 
   159 #endif /* _SDL_sysrender_h */
   160 
   161 /* vi: set ts=4 sw=4 expandtab: */