src/video/SDL_sysvideo.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 16 Feb 2011 00:11:48 -0800
changeset 5306 cf3cd833dcd3
parent 5305 75f5ff92ad08
child 5398 83816c8a2b58
permissions -rw-r--r--
Fixed resetting the Direc3D renderer on mode change
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2011 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #ifndef _SDL_sysvideo_h
    25 #define _SDL_sysvideo_h
    26 
    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     Uint32 flags;
    78 
    79     SDL_DisplayMode fullscreen_mode;
    80     
    81     SDL_Surface *surface;
    82     SDL_bool surface_valid;
    83 
    84     SDL_WindowShaper *shaper;
    85 
    86     SDL_WindowUserData *data;
    87 
    88     void *driverdata;
    89 
    90     SDL_Window *prev;
    91     SDL_Window *next;
    92 };
    93 #define FULLSCREEN_VISIBLE(W) \
    94     (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
    95      ((W)->flags & SDL_WINDOW_SHOWN) && \
    96      !((W)->flags & SDL_WINDOW_MINIMIZED))
    97 
    98 /*
    99  * Define the SDL display structure This corresponds to physical monitors
   100  * attached to the system.
   101  */
   102 struct SDL_VideoDisplay
   103 {
   104     int max_display_modes;
   105     int num_display_modes;
   106     SDL_DisplayMode *display_modes;
   107     SDL_DisplayMode desktop_mode;
   108     SDL_DisplayMode current_mode;
   109 
   110     SDL_Window *fullscreen_window;
   111 
   112     SDL_VideoDevice *device;
   113 
   114     void *driverdata;
   115 };
   116 
   117 /* Forward declaration */
   118 struct SDL_SysWMinfo;
   119 
   120 /* Define the SDL video driver structure */
   121 #define _THIS	SDL_VideoDevice *_this
   122 
   123 struct SDL_VideoDevice
   124 {
   125     /* * * */
   126     /* The name of this video driver */
   127     const char *name;
   128 
   129     /* * * */
   130     /* Initialization/Query functions */
   131 
   132     /*
   133      * Initialize the native video subsystem, filling in the list of
   134      * displays for this driver, returning 0 or -1 if there's an error.
   135      */
   136     int (*VideoInit) (_THIS);
   137 
   138     /*
   139      * Reverse the effects VideoInit() -- called if VideoInit() fails or
   140      * if the application is shutting down the video subsystem.
   141      */
   142     void (*VideoQuit) (_THIS);
   143 
   144     /* * * */
   145     /*
   146      * Display functions
   147      */
   148 
   149     /*
   150      * Get the bounds of a display
   151      */
   152     int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
   153 
   154     /*
   155      * Get a list of the available display modes for a display.
   156      */
   157     void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
   158 
   159     /*
   160      * Setting the display mode is independent of creating windows, so
   161      * when the display mode is changed, all existing windows should have
   162      * their data updated accordingly, including the display surfaces
   163      * associated with them.
   164      */
   165     int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
   166 
   167     /* * * */
   168     /*
   169      * Window functions
   170      */
   171     int (*CreateWindow) (_THIS, SDL_Window * window);
   172     int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
   173     void (*SetWindowTitle) (_THIS, SDL_Window * window);
   174     void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
   175     void (*SetWindowPosition) (_THIS, SDL_Window * window);
   176     void (*SetWindowSize) (_THIS, SDL_Window * window);
   177     void (*ShowWindow) (_THIS, SDL_Window * window);
   178     void (*HideWindow) (_THIS, SDL_Window * window);
   179     void (*RaiseWindow) (_THIS, SDL_Window * window);
   180     void (*MaximizeWindow) (_THIS, SDL_Window * window);
   181     void (*MinimizeWindow) (_THIS, SDL_Window * window);
   182     void (*RestoreWindow) (_THIS, SDL_Window * window);
   183     void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
   184     void (*SetWindowGrab) (_THIS, SDL_Window * window);
   185     void (*DestroyWindow) (_THIS, SDL_Window * window);
   186     int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
   187     int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, SDL_Rect * rects, int numrects);
   188     void (*DestroyWindowFramebuffer) (_THIS, SDL_Window * window);
   189 
   190     /* * * */
   191     /*
   192      * Shaped-window functions
   193      */
   194     SDL_ShapeDriver shape_driver;
   195 
   196     /* Get some platform dependent window information */
   197       SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
   198                                   struct SDL_SysWMinfo * info);
   199 
   200     /* * * */
   201     /*
   202      * OpenGL support
   203      */
   204     int (*GL_LoadLibrary) (_THIS, const char *path);
   205     void *(*GL_GetProcAddress) (_THIS, const char *proc);
   206     void (*GL_UnloadLibrary) (_THIS);
   207       SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
   208     int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
   209     int (*GL_SetSwapInterval) (_THIS, int interval);
   210     int (*GL_GetSwapInterval) (_THIS);
   211     void (*GL_SwapWindow) (_THIS, SDL_Window * window);
   212     void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
   213 
   214     /* * * */
   215     /*
   216      * Event manager functions
   217      */
   218     void (*PumpEvents) (_THIS);
   219 
   220     /* Suspend the screensaver */
   221     void (*SuspendScreenSaver) (_THIS);
   222 
   223     /* Text input */
   224     void (*StartTextInput) (_THIS);
   225     void (*StopTextInput) (_THIS);
   226     void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
   227 
   228     /* Clipboard */
   229     int (*SetClipboardText) (_THIS, const char *text);
   230     char * (*GetClipboardText) (_THIS);
   231     SDL_bool (*HasClipboardText) (_THIS);
   232 
   233     /* * * */
   234     /* Data common to all drivers */
   235     SDL_bool suspend_screensaver;
   236     int num_displays;
   237     SDL_VideoDisplay *displays;
   238     SDL_Window *windows;
   239     Uint8 window_magic;
   240     Uint32 next_object_id;
   241     char * clipboard_text;
   242 
   243     /* * * */
   244     /* Data used by the GL drivers */
   245     struct
   246     {
   247         int red_size;
   248         int green_size;
   249         int blue_size;
   250         int alpha_size;
   251         int depth_size;
   252         int buffer_size;
   253         int stencil_size;
   254         int double_buffer;
   255         int accum_red_size;
   256         int accum_green_size;
   257         int accum_blue_size;
   258         int accum_alpha_size;
   259         int stereo;
   260         int multisamplebuffers;
   261         int multisamplesamples;
   262         int accelerated;
   263         int major_version;
   264         int minor_version;
   265         int retained_backing;
   266         int driver_loaded;
   267         char driver_path[256];
   268         void *dll_handle;
   269     } gl_config;
   270 
   271     /* * * */
   272     /* Data private to this driver */
   273     void *driverdata;
   274     struct SDL_GLDriverData *gl_data;
   275 
   276 #if SDL_VIDEO_DRIVER_PANDORA
   277     struct SDL_PrivateGLESData *gles_data;
   278 #endif
   279 
   280     /* * * */
   281     /* The function used to dispose of this structure */
   282     void (*free) (_THIS);
   283 };
   284 
   285 typedef struct VideoBootStrap
   286 {
   287     const char *name;
   288     const char *desc;
   289     int (*available) (void);
   290     SDL_VideoDevice *(*create) (int devindex);
   291 } VideoBootStrap;
   292 
   293 #if SDL_VIDEO_DRIVER_COCOA
   294 extern VideoBootStrap COCOA_bootstrap;
   295 #endif
   296 #if SDL_VIDEO_DRIVER_X11
   297 extern VideoBootStrap X11_bootstrap;
   298 #endif
   299 #if SDL_VIDEO_DRIVER_DIRECTFB
   300 extern VideoBootStrap DirectFB_bootstrap;
   301 #endif
   302 #if SDL_VIDEO_DRIVER_WINDOWS
   303 extern VideoBootStrap WINDOWS_bootstrap;
   304 #endif
   305 #if SDL_VIDEO_DRIVER_BWINDOW
   306 extern VideoBootStrap BWINDOW_bootstrap;
   307 #endif
   308 #if SDL_VIDEO_DRIVER_PANDORA
   309 extern VideoBootStrap PND_bootstrap;
   310 #endif
   311 #if SDL_VIDEO_DRIVER_NDS
   312 extern VideoBootStrap NDS_bootstrap;
   313 #endif
   314 #if SDL_VIDEO_DRIVER_UIKIT
   315 extern VideoBootStrap UIKIT_bootstrap;
   316 #endif
   317 #if SDL_VIDEO_DRIVER_ANDROID
   318 extern VideoBootStrap Android_bootstrap;
   319 #endif
   320 #if SDL_VIDEO_DRIVER_DUMMY
   321 extern VideoBootStrap DUMMY_bootstrap;
   322 #endif
   323 
   324 extern SDL_VideoDevice *SDL_GetVideoDevice(void);
   325 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
   326 extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
   327 extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
   328 extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
   329 
   330 extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
   331 
   332 extern void SDL_OnWindowShown(SDL_Window * window);
   333 extern void SDL_OnWindowHidden(SDL_Window * window);
   334 extern void SDL_OnWindowResized(SDL_Window * window);
   335 extern void SDL_OnWindowMinimized(SDL_Window * window);
   336 extern void SDL_OnWindowRestored(SDL_Window * window);
   337 extern void SDL_OnWindowFocusGained(SDL_Window * window);
   338 extern void SDL_OnWindowFocusLost(SDL_Window * window);
   339 extern SDL_Window * SDL_GetFocusWindow(void);
   340 
   341 #endif /* _SDL_sysvideo_h */
   342 
   343 /* vi: set ts=4 sw=4 expandtab: */