include/SDL_compat.h
author Ryan C. Gordon <icculus@icculus.org>
Tue, 15 Dec 2009 18:00:16 +0000
changeset 3567 fb9ea4b549c3
parent 3560 5543db4239e6
child 3581 15eea7a1fa97
permissions -rw-r--r--
Added a warning comment to SDL_putenv().

"Fixes" Bugzilla #779.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2009 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 
    23  /**
    24  *  \defgroup Compatibility SDL 1.2 Compatibility API
    25  */
    26 /*@{*/
    27 
    28 /**
    29  *  \file SDL_compat.h
    30  *
    31  *  This file contains functions for backwards compatibility with SDL 1.2.
    32  */
    33 
    34 /**
    35  *  \def SDL_NO_COMPAT
    36  *
    37  *  #define SDL_NO_COMPAT to prevent SDL_compat.h from being included.
    38  *  SDL_NO_COMPAT is intended to make it easier to covert SDL 1.2 code to
    39  *  SDL 1.3/2.0.
    40  */
    41 
    42  /*@}*/
    43 
    44 #ifdef SDL_NO_COMPAT
    45 #define _SDL_compat_h
    46 #endif
    47 
    48 #ifndef _SDL_compat_h
    49 #define _SDL_compat_h
    50 
    51 #include "SDL_video.h"
    52 #include "SDL_version.h"
    53 
    54 #include "begin_code.h"
    55 /* Set up for C function definitions, even when using C++ */
    56 #ifdef __cplusplus
    57 /* *INDENT-OFF* */
    58 extern "C" {
    59 /* *INDENT-ON* */
    60 #endif
    61 
    62 /**
    63  *  \addtogroup Compatibility
    64  */
    65 /*@{*/
    66 
    67 /**
    68  *  \name Surface flags
    69  */
    70 /*@{*/
    71 #define SDL_SWSURFACE       0x00000000  /**< \note Not used */
    72 #define SDL_SRCALPHA        0x00010000
    73 #define SDL_SRCCOLORKEY     0x00020000
    74 #define SDL_ANYFORMAT       0x00100000
    75 #define SDL_HWPALETTE       0x00200000
    76 #define SDL_DOUBLEBUF       0x00400000
    77 #define SDL_FULLSCREEN      0x00800000
    78 #define SDL_RESIZABLE       0x01000000
    79 #define SDL_NOFRAME         0x02000000
    80 #define SDL_OPENGL          0x04000000
    81 #define SDL_HWSURFACE       0x08000001  /**< \note Not used */
    82 #define SDL_ASYNCBLIT       0x08000000  /**< \note Not used */
    83 #define SDL_RLEACCELOK      0x08000000  /**< \note Not used */
    84 #define SDL_HWACCEL         0x08000000  /**< \note Not used */
    85 /*@}*//*Surface flags*/
    86 
    87 #define SDL_APPMOUSEFOCUS	0x01
    88 #define SDL_APPINPUTFOCUS	0x02
    89 #define SDL_APPACTIVE		0x04
    90 
    91 #define SDL_LOGPAL 0x01
    92 #define SDL_PHYSPAL 0x02
    93 
    94 #define SDL_ACTIVEEVENT	SDL_EVENT_RESERVED1
    95 #define SDL_VIDEORESIZE	SDL_EVENT_RESERVED2
    96 #define SDL_VIDEOEXPOSE	SDL_EVENT_RESERVED3
    97 #define SDL_ACTIVEEVENTMASK	SDL_EVENTMASK(SDL_ACTIVEEVENT)
    98 #define SDL_VIDEORESIZEMASK SDL_EVENTMASK(SDL_VIDEORESIZE)
    99 #define SDL_VIDEOEXPOSEMASK SDL_EVENTMASK(SDL_VIDEOEXPOSE)
   100 
   101 #define SDL_BUTTON_WHEELUP	4
   102 #define SDL_BUTTON_WHEELDOWN	5
   103 
   104 #define SDL_DEFAULT_REPEAT_DELAY	500
   105 #define SDL_DEFAULT_REPEAT_INTERVAL	30
   106 
   107 typedef struct SDL_VideoInfo
   108 {
   109     Uint32 hw_available:1;
   110     Uint32 wm_available:1;
   111     Uint32 UnusedBits1:6;
   112     Uint32 UnusedBits2:1;
   113     Uint32 blit_hw:1;
   114     Uint32 blit_hw_CC:1;
   115     Uint32 blit_hw_A:1;
   116     Uint32 blit_sw:1;
   117     Uint32 blit_sw_CC:1;
   118     Uint32 blit_sw_A:1;
   119     Uint32 blit_fill:1;
   120     Uint32 UnusedBits3:16;
   121     Uint32 video_mem;
   122 
   123     SDL_PixelFormat *vfmt;
   124 
   125     int current_w;
   126     int current_h;
   127 } SDL_VideoInfo;
   128 
   129 /**
   130  *  \name Overlay formats
   131  *
   132  *  The most common video overlay formats.
   133  *  
   134  *  For an explanation of these pixel formats, see:
   135  *  http://www.webartz.com/fourcc/indexyuv.htm
   136  *  
   137  *  For information on the relationship between color spaces, see:
   138  *  http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
   139  */
   140 /*@{*/
   141 #define SDL_YV12_OVERLAY  0x32315659    /**< Planar mode: Y + V + U  (3 planes) */
   142 #define SDL_IYUV_OVERLAY  0x56555949    /**< Planar mode: Y + U + V  (3 planes) */
   143 #define SDL_YUY2_OVERLAY  0x32595559    /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
   144 #define SDL_UYVY_OVERLAY  0x59565955    /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
   145 #define SDL_YVYU_OVERLAY  0x55595659    /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
   146 /*@}*//*Overlay formats*/
   147 
   148 /**
   149  *  The YUV hardware video overlay.
   150  */
   151 typedef struct SDL_Overlay
   152 {
   153     Uint32 format;              /**< Read-only */
   154     int w, h;                   /**< Read-only */
   155     int planes;                 /**< Read-only */
   156     Uint16 *pitches;            /**< Read-only */
   157     Uint8 **pixels;             /**< Read-write */
   158 
   159     /** 
   160      *  \name Hardware-specific surface info
   161      */
   162     /*@{*/
   163     struct private_yuvhwfuncs *hwfuncs;
   164     struct private_yuvhwdata *hwdata;
   165     /*@}*//*Hardware-specific surface info*/
   166 
   167     /** 
   168      *  \name Special flags
   169      */
   170     /*@{*/
   171     Uint32 hw_overlay:1;        /**< Flag: This overlay hardware accelerated? */
   172     Uint32 UnusedBits:31;
   173     /*@}*//*Special flags*/
   174 } SDL_Overlay;
   175 
   176 typedef enum
   177 {
   178     SDL_GRAB_QUERY = -1,
   179     SDL_GRAB_OFF = 0,
   180     SDL_GRAB_ON = 1
   181 } SDL_GrabMode;
   182 
   183 struct SDL_SysWMinfo;
   184 
   185 /**
   186  *  \name Obsolete or renamed key codes
   187  */
   188 /*@{*/
   189 
   190 /** 
   191  *  \name Renamed keys
   192  *
   193  *  These key constants were renamed for clarity or consistency. 
   194  */
   195 /*@{*/
   196 #define SDLK_KP0 SDLK_KP_0
   197 #define SDLK_KP1 SDLK_KP_1
   198 #define SDLK_KP2 SDLK_KP_2
   199 #define SDLK_KP3 SDLK_KP_3
   200 #define SDLK_KP4 SDLK_KP_4
   201 #define SDLK_KP5 SDLK_KP_5
   202 #define SDLK_KP6 SDLK_KP_6
   203 #define SDLK_KP7 SDLK_KP_7
   204 #define SDLK_KP8 SDLK_KP_8
   205 #define SDLK_KP9 SDLK_KP_9
   206 #define SDLK_NUMLOCK SDLK_NUMLOCKCLEAR
   207 #define SDLK_SCROLLOCK SDLK_SCROLLLOCK
   208 #define SDLK_PRINT SDLK_PRINTSCREEN
   209 /*@}*//*Renamed keys*/
   210 
   211 /**
   212  *  \name META modifier
   213  *  
   214  *  The META modifier is equivalent to the GUI modifier from the USB standard.
   215  */
   216 /*@{*/
   217 #define KMOD_LMETA KMOD_LGUI
   218 #define KMOD_RMETA KMOD_RGUI
   219 #define KMOD_META KMOD_GUI
   220 /*@}*//*META modifier*/
   221 
   222 /** 
   223  *  \name Not in USB
   224  *
   225  *  These keys don't appear in the USB specification (or at least not under 
   226  *  those names). I'm unsure if the following assignments make sense or if these
   227  *  codes should be defined as actual additional SDLK_ constants.
   228  */
   229 /*@{*/
   230 #define SDLK_LSUPER SDLK_LMETA
   231 #define SDLK_RSUPER SDLK_RMETA
   232 #define SDLK_COMPOSE SDLK_APPLICATION
   233 #define SDLK_BREAK SDLK_STOP
   234 #define SDLK_EURO SDLK_2
   235 /*@}*//*Not in USB*/
   236 
   237 /*@}*//*Obsolete or renamed key codes*/
   238 
   239 #define SDL_SetModuleHandle(x)
   240 #define SDL_AllocSurface    SDL_CreateRGBSurface
   241 
   242 extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void);
   243 extern DECLSPEC char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
   244 extern DECLSPEC char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
   245 extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
   246 extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
   247                                             int height,
   248                                             int bpp, Uint32 flags);
   249 extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(const SDL_PixelFormat *
   250                                                  format, Uint32 flags);
   251 extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height,
   252                                                       int bpp, Uint32 flags);
   253 extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
   254 extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
   255                                              int numrects, SDL_Rect * rects);
   256 extern DECLSPEC void SDLCALL SDL_UpdateRect(SDL_Surface * screen,
   257                                             Sint32 x,
   258                                             Sint32 y, Uint32 w, Uint32 h);
   259 extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface * screen);
   260 extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface * surface,
   261                                          Uint32 flag, Uint8 alpha);
   262 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat(SDL_Surface * surface);
   263 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *
   264                                                             surface);
   265 extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title,
   266                                                const char *icon);
   267 extern DECLSPEC void SDLCALL SDL_WM_GetCaption(const char **title,
   268                                                const char **icon);
   269 extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask);
   270 extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
   271 extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface);
   272 extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
   273 extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface,
   274                                            int flags,
   275                                            const SDL_Color * colors,
   276                                            int firstcolor, int ncolors);
   277 extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface * surface,
   278                                           const SDL_Color * colors,
   279                                           int firstcolor, int ncolors);
   280 extern DECLSPEC int SDLCALL SDL_GetWMInfo(struct SDL_SysWMinfo *info);
   281 extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
   282 extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
   283 extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay(int width,
   284                                                           int height,
   285                                                           Uint32 format,
   286                                                           SDL_Surface *
   287                                                           display);
   288 extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay * overlay);
   289 extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay * overlay);
   290 extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay,
   291                                                   SDL_Rect * dstrect);
   292 extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
   293 extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
   294 extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
   295 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
   296 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
   297 
   298 #define SDL_RenderFill  SDL_RenderRect
   299 
   300 /*@}*//*Compatibility*/
   301 
   302 /* Ends C function definitions when using C++ */
   303 #ifdef __cplusplus
   304 /* *INDENT-OFF* */
   305 }
   306 /* *INDENT-ON* */
   307 #endif
   308 #include "close_code.h"
   309 
   310 #endif /* _SDL_compat_h */
   311 
   312 /* vi: set ts=4 sw=4 expandtab: */