src/video/SDL_sysvideo.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 15 Sep 2008 04:32:36 +0000
changeset 2753 0969758c8809
parent 2742 b86247d21929
child 2859 99210400e8b9
permissions -rw-r--r--
indent
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@0
    23
slouken@0
    24
#ifndef _SDL_sysvideo_h
slouken@0
    25
#define _SDL_sysvideo_h
slouken@0
    26
slouken@0
    27
#include "SDL_mouse.h"
slouken@2268
    28
#include "SDL_keysym.h"
slouken@0
    29
slouken@0
    30
/* The SDL video driver */
slouken@1895
    31
slouken@1895
    32
typedef struct SDL_Window SDL_Window;
slouken@1895
    33
typedef struct SDL_Texture SDL_Texture;
slouken@1895
    34
typedef struct SDL_Renderer SDL_Renderer;
slouken@1895
    35
typedef struct SDL_RenderDriver SDL_RenderDriver;
slouken@1895
    36
typedef struct SDL_VideoDisplay SDL_VideoDisplay;
slouken@0
    37
typedef struct SDL_VideoDevice SDL_VideoDevice;
slouken@0
    38
slouken@1895
    39
/* Define the SDL texture structure */
slouken@2753
    40
struct SDL_Texture
slouken@2753
    41
{
slouken@2753
    42
    Uint32 id;
slouken@1895
    43
slouken@2753
    44
    Uint32 format;              /**< The pixel format of the texture */
slouken@2753
    45
    int access;                 /**< SDL_TextureAccess */
slouken@2753
    46
    int w;                      /**< The width of the texture */
slouken@2753
    47
    int h;                      /**< The height of the texture */
slouken@2753
    48
    int modMode;                /**< The texture modulation mode */
slouken@2753
    49
    int blendMode;                      /**< The texture blend mode */
slouken@2753
    50
    int scaleMode;                      /**< The texture scale mode */
slouken@2753
    51
    Uint8 r, g, b, a;                   /**< Texture modulation values */
slouken@1895
    52
slouken@2753
    53
    SDL_Renderer *renderer;
slouken@1895
    54
slouken@2753
    55
    void *driverdata;                   /**< Driver specific texture representation */
slouken@1895
    56
slouken@2753
    57
    SDL_Texture *next;
slouken@1895
    58
};
slouken@1895
    59
slouken@1895
    60
/* Define the SDL renderer structure */
slouken@2753
    61
struct SDL_Renderer
slouken@2753
    62
{
slouken@2753
    63
    int (*ActivateRenderer) (SDL_Renderer * renderer);
slouken@2753
    64
    int (*DisplayModeChanged) (SDL_Renderer * renderer);
slouken@2753
    65
    int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
slouken@2753
    66
    int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@2753
    67
                               void **pixels, int *pitch);
slouken@2753
    68
    int (*SetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@2753
    69
                              const SDL_Color * colors, int firstcolor,
slouken@2753
    70
                              int ncolors);
slouken@2753
    71
    int (*GetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@2753
    72
                              SDL_Color * colors, int firstcolor,
slouken@2753
    73
                              int ncolors);
slouken@2753
    74
    int (*SetTextureColorMod) (SDL_Renderer * renderer,
slouken@2753
    75
                               SDL_Texture * texture);
slouken@2753
    76
    int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
slouken@2753
    77
                               SDL_Texture * texture);
slouken@2753
    78
    int (*SetTextureBlendMode) (SDL_Renderer * renderer,
slouken@2753
    79
                                SDL_Texture * texture);
slouken@2753
    80
    int (*SetTextureScaleMode) (SDL_Renderer * renderer,
slouken@2753
    81
                                SDL_Texture * texture);
slouken@2753
    82
    int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@2753
    83
                          const SDL_Rect * rect, const void *pixels,
slouken@2753
    84
                          int pitch);
slouken@2753
    85
    int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@2753
    86
                        const SDL_Rect * rect, int markDirty, void **pixels,
slouken@2753
    87
                        int *pitch);
slouken@2753
    88
    void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
slouken@2753
    89
    void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@2753
    90
                          int numrects, const SDL_Rect * rects);
slouken@2753
    91
    int (*RenderFill) (SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
slouken@2753
    92
                       Uint8 a, const SDL_Rect * rect);
slouken@2753
    93
    int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
slouken@2753
    94
                       const SDL_Rect * srcrect, const SDL_Rect * dstrect);
