src/render/SDL_sysrender.h
author Sam Lantinga <slouken@libsdl.org>
Fri, 22 Sep 2017 11:25:52 -0700
changeset 11525 8df7a59b5528
parent 11282 180e8906dc3c
child 11729 d1ce8396c356
permissions -rw-r--r--
Fixed Mac OS X build
slouken@5154
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@10737
     3
  Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
slouken@5154
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@5154
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@5154
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@5154
    20
*/
icculus@8093
    21
#include "../SDL_internal.h"
slouken@5154
    22
slouken@10638
    23
#ifndef SDL_sysrender_h_
slouken@10638
    24
#define SDL_sysrender_h_
slouken@5154
    25
slouken@5154
    26
#include "SDL_render.h"
slouken@5154
    27
#include "SDL_events.h"
slouken@5156
    28
#include "SDL_yuv_sw_c.h"
slouken@5154
    29
slouken@5154
    30
/* The SDL 2D rendering system */
slouken@5154
    31
slouken@5154
    32
typedef struct SDL_RenderDriver SDL_RenderDriver;
slouken@5154
    33
slouken@6528
    34
typedef struct
slouken@6528
    35
{
slouken@6528
    36
    float x;
slouken@6528
    37
    float y;
slouken@6528
    38
} SDL_FPoint;
slouken@6528
    39
slouken@6528
    40
typedef struct
slouken@6528
    41
{
slouken@6528
    42
    float x;
slouken@6528
    43
    float y;
slouken@6528
    44
    float w;
slouken@6528
    45
    float h;
slouken@6528
    46
} SDL_FRect;
slouken@6528
    47
slouken@5154
    48
/* Define the SDL texture structure */
slouken@5154
    49
struct SDL_Texture
slouken@5154
    50
{
slouken@5154
    51
    const void *magic;
slouken@5154
    52
    Uint32 format;              /**< The pixel format of the texture */
slouken@5154
    53
    int access;                 /**< SDL_TextureAccess */
slouken@5154
    54
    int w;                      /**< The width of the texture */
slouken@5154
    55
    int h;                      /**< The height of the texture */
slouken@5154
    56
    int modMode;                /**< The texture modulation mode */
slouken@5154
    57
    SDL_BlendMode blendMode;    /**< The texture blend mode */
slouken@5154
    58
    Uint8 r, g, b, a;           /**< Texture modulation values */
slouken@5154
    59
slouken@5154
    60
    SDL_Renderer *renderer;
slouken@5154
    61
slouken@5156
    62
    /* Support for formats not supported directly by the renderer */
slouken@5156
    63
    SDL_Texture *native;
slouken@5156
    64
    SDL_SW_YUVTexture *yuv;
slouken@5156
    65
    void *pixels;
slouken@5156
    66
    int pitch;
slouken@5156
    67
    SDL_Rect locked_rect;
slouken@5156
    68
slouken@5154
    69
    void *driverdata;           /**< Driver specific texture representation */
slouken@5154
    70
slouken@5154
    71
    SDL_Texture *prev;
slouken@5154
    72
    SDL_Texture *next;
slouken@5154
    73
};
slouken@5154
    74
slouken@5154
    75
/* Define the SDL renderer structure */
slouken@5154
    76
struct SDL_Renderer
slouken@5154
    77
{
slouken@5154
    78
    const void *magic;
slouken@5154
    79
slouken@5154
    80
    void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
slouken@7239
    81
    int (*GetOutputSize) (SDL_Renderer * renderer, int *w, int *h);
slouken@11282
    82
    SDL_bool (*SupportsBlendMode)(SDL_Renderer * renderer, SDL_BlendMode blendMode);
slouken@5154
    83
    int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
slouken@5154
    84
    int (*SetTextureColorMod) (SDL_Renderer * renderer,
slouken@5154
    85
                               SDL_Texture * texture);
slouken@5154
    86
    int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
slouken@5154
    87
                               SDL_Texture * texture);
slouken@5154
    88
    int (*SetTextureBlendMode) (SDL_Renderer * renderer,
slouken@5154
    89
                                SDL_Texture * texture);
slouken@5154
    90
    int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@5154
    91
                          const SDL_Rect * rect, const void *pixels,
slouken@5154
    92
                          int pitch);
slouken@7759
    93
    int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@7759
    94
                            const SDL_Rect * rect,
slouken@7759
    95
                            const Uint8 *Yplane, int Ypitch,
slouken@7759
    96
                            const Uint8 *Uplane, int Upitch,
slouken@7759
    97
                            const Uint8 *Vplane, int Vpitch);
slouken@5154
    98
    int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@5156
    99
                        const SDL_Rect * rect, void **pixels, int *pitch);
slouken@5154
   100
    void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
slouken@6247
   101
    int (*SetRenderTarget) (SDL_Renderer * renderer, SDL_Texture * texture);
slouken@5297
   102
    int (*UpdateViewport) (SDL_Renderer * renderer);
slouken@7141
   103
    int (*UpdateClipRect) (SDL_Renderer * renderer);
slouken@5154
   104
    int (*RenderClear) (SDL_Renderer * renderer);
slouken@6528
   105
    int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_FPoint * points,
slouken@5154
   106
                             int count);
slouken@6528
   107
    int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_FPoint * points,
slouken@5154
   108
                            int count);
slouken@6528
   109
    int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_FRect * rects,
slouken@5154
   110
                            int count);
