src/video/SDL_sysvideo.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 18 May 2013 14:17:52 -0700
changeset 7191 75360622e65f
parent 7178 8e2156e2ff3e
child 7390 e4b98404baa4
permissions -rw-r--r--
File style cleanup for the SDL 2.0 release
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 #include "SDL_config.h"
    22 
    23 #ifndef _SDL_sysvideo_h
    24 #define _SDL_sysvideo_h
    25 
    26 #include "SDL_messagebox.h"
    27 #include "SDL_shape.h"
    28 
    29 /* The SDL video driver */
    30 
    31 typedef struct SDL_WindowShaper SDL_WindowShaper;
    32 typedef struct SDL_ShapeDriver SDL_ShapeDriver;
    33 typedef struct SDL_VideoDisplay SDL_VideoDisplay;
    34 typedef struct SDL_VideoDevice SDL_VideoDevice;
    35 
    36 /* Define the SDL window-shaper structure */
    37 struct SDL_WindowShaper
    38 {
    39     /* The window associated with the shaper */
    40     SDL_Window *window;
    41 
    42     /* The user's specified coordinates for the window, for once we give it a shape. */
    43     Uint32 userx,usery;
    44 
    45     /* The parameters for shape calculation. */
    46     SDL_WindowShapeMode mode;
    47 
    48     /* Has this window been assigned a shape? */
    49     SDL_bool hasshape;
    50 
    51     void *driverdata;
    52 };
    53 
    54 /* Define the SDL shape driver structure */
    55 struct SDL_ShapeDriver
    56 {
    57     SDL_WindowShaper *(*CreateShaper)(SDL_Window * window);
    58     int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
    59     int (*ResizeWindowShape)(SDL_Window *window);
    60 };
    61 
    62 typedef struct SDL_WindowUserData
    63 {
    64     char *name;
    65     void *data;
    66     struct SDL_WindowUserData *next;
    67 } SDL_WindowUserData;
    68 
    69 /* Define the SDL window structure, corresponding to toplevel windows */
    70 struct SDL_Window
    71 {
    72     const void *magic;
    73     Uint32 id;
    74     char *title;
    75     int x, y;
    76     int w, h;
    77     int min_w, min_h;
    78     int max_w, max_h;
    79     Uint32 flags;
    80 
    81     /* Stored position and size for windowed mode */
    82     SDL_Rect windowed;
    83 
    84     SDL_DisplayMode fullscreen_mode;
    85 
    86     float brightness;
    87     Uint16 *gamma;
    88     Uint16 *saved_gamma;        /* (just offset into gamma) */
    89 
    90     SDL_Surface *surface;
    91     SDL_bool surface_valid;
    92 
    93     SDL_WindowShaper *shaper;
    94 
    95     SDL_WindowUserData *data;
    96 
    97     void *driverdata;
    98 
    99     SDL_Window *prev;
   100     SDL_Window *next;
   101 };
   102 #define FULLSCREEN_VISIBLE(W) \
   103     (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
   104      ((W)->flags & SDL_WINDOW_SHOWN) && \
   105      !((W)->flags & SDL_WINDOW_MINIMIZED))
   106 
   107 /*
   108  * Define the SDL display structure This corresponds to physical monitors
   109  * attached to the system.
   110  */
   111 struct SDL_VideoDisplay
   112 {
   113     char *name;
   114     int max_display_modes;
   115     int num_display_modes;
   116     SDL_DisplayMode *display_modes;
   117     SDL_DisplayMode desktop_mode;
   118     SDL_DisplayMode current_mode;
   119 
   120     SDL_Window *fullscreen_window;
   121 
   122     SDL_VideoDevice *device;
   123 
   124     void *driverdata;
   125 };
   126 
   127 /* Forward declaration */
   128 struct SDL_SysWMinfo;
   129 
   130 /* Define the SDL video driver structure */
   131 #define _THIS   SDL_VideoDevice *_this
   132 
   133 struct SDL_VideoDevice
   134 {
   135     /* * * */
   136     /* The name of this video driver */
   137     const char *name;
   138 
   139     /* * * */
   140     /* Initialization/Query functions */
   141 
   142     /*
   143      * Initialize the native video subsystem, filling in the list of
   144      * displays for this driver, returning 0 or -1 if there's an error.
   145      */
   146     int (*VideoInit) (_THIS);
   147 
   148     /*
   149      * Reverse the effects VideoInit() -- called if VideoInit() fails or
   150      * if the application is shutting down the video subsystem.
   151      */
   152     void (*VideoQuit) (_THIS);
   153 
   154     /* * * */
   155     /*
   156      * Display functions
   157      */
   158 
   159     /*
   160      * Get the bounds of a display
   161      */
   162     int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
   163 
   164     /*
   165      * Get a list of the available display modes for a display.
   166      */
   167     void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
   168 
   169     /*
   170      * Setting the display mode is independent of creating windows, so
   171      * when the display mode is changed, all existing windows should have
   172      * their data updated accordingly, including the display surfaces
   173      * associated with them.
   174      */
   175     int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
   176 
   177     /* * * */
   178     /*
   179      * Window functions
   180      */
   181     int (*CreateWindow) (_THIS, SDL_Window * window);
   182     int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
   183     void (*SetWindowTitle) (_THIS, SDL_Window * window);
   184     void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
   185     void (*SetWindowPosition) (_THIS, SDL_Window * window);
   186     void (*SetWindowSize) (_THIS, SDL_Window * window);
   187     void (*SetWindowMinimumSize) (_THIS, SDL_Window * window);
   188     void (*SetWindowMaximumSize) (_THIS, SDL_Window * window);
   189     void (*ShowWindow) (_THIS, SDL_Window * window);
   190     void (*HideWindow) (_THIS, SDL_Window * window);
   191     void (*RaiseWindow) (_THIS, SDL_Window * window);
   192     void (*MaximizeWindow) (_THIS, SDL_Window * window);
   193     void (*MinimizeWindow) (_THIS, SDL_Window * window);
   194     void (*RestoreWindow) (_THIS, SDL_Window * window);
   195     void (*SetWindowBordered) (_THIS, SDL_Window * window, SDL_bool bordered);
   196     void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
   197     int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
   198     int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
   199     void (*SetWindowGrab) (_THIS, SDL_Window * window, SDL_bool grabbed);
   200     void (*DestroyWindow) (_THIS, SDL_Window * window);
   201     int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
   202     int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
   203     void (*DestroyWindowFramebuffer) (_THIS, SDL_Window * window);
   204     void (*OnWindowEnter) (_THIS, SDL_Window * window);
   205 
   206     /* * * */
   207     /*
   208      * Shaped-window functions
   209      */
   210     SDL_ShapeDriver shape_driver;
   211 
   212     /* Get some platform dependent window information */
   213       SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
   214                                   struct SDL_SysWMinfo * info);
   215 
   216     /* * * */
   217     /*
   218      * OpenGL support
   219      */
   220     int (*GL_LoadLibrary) (_THIS, const char *path);
   221     void *(*GL_GetProcAddress) (_THIS, const char *proc);
   222     void (*GL_UnloadLibrary) (_THIS);
   223       SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
   224     int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
   225     int (*GL_SetSwapInterval) (_THIS, int interval);
   226     int (*GL_GetSwapInterval) (_THIS);
   227     void (*GL_SwapWindow) (_THIS, SDL_Window * window);
   228     void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
   229 
   230     /* * * */
   231     /*
   232      * Event manager functions
   233      */
   234     void (*PumpEvents) (_THIS);
   235 
   236     /* Suspend the screensaver */
   237     void (*SuspendScreenSaver) (_THIS);
   238 
   239     /* Text input */
   240     void (*StartTextInput) (_THIS);
   241     void (*StopTextInput) (_THIS);
   242     void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
   243 
   244     /* Screen keyboard */
   245     SDL_bool (*HasScreenKeyboardSupport) (_THIS);
   246     void (*ShowScreenKeyboard) (_THIS, SDL_Window *window);
   247     void (*HideScreenKeyboard) (_THIS, SDL_Window *window);
   248     SDL_bool (*IsScreenKeyboardShown) (_THIS, SDL_Window *window);
   249 
   250     /* Clipboard */
   251     int (*SetClipboardText) (_THIS, const char *text);
   252     char * (*GetClipboardText) (_THIS);
   253     SDL_bool (*HasClipboardText) (_THIS);
   254 
   255     /* MessageBox */
   256     int (*ShowMessageBox) (_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid);
   257 
   258     /* * * */
   259     /* Data common to all drivers */
   260     SDL_bool suspend_screensaver;
   261     int num_displays;
   262     SDL_VideoDisplay *displays;
   263     SDL_Window *windows;
   264     Uint8 window_magic;
   265     Uint32 next_object_id;
   266     char * clipboard_text;
   267 
   268     /* * * */
   269     /* Data used by the GL drivers */
   270     struct
   271     {
   272         int red_size;
   273         int green_size;
   274         int blue_size;
   275         int alpha_size;
   276         int depth_size;
   277         int buffer_size;
   278         int stencil_size;
   279         int double_buffer;
   280         int accum_red_size;
   281         int accum_green_size;
   282         int accum_blue_size;
   283         int accum_alpha_size;
   284         int stereo;
   285         int multisamplebuffers;
   286         int multisamplesamples;
   287         int accelerated;
   288         int major_version;
   289         int minor_version;
   290         int flags;
   291         int profile_mask;
   292         int use_egl;
   293         int share_with_current_context;
   294         int retained_backing;
   295         int driver_loaded;
   296         char driver_path[256];
   297         void *dll_handle;
   298     } gl_config;
   299 
   300     /* * * */
   301     /* Cache current GL context; don't call the OS when it hasn't changed. */
   302     SDL_Window *current_glwin;
   303     SDL_GLContext current_glctx;
   304 
   305     /* * * */
   306     /* Data private to this driver */
   307     void *driverdata;
   308     struct SDL_GLDriverData *gl_data;
   309 
   310 #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
   311     struct SDL_PrivateGLESData *gles_data;
   312 #endif
   313 
   314     /* * * */
   315     /* The function used to dispose of this structure */
   316     void (*free) (_THIS);
   317 };
   318 
   319 typedef struct VideoBootStrap
   320 {
   321     const char *name;
   322     const char *desc;
   323     int (*available) (void);
   324     SDL_VideoDevice *(*create) (int devindex);
   325 } VideoBootStrap;
   326 
   327 #if SDL_VIDEO_DRIVER_COCOA
   328 extern VideoBootStrap COCOA_bootstrap;
   329 #endif
   330 #if SDL_VIDEO_DRIVER_X11
   331 extern VideoBootStrap X11_bootstrap;
   332 #endif
   333 #if SDL_VIDEO_DRIVER_DIRECTFB
   334 extern VideoBootStrap DirectFB_bootstrap;
   335 #endif
   336 #if SDL_VIDEO_DRIVER_WINDOWS
   337 extern VideoBootStrap WINDOWS_bootstrap;
   338 #endif
   339 #if SDL_VIDEO_DRIVER_BWINDOW
   340 extern VideoBootStrap BWINDOW_bootstrap;
   341 #endif
   342 #if SDL_VIDEO_DRIVER_PANDORA
   343 extern VideoBootStrap PND_bootstrap;
   344 #endif
   345 #if SDL_VIDEO_DRIVER_UIKIT
   346 extern VideoBootStrap UIKIT_bootstrap;
   347 #endif
   348 #if SDL_VIDEO_DRIVER_ANDROID
   349 extern VideoBootStrap Android_bootstrap;
   350 #endif
   351 #if SDL_VIDEO_DRIVER_PSP
   352 extern VideoBootStrap PSP_bootstrap;
   353 #endif
   354 #if SDL_VIDEO_DRIVER_DUMMY
   355 extern VideoBootStrap DUMMY_bootstrap;
   356 #endif
   357 
   358 extern SDL_VideoDevice *SDL_GetVideoDevice(void);
   359 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
   360 extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
   361 extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
   362 extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
   363 
   364 extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
   365 
   366 extern void SDL_OnWindowShown(SDL_Window * window);
   367 extern void SDL_OnWindowHidden(SDL_Window * window);
   368 extern void SDL_OnWindowResized(SDL_Window * window);
   369 extern void SDL_OnWindowMinimized(SDL_Window * window);
   370 extern void SDL_OnWindowRestored(SDL_Window * window);
   371 extern void SDL_OnWindowEnter(SDL_Window * window);
   372 extern void SDL_OnWindowLeave(SDL_Window * window);
   373 extern void SDL_OnWindowFocusGained(SDL_Window * window);
   374 extern void SDL_OnWindowFocusLost(SDL_Window * window);
   375 extern void SDL_UpdateWindowGrab(SDL_Window * window);
   376 extern SDL_Window * SDL_GetFocusWindow(void);
   377 
   378 extern SDL_bool SDL_ShouldAllowTopmost(void);
   379 
   380 #endif /* _SDL_sysvideo_h */
   381 
   382 /* vi: set ts=4 sw=4 expandtab: */