slouken@2753
    95
    void (*RenderPresent) (SDL_Renderer * renderer);
slouken@2753
    96
    void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
slouken@1895
    97
slouken@2753
    98
    void (*DestroyRenderer) (SDL_Renderer * renderer);
slouken@1895
    99
slouken@2753
   100
    /* The current renderer info */
slouken@2753
   101
    SDL_RendererInfo info;
slouken@1895
   102
slouken@2753
   103
    /* The window associated with the renderer */
slouken@2753
   104
    SDL_WindowID window;
slouken@1895
   105
slouken@2753
   106
    void *driverdata;
slouken@1895
   107
};
slouken@1895
   108
slouken@1895
   109
/* Define the SDL render driver structure */
slouken@2753
   110
struct SDL_RenderDriver
slouken@2753
   111
{
slouken@2753
   112
    SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
slouken@1895
   113
slouken@2753
   114
    /* Info about the renderer capabilities */
slouken@2753
   115
    SDL_RendererInfo info;
slouken@1895
   116
};
slouken@1895
   117
slouken@1895
   118
/* Define the SDL window structure, corresponding to toplevel windows */
slouken@2753
   119
struct SDL_Window
slouken@2753
   120
{
slouken@2753
   121
    Uint32 id;
slouken@1895
   122
slouken@2753
   123
    char *title;
slouken@2753
   124
    int x, y;
slouken@2753
   125
    int w, h;
slouken@2753
   126
    Uint32 flags;
slouken@1895
   127
slouken@2753
   128
    int display;
slouken@2753
   129
    SDL_Renderer *renderer;
slouken@1895
   130
slouken@2753
   131
    void *userdata;
slouken@2753
   132
    void *driverdata;
slouken@1895
   133
};
slouken@1895
   134
#define FULLSCREEN_VISIBLE(W) \
slouken@1895
   135
    (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
slouken@1895
   136
     ((W)->flags & SDL_WINDOW_SHOWN) && \
slouken@1895
   137
     !((W)->flags & SDL_WINDOW_MINIMIZED))
slouken@1895
   138
hfutrell@2742
   139
/*
hfutrell@2742
   140
 * Define the SDL display structure This corresponds to physical monitors
hfutrell@2742
   141
 * attached to the system.
slouken@1895
   142
 */
slouken@2753
   143
struct SDL_VideoDisplay
slouken@2753
   144
{
slouken@2753
   145
    int max_display_modes;
slouken@2753
   146
    int num_display_modes;
slouken@2753
   147
    SDL_DisplayMode *display_modes;
slouken@2753
   148
    SDL_DisplayMode desktop_mode;
slouken@2753
   149
    SDL_DisplayMode current_mode;
slouken@2753
   150
    SDL_DisplayMode fullscreen_mode;
slouken@2753
   151
    SDL_Palette *palette;
slouken@1895
   152
slouken@2753
   153
    Uint16 *gamma;
slouken@2753
   154
    Uint16 *saved_gamma;        /* (just offset into gamma) */
slouken@1895
   155
slouken@2753
   156
    int num_render_drivers;
slouken@2753
   157
    SDL_RenderDriver *render_drivers;
slouken@1895
   158
slouken@2753
   159
    int num_windows;
slouken@2753
   160
    SDL_Window *windows;
slouken@1895
   161
slouken@2753
   162
    SDL_Renderer *current_renderer;
slouken@1895
   163
slouken@2753
   164
    /* The hash list of textures */
slouken@2753
   165
    SDL_Texture *textures[64];
slouken@1895
   166
slouken@2753
   167
    SDL_VideoDevice *device;
slouken@1895
   168
slouken@2753
   169
    void *driverdata;
slouken@1895
   170
};
slouken@1895
   171
slouken@0
   172
/* Define the SDL video driver structure */
slouken@0
   173
#define _THIS	SDL_VideoDevice *_this
slouken@0
   174
slouken@2753
   175