slouken@5154
   111
    int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@6528
   112
                       const SDL_Rect * srcrect, const SDL_FRect * dstrect);
gabomdq@6320
   113
    int (*RenderCopyEx) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@6528
   114
                       const SDL_Rect * srcquad, const SDL_FRect * dstrect,
slouken@6528
   115
                       const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
slouken@5154
   116
    int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
slouken@5154
   117
                             Uint32 format, void * pixels, int pitch);
slouken@5154
   118
    void (*RenderPresent) (SDL_Renderer * renderer);
slouken@5154
   119
    void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
slouken@5154
   120
slouken@5154
   121
    void (*DestroyRenderer) (SDL_Renderer * renderer);
slouken@5154
   122
gabomdq@6414
   123
    int (*GL_BindTexture) (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh);
gabomdq@6414
   124
    int (*GL_UnbindTexture) (SDL_Renderer * renderer, SDL_Texture *texture);
gabomdq@6414
   125
slouken@5154
   126
    /* The current renderer info */
slouken@5154
   127
    SDL_RendererInfo info;
slouken@5154
   128
slouken@5154
   129
    /* The window associated with the renderer */
slouken@5154
   130
    SDL_Window *window;
slouken@6260
   131
    SDL_bool hidden;
slouken@5154
   132
slouken@6530
   133
    /* The logical resolution for rendering */
slouken@6530
   134
    int logical_w;
slouken@6530
   135
    int logical_h;
slouken@6581
   136
    int logical_w_backup;
slouken@6581
   137
    int logical_h_backup;
slouken@6530
   138
flibitijibibo@10039
   139
    /* Whether or not to force the viewport to even integer intervals */
flibitijibibo@10039
   140
    SDL_bool integer_scale;
flibitijibibo@10039
   141
slouken@5297
   142
    /* The drawable area within the window */
slouken@5297
   143
    SDL_Rect viewport;
slouken@6246
   144
    SDL_Rect viewport_backup;
slouken@5297
   145
slouken@7141
   146
    /* The clip rectangle within the window */
slouken@7141
   147
    SDL_Rect clip_rect;
slouken@7141
   148
    SDL_Rect clip_rect_backup;
slouken@7141
   149
jorgenpt@8728
   150
    /* Wether or not the clipping rectangle is used. */
jorgenpt@8728
   151
    SDL_bool clipping_enabled;
jorgenpt@8728
   152
    SDL_bool clipping_enabled_backup;
jorgenpt@8728
   153
slouken@6528
   154
    /* The render output coordinate scale */
slouken@6528
   155
    SDL_FPoint scale;
slouken@6528
   156
    SDL_FPoint scale_backup;
slouken@6528
   157
slouken@11178
   158
    /* The pixel to point coordinate scale */
slouken@11178
   159
    SDL_FPoint dpi_scale;
slouken@11178
   160
slouken@5154
   161
    /* The list of textures */
slouken@5154
   162
    SDL_Texture *textures;
slouken@6246
   163
    SDL_Texture *target;
slouken@5154
   164
slouken@5154
   165
    Uint8 r, g, b, a;                   /**< Color for drawing operations values */
slouken@5154
   166
    SDL_BlendMode blendMode;            /**< The drawing blend mode */
slouken@5154
   167
slouken@5154
   168
    void *driverdata;
slouken@5154
   169
};
slouken@5154
   170
slouken@5154
   171
/* Define the SDL render driver structure */
slouken@5154
   172
struct SDL_RenderDriver
slouken@5154
   173
{
slouken@5154
   174
    SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
slouken@5154
   175
slouken@5154
   176
    /* Info about the renderer capabilities */
slouken@5154
   177
    SDL_RendererInfo info;
slouken@5154
   178
};
slouken@5154
   179
icculus@10914
   180
/* Not all of these are available in a given build. Use #ifdefs, etc. */
slouken@5154
   181
extern SDL_RenderDriver D3D_RenderDriver;
dludwig@8400
   182
extern SDL_RenderDriver D3D11_RenderDriver;
slouken@5154
   183
extern SDL_RenderDriver GL_RenderDriver;
slouken@5209
   184
extern SDL_RenderDriver GLES2_RenderDriver;
slouken@5201
   185
extern SDL_RenderDriver GLES_RenderDriver;
slouken@5199
   186
extern SDL_RenderDriver DirectFB_RenderDriver;
kimonline@7009
   187
extern SDL_RenderDriver PSP_RenderDriver;
slouken@5154
   188
extern SDL_RenderDriver SW_RenderDriver;
slouken@5154
   189
slouken@11282
   190
/* Blend mode functions */
slouken@11282
   191
extern SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode);
slouken@11282
   192
extern SDL_BlendFactor SDL_GetBlendModeDstColorFactor(SDL_BlendMode blendMode);
slouken@11282
   193
extern SDL_BlendOperation SDL_GetBlendModeColorOperation(SDL_BlendMode blendMode);
slouken@11282
   194
extern SDL_BlendFactor SDL_GetBlendModeSrcAlphaFactor(SDL_BlendMode blendMode);
slouken@11282
   195
extern SDL_BlendFactor SDL_GetBlendModeDstAlphaFactor(SDL_BlendMode blendMode);
slouken@11282
   196
extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode);
slouken@11282
   197
slouken@10638
   198
#endif /* SDL_sysrender_h_ */
slouken@5154
   199
slouken@5154
   200
/* vi: set ts=4 sw=4 expandtab: */