src/video/SDL_sysvideo.h
author DavidLudwig <dludwig@pobox.com>
Sun, 04 Nov 2012 09:46:59 -0500
changeset 8337 4a67a3cca43d
parent 8327 bc51589f33dc
parent 6602 533131e24aeb
child 8340 e470405f3ae9
permissions -rw-r--r--
Merge with latest, official SDL code
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6138
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
slouken@0
     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@0
     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@0
    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@0
    20
*/
slouken@1402
    21
#include "SDL_config.h"
slouken@0
    22
slouken@0
    23
#ifndef _SDL_sysvideo_h
slouken@0
    24
#define _SDL_sysvideo_h
slouken@0
    25
slouken@6602
    26
#include "SDL_messagebox.h"
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@5165
    62
typedef struct SDL_WindowUserData
slouken@5165
    63
{
slouken@5165
    64
    char *name;
slouken@5165
    65
    void *data;
slouken@5165
    66
    struct SDL_WindowUserData *next;
slouken@5165
    67
} SDL_WindowUserData;
slouken@5165
    68
slouken@1895
    69
/* Define the SDL window structure, corresponding to toplevel windows */
slouken@2753
    70
struct SDL_Window
slouken@2753
    71
{
slouken@3695
    72
    const void *magic;
slouken@2753
    73
    Uint32 id;
slouken@2753
    74
    char *title;
slouken@2753
    75
    int x, y;
slouken@2753
    76
    int w, h;
slouken@2753
    77
    Uint32 flags;
slouken@1895
    78
slouken@5398
    79
    /* Stored position and size for windowed mode */
slouken@5398
    80
    SDL_Rect windowed;
slouken@5398
    81
slouken@3500
    82
    SDL_DisplayMode fullscreen_mode;
eligottlieb@4782
    83
    
slouken@5466
    84
    float brightness;
slouken@5466
    85
    Uint16 *gamma;
slouken@5466
    86
    Uint16 *saved_gamma;        /* (just offset into gamma) */
slouken@5466
    87
slouken@5166
    88
    SDL_Surface *surface;
slouken@5174
    89
    SDL_bool surface_valid;
slouken@5166
    90
eligottlieb@4782
    91
    SDL_WindowShaper *shaper;
slouken@3500
    92
slouken@5165
    93
    SDL_WindowUserData *data;
slouken@5165
    94
slouken@2753
    95
    void *driverdata;
slouken@3685
    96
slouken@3685
    97
    SDL_Window *prev;
slouken@3685
    98
    SDL_Window *next;
slouken@1895
    99
};
slouken@1895
   100
#define FULLSCREEN_VISIBLE(W) \
slouken@1895
   101
    (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
slouken@1895
   102
     ((W)->flags & SDL_WINDOW_SHOWN) && \
slouken@1895
   103
     !((W)->flags & SDL_WINDOW_MINIMIZED))
slouken@1895
   104
hfutrell@2742
   105
/*
hfutrell@2742
   106
 * Define the SDL display structure This corresponds to physical monitors
hfutrell@2742
   107
 * attached to the system.
slouken@1895
   108
 */
slouken@2753
   109
struct SDL_VideoDisplay
slouken@2753
   110
{
slouken@2753
   111
    int max_display_modes;
slouken@2753
   112
    int num_display_modes;
slouken@2753
   113
    SDL_DisplayMode *display_modes;
slouken@2753
   114
    SDL_DisplayMode desktop_mode;
slouken@2753
   115
    SDL_DisplayMode current_mode;
slouken@1895
   116
slouken@3517
   117
    SDL_Window *fullscreen_window;
slouken@1895
   118
slouken@2753
   119
    SDL_VideoDevice *device;
slouken@1895
   120
slouken@2753
   121
    void *driverdata;
slouken@1895
   122
};
slouken@1895
   123
slouken@5272
   124
/* Forward declaration */
slouken@5272
   125
struct SDL_SysWMinfo;
slouken@5272
   126
slouken@0
   127
/* Define the SDL video driver structure */
slouken@0
   128
#define _THIS	SDL_VideoDevice *_this
slouken@0
   129
slouken@2753
   130