struct SDL_VideoDevice
slouken@2753
   176
{
slouken@2753
   177
    /* * * */
slouken@2753
   178
    /* The name of this video driver */
slouken@2753
   179
    const char *name;
slouken@0
   180
slouken@2753
   181
    /* * * */
slouken@2753
   182
    /* Initialization/Query functions */
slouken@0
   183
slouken@2753
   184
    /*
slouken@2753
   185
     * Initialize the native video subsystem, filling in the list of
slouken@2753
   186
     * displays for this driver, returning 0 or -1 if there's an error.
slouken@2753
   187
     */
slouken@2753
   188
    int (*VideoInit) (_THIS);
slouken@0
   189
slouken@2753
   190
    /*
slouken@2753
   191
     * Reverse the effects VideoInit() -- called if VideoInit() fails or
slouken@2753
   192
     * if the application is shutting down the video subsystem.
slouken@2753
   193
     */
slouken@2753
   194
    void (*VideoQuit) (_THIS);
slouken@1913
   195
slouken@2753
   196
    /* * * */
slouken@2753
   197
    /*
slouken@2753
   198
     * Display functions
slouken@2753
   199
     */
slouken@0
   200
slouken@2753
   201
    /*
slouken@2753
   202
     * Get a list of the available display modes. e.g.
slouken@2753
   203
     * SDL_AddDisplayMode(_this->current_display, mode)
slouken@2753
   204
     */
slouken@2753
   205
    void (*GetDisplayModes) (_THIS);
slouken@0
   206
slouken@2753
   207
    /*
slouken@2753
   208
     * Setting the display mode is independent of creating windows, so
slouken@2753
   209
     * when the display mode is changed, all existing windows should have
slouken@2753
   210
     * their data updated accordingly, including the display surfaces
slouken@2753
   211
     * associated with them.
slouken@2753
   212
     */
slouken@2753
   213
    int (*SetDisplayMode) (_THIS, SDL_DisplayMode * mode);
slouken@0
   214
slouken@2753
   215
    /* Set the color entries of the display palette */
slouken@2753
   216
    int (*SetDisplayPalette) (_THIS, SDL_Palette * palette);
slouken@0
   217
slouken@2753
   218
    /* Get the color entries of the display palette */
slouken@2753
   219
    int (*GetDisplayPalette) (_THIS, SDL_Palette * palette);
slouken@0
   220
slouken@2753
   221
    /* Set the gamma ramp */
slouken@2753
   222
    int (*SetDisplayGammaRamp) (_THIS, Uint16 * ramp);
slouken@0
   223
slouken@2753
   224
    /* Get the gamma ramp */
slouken@2753
   225
    int (*GetDisplayGammaRamp) (_THIS, Uint16 * ramp);
slouken@0
   226
slouken@2753
   227
    /* * * */
slouken@2753
   228
    /*
slouken@2753
   229
     * Window functions
slouken@2753
   230
     */
slouken@2753
   231
    int (*CreateWindow) (_THIS, SDL_Window * window);
slouken@2753
   232
    int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
slouken@2753
   233
    void (*SetWindowTitle) (_THIS, SDL_Window * window);
slouken@2753
   234
    void (*SetWindowPosition) (_THIS, SDL_Window * window);
slouken@2753
   235
    void (*SetWindowSize) (_THIS, SDL_Window * window);
slouken@2753
   236
    void (*ShowWindow) (_THIS, SDL_Window * window);
slouken@2753
   237
    void (*HideWindow) (_THIS, SDL_Window * window);
slouken@2753
   238
    void (*RaiseWindow) (_THIS, SDL_Window * window);
slouken@2753
   239
    void (*MaximizeWindow) (_THIS, SDL_Window * window);
slouken@2753
   240
    void (*MinimizeWindow) (_THIS, SDL_Window * window);
slouken@2753
   241
    void (*RestoreWindow) (_THIS, SDL_Window * window);
slouken@2753
   242
    void (*SetWindowGrab) (_THIS, SDL_Window * window);
slouken@2753
   243
    void (*DestroyWindow) (_THIS, SDL_Window * window);
slouken@0
   244
slouken@2753
   245
    /* Get some platform dependent window information */
slouken@2753
   246
      SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
slouken@2753
   247
                                  struct SDL_SysWMinfo * info);
slouken@0
   248
slouken@2753
   249
    /* * * */
slouken@2753
   250
    /*
slouken@2753
   251
     * OpenGL support
slouken@2753
   252
     */
slouken@2753
   253
    int (*GL_LoadLibrary) (_THIS, const char *path);
slouken@2753
   254
    void *(*GL_GetProcAddress) (_THIS, const char *proc);
slouken@2753
   255
      SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
slouken@2753
   256
    int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
slouken@2753
   257
    int (*GL_SetSwapInterval) (_THIS, int interval);
slouken@2753
   258
    int (*GL_GetSwapInterval) (_THIS);
slouken@2753
   259
    void (*GL_SwapWindow) (_THIS, SDL_Window * window);
