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