struct SDL_VideoDevice
slouken@2753
   131
{
slouken@2753
   132
    /* * * */
slouken@2753
   133
    /* The name of this video driver */
slouken@2753
   134
    const char *name;
slouken@0
   135
slouken@2753
   136
    /* * * */
slouken@2753
   137
    /* Initialization/Query functions */
slouken@0
   138
slouken@2753
   139
    /*
slouken@2753
   140
     * Initialize the native video subsystem, filling in the list of
slouken@2753
   141
     * displays for this driver, returning 0 or -1 if there's an error.
slouken@2753
   142
     */
slouken@2753
   143
    int (*VideoInit) (_THIS);
slouken@0
   144
slouken@2753
   145
    /*
slouken@2753
   146
     * Reverse the effects VideoInit() -- called if VideoInit() fails or
slouken@2753
   147
     * if the application is shutting down the video subsystem.
slouken@2753
   148
     */
slouken@2753
   149
    void (*VideoQuit) (_THIS);
slouken@1913
   150
slouken@2753
   151
    /* * * */
slouken@2753
   152
    /*
slouken@2753
   153
     * Display functions
slouken@2753
   154
     */
slouken@0
   155
slouken@2753
   156
    /*
slouken@3528
   157
     * Get the bounds of a display
slouken@3528
   158
     */
slouken@3528
   159
    int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
slouken@3528
   160
slouken@3528
   161
    /*
slouken@5246
   162
     * Get a list of the available display modes for a display.
slouken@2753
   163
     */
slouken@3500
   164
    void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
slouken@0
   165
slouken@2753
   166
    /*
slouken@2753
   167
     * Setting the display mode is independent of creating windows, so
slouken@2753
   168
     * when the display mode is changed, all existing windows should have
slouken@2753
   169
     * their data updated accordingly, including the display surfaces
slouken@2753
   170
     * associated with them.
slouken@2753
   171
     */
slouken@3500
   172
    int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
slouken@0
   173
slouken@2753
   174
    /* * * */
slouken@2753
   175
    /*
slouken@2753
   176
     * Window functions
slouken@2753
   177
     */
slouken@2753
   178
    int (*CreateWindow) (_THIS, SDL_Window * window);
slouken@2753
   179
    int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
slouken@2753
   180
    void (*SetWindowTitle) (_THIS, SDL_Window * window);
slouken@2967
   181
    void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
slouken@2753
   182
    void (*SetWindowPosition) (_THIS, SDL_Window * window);
slouken@2753
   183
    void (*SetWindowSize) (_THIS, SDL_Window * window);
slouken@2753
   184
    void (*ShowWindow) (_THIS, SDL_Window * window);
slouken@2753
   185
    void (*HideWindow) (_THIS, SDL_Window * window);
slouken@2753
   186
    void (*RaiseWindow) (_THIS, SDL_Window * window);
slouken@2753
   187
    void (*MaximizeWindow) (_THIS, SDL_Window * window);
slouken@2753
   188
    void (*MinimizeWindow) (_THIS, SDL_Window * window);
slouken@2753
   189
    void (*RestoreWindow) (_THIS, SDL_Window * window);
icculus@6422
   190
    void (*SetWindowBordered) (_THIS, SDL_Window * window, SDL_bool bordered);
slouken@5305
   191
    void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
slouken@5466
   192
    int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
slouken@5466
   193
    int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
slouken@2753
   194
    void (*SetWindowGrab) (_THIS, SDL_Window * window);
slouken@2753
   195
    void (*DestroyWindow) (_THIS, SDL_Window * window);
slouken@5166
   196
    int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
slouken@5297
   197
    int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, SDL_Rect * rects, int numrects);
slouken@5166
   198
    void (*DestroyWindowFramebuffer) (_THIS, SDL_Window * window);
slouken@5166
   199
eligottlieb@4782
   200
    /* * * */
eligottlieb@4782
   201
    /*
eligottlieb@4782
   202
     * Shaped-window functions
eligottlieb@4782
   203
     */
eligottlieb@4782
   204
    SDL_ShapeDriver shape_driver;
slouken@0
   205
slouken@2753
   206
    /* Get some platform dependent window information */
slouken@2753
   207
      SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
slouken@2753
   208
                                  struct SDL_SysWMinfo * info);
slouken@0
   209
slouken@2753
   210
    /* * * */
slouken@2753
   211
    /*
slouken@2753
   212
     * OpenGL support
slouken@2753
   213
     */
slouken@2753
   214
    int (*GL_LoadLibrary) (_THIS, const char *path);
slouken@2753
   215
    void *(*GL_GetProcAddress) (_THIS, const char *proc);
slouken@3057
   216
    void (*GL_UnloadLibrary) (_THIS);
slouken@2753
   217
      SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