slouken@2753
   260
    void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
slouken@0
   261
slouken@2753
   262
    /* * * */
slouken@2753
   263
    /*
slouken@2753
   264
     * Event manager functions
slouken@2753
   265
     */
slouken@2753
   266
    void (*PumpEvents) (_THIS);
slouken@0
   267
slouken@2753
   268
    /* * * */
slouken@2753
   269
    /* Data common to all drivers */
slouken@2753
   270
    int num_displays;
slouken@2753
   271
    SDL_VideoDisplay *displays;
slouken@2753
   272
    int current_display;
slouken@2753
   273
    Uint32 next_object_id;
slouken@0
   274
slouken@2753
   275
    /* * * */
slouken@2753
   276
    /* Data used by the GL drivers */
slouken@2753
   277
    struct
slouken@2753
   278
    {
slouken@2753
   279
        int red_size;
slouken@2753
   280
        int green_size;
slouken@2753
   281
        int blue_size;
slouken@2753
   282
        int alpha_size;
slouken@2753
   283
        int depth_size;
slouken@2753
   284
        int buffer_size;
slouken@2753
   285
        int stencil_size;
slouken@2753
   286
        int double_buffer;
slouken@2753
   287
        int accum_red_size;
slouken@2753
   288
        int accum_green_size;
slouken@2753
   289
        int accum_blue_size;
slouken@2753
   290
        int accum_alpha_size;
slouken@2753
   291
        int stereo;
slouken@2753
   292
        int multisamplebuffers;
slouken@2753
   293
        int multisamplesamples;
slouken@2753
   294
        int accelerated;
slouken@2753
   295
        int retained_backing;
slouken@2753
   296
        int driver_loaded;
slouken@2753
   297
        char driver_path[256];
slouken@2753
   298
        void *dll_handle;
slouken@2753
   299
    } gl_config;
slouken@0
   300
slouken@2753
   301
    /* * * */
slouken@2753
   302
    /* Data private to this driver */
slouken@2753
   303
    void *driverdata;
slouken@2753
   304
    struct SDL_GLDriverData *gl_data;
slouken@0
   305
slouken@2753
   306
    /* * * */
slouken@2753
   307
    /* The function used to dispose of this structure */
slouken@2753
   308
    void (*free) (_THIS);
slouken@1895
   309
};
slouken@0
   310
slouken@2753
   311
typedef struct VideoBootStrap
slouken@2753
   312
{
slouken@2753
   313
    const char *name;
slouken@2753
   314
    const char *desc;
slouken@2753
   315
    int (*available) (void);
slouken@2753
   316
    SDL_VideoDevice *(*create) (int devindex);
slouken@2753
   317
} VideoBootStrap;
slouken@0
   318
slouken@1931
   319
#if SDL_VIDEO_DRIVER_COCOA
slouken@1931
   320
extern VideoBootStrap COCOA_bootstrap;
slouken@1361
   321
#endif
slouken@1361
   322
#if SDL_VIDEO_DRIVER_X11
slouken@0
   323
extern VideoBootStrap X11_bootstrap;
slouken@0
   324
#endif
slouken@1361
   325
#if SDL_VIDEO_DRIVER_NANOX
slouken@30
   326
extern VideoBootStrap NX_bootstrap;
slouken@30
   327
#endif
slouken@1361
   328
#if SDL_VIDEO_DRIVER_IPOD
icculus@1140
   329
extern VideoBootStrap iPod_bootstrap;
icculus@1140
   330
#endif
slouken@1361
   331
#if SDL_VIDEO_DRIVER_WSCONS
slouken@1361
   332
extern VideoBootStrap WSCONS_bootstrap;
slouken@1361
   333
#endif
slouken@1361
   334
#if SDL_VIDEO_DRIVER_FBCON
slouken@0
   335
extern VideoBootStrap FBCON_bootstrap;
slouken@0
   336
#endif
slouken@1361
   337
#if SDL_VIDEO_DRIVER_DIRECTFB
slouken@167
   338
extern VideoBootStrap DirectFB_bootstrap;
slouken@167
   339
#endif
slouken@1361
   340
#if SDL_VIDEO_DRIVER_PS2GS
slouken@0
   341
extern VideoBootStrap PS2GS_bootstrap;
slouken@0
   342
#endif
slouken@1361
   343
#if SDL_VIDEO_DRIVER_VGL
slouken@75
   344
extern VideoBootStrap VGL_bootstrap;
slouken@75
   345
