include/SDL_compat.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 09 Dec 2009 15:56:56 +0000
changeset 3536 0267b8b1595c
parent 3407 d3baf5ac4e37
child 3560 5543db4239e6
permissions -rw-r--r--
Added interfaces for batch drawing of points, lines and rects:
SDL_DrawPoints()
SDL_BlendPoints()
SDL_BlendLines()
SDL_DrawLines()
SDL_FillRects()
SDL_BlendRects()
SDL_RenderPoints()
SDL_RenderLines()
SDL_RenderRects()
Renamed SDL_RenderFill() to SDL_RenderRect()
     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_0	'0'
   197 #define SDLK_1	'1'
   198 #define SDLK_2	'2'
   199 #define SDLK_3	'3'
   200 #define SDLK_4	'4'
   201 #define SDLK_5	'5'
   202 #define SDLK_6	'6'
   203 #define SDLK_7	'7'
   204 #define SDLK_8	'8'
   205 #define SDLK_9	'9'
   206 #define SDLK_a  'a'
   207 #define SDLK_b  'b'
   208 #define SDLK_c  'c'
   209 #define SDLK_d  'd'
   210 #define SDLK_e  'e'
   211 #define SDLK_f  'f'
   212 #define SDLK_g  'g'
   213 #define SDLK_h  'h'
   214 #define SDLK_i  'i'
   215 #define SDLK_j  'j'
   216 #define SDLK_k  'k'
   217 #define SDLK_l  'l'
   218 #define SDLK_m  'm'
   219 #define SDLK_n  'n'
   220 #define SDLK_o  'o'
   221 #define SDLK_p  'p'
   222 #define SDLK_q  'q'
   223 #define SDLK_r  'r'
   224 #define SDLK_s  's'
   225 #define SDLK_t  't'
   226 #define SDLK_u  'u'
   227 #define SDLK_v  'v'
   228 #define SDLK_w  'w'
   229 #define SDLK_x  'x'
   230 #define SDLK_y  'y'
   231 #define SDLK_z  'z'
   232 #define SDLK_QUOTE      '\''
   233 #define SDLK_MINUS      '-'
   234 #define SDLK_BACKQUOTE  '`'
   235 #define SDLK_EXCLAIM    '!'
   236 #define SDLK_QUOTEDBL   '"'
   237 #define SDLK_HASH       '#'
   238 #define SDLK_DOLLAR     '$'
   239 #define SDLK_AMPERSAND  '&'
   240 #define SDLK_LEFTPAREN  '('
   241 #define SDLK_RIGHTPAREN ')'
   242 #define SDLK_ASTERISK   '*'
   243 #define SDLK_PLUS       '+'
   244 #define SDLK_COLON      ':'
   245 #define SDLK_LESS       '<'
   246 #define SDLK_GREATER    '>'
   247 #define SDLK_QUESTION   '?'
   248 #define SDLK_AT         '@'
   249 #define SDLK_CARET      '^'
   250 #define SDLK_UNDERSCORE '_'
   251 #define SDLK_KP0 SDLK_KP_0
   252 #define SDLK_KP1 SDLK_KP_1
   253 #define SDLK_KP2 SDLK_KP_2
   254 #define SDLK_KP3 SDLK_KP_3
   255 #define SDLK_KP4 SDLK_KP_4
   256 #define SDLK_KP5 SDLK_KP_5
   257 #define SDLK_KP6 SDLK_KP_6
   258 #define SDLK_KP7 SDLK_KP_7
   259 #define SDLK_KP8 SDLK_KP_8
   260 #define SDLK_KP9 SDLK_KP_9
   261 #define SDLK_NUMLOCK SDLK_NUMLOCKCLEAR
   262 #define SDLK_SCROLLOCK SDLK_SCROLLLOCK
   263 #define SDLK_PRINT SDLK_PRINTSCREEN
   264 /*@}*//*Renamed keys*/
   265 
   266 /**
   267  *  \name META modifier
   268  *  
   269  *  The META modifier is equivalent to the GUI modifier from the USB standard.
   270  */
   271 /*@{*/
   272 #define KMOD_LMETA KMOD_LGUI
   273 #define KMOD_RMETA KMOD_RGUI
   274 #define KMOD_META KMOD_GUI
   275 /*@}*//*META modifier*/
   276 
   277 /** 
   278  *  \name Not in USB
   279  *
   280  *  These keys don't appear in the USB specification (or at least not under 
   281  *  those names). I'm unsure if the following assignments make sense or if these
   282  *  codes should be defined as actual additional SDLK_ constants.
   283  */
   284 /*@{*/
   285 #define SDLK_LSUPER SDLK_LMETA
   286 #define SDLK_RSUPER SDLK_RMETA
   287 #define SDLK_COMPOSE SDLK_APPLICATION
   288 #define SDLK_BREAK SDLK_STOP
   289 #define SDLK_EURO SDLK_2
   290 /*@}*//*Not in USB*/
   291 
   292 /*@}*//*Obsolete or renamed key codes*/
   293 
   294 #define SDL_SetModuleHandle(x)
   295 #define SDL_AllocSurface    SDL_CreateRGBSurface
   296 
   297 extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void);
   298 extern DECLSPEC char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
   299 extern DECLSPEC char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
   300 extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
   301 extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
   302                                             int height,
   303                                             int bpp, Uint32 flags);
   304 extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(const SDL_PixelFormat *
   305                                                  format, Uint32 flags);
   306 extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height,
   307                                                       int bpp, Uint32 flags);
   308 extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
   309 extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
   310                                              int numrects, SDL_Rect * rects);
   311 extern DECLSPEC void SDLCALL SDL_UpdateRect(SDL_Surface * screen,
   312                                             Sint32 x,
   313                                             Sint32 y, Uint32 w, Uint32 h);
   314 extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface * screen);
   315 extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface * surface,
   316                                          Uint32 flag, Uint8 alpha);
   317 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat(SDL_Surface * surface);
   318 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *
   319                                                             surface);
   320 extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title,
   321                                                const char *icon);
   322 extern DECLSPEC void SDLCALL SDL_WM_GetCaption(const char **title,
   323                                                const char **icon);
   324 extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask);
   325 extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
   326 extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface);
   327 extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
   328 extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface,
   329                                            int flags,
   330                                            const SDL_Color * colors,
   331                                            int firstcolor, int ncolors);
   332 extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface * surface,
   333                                           const SDL_Color * colors,
   334                                           int firstcolor, int ncolors);
   335 extern DECLSPEC int SDLCALL SDL_GetWMInfo(struct SDL_SysWMinfo *info);
   336 extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
   337 extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
   338 extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay(int width,
   339                                                           int height,
   340                                                           Uint32 format,
   341                                                           SDL_Surface *
   342                                                           display);
   343 extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay * overlay);
   344 extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay * overlay);
   345 extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay,
   346                                                   SDL_Rect * dstrect);
   347 extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
   348 extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
   349 extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
   350 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
   351 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
   352 
   353 #define SDL_RenderFill  SDL_RenderRect
   354 
   355 /*@}*//*Compatibility*/
   356 
   357 /* Ends C function definitions when using C++ */
   358 #ifdef __cplusplus
   359 /* *INDENT-OFF* */
   360 }
   361 /* *INDENT-ON* */
   362 #endif
   363 #include "close_code.h"
   364 
   365 #endif /* _SDL_compat_h */
   366 
   367 /* vi: set ts=4 sw=4 expandtab: */