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