#endif
slouken@1361
   346
#if SDL_VIDEO_DRIVER_SVGALIB
slouken@0
   347
extern VideoBootStrap SVGALIB_bootstrap;
slouken@0
   348
#endif
slouken@1361
   349
#if SDL_VIDEO_DRIVER_GAPI
slouken@1361
   350
extern VideoBootStrap GAPI_bootstrap;
slouken@1361
   351
#endif
slouken@1895
   352
#if SDL_VIDEO_DRIVER_WIN32
slouken@1895
   353
extern VideoBootStrap WIN32_bootstrap;
slouken@1361
   354
#endif
slouken@1361
   355
#if SDL_VIDEO_DRIVER_BWINDOW
slouken@1361
   356
extern VideoBootStrap BWINDOW_bootstrap;
slouken@1361
   357
#endif
slouken@1361
   358
#if SDL_VIDEO_DRIVER_PHOTON
slouken@1361
   359
extern VideoBootStrap ph_bootstrap;
slouken@1361
   360
#endif
slouken@1361
   361
#if SDL_VIDEO_DRIVER_EPOC
slouken@1361
   362
extern VideoBootStrap EPOC_bootstrap;
slouken@1361
   363
#endif
slouken@1361
   364
#if SDL_VIDEO_DRIVER_XBIOS
slouken@1361
   365
extern VideoBootStrap XBIOS_bootstrap;
slouken@1361
   366
#endif
slouken@1361
   367
#if SDL_VIDEO_DRIVER_GEM
slouken@1361
   368
extern VideoBootStrap GEM_bootstrap;
slouken@1361
   369
#endif
slouken@1361
   370
#if SDL_VIDEO_DRIVER_DC
slouken@1361
   371
extern VideoBootStrap DC_bootstrap;
slouken@1361
   372
#endif
slouken@1361
   373
#if SDL_VIDEO_DRIVER_RISCOS
slouken@1361
   374
extern VideoBootStrap RISCOS_bootstrap;
slouken@1361
   375
#endif
slouken@1361
   376
#if SDL_VIDEO_DRIVER_OS2FS
slouken@1361
   377
extern VideoBootStrap OS2FSLib_bootstrap;
slouken@1361
   378
#endif
hfutrell@2742
   379
#if SDL_VIDEO_DRIVER_UIKIT
hfutrell@2742
   380
extern VideoBootStrap UIKIT_bootstrap;
hfutrell@2742
   381
#endif
slouken@1361
   382
#if SDL_VIDEO_DRIVER_DUMMY
slouken@173
   383
extern VideoBootStrap DUMMY_bootstrap;
slouken@173
   384
#endif
slouken@2735
   385
#if SDL_VIDEO_DRIVER_NDS
slouken@2735
   386
extern VideoBootStrap NDS_bootstrap;
slouken@2735
   387
#endif
slouken@1361
   388
slouken@1895
   389
#define SDL_CurrentDisplay	(_this->displays[_this->current_display])
slouken@0
   390
slouken@1895
   391
extern SDL_VideoDevice *SDL_GetVideoDevice();
slouken@2753
   392
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
slouken@2753
   393
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
slouken@2753
   394
extern SDL_bool
slouken@2753
   395
SDL_AddDisplayMode(int displayIndex, const SDL_DisplayMode * mode);
slouken@2753
   396
extern void
slouken@2753
   397
SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver);
slouken@1895
   398
slouken@2753
   399
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
slouken@1895
   400
extern SDL_Window *SDL_GetWindowFromID(SDL_WindowID windowID);
slouken@1895
   401
extern SDL_VideoDisplay *SDL_GetDisplayFromWindow(SDL_Window * window);
slouken@1895
   402
slouken@2753
   403
extern void SDL_OnWindowShown(SDL_Window * window);
slouken@2753
   404
extern void SDL_OnWindowHidden(SDL_Window * window);
slouken@2753
   405
extern void SDL_OnWindowResized(SDL_Window * window);
slouken@2753
   406
extern void SDL_OnWindowFocusGained(SDL_Window * window);
slouken@2753
   407
extern void SDL_OnWindowFocusLost(SDL_Window * window);
slouken@1895
   408
extern SDL_WindowID SDL_GetFocusWindow(void);
slouken@0
   409
slouken@2753
   410
#endif /* _SDL_sysvideo_h */
slouken@1895
   411
slouken@1895
   412
/* vi: set ts=4 sw=4 expandtab: */