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