src/video/SDL_sysvideo.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 02 Feb 2011 14:34:54 -0800
changeset 5154 fb424691cfc7
parent 5150 1435f8a6425c
child 5165 2b1989f59674
permissions -rw-r--r--
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@3697
     3
    Copyright (C) 1997-2010 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
eligottlieb@4782
    27
#include "SDL_shape.h"
slouken@0
    28
slouken@0
    29
/* The SDL video driver */
slouken@1895
    30
eligottlieb@4782
    31
typedef struct SDL_WindowShaper SDL_WindowShaper;
eligottlieb@4782
    32
typedef struct SDL_ShapeDriver SDL_ShapeDriver;
slouken@1895
    33
typedef struct SDL_VideoDisplay SDL_VideoDisplay;
slouken@0
    34
typedef struct SDL_VideoDevice SDL_VideoDevice;
slouken@0
    35
eligottlieb@4782
    36
/* Define the SDL window-shaper structure */
eligottlieb@4782
    37
struct SDL_WindowShaper
eligottlieb@4782
    38
{   
eligottlieb@4782
    39
    /* The window associated with the shaper */
eligottlieb@4782
    40
    SDL_Window *window;
eligottlieb@4782
    41
    
eligottlieb@4851
    42
    /* The user's specified coordinates for the window, for once we give it a shape. */
eligottlieb@4851
    43
    Uint32 userx,usery;
eligottlieb@4782
    44
    
eligottlieb@4807
    45
    /* The parameters for shape calculation. */
eligottlieb@4807
    46
    SDL_WindowShapeMode mode;
eligottlieb@4782
    47
    
eligottlieb@4782
    48
    /* Has this window been assigned a shape? */
eligottlieb@4782
    49
    SDL_bool hasshape;
eligottlieb@4782
    50
    
eligottlieb@4782
    51
    void *driverdata;
eligottlieb@4782
    52
};
eligottlieb@4782
    53
eligottlieb@4782
    54
/* Define the SDL shape driver structure */
eligottlieb@4782
    55
struct SDL_ShapeDriver
eligottlieb@4782
    56
{
eligottlieb@4782
    57
    SDL_WindowShaper *(*CreateShaper)(SDL_Window * window);
egottlieb@4849
    58
    int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
eligottlieb@4782
    59
    int (*ResizeWindowShape)(SDL_Window *window);
eligottlieb@4782
    60
};
eligottlieb@4782
    61
slouken@1895
    62
/* Define the SDL window structure, corresponding to toplevel windows */
slouken@2753
    63
struct SDL_Window
slouken@2753
    64
{
slouken@3695
    65
    const void *magic;
slouken@2753
    66
    Uint32 id;
slouken@2753
    67
    char *title;
slouken@2753
    68
    int x, y;
slouken@2753
    69
    int w, h;
slouken@2753
    70
    Uint32 flags;
slouken@1895
    71
slouken@3685
    72
    SDL_VideoDisplay *display;
slouken@1895
    73
slouken@3500
    74
    SDL_DisplayMode fullscreen_mode;
eligottlieb@4782
    75
    
eligottlieb@4782
    76
    SDL_WindowShaper *shaper;
slouken@3500
    77
slouken@2753
    78
    void *userdata;
slouken@2753
    79
    void *driverdata;
slouken@3685
    80
slouken@3685
    81
    SDL_Window *prev;
slouken@3685
    82
    SDL_Window *next;
slouken@1895
    83
};
slouken@1895
    84
#define FULLSCREEN_VISIBLE(W) \
slouken@1895
    85
    (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
slouken@1895
    86
     ((W)->flags & SDL_WINDOW_SHOWN) && \
slouken@1895
    87
     !((W)->flags & SDL_WINDOW_MINIMIZED))
slouken@1895
    88
hfutrell@2742
    89
/*
hfutrell@2742
    90
 * Define the SDL display structure This corresponds to physical monitors
hfutrell@2742
    91
 * attached to the system.
slouken@1895
    92
 */
slouken@2753
    93
