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