slouken@2753
   218
    int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
slouken@2753
   219
    int (*GL_SetSwapInterval) (_THIS, int interval);
slouken@2753
   220
    int (*GL_GetSwapInterval) (_THIS);
slouken@2753
   221
    void (*GL_SwapWindow) (_THIS, SDL_Window * window);
slouken@2753
   222
    void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
slouken@0
   223
slouken@2753
   224
    /* * * */
slouken@2753
   225
    /*
slouken@2753
   226
     * Event manager functions
slouken@2753
   227
     */
slouken@2753
   228
    void (*PumpEvents) (_THIS);
slouken@0
   229
slouken@3025
   230
    /* Suspend the screensaver */
slouken@3025
   231
    void (*SuspendScreenSaver) (_THIS);
slouken@3025
   232
slouken@3280
   233
    /* Text input */
slouken@3280
   234
    void (*StartTextInput) (_THIS);
slouken@3280
   235
    void (*StopTextInput) (_THIS);
slouken@3280
   236
    void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
slouken@3280
   237
slouken@6392
   238
    /* Screen keyboard */
slouken@6392
   239
    SDL_bool (*SDL_HasScreenKeyboardSupport) (_THIS, SDL_Window *window);
slouken@6392
   240
    int (*SDL_ShowScreenKeyboard) (_THIS, SDL_Window *window);
slouken@6392
   241
    int (*SDL_HideScreenKeyboard) (_THIS, SDL_Window *window);
slouken@6392
   242
    int (*SDL_ToggleScreenKeyboard) (_THIS, SDL_Window *window);
slouken@6392
   243
    SDL_bool (*SDL_IsScreenKeyboardShown) (_THIS, SDL_Window *window);
slouken@6392
   244
slouken@4495
   245
    /* Clipboard */
slouken@4495
   246
    int (*SetClipboardText) (_THIS, const char *text);
slouken@4495
   247
    char * (*GetClipboardText) (_THIS);
slouken@4495
   248
    SDL_bool (*HasClipboardText) (_THIS);
slouken@4495
   249
slouken@6602
   250
    /* MessageBox */
slouken@6602
   251
    int (*ShowMessageBox) (_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid);
slouken@6602
   252
slouken@2753
   253
    /* * * */
slouken@2753
   254
    /* Data common to all drivers */
slouken@3025
   255
    SDL_bool suspend_screensaver;
slouken@2753
   256
    int num_displays;
slouken@2753
   257
    SDL_VideoDisplay *displays;
slouken@5246
   258
    SDL_Window *windows;
slouken@3695
   259
    Uint8 window_magic;
slouken@2753
   260
    Uint32 next_object_id;
slouken@4495
   261
    char * clipboard_text;
slouken@0
   262
slouken@2753
   263
    /* * * */
slouken@2753
   264
    /* Data used by the GL drivers */
slouken@2753
   265
    struct
slouken@2753
   266
    {
slouken@2753
   267
        int red_size;
slouken@2753
   268
        int green_size;
slouken@2753
   269
        int blue_size;
slouken@2753
   270
        int alpha_size;
slouken@2753
   271
        int depth_size;
slouken@2753
   272
        int buffer_size;
slouken@2753
   273
        int stencil_size;
slouken@2753
   274
        int double_buffer;
slouken@2753
   275
        int accum_red_size;
slouken@2753
   276
        int accum_green_size;
slouken@2753
   277
        int accum_blue_size;
slouken@2753
   278
        int accum_alpha_size;
slouken@2753
   279
        int stereo;
slouken@2753
   280
        int multisamplebuffers;
slouken@2753
   281
        int multisamplesamples;
slouken@2753
   282
        int accelerated;
slouken@3100
   283
        int major_version;
slouken@3100
   284
        int minor_version;
slouken@6296
   285
        int flags;
slouken@6296
   286
        int profile_mask;
slouken@6370
   287
        int use_egl;
slouken@6393
   288
        int share_with_current_context;
slouken@2753
   289
        int retained_backing;
slouken@2753
   290
        int driver_loaded;
slouken@2753
   291
        char driver_path[256];
slouken@2753
   292
        void *dll_handle;
slouken@2753
   293
    } gl_config;
slouken@0
   294
slouken@2753
   295
    /* * * */
icculus@5563
   296
    /* Cache current GL context; don't call the OS when it hasn't changed. */
icculus@5563
   297
    SDL_Window *current_glwin;
icculus@5563
   298
    SDL_GLContext current_glctx;
