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