include/SDL_compat.h
author Bob Pendleton <bob@pendleton.com>
Fri, 14 Mar 2008 18:17:49 +0000
changeset 2328 91e601d9df8b
parent 2303 d87417504c75
child 2329 c1a390f6a819
permissions -rw-r--r--
re: bug#563. checking in some commented out trace code and a fix so that the in testalpha.c the background only flashes when alpha == 255. The problem that is being
fixed is caused by clearing SDL_COPY_RLE_COLORKEY without setting SDL_COPY_RLE_DESIRED in SDL_UnRELSurface.
     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 
    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 } SDL_VideoInfo;
    92 
    93 /* The most common video overlay formats.
    94    For an explanation of these pixel formats, see:
    95    http://www.webartz.com/fourcc/indexyuv.htm
    96 
    97    For information on the relationship between color spaces, see:
    98    http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
    99  */
   100 #define SDL_YV12_OVERLAY  0x32315659    /* Planar mode: Y + V + U  (3 planes) */
   101 #define SDL_IYUV_OVERLAY  0x56555949    /* Planar mode: Y + U + V  (3 planes) */
   102 #define SDL_YUY2_OVERLAY  0x32595559    /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
   103 #define SDL_UYVY_OVERLAY  0x59565955    /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
   104 #define SDL_YVYU_OVERLAY  0x55595659    /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
   105 
   106 /* The YUV hardware video overlay */
   107 typedef struct SDL_Overlay
   108 {
   109     Uint32 format;              /* Read-only */
   110     int w, h;                   /* Read-only */
   111     int planes;                 /* Read-only */
   112     Uint16 *pitches;            /* Read-only */
   113     Uint8 **pixels;             /* Read-write */
   114 
   115     /* Hardware-specific surface info */
   116     struct private_yuvhwfuncs *hwfuncs;
   117     struct private_yuvhwdata *hwdata;
   118 
   119     /* Special flags */
   120     Uint32 hw_overlay:1;        /* Flag: This overlay hardware accelerated? */
   121     Uint32 UnusedBits:31;
   122 } SDL_Overlay;
   123 
   124 typedef enum
   125 {
   126     SDL_GRAB_QUERY = -1,
   127     SDL_GRAB_OFF = 0,
   128     SDL_GRAB_ON = 1
   129 } SDL_GrabMode;
   130 
   131 struct SDL_SysWMinfo;
   132 
   133 /* Obsolete or renamed key codes */
   134 
   135 /* These key constants were renamed for clarity or consistency. */
   136 #define SDLK_a  'a'
   137 #define SDLK_b  'b'
   138 #define SDLK_c  'c'
   139 #define SDLK_d  'd'
   140 #define SDLK_e  'e'
   141 #define SDLK_f  'f'
   142 #define SDLK_g  'g'
   143 #define SDLK_h  'h'
   144 #define SDLK_i  'i'
   145 #define SDLK_j  'j'
   146 #define SDLK_k  'k'
   147 #define SDLK_l  'l'
   148 #define SDLK_m  'm'
   149 #define SDLK_n  'n'
   150 #define SDLK_o  'o'
   151 #define SDLK_p  'p'
   152 #define SDLK_q  'q'
   153 #define SDLK_r  'r'
   154 #define SDLK_s  's'
   155 #define SDLK_t  't'
   156 #define SDLK_u  'u'
   157 #define SDLK_v  'v'
   158 #define SDLK_w  'w'
   159 #define SDLK_x  'x'
   160 #define SDLK_y  'y'
   161 #define SDLK_z  'z'
   162 #define SDLK_QUOTE      '\''
   163 #define SDLK_MINUS      '-'
   164 #define SDLK_BACKQUOTE  '`'
   165 #define SDLK_EXCLAIM    '!'
   166 #define SDLK_QUOTEDBL   '"'
   167 #define SDLK_HASH       '#'
   168 #define SDLK_DOLLAR     '$'
   169 #define SDLK_AMPERSAND  '&'
   170 #define SDLK_LEFTPAREN  '('
   171 #define SDLK_RIGHTPAREN ')'
   172 #define SDLK_ASTERISK   '*'
   173 #define SDLK_PLUS       '+'
   174 #define SDLK_COLON      ':'
   175 #define SDLK_LESS       '<'
   176 #define SDLK_GREATER    '>'
   177 #define SDLK_QUESTION   '?'
   178 #define SDLK_AT         '@'
   179 #define SDLK_CARET      '^'
   180 #define SDLK_UNDERSCORE '_'
   181 #define SDLK_KP0 SDLK_KP_0
   182 #define SDLK_KP1 SDLK_KP_1
   183 #define SDLK_KP2 SDLK_KP_2
   184 #define SDLK_KP3 SDLK_KP_3
   185 #define SDLK_KP4 SDLK_KP_4
   186 #define SDLK_KP5 SDLK_KP_5
   187 #define SDLK_KP6 SDLK_KP_6
   188 #define SDLK_KP7 SDLK_KP_7
   189 #define SDLK_KP8 SDLK_KP_8
   190 #define SDLK_KP9 SDLK_KP_9
   191 #define SDLK_NUMLOCK SDLK_NUMLOCKCLEAR
   192 #define SDLK_SCROLLOCK SDLK_SCROLLLOCK
   193 #define SDLK_PRINT SDLK_PRINTSCREEN
   194 
   195 /* The META modifier is equivalent to the GUI modifier from the USB standard */
   196 #define KMOD_LMETA KMOD_LGUI
   197 #define KMOD_RMETA KMOD_RGUI
   198 #define KMOD_META KMOD_GUI
   199 
   200 /* 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. */
   201 #define SDLK_LSUPER SDLK_LMETA
   202 #define SDLK_RSUPER SDLK_RMETA
   203 #define SDLK_COMPOSE SDLK_APPLICATION
   204 #define SDLK_BREAK SDLK_STOP
   205 #define SDLK_EURO SDLK_2
   206 
   207 
   208 #define SDL_SetModuleHandle(x)
   209 #define SDL_AllocSurface    SDL_CreateRGBSurface
   210 
   211 extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void);
   212 extern DECLSPEC char *SDLCALL SDL_AudioDriverName(char *namebuf,
   213                                                   int maxlen);
   214 extern DECLSPEC char *SDLCALL SDL_VideoDriverName(char *namebuf,
   215                                                   int maxlen);
   216 extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
   217 extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
   218                                             int height,
   219                                             int bpp,
   220                                             Uint32 flags);
   221 extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(SDL_PixelFormat * format,
   222                                                  Uint32 flags);
   223 extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width,
   224                                                       int height,
   225                                                       int bpp,
   226                                                       Uint32 flags);
   227 extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
   228 extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
   229                                              int numrects,
   230                                              SDL_Rect * rects);
   231 extern DECLSPEC void SDLCALL SDL_UpdateRect(SDL_Surface * screen,
   232                                             Sint32 x,
   233                                             Sint32 y,
   234                                             Uint32 w,
   235                                             Uint32 h);
   236 extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface * screen);
   237 extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface * surface,
   238                                          Uint32 flag,
   239                                          Uint8 alpha);
   240 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat(SDL_Surface * surface);
   241 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface * surface);
   242 extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title,
   243                                                const char *icon);
   244 extern DECLSPEC void SDLCALL SDL_WM_GetCaption(const char **title,
   245                                                const char **icon);
   246 extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon,
   247                                             Uint8 * mask);
   248 extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
   249 extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface);
   250 extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
   251 extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface,
   252                                            int flags,
   253                                            const SDL_Color * colors,
   254                                            int firstcolor,
   255                                            int ncolors);
   256 extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface * surface,
   257                                           const SDL_Color * colors,
   258                                           int firstcolor,
   259                                           int ncolors);
   260 extern DECLSPEC int SDLCALL SDL_GetWMInfo(struct SDL_SysWMinfo *info);
   261 extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
   262 extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x,
   263                                            Uint16 y);
   264 extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay(int width,
   265                                                           int height,
   266                                                           Uint32 format,
   267                                                           SDL_Surface *
   268                                                           display);
   269 extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay * overlay);
   270 extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay * overlay);
   271 extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay,
   272                                                   SDL_Rect * dstrect);
   273 extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
   274 extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
   275 extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay,
   276 int interval);
   277 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay,
   278                                               int *interval);
   279 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
   280 
   281 /* Ends C function definitions when using C++ */
   282 #ifdef __cplusplus
   283 /* *INDENT-OFF* */
   284 }
   285 /* *INDENT-ON* */
   286 #endif
   287 #include "close_code.h"
   288 
   289 #endif /* _SDL_compat_h */
   290 
   291 /* vi: set ts=4 sw=4 expandtab: */