icculus@5563
   299
icculus@5563
   300
    /* * * */
slouken@2753
   301
    /* Data private to this driver */
slouken@2753
   302
    void *driverdata;
slouken@2753
   303
    struct SDL_GLDriverData *gl_data;
slouken@0
   304
slouken@6370
   305
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
slouken@3161
   306
    struct SDL_PrivateGLESData *gles_data;
slouken@3161
   307
#endif
slouken@3161
   308
slouken@2753
   309
    /* * * */
slouken@2753
   310
    /* The function used to dispose of this structure */
slouken@2753
   311
    void (*free) (_THIS);
slouken@1895
   312
};
slouken@0
   313
slouken@2753
   314
typedef struct VideoBootStrap
slouken@2753
   315
{
slouken@2753
   316
    const char *name;
slouken@2753
   317
    const char *desc;
slouken@2753
   318
    int (*available) (void);
slouken@2753
   319
    SDL_VideoDevice *(*create) (int devindex);
slouken@2753
   320
} VideoBootStrap;
slouken@0
   321
slouken@1931
   322
#if SDL_VIDEO_DRIVER_COCOA
slouken@1931
   323
extern VideoBootStrap COCOA_bootstrap;
slouken@1361
   324
#endif
slouken@1361
   325
#if SDL_VIDEO_DRIVER_X11
slouken@0
   326
extern VideoBootStrap X11_bootstrap;
slouken@0
   327
#endif
slouken@1361
   328
#if SDL_VIDEO_DRIVER_DIRECTFB
slouken@167
   329
extern VideoBootStrap DirectFB_bootstrap;
slouken@167
   330
#endif
slouken@5062
   331
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@5062
   332
extern VideoBootStrap WINDOWS_bootstrap;
slouken@1361
   333
#endif
dludwig@8327
   334
#if SDL_VIDEO_DRIVER_WINRT
dludwig@8327
   335
extern VideoBootStrap WINRT_bootstrap;
dludwig@8327
   336
#endif
slouken@1361
   337
#if SDL_VIDEO_DRIVER_BWINDOW
slouken@1361
   338
extern VideoBootStrap BWINDOW_bootstrap;
slouken@1361
   339
#endif
slouken@5150
   340
#if SDL_VIDEO_DRIVER_PANDORA
slouken@5150
   341
extern VideoBootStrap PND_bootstrap;
slouken@3083
   342
#endif
slouken@5150
   343
#if SDL_VIDEO_DRIVER_NDS
slouken@5150
   344
extern VideoBootStrap NDS_bootstrap;
slouken@1361
   345
#endif
hfutrell@2742
   346
#if SDL_VIDEO_DRIVER_UIKIT
hfutrell@2742
   347
extern VideoBootStrap UIKIT_bootstrap;
hfutrell@2742
   348
#endif
slouken@5150
   349
#if SDL_VIDEO_DRIVER_ANDROID
slouken@5150
   350
extern VideoBootStrap Android_bootstrap;
slouken@5150
   351
#endif
slouken@1361
   352
#if SDL_VIDEO_DRIVER_DUMMY
slouken@173
   353
extern VideoBootStrap DUMMY_bootstrap;
slouken@173
   354
#endif
slouken@1361
   355
slouken@4472
   356
extern SDL_VideoDevice *SDL_GetVideoDevice(void);
slouken@2753
   357
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
slouken@2753
   358
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
slouken@3500
   359
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
slouken@5246
   360
extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
slouken@1895
   361
slouken@2753
   362
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
slouken@1895
   363
slouken@2753
   364
extern void SDL_OnWindowShown(SDL_Window * window);
slouken@2753
   365
extern void SDL_OnWindowHidden(SDL_Window * window);
slouken@5166
   366
extern void SDL_OnWindowResized(SDL_Window * window);
slouken@3502
   367
extern void SDL_OnWindowMinimized(SDL_Window * window);
slouken@3502
   368
extern void SDL_OnWindowRestored(SDL_Window * window);
slouken@2753
   369
extern void SDL_OnWindowFocusGained(SDL_Window * window);
slouken@2753
   370
extern void SDL_OnWindowFocusLost(SDL_Window * window);
slouken@3685
   371
extern SDL_Window * SDL_GetFocusWindow(void);
slouken@0
   372
slouken@2753
   373
#endif /* _SDL_sysvideo_h */
slouken@1895
   374
slouken@1895
   375
/* vi: set ts=4 sw=4 expandtab: */