include/SDL_compat.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 11 Aug 2007 20:54:31 +0000
changeset 2222 926294b2bb4e
parent 2153 760c1bd2d625
child 2266 e61ad15a205f
permissions -rw-r--r--
Emphasized the separation between SDL_Surface and SDL_Texture
- SDL_Surface is a system memory representation of pixel data
- SDL_Texture is a video memory representation of pixel data

The concept of SDL_Surface with SDL_HWSURFACE is no longer used.

Separated SDL_Texture types by usage rather than memory type
- SDL_TEXTUREACCESS_STATIC is for rarely changed pixel data,
can be placed in video memory.
- SDL_TEXTUREACCESS_STREAMING is for frequently changing pixel
data, usually placed in system memory or AGP memory.

Optimized the SDL_compat usage of the OpenGL renderer by only
using one copy of the framebuffer instead of two.
     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_ANYFORMAT       0x00100000
    41 #define SDL_HWPALETTE       0x00200000
    42 #define SDL_DOUBLEBUF       0x00400000
    43 #define SDL_FULLSCREEN      0x00800000
    44 #define SDL_RESIZABLE       0x01000000
    45 #define SDL_NOFRAME         0x02000000
    46 #define SDL_OPENGL          0x04000000
    47 #define SDL_HWSURFACE       0x08000001  /* Not used */
    48 #define SDL_ASYNCBLIT       0x08000000  /* Not used */
    49 #define SDL_HWACCEL         0x08000000  /* Not used */
    50 
    51 #define SDL_APPMOUSEFOCUS	0x01
    52 #define SDL_APPINPUTFOCUS	0x02
    53 #define SDL_APPACTIVE		0x04
    54 
    55 #define SDL_LOGPAL 0x01
    56 #define SDL_PHYSPAL 0x02
    57 
    58 #define SDL_ACTIVEEVENT	SDL_EVENT_RESERVED1
    59 #define SDL_VIDEORESIZE	SDL_EVENT_RESERVED2
    60 #define SDL_VIDEOEXPOSE	SDL_EVENT_RESERVED3
    61 #define SDL_ACTIVEEVENTMASK	SDL_EVENTMASK(SDL_ACTIVEEVENT)
    62 #define SDL_VIDEORESIZEMASK SDL_EVENTMASK(SDL_VIDEORESIZE)
    63 #define SDL_VIDEOEXPOSEMASK SDL_EVENTMASK(SDL_VIDEOEXPOSE)
    64 
    65 #define SDL_BUTTON_WHEELUP	4
    66 #define SDL_BUTTON_WHEELDOWN	5
    67 
    68 #define SDL_DEFAULT_REPEAT_DELAY	500
    69 #define SDL_DEFAULT_REPEAT_INTERVAL	30
    70 
    71 typedef struct SDL_VideoInfo
    72 {
    73     Uint32 hw_available:1;
    74     Uint32 wm_available:1;
    75     Uint32 UnusedBits1:6;
    76     Uint32 UnusedBits2:1;
    77     Uint32 blit_hw:1;
    78     Uint32 blit_hw_CC:1;
    79     Uint32 blit_hw_A:1;
    80     Uint32 blit_sw:1;
    81     Uint32 blit_sw_CC:1;
    82     Uint32 blit_sw_A:1;
    83     Uint32 blit_fill:1;
    84     Uint32 UnusedBits3:16;
    85     Uint32 video_mem;
    86 
    87     SDL_PixelFormat *vfmt;
    88 } SDL_VideoInfo;
    89 
    90 /* The most common video overlay formats.
    91    For an explanation of these pixel formats, see:
    92    http://www.webartz.com/fourcc/indexyuv.htm
    93 
    94    For information on the relationship between color spaces, see:
    95    http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
    96  */
    97 #define SDL_YV12_OVERLAY  0x32315659    /* Planar mode: Y + V + U  (3 planes) */
    98 #define SDL_IYUV_OVERLAY  0x56555949    /* Planar mode: Y + U + V  (3 planes) */
    99 #define SDL_YUY2_OVERLAY  0x32595559    /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
   100 #define SDL_UYVY_OVERLAY  0x59565955    /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
   101 #define SDL_YVYU_OVERLAY  0x55595659    /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
   102 
   103 /* The YUV hardware video overlay */
   104 typedef struct SDL_Overlay
   105 {
   106     Uint32 format;              /* Read-only */
   107     int w, h;                   /* Read-only */
   108     int planes;                 /* Read-only */
   109     Uint16 *pitches;            /* Read-only */
   110     Uint8 **pixels;             /* Read-write */
   111 
   112     /* Hardware-specific surface info */
   113     struct private_yuvhwfuncs *hwfuncs;
   114     struct private_yuvhwdata *hwdata;
   115 
   116     /* Special flags */
   117     Uint32 hw_overlay:1;        /* Flag: This overlay hardware accelerated? */
   118     Uint32 UnusedBits:31;
   119 } SDL_Overlay;
   120 
   121 typedef enum
   122 {
   123     SDL_GRAB_QUERY = -1,
   124     SDL_GRAB_OFF = 0,
   125     SDL_GRAB_ON = 1
   126 } SDL_GrabMode;
   127 
   128 struct SDL_SysWMinfo;
   129 
   130 #define SDL_SetModuleHandle(x)
   131 #define SDL_AllocSurface    SDL_CreateRGBSurface
   132 
   133 extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void);
   134 extern DECLSPEC char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
   135 extern DECLSPEC char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
   136 extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
   137 extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp,
   138                                             Uint32 flags);
   139 extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(SDL_PixelFormat * format,
   140                                                  Uint32 flags);
   141 extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height,
   142                                                       int bpp, Uint32 flags);
   143 extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
   144 extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
   145                                              int numrects, SDL_Rect * rects);
   146 extern DECLSPEC void SDLCALL SDL_UpdateRect(SDL_Surface * screen, Sint32 x,
   147                                             Sint32 y, Uint32 w, Uint32 h);
   148 extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface * screen);
   149 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat(SDL_Surface * surface);
   150 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *
   151                                                             surface);
   152 extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title,
   153                                                const char *icon);
   154 extern DECLSPEC void SDLCALL SDL_WM_GetCaption(const char **title,
   155                                                const char **icon);
   156 extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask);
   157 extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
   158 extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface);
   159 extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
   160 extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface, int flags,
   161                                            const SDL_Color * colors,
   162                                            int firstcolor, int ncolors);
   163 extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface * surface,
   164                                           const SDL_Color * colors,
   165                                           int firstcolor, int ncolors);
   166 extern DECLSPEC int SDLCALL SDL_GetWMInfo(struct SDL_SysWMinfo *info);
   167 extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
   168 extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
   169 extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay(int width,
   170                                                           int height,
   171                                                           Uint32 format,
   172                                                           SDL_Surface *
   173                                                           display);
   174 extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay * overlay);
   175 extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay * overlay);
   176 extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay,
   177                                                   SDL_Rect * dstrect);
   178 extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
   179 extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
   180 extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
   181 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
   182 
   183 /* Ends C function definitions when using C++ */
   184 #ifdef __cplusplus
   185 /* *INDENT-OFF* */
   186 }
   187 /* *INDENT-ON* */
   188 #endif
   189 #include "close_code.h"
   190 
   191 #endif /* _SDL_compat_h */
   192 
   193 /* vi: set ts=4 sw=4 expandtab: */