struct SDL_VideoDisplay
slouken@2753
    94
{
slouken@2753
    95
    int max_display_modes;
slouken@2753
    96
    int num_display_modes;
slouken@2753
    97
    SDL_DisplayMode *display_modes;
slouken@2753
    98
    SDL_DisplayMode desktop_mode;
slouken@2753
    99
    SDL_DisplayMode current_mode;
slouken@3502
   100
    SDL_bool updating_fullscreen;
slouken@1895
   101
slouken@2753
   102
    Uint16 *gamma;
slouken@2753
   103
    Uint16 *saved_gamma;        /* (just offset into gamma) */
slouken@1895
   104
slouken@2753
   105
    SDL_Window *windows;
slouken@3517
   106
    SDL_Window *fullscreen_window;
slouken@1895
   107
slouken@2753
   108
    SDL_VideoDevice *device;
slouken@1895
   109
slouken@2753
   110
    void *driverdata;
slouken@1895
   111
};
slouken@1895
   112
slouken@0
   113
/* Define the SDL video driver structure */
slouken@0
   114
#define _THIS	SDL_VideoDevice *_this
slouken@0
   115
slouken@2753
   116
struct SDL_VideoDevice
slouken@2753
   117
{
slouken@2753
   118
    /* * * */
slouken@2753
   119
    /* The name of this video driver */
slouken@2753
   120
    const char *name;
slouken@0
   121
slouken@2753
   122
    /* * * */
slouken@2753
   123
    /* Initialization/Query functions */
slouken@0
   124
slouken@2753
   125
    /*
slouken@2753
   126
     * Initialize the native video subsystem, filling in the list of
slouken@2753
   127
     * displays for this driver, returning 0 or -1 if there's an error.
slouken@2753
   128
     */
slouken@2753
   129
    int (*VideoInit) (_THIS);
slouken@0
   130
slouken@2753
   131
    /*
slouken@2753
   132
     * Reverse the effects VideoInit() -- called if VideoInit() fails or
slouken@2753
   133
     * if the application is shutting down the video subsystem.
slouken@2753
   134
     */
slouken@2753
   135
    void (*VideoQuit) (_THIS);
slouken@1913
   136
slouken@2753
   137
    /* * * */
slouken@2753
   138
    /*
slouken@2753
   139
     * Display functions
slouken@2753
   140
     */
slouken@0
   141
slouken@2753
   142
    /*
slouken@3528
   143
     * Get the bounds of a display
slouken@3528
   144
     */
slouken@3528
   145
    int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
slouken@3528
   146
slouken@3528
   147
    /*
slouken@2753
   148
     * Get a list of the available display modes. e.g.
slouken@2753
   149
     * SDL_AddDisplayMode(_this->current_display, mode)
slouken@2753
   150
     */
slouken@3500
   151
    void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
slouken@0
   152
slouken@2753
   153
    /*
slouken@2753
   154
     * Setting the display mode is independent of creating windows, so
slouken@2753
   155
     * when the display mode is changed, all existing windows should have
slouken@2753
   156
     * their data updated accordingly, including the display surfaces
slouken@2753
   157
     * associated with them.
slouken@2753
   158
     */
slouken@3500
   159
    int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
slouken@0
   160
slouken@2753
   161
    /* Set the gamma ramp */
slouken@3500
   162
    int (*SetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
slouken@0
   163
slouken@2753
   164
    /* Get the gamma ramp */
slouken@3500
   165
    int (*GetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
slouken@0
   166
slouken@2753
   167
    /* * * */
slouken@2753
   168
    /*
slouken@2753
   169
     * Window functions
slouken@2753
   170
     */
slouken@2753
   171
    int (*CreateWindow) (_THIS, SDL_Window * window);
slouken@2753
   172
    int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
slouken@2753
   173
    void (*SetWindowTitle) (_THIS, SDL_Window * window);
slouken@2967
   174
    void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
slouken@2753
   175
    void (*SetWindowPosition) (_THIS, SDL_Window * window);
slouken@2753
   176
    void (*SetWindowSize) (_THIS, SDL_Window * window);
slouken@2753
   177
    void (*ShowWindow) (_THIS, SDL_Window * window);
slouken@2753
   178
    void (*HideWindow) (_THIS, SDL_Window * window);
slouken@2753
   179
    void (*RaiseWindow) (_THIS, SDL_Window * window);
slouken@2753
   180
    void (*MaximizeWindow) (_THIS, SDL_Window * window);
slouken@2753
   181
    void (*MinimizeWindow) (_THIS, SDL_Window * window);
slouken@2753
   182
    void (*RestoreWindow) (_THIS, SDL_Window * window);
slouken@2753
   183
    void (*SetWindowGrab) (_THIS, SDL_Window * window);
slouken@2753
   184
    void (*DestroyWindow) (_THIS, SDL_Window * window);
eligottlieb@4782
   185
    
eligottlieb@4782
   186
    /* * * */
eligottlieb@4782
   187
    /*
eligottlieb@4782
   188
     * Shaped-window functions
eligottlieb@4782
   189
     */
eligottlieb@4782
   190
    SDL_ShapeDriver shape_driver;
slouken@0
   191
slouken@2753
   192
    /* Get some platform dependent window information */
slouken@2753
   193
      SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
slouken@2753
   194
                                  struct SDL_SysWMinfo * info);
slouken@0
   195
slouken@2753
   196
    /* * * */
slouken@2753
   197
    /*
slouken@2753
   198
     * OpenGL support
slouken@2753
   199
     */
slouken@2753
   200
    int (*GL_LoadLibrary) (_THIS, const char *path);
slouken@2753
   201
    void *(*GL_GetProcAddress) (_THIS, const char *proc);
slouken@3057
   202
    void (*GL_UnloadLibrary) (_THIS);
slouken@2753
   203
      SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
slouken@2753
   204
    int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
slouken@2753
   205
    int (*GL_SetSwapInterval) (_THIS, int interval);
slouken@2753
   206
    int (*GL_GetSwapInterval) (_THIS);
slouken@2753
   207
    void (*GL_SwapWindow) (_THIS, SDL_Window * window);
slouken@2753
   208
    void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
slouken@0
   209
slouken@2753
   210
    /* * * */
slouken@2753
   211
    /*
slouken@2753
   212
     * Event manager functions
slouken@2753
   213
     */
slouken@2753
   214
    void (*PumpEvents) (_THIS);
slouken@0
   215
slouken@3025
   216
    /* Suspend the screensaver */
slouken@3025
   217
    void (*SuspendScreenSaver) (_THIS);
slouken@3025
   218
slouken@3280
   219
    /* Text input */
slouken@3280
   220
    void (*StartTextInput) (_THIS);
slouken@3280
   221
    void (*StopTextInput) (_THIS);
slouken@3280
   222
    void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
slouken@3280
   223
slouken@4495
   224
    /* Clipboard */
slouken@4495
   225
    int (*SetClipboardText) (_THIS, const char *text);
slouken@4495
   226
    char * (*GetClipboardText) (_THIS);
slouken@4495
   227
    SDL_bool (*HasClipboardText) (_THIS);
slouken@4495
   228
slouken@2753
   229
    /* * * */
slouken@2753
   230
    /* Data common to all drivers */
slouken@3025
   231
    SDL_bool suspend_screensaver;
slouken@2753
   232
    int num_displays;
slouken@2753
   233
    SDL_VideoDisplay *displays;
slouken@2753
   234
    int current_display;
slouken@3695
   235
    Uint8 window_magic;
slouken@2753
   236
    Uint32 next_object_id;
slouken@4495
   237
    char * clipboard_text;
slouken@0
   238
slouken@2753
   239
    /* * * */
slouken@2753
   240
    /* Data used by the GL drivers */
slouken@2753
   241
    struct
slouken@2753
   242
    {
slouken@2753
   243
        int red_size;
slouken@2753
   244
        int green_size;
slouken@2753
   245
        int blue_size;
slouken@2753
   246
        int alpha_size;
slouken@2753
   247
        int depth_size;
slouken@2753
   248
        int buffer_size;
slouken@2753
   249
        int stencil_size;
slouken@2753
   250
        int double_buffer;
slouken@2753
   251
        int accum_red_size;
slouken@2753
   252
        int accum_green_size;
slouken@2753
   253
        int accum_blue_size;
slouken@2753
   254
        int accum_alpha_size;
slouken@2753
   255
        int stereo;
slouken@2753
   256
        int multisamplebuffers;
slouken@2753
   257
        int multisamplesamples;
slouken@2753
   258
        int accelerated;
slouken@3100
   259
        int major_version;
slouken@3100
   260
        int minor_version;
slouken@2753
   261
        int retained_backing;
slouken@2753
   262
        int driver_loaded;
slouken@2753
   263
        char driver_path[256];
slouken@2753
   264
        void *dll_handle;
slouken@2753
   265
    } gl_config;
slouken@0
   266
slouken@2753
   267
    /* * * */
slouken@2753
   268
    /* Data private to this driver */
slouken@2753
   269
    void *driverdata;
slouken@2753
   270
    struct SDL_GLDriverData *gl_data;
slouken@0
   271
slouken@3161
   272
#if SDL_VIDEO_DRIVER_PANDORA
slouken@3161
   273
    struct SDL_PrivateGLESData *gles_data;
slouken@3161
   274
#endif
slouken@3161
   275
slouken@2753
   276
    /* * * */
slouken@2753
   277
    /* The function used to dispose of this structure */
slouken@2753
   278
    void (*free) (_THIS);
slouken@1895
   279
};
slouken@0
   280
slouken@2753
   281
typedef struct VideoBootStrap
slouken@2753
   282
{
slouken@2753
   283
    const char *name;
slouken@2753
   284
    const char *desc;
slouken@2753
   285
    int (*available) (void);
slouken@2753
   286
    SDL_VideoDevice *(*create) (int devindex);
slouken@2753
   287
} VideoBootStrap;
slouken@0
   288
slouken@1931
   289
#if SDL_VIDEO_DRIVER_COCOA
slouken@1931
   290
extern VideoBootStrap COCOA_bootstrap;
slouken@1361
   291
#endif
slouken@1361
   292
#if SDL_VIDEO_DRIVER_X11
slouken@0
   293
extern VideoBootStrap X11_bootstrap;
slouken@0
   294
#endif
slouken@1361
   295
#if SDL_VIDEO_DRIVER_DIRECTFB
slouken@167
   296
extern VideoBootStrap DirectFB_bootstrap;
slouken@167
   297
#endif
slouken@5062
   298
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@5062
   299
extern VideoBootStrap WINDOWS_bootstrap;
slouken@1361
   300
#endif
slouken@1361
   301
#if SDL_VIDEO_DRIVER_BWINDOW
slouken@1361
   302
extern VideoBootStrap BWINDOW_bootstrap;
slouken@1361
   303
#endif
slouken@5150
   304
#if SDL_VIDEO_DRIVER_PANDORA
slouken@5150
   305
extern VideoBootStrap PND_bootstrap;
slouken@3083
   306
#endif
slouken@5150
   307
#if SDL_VIDEO_DRIVER_NDS
slouken@5150
   308
extern VideoBootStrap NDS_bootstrap;
slouken@1361
   309
#endif
hfutrell@2742
   310
#if SDL_VIDEO_DRIVER_UIKIT
hfutrell@2742
   311
extern VideoBootStrap UIKIT_bootstrap;
hfutrell@2742
   312
#endif
slouken@5150
   313
#if SDL_VIDEO_DRIVER_ANDROID
slouken@5150
   314
extern VideoBootStrap Android_bootstrap;
slouken@5150
   315
#endif
slouken@1361
   316
#if SDL_VIDEO_DRIVER_DUMMY
slouken@173
   317
extern VideoBootStrap DUMMY_bootstrap;
slouken@173
   318
#endif
slouken@1361
   319
slouken@3685
   320
#define SDL_CurrentDisplay	(&_this->displays[_this->current_display])
slouken@0
   321
slouken@4472
   322
extern SDL_VideoDevice *SDL_GetVideoDevice(void);
slouken@2753
   323
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
slouken@2753
   324
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
slouken@3500
   325
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
slouken@3500
   326
extern int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display);
slouken@3500
   327
extern int SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode);
slouken@3500
   328
extern int SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
slouken@3500
   329
extern int SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
slouken@3500
   330
extern SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
slouken@3500
   331
extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode);
slouken@3500
   332
extern int SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue);
slouken@3500
   333
extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue);
slouken@1895
   334
slouken@2753
   335
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
slouken@1895
   336
slouken@2753
   337
extern void SDL_OnWindowShown(SDL_Window * window);
slouken@2753
   338
extern void SDL_OnWindowHidden(SDL_Window * window);
slouken@3502
   339
extern void SDL_OnWindowMinimized(SDL_Window * window);
slouken@3502
   340
extern void SDL_OnWindowRestored(SDL_Window * window);
slouken@2753
   341
extern void SDL_OnWindowFocusGained(SDL_Window * window);
slouken@2753
   342
extern void SDL_OnWindowFocusLost(SDL_Window * window);
slouken@3685
   343
extern SDL_Window * SDL_GetFocusWindow(void);
slouken@0
   344
slouken@2753
   345
#endif /* _SDL_sysvideo_h */
slouken@1895
   346
slouken@1895
   347
/* vi: set ts=4 sw=4 expandtab: */