Removed the SDL 1.2 compatibility API... we'll see how painful this is.
authorSam Lantinga <slouken@libsdl.org>
Sun, 22 Jan 2012 18:11:41 -0500
changeset 62561d905b13b102
parent 6255 25bfc0f21c56
child 6257 4b6e961362fb
Removed the SDL 1.2 compatibility API... we'll see how painful this is.
Makefile.in
include/SDL.h
include/SDL_compat.h
include/SDL_events.h
src/SDL_compat.c
src/video/SDL_surface.c
test/Makefile.in
test/common.h
test/testalpha.c
test/testbitmap.c
test/testblitspeed.c
test/testcursor.c
test/testdyngl.c
test/testdyngles.c
test/testfill.c
test/testgamma.c
test/testgl.c
test/testime.c
test/testjoystick.c
test/testnative.c
test/testoverlay.c
test/testoverlay2.c
test/testshader.c
test/testsprite.c
test/testtimer.c
test/testvidinfo.c
test/testwin.c
test/testwm.c
test/threadwin.c
     1.1 --- a/Makefile.in	Sun Jan 22 17:50:35 2012 -0500
     1.2 +++ b/Makefile.in	Sun Jan 22 18:11:41 2012 -0500
     1.3 @@ -46,7 +46,6 @@
     1.4  	SDL_audio.h \
     1.5  	SDL_blendmode.h \
     1.6  	SDL_clipboard.h \
     1.7 -	SDL_compat.h \
     1.8  	SDL_cpuinfo.h \
     1.9  	SDL_endian.h \
    1.10  	SDL_error.h \
     2.1 --- a/include/SDL.h	Sun Jan 22 17:50:35 2012 -0500
     2.2 +++ b/include/SDL.h	Sun Jan 22 18:11:41 2012 -0500
     2.3 @@ -90,7 +90,6 @@
     2.4  #include "SDL_timer.h"
     2.5  #include "SDL_version.h"
     2.6  #include "SDL_video.h"
     2.7 -#include "SDL_compat.h"
     2.8  
     2.9  #include "begin_code.h"
    2.10  /* Set up for C function definitions, even when using C++ */
     3.1 --- a/include/SDL_compat.h	Sun Jan 22 17:50:35 2012 -0500
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,365 +0,0 @@
     3.4 -/*
     3.5 -  Simple DirectMedia Layer
     3.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     3.7 -
     3.8 -  This software is provided 'as-is', without any express or implied
     3.9 -  warranty.  In no event will the authors be held liable for any damages
    3.10 -  arising from the use of this software.
    3.11 -
    3.12 -  Permission is granted to anyone to use this software for any purpose,
    3.13 -  including commercial applications, and to alter it and redistribute it
    3.14 -  freely, subject to the following restrictions:
    3.15 -
    3.16 -  1. The origin of this software must not be misrepresented; you must not
    3.17 -     claim that you wrote the original software. If you use this software
    3.18 -     in a product, an acknowledgment in the product documentation would be
    3.19 -     appreciated but is not required.
    3.20 -  2. Altered source versions must be plainly marked as such, and must not be
    3.21 -     misrepresented as being the original software.
    3.22 -  3. This notice may not be removed or altered from any source distribution.
    3.23 -*/
    3.24 -
    3.25 - /**
    3.26 - *  \defgroup Compatibility SDL 1.2 Compatibility API
    3.27 - */
    3.28 -/*@{*/
    3.29 -
    3.30 -/**
    3.31 - *  \file SDL_compat.h
    3.32 - *
    3.33 - *  This file contains functions for backwards compatibility with SDL 1.2.
    3.34 - */
    3.35 -
    3.36 -/**
    3.37 - *  \def SDL_NO_COMPAT
    3.38 - *
    3.39 - *  #define SDL_NO_COMPAT to prevent SDL_compat.h from being included.
    3.40 - *  SDL_NO_COMPAT is intended to make it easier to covert SDL 1.2 code to
    3.41 - *  SDL 1.3/2.0.
    3.42 - */
    3.43 -
    3.44 - /*@}*/
    3.45 -
    3.46 -#ifdef SDL_NO_COMPAT
    3.47 -#define _SDL_compat_h
    3.48 -#endif
    3.49 -
    3.50 -#ifndef _SDL_compat_h
    3.51 -#define _SDL_compat_h
    3.52 -
    3.53 -#include "SDL_video.h"
    3.54 -#include "SDL_version.h"
    3.55 -
    3.56 -#include "begin_code.h"
    3.57 -/* Set up for C function definitions, even when using C++ */
    3.58 -#ifdef __cplusplus
    3.59 -/* *INDENT-OFF* */
    3.60 -extern "C" {
    3.61 -/* *INDENT-ON* */
    3.62 -#endif
    3.63 -
    3.64 -/**
    3.65 - *  \addtogroup Compatibility
    3.66 - */
    3.67 -/*@{*/
    3.68 -
    3.69 -/* Platform */
    3.70 -#ifdef __WIN32__
    3.71 -#undef __WIN32__
    3.72 -#define __WIN32__   1
    3.73 -#endif
    3.74 -
    3.75 -/**
    3.76 - *  \name Surface flags
    3.77 - */
    3.78 -/*@{*/
    3.79 -#define SDL_SWSURFACE       0x00000000  /**< \note Not used */
    3.80 -#define SDL_SRCALPHA        0x00010000
    3.81 -#define SDL_SRCCOLORKEY     0x00020000
    3.82 -#define SDL_ANYFORMAT       0x00100000
    3.83 -#define SDL_HWPALETTE       0x00200000
    3.84 -#define SDL_DOUBLEBUF       0x00400000
    3.85 -#define SDL_FULLSCREEN      0x00800000
    3.86 -#define SDL_RESIZABLE       0x01000000
    3.87 -#define SDL_NOFRAME         0x02000000
    3.88 -#define SDL_OPENGL          0x04000000
    3.89 -#define SDL_HWSURFACE       0x08000001  /**< \note Not used */
    3.90 -#define SDL_ASYNCBLIT       0x08000000  /**< \note Not used */
    3.91 -#define SDL_RLEACCELOK      0x08000000  /**< \note Not used */
    3.92 -#define SDL_HWACCEL         0x08000000  /**< \note Not used */
    3.93 -/*@}*//*Surface flags*/
    3.94 -
    3.95 -#define SDL_APPMOUSEFOCUS	0x01
    3.96 -#define SDL_APPINPUTFOCUS	0x02
    3.97 -#define SDL_APPACTIVE		0x04
    3.98 -
    3.99 -#define SDL_LOGPAL 0x01
   3.100 -#define SDL_PHYSPAL 0x02
   3.101 -
   3.102 -#define SDL_ACTIVEEVENT	SDL_EVENT_COMPAT1
   3.103 -#define SDL_VIDEORESIZE	SDL_EVENT_COMPAT2
   3.104 -#define SDL_VIDEOEXPOSE	SDL_EVENT_COMPAT3
   3.105 -#define SDL_ACTIVEEVENTMASK	SDL_ACTIVEEVENT, SDL_ACTIVEEVENT
   3.106 -#define SDL_VIDEORESIZEMASK SDL_VIDEORESIZE, SDL_VIDEORESIZE
   3.107 -#define SDL_VIDEOEXPOSEMASK SDL_VIDEOEXPOSE, SDL_VIDEOEXPOSE
   3.108 -#define SDL_WINDOWEVENTMASK SDL_WINDOWEVENT, SDL_WINDOWEVENT
   3.109 -#define SDL_KEYDOWNMASK SDL_KEYDOWN, SDL_KEYDOWN
   3.110 -#define SDL_KEYUPMASK SDL_KEYUP, SDL_KEYUP
   3.111 -#define SDL_KEYEVENTMASK SDL_KEYDOWN, SDL_KEYUP
   3.112 -#define SDL_TEXTEDITINGMASK SDL_TEXTEDITING, SDL_TEXTEDITING
   3.113 -#define SDL_TEXTINPUTMASK SDL_TEXTINPUT, SDL_TEXTINPUT
   3.114 -#define SDL_MOUSEMOTIONMASK SDL_MOUSEMOTION, SDL_MOUSEMOTION
   3.115 -#define SDL_MOUSEBUTTONDOWNMASK SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONDOWN
   3.116 -#define SDL_MOUSEBUTTONUPMASK SDL_MOUSEBUTTONUP, SDL_MOUSEBUTTONUP
   3.117 -#define SDL_MOUSEWHEELMASK SDL_MOUSEWHEEL, SDL_MOUSEWHEEL
   3.118 -#define SDL_MOUSEEVENTMASK SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP
   3.119 -#define SDL_JOYAXISMOTIONMASK SDL_JOYAXISMOTION, SDL_JOYAXISMOTION
   3.120 -#define SDL_JOYBALLMOTIONMASK SDL_JOYBALLMOTION, SDL_JOYBALLMOTION
   3.121 -#define SDL_JOYHATMOTIONMASK SDL_JOYHATMOTION, SDL_JOYHATMOTION
   3.122 -#define SDL_JOYBUTTONDOWNMASK SDL_JOYBUTTONDOWN, SDL_JOYBUTTONDOWN
   3.123 -#define SDL_JOYBUTTONUPMASK SDL_JOYBUTTONUP, SDL_JOYBUTTONUP
   3.124 -#define SDL_JOYEVENTMASK SDL_JOYAXISMOTION, SDL_JOYBUTTONUP
   3.125 -#define SDL_QUITMASK SDL_QUIT, SDL_QUIT
   3.126 -#define SDL_SYSWMEVENTMASK SDL_SYSWMEVENT, SDL_SYSWMEVENT
   3.127 -#define SDL_PROXIMITYINMASK SDL_PROXIMITYIN, SDL_PROXIMITYIN
   3.128 -#define SDL_PROXIMITYOUTMASK SDL_PROXIMITYOUT, SDL_PROXIMITYOUT
   3.129 -#define SDL_ALLEVENTS SDL_FIRSTEVENT, SDL_LASTEVENT
   3.130 -
   3.131 -#define SDL_BUTTON_WHEELUP	4
   3.132 -#define SDL_BUTTON_WHEELDOWN	5
   3.133 -
   3.134 -#define SDL_DEFAULT_REPEAT_DELAY	500
   3.135 -#define SDL_DEFAULT_REPEAT_INTERVAL	30
   3.136 -
   3.137 -typedef struct SDL_VideoInfo
   3.138 -{
   3.139 -    Uint32 hw_available:1;
   3.140 -    Uint32 wm_available:1;
   3.141 -    Uint32 UnusedBits1:6;
   3.142 -    Uint32 UnusedBits2:1;
   3.143 -    Uint32 blit_hw:1;
   3.144 -    Uint32 blit_hw_CC:1;
   3.145 -    Uint32 blit_hw_A:1;
   3.146 -    Uint32 blit_sw:1;
   3.147 -    Uint32 blit_sw_CC:1;
   3.148 -    Uint32 blit_sw_A:1;
   3.149 -    Uint32 blit_fill:1;
   3.150 -    Uint32 UnusedBits3:16;
   3.151 -    Uint32 video_mem;
   3.152 -
   3.153 -    SDL_PixelFormat *vfmt;
   3.154 -
   3.155 -    int current_w;
   3.156 -    int current_h;
   3.157 -} SDL_VideoInfo;
   3.158 -
   3.159 -/**
   3.160 - *  \name Overlay formats
   3.161 - *
   3.162 - *  The most common video overlay formats.
   3.163 - *  
   3.164 - *  For an explanation of these pixel formats, see:
   3.165 - *  http://www.webartz.com/fourcc/indexyuv.htm
   3.166 - *  
   3.167 - *  For information on the relationship between color spaces, see:
   3.168 - *  http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
   3.169 - */
   3.170 -/*@{*/
   3.171 -#define SDL_YV12_OVERLAY  0x32315659    /**< Planar mode: Y + V + U  (3 planes) */
   3.172 -#define SDL_IYUV_OVERLAY  0x56555949    /**< Planar mode: Y + U + V  (3 planes) */
   3.173 -#define SDL_YUY2_OVERLAY  0x32595559    /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
   3.174 -#define SDL_UYVY_OVERLAY  0x59565955    /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
   3.175 -#define SDL_YVYU_OVERLAY  0x55595659    /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
   3.176 -/*@}*//*Overlay formats*/
   3.177 -
   3.178 -/**
   3.179 - *  The YUV hardware video overlay.
   3.180 - */
   3.181 -typedef struct SDL_Overlay
   3.182 -{
   3.183 -    Uint32 format;              /**< Read-only */
   3.184 -    int w, h;                   /**< Read-only */
   3.185 -    int planes;                 /**< Read-only */
   3.186 -    Uint16 *pitches;            /**< Read-only */
   3.187 -    Uint8 **pixels;             /**< Read-write */
   3.188 -
   3.189 -    /** 
   3.190 -     *  \name Hardware-specific surface info
   3.191 -     */
   3.192 -    /*@{*/
   3.193 -    struct private_yuvhwfuncs *hwfuncs;
   3.194 -    struct private_yuvhwdata *hwdata;
   3.195 -    /*@}*//*Hardware-specific surface info*/
   3.196 -
   3.197 -    /** 
   3.198 -     *  \name Special flags
   3.199 -     */
   3.200 -    /*@{*/
   3.201 -    Uint32 hw_overlay:1;        /**< Flag: This overlay hardware accelerated? */
   3.202 -    Uint32 UnusedBits:31;
   3.203 -    /*@}*//*Special flags*/
   3.204 -} SDL_Overlay;
   3.205 -
   3.206 -typedef enum
   3.207 -{
   3.208 -    SDL_GRAB_QUERY = -1,
   3.209 -    SDL_GRAB_OFF = 0,
   3.210 -    SDL_GRAB_ON = 1
   3.211 -} SDL_GrabMode;
   3.212 -
   3.213 -struct SDL_SysWMinfo;
   3.214 -
   3.215 -/**
   3.216 - *  \name Obsolete or renamed key codes
   3.217 - */
   3.218 -/*@{*/
   3.219 -
   3.220 -#define SDL_keysym		SDL_Keysym
   3.221 -#define SDL_KeySym		SDL_Keysym
   3.222 -#define SDL_scancode	SDL_Scancode
   3.223 -#define SDL_ScanCode	SDL_Scancode
   3.224 -#define SDLKey          SDL_Keycode
   3.225 -#define SDLMod          SDL_Keymod
   3.226 -
   3.227 -/** 
   3.228 - *  \name Renamed keys
   3.229 - *
   3.230 - *  These key constants were renamed for clarity or consistency. 
   3.231 - */
   3.232 -/*@{*/
   3.233 -#define SDLK_KP0 SDLK_KP_0
   3.234 -#define SDLK_KP1 SDLK_KP_1
   3.235 -#define SDLK_KP2 SDLK_KP_2
   3.236 -#define SDLK_KP3 SDLK_KP_3
   3.237 -#define SDLK_KP4 SDLK_KP_4
   3.238 -#define SDLK_KP5 SDLK_KP_5
   3.239 -#define SDLK_KP6 SDLK_KP_6
   3.240 -#define SDLK_KP7 SDLK_KP_7
   3.241 -#define SDLK_KP8 SDLK_KP_8
   3.242 -#define SDLK_KP9 SDLK_KP_9
   3.243 -#define SDLK_NUMLOCK SDLK_NUMLOCKCLEAR
   3.244 -#define SDLK_SCROLLOCK SDLK_SCROLLLOCK
   3.245 -#define SDLK_PRINT SDLK_PRINTSCREEN
   3.246 -#define SDLK_LMETA SDLK_LGUI
   3.247 -#define SDLK_RMETA SDLK_RGUI
   3.248 -/*@}*//*Renamed keys*/
   3.249 -
   3.250 -/**
   3.251 - *  \name META modifier
   3.252 - *  
   3.253 - *  The META modifier is equivalent to the GUI modifier from the USB standard.
   3.254 - */
   3.255 -/*@{*/
   3.256 -#define KMOD_LMETA KMOD_LGUI
   3.257 -#define KMOD_RMETA KMOD_RGUI
   3.258 -#define KMOD_META KMOD_GUI
   3.259 -/*@}*//*META modifier*/
   3.260 -
   3.261 -/** 
   3.262 - *  \name Not in USB
   3.263 - *
   3.264 - *  These keys don't appear in the USB specification (or at least not under 
   3.265 - *  those names). I'm unsure if the following assignments make sense or if these
   3.266 - *  codes should be defined as actual additional SDLK_ constants.
   3.267 - */
   3.268 -/*@{*/
   3.269 -#define SDLK_LSUPER SDLK_LMETA
   3.270 -#define SDLK_RSUPER SDLK_RMETA
   3.271 -#define SDLK_COMPOSE SDLK_APPLICATION
   3.272 -#define SDLK_BREAK SDLK_STOP
   3.273 -#define SDLK_EURO SDLK_2
   3.274 -/*@}*//*Not in USB*/
   3.275 -
   3.276 -/*@}*//*Obsolete or renamed key codes*/
   3.277 -
   3.278 -#define SDL_SetModuleHandle(x)
   3.279 -#define SDL_AllocSurface    SDL_CreateRGBSurface
   3.280 -
   3.281 -extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void);
   3.282 -extern DECLSPEC const char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
   3.283 -extern DECLSPEC const char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
   3.284 -extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
   3.285 -extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
   3.286 -                                            int height,
   3.287 -                                            int bpp, Uint32 flags);
   3.288 -extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(const SDL_PixelFormat *
   3.289 -                                                 format, Uint32 flags);
   3.290 -extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height,
   3.291 -                                                      int bpp, Uint32 flags);
   3.292 -extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
   3.293 -extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
   3.294 -                                             int numrects, SDL_Rect * rects);
   3.295 -extern DECLSPEC void SDLCALL SDL_UpdateRect(SDL_Surface * screen,
   3.296 -                                            Sint32 x,
   3.297 -                                            Sint32 y, Uint32 w, Uint32 h);
   3.298 -extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface * screen);
   3.299 -extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface * surface,
   3.300 -                                         Uint32 flag, Uint8 alpha);
   3.301 -extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat(SDL_Surface * surface);
   3.302 -extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *
   3.303 -                                                            surface);
   3.304 -extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title,
   3.305 -                                               const char *icon);
   3.306 -extern DECLSPEC void SDLCALL SDL_WM_GetCaption(const char **title,
   3.307 -                                               const char **icon);
   3.308 -extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask);
   3.309 -extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
   3.310 -extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface);
   3.311 -extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
   3.312 -extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface,
   3.313 -                                           int flags,
   3.314 -                                           const SDL_Color * colors,
   3.315 -                                           int firstcolor, int ncolors);
   3.316 -extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface * surface,
   3.317 -                                          const SDL_Color * colors,
   3.318 -                                          int firstcolor, int ncolors);
   3.319 -extern DECLSPEC int SDLCALL SDL_GetWMInfo(struct SDL_SysWMinfo *info);
   3.320 -extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
   3.321 -extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
   3.322 -extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay(int width,
   3.323 -                                                          int height,
   3.324 -                                                          Uint32 format,
   3.325 -                                                          SDL_Surface *
   3.326 -                                                          display);
   3.327 -extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay * overlay);
   3.328 -extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay * overlay);
   3.329 -extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay,
   3.330 -                                                  SDL_Rect * dstrect);
   3.331 -extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
   3.332 -extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
   3.333 -extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue);
   3.334 -extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 * red,
   3.335 -                                             const Uint16 * green,
   3.336 -                                             const Uint16 * blue);
   3.337 -extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 * red, Uint16 * green,
   3.338 -                                             Uint16 * blue);
   3.339 -extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
   3.340 -extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
   3.341 -extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
   3.342 -
   3.343 -typedef SDL_Window* SDL_WindowID;
   3.344 -
   3.345 -#define SDL_KillThread(X)
   3.346 -
   3.347 -/* The timeslice and timer resolution are no longer relevant */
   3.348 -#define SDL_TIMESLICE		10
   3.349 -#define TIMER_RESOLUTION	10
   3.350 -
   3.351 -typedef Uint32 (SDLCALL * SDL_OldTimerCallback) (Uint32 interval);
   3.352 -extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_OldTimerCallback callback);
   3.353 -
   3.354 -extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
   3.355 -
   3.356 -/*@}*//*Compatibility*/
   3.357 -
   3.358 -/* Ends C function definitions when using C++ */
   3.359 -#ifdef __cplusplus
   3.360 -/* *INDENT-OFF* */
   3.361 -}
   3.362 -/* *INDENT-ON* */
   3.363 -#endif
   3.364 -#include "close_code.h"
   3.365 -
   3.366 -#endif /* _SDL_compat_h */
   3.367 -
   3.368 -/* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/include/SDL_events.h	Sun Jan 22 17:50:35 2012 -0500
     4.2 +++ b/include/SDL_events.h	Sun Jan 22 18:11:41 2012 -0500
     4.3 @@ -109,12 +109,6 @@
     4.4      /* Drag and drop events */
     4.5      SDL_DROPFILE        = 0x1000, /**< The system requests a file open */
     4.6  
     4.7 -    /* Obsolete events */
     4.8 -    SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */
     4.9 -    SDL_EVENT_COMPAT2,
    4.10 -    SDL_EVENT_COMPAT3,
    4.11 -
    4.12 -
    4.13      /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
    4.14       *  and should be allocated with SDL_RegisterEvents()
    4.15       */
    4.16 @@ -419,36 +413,6 @@
    4.17      SDL_SysWMmsg *msg;  /**< driver dependent data, defined in SDL_syswm.h */
    4.18  } SDL_SysWMEvent;
    4.19  
    4.20 -#ifndef SDL_NO_COMPAT
    4.21 -/**
    4.22 - *  \addtogroup Compatibility 
    4.23 - */
    4.24 -/*@{*/
    4.25 -
    4.26 -/**
    4.27 - *  \name Typedefs for backwards compatibility
    4.28 - */
    4.29 -/*@{*/
    4.30 -typedef struct SDL_ActiveEvent
    4.31 -{
    4.32 -    Uint32 type;
    4.33 -    Uint32 timestamp;
    4.34 -    Uint8 gain;
    4.35 -    Uint8 state;
    4.36 -} SDL_ActiveEvent;
    4.37 -
    4.38 -typedef struct SDL_ResizeEvent
    4.39 -{
    4.40 -    Uint32 type;
    4.41 -    Uint32 timestamp;
    4.42 -    int w;
    4.43 -    int h;
    4.44 -} SDL_ResizeEvent;
    4.45 -/*@}*/
    4.46 -
    4.47 -/*@}*//*Compatibility*/
    4.48 -#endif
    4.49 -
    4.50  /**
    4.51   *  \brief General event structure
    4.52   */
    4.53 @@ -474,14 +438,6 @@
    4.54      SDL_MultiGestureEvent mgesture; /**< Multi Finger Gesture data */
    4.55      SDL_DollarGestureEvent dgesture; /**< Multi Finger Gesture data */
    4.56      SDL_DropEvent drop;             /**< Drag and drop event data */
    4.57 -
    4.58 -    /** Temporarily here for backwards compatibility */
    4.59 -    /*@{*/
    4.60 -#ifndef SDL_NO_COMPAT
    4.61 -    SDL_ActiveEvent active;
    4.62 -    SDL_ResizeEvent resize;
    4.63 -#endif
    4.64 -    /*@}*/
    4.65  } SDL_Event;
    4.66  
    4.67  
     5.1 --- a/src/SDL_compat.c	Sun Jan 22 17:50:35 2012 -0500
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,1816 +0,0 @@
     5.4 -/*
     5.5 -  Simple DirectMedia Layer
     5.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     5.7 -
     5.8 -  This software is provided 'as-is', without any express or implied
     5.9 -  warranty.  In no event will the authors be held liable for any damages
    5.10 -  arising from the use of this software.
    5.11 -
    5.12 -  Permission is granted to anyone to use this software for any purpose,
    5.13 -  including commercial applications, and to alter it and redistribute it
    5.14 -  freely, subject to the following restrictions:
    5.15 -
    5.16 -  1. The origin of this software must not be misrepresented; you must not
    5.17 -     claim that you wrote the original software. If you use this software
    5.18 -     in a product, an acknowledgment in the product documentation would be
    5.19 -     appreciated but is not required.
    5.20 -  2. Altered source versions must be plainly marked as such, and must not be
    5.21 -     misrepresented as being the original software.
    5.22 -  3. This notice may not be removed or altered from any source distribution.
    5.23 -*/
    5.24 -#include "SDL_config.h"
    5.25 -
    5.26 -/* This file contains functions for backwards compatibility with SDL 1.2 */
    5.27 -
    5.28 -#include "SDL.h"
    5.29 -#include "SDL_syswm.h"
    5.30 -
    5.31 -#include "video/SDL_sysvideo.h"
    5.32 -#include "video/SDL_pixels_c.h"
    5.33 -#include "render/SDL_yuv_sw_c.h"
    5.34 -
    5.35 -
    5.36 -static SDL_Window *SDL_VideoWindow = NULL;
    5.37 -static SDL_Surface *SDL_WindowSurface = NULL;
    5.38 -static SDL_Surface *SDL_VideoSurface = NULL;
    5.39 -static SDL_Surface *SDL_ShadowSurface = NULL;
    5.40 -static SDL_Surface *SDL_PublicSurface = NULL;
    5.41 -static SDL_GLContext *SDL_VideoContext = NULL;
    5.42 -static Uint32 SDL_VideoFlags = 0;
    5.43 -static SDL_Rect SDL_VideoViewport;
    5.44 -static char *wm_title = NULL;
    5.45 -static SDL_Surface *SDL_VideoIcon;
    5.46 -static int SDL_enabled_UNICODE = 0;
    5.47 -
    5.48 -const char *
    5.49 -SDL_AudioDriverName(char *namebuf, int maxlen)
    5.50 -{
    5.51 -    const char *name = SDL_GetCurrentAudioDriver();
    5.52 -    if (name) {
    5.53 -        if (namebuf) {
    5.54 -            SDL_strlcpy(namebuf, name, maxlen);
    5.55 -            return namebuf;
    5.56 -        } else {
    5.57 -            return name;
    5.58 -        }
    5.59 -    }
    5.60 -    return NULL;
    5.61 -}
    5.62 -
    5.63 -const char *
    5.64 -SDL_VideoDriverName(char *namebuf, int maxlen)
    5.65 -{
    5.66 -    const char *name = SDL_GetCurrentVideoDriver();
    5.67 -    if (name) {
    5.68 -        if (namebuf) {
    5.69 -            SDL_strlcpy(namebuf, name, maxlen);
    5.70 -            return namebuf;
    5.71 -        } else {
    5.72 -            return name;
    5.73 -        }
    5.74 -    }
    5.75 -    return NULL;
    5.76 -}
    5.77 -
    5.78 -static int
    5.79 -GetVideoDisplay()
    5.80 -{
    5.81 -    const char *variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_DISPLAY");
    5.82 -    if ( !variable ) {
    5.83 -        variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_HEAD");
    5.84 -    }
    5.85 -    if ( variable ) {
    5.86 -        return SDL_atoi(variable);
    5.87 -    } else {
    5.88 -        return 0;
    5.89 -    }
    5.90 -}
    5.91 -
    5.92 -const SDL_VideoInfo *
    5.93 -SDL_GetVideoInfo(void)
    5.94 -{
    5.95 -    static SDL_VideoInfo info;
    5.96 -    SDL_DisplayMode mode;
    5.97 -
    5.98 -    /* Memory leak, compatibility code, who cares? */
    5.99 -    if (!info.vfmt && SDL_GetDesktopDisplayMode(GetVideoDisplay(), &mode) == 0) {
   5.100 -        info.vfmt = SDL_AllocFormat(mode.format);
   5.101 -        info.current_w = mode.w;
   5.102 -        info.current_h = mode.h;
   5.103 -    }
   5.104 -    return &info;
   5.105 -}
   5.106 -
   5.107 -int
   5.108 -SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags)
   5.109 -{
   5.110 -    int i, actual_bpp = 0;
   5.111 -
   5.112 -    if (!SDL_GetVideoDevice()) {
   5.113 -        return 0;
   5.114 -    }
   5.115 -
   5.116 -    if (!(flags & SDL_FULLSCREEN)) {
   5.117 -        SDL_DisplayMode mode;
   5.118 -        SDL_GetDesktopDisplayMode(GetVideoDisplay(), &mode);
   5.119 -        return SDL_BITSPERPIXEL(mode.format);
   5.120 -    }
   5.121 -
   5.122 -    for (i = 0; i < SDL_GetNumDisplayModes(GetVideoDisplay()); ++i) {
   5.123 -        SDL_DisplayMode mode;
   5.124 -        SDL_GetDisplayMode(GetVideoDisplay(), i, &mode);
   5.125 -        if (!mode.w || !mode.h || (width == mode.w && height == mode.h)) {
   5.126 -            if (!mode.format) {
   5.127 -                return bpp;
   5.128 -            }
   5.129 -            if (SDL_BITSPERPIXEL(mode.format) >= (Uint32) bpp) {
   5.130 -                actual_bpp = SDL_BITSPERPIXEL(mode.format);
   5.131 -            }
   5.132 -        }
   5.133 -    }
   5.134 -    return actual_bpp;
   5.135 -}
   5.136 -
   5.137 -SDL_Rect **
   5.138 -SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags)
   5.139 -{
   5.140 -    int i, nmodes;
   5.141 -    SDL_Rect **modes;
   5.142 -
   5.143 -    if (!SDL_GetVideoDevice()) {
   5.144 -        return NULL;
   5.145 -    }
   5.146 -
   5.147 -    if (!(flags & SDL_FULLSCREEN)) {
   5.148 -        return (SDL_Rect **) (-1);
   5.149 -    }
   5.150 -
   5.151 -    if (!format) {
   5.152 -        format = SDL_GetVideoInfo()->vfmt;
   5.153 -    }
   5.154 -
   5.155 -    /* Memory leak, but this is a compatibility function, who cares? */
   5.156 -    nmodes = 0;
   5.157 -    modes = NULL;
   5.158 -    for (i = 0; i < SDL_GetNumDisplayModes(GetVideoDisplay()); ++i) {
   5.159 -        SDL_DisplayMode mode;
   5.160 -        int bpp;
   5.161 -
   5.162 -        SDL_GetDisplayMode(GetVideoDisplay(), i, &mode);
   5.163 -        if (!mode.w || !mode.h) {
   5.164 -            return (SDL_Rect **) (-1);
   5.165 -        }
   5.166 -        
   5.167 -        /* Copied from src/video/SDL_pixels.c:SDL_PixelFormatEnumToMasks */
   5.168 -        if (SDL_BYTESPERPIXEL(mode.format) <= 2) {
   5.169 -            bpp = SDL_BITSPERPIXEL(mode.format);
   5.170 -        } else {
   5.171 -            bpp = SDL_BYTESPERPIXEL(mode.format) * 8;
   5.172 -        }
   5.173 -
   5.174 -        if (bpp != format->BitsPerPixel) {
   5.175 -            continue;
   5.176 -        }
   5.177 -        if (nmodes > 0 && modes[nmodes - 1]->w == mode.w
   5.178 -            && modes[nmodes - 1]->h == mode.h) {
   5.179 -            continue;
   5.180 -        }
   5.181 -
   5.182 -        modes = SDL_realloc(modes, (nmodes + 2) * sizeof(*modes));
   5.183 -        if (!modes) {
   5.184 -            return NULL;
   5.185 -        }
   5.186 -        modes[nmodes] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect));
   5.187 -        if (!modes[nmodes]) {
   5.188 -            return NULL;
   5.189 -        }
   5.190 -        modes[nmodes]->x = 0;
   5.191 -        modes[nmodes]->y = 0;
   5.192 -        modes[nmodes]->w = mode.w;
   5.193 -        modes[nmodes]->h = mode.h;
   5.194 -        ++nmodes;
   5.195 -    }
   5.196 -    if (modes) {
   5.197 -        modes[nmodes] = NULL;
   5.198 -    }
   5.199 -    return modes;
   5.200 -}
   5.201 -
   5.202 -static int
   5.203 -SDL_CompatEventFilter(void *userdata, SDL_Event * event)
   5.204 -{
   5.205 -    SDL_Event fake;
   5.206 -
   5.207 -    switch (event->type) {
   5.208 -    case SDL_WINDOWEVENT:
   5.209 -        switch (event->window.event) {
   5.210 -        case SDL_WINDOWEVENT_EXPOSED:
   5.211 -            if (!SDL_HasEvent(SDL_VIDEOEXPOSE)) {
   5.212 -                fake.type = SDL_VIDEOEXPOSE;
   5.213 -                SDL_PushEvent(&fake);
   5.214 -            }
   5.215 -            break;
   5.216 -        case SDL_WINDOWEVENT_RESIZED:
   5.217 -            SDL_FlushEvent(SDL_VIDEORESIZE);
   5.218 -            /* We don't want to expose that the window width and height will
   5.219 -               be different if we don't get the desired fullscreen mode.
   5.220 -            */
   5.221 -            if (SDL_VideoWindow && !(SDL_GetWindowFlags(SDL_VideoWindow) & SDL_WINDOW_FULLSCREEN)) {
   5.222 -                fake.type = SDL_VIDEORESIZE;
   5.223 -                fake.resize.w = event->window.data1;
   5.224 -                fake.resize.h = event->window.data2;
   5.225 -                SDL_PushEvent(&fake);
   5.226 -            }
   5.227 -            break;
   5.228 -        case SDL_WINDOWEVENT_MINIMIZED:
   5.229 -            fake.type = SDL_ACTIVEEVENT;
   5.230 -            fake.active.gain = 0;
   5.231 -            fake.active.state = SDL_APPACTIVE;
   5.232 -            SDL_PushEvent(&fake);
   5.233 -            break;
   5.234 -        case SDL_WINDOWEVENT_RESTORED:
   5.235 -            fake.type = SDL_ACTIVEEVENT;
   5.236 -            fake.active.gain = 1;
   5.237 -            fake.active.state = SDL_APPACTIVE;
   5.238 -            SDL_PushEvent(&fake);
   5.239 -            break;
   5.240 -        case SDL_WINDOWEVENT_ENTER:
   5.241 -            fake.type = SDL_ACTIVEEVENT;
   5.242 -            fake.active.gain = 1;
   5.243 -            fake.active.state = SDL_APPMOUSEFOCUS;
   5.244 -            SDL_PushEvent(&fake);
   5.245 -            break;
   5.246 -        case SDL_WINDOWEVENT_LEAVE:
   5.247 -            fake.type = SDL_ACTIVEEVENT;
   5.248 -            fake.active.gain = 0;
   5.249 -            fake.active.state = SDL_APPMOUSEFOCUS;
   5.250 -            SDL_PushEvent(&fake);
   5.251 -            break;
   5.252 -        case SDL_WINDOWEVENT_FOCUS_GAINED:
   5.253 -            fake.type = SDL_ACTIVEEVENT;
   5.254 -            fake.active.gain = 1;
   5.255 -            fake.active.state = SDL_APPINPUTFOCUS;
   5.256 -            SDL_PushEvent(&fake);
   5.257 -            break;
   5.258 -        case SDL_WINDOWEVENT_FOCUS_LOST:
   5.259 -            fake.type = SDL_ACTIVEEVENT;
   5.260 -            fake.active.gain = 0;
   5.261 -            fake.active.state = SDL_APPINPUTFOCUS;
   5.262 -            SDL_PushEvent(&fake);
   5.263 -            break;
   5.264 -        case SDL_WINDOWEVENT_CLOSE:
   5.265 -            fake.type = SDL_QUIT;
   5.266 -            SDL_PushEvent(&fake);
   5.267 -            break;
   5.268 -        }
   5.269 -    case SDL_KEYDOWN:
   5.270 -    case SDL_KEYUP:
   5.271 -        {
   5.272 -            Uint32 unicode = 0;
   5.273 -            if (event->key.type == SDL_KEYDOWN && event->key.keysym.sym < 256) {
   5.274 -                unicode = event->key.keysym.sym;
   5.275 -                if (unicode >= 'a' && unicode <= 'z') {
   5.276 -                    int shifted = !!(event->key.keysym.mod & KMOD_SHIFT);
   5.277 -                    int capslock = !!(event->key.keysym.mod & KMOD_CAPS);
   5.278 -                    if ((shifted ^ capslock) != 0) {
   5.279 -                        unicode = SDL_toupper(unicode);
   5.280 -                    }
   5.281 -                }
   5.282 -            }
   5.283 -            if (unicode) {
   5.284 -                event->key.keysym.unicode = unicode;
   5.285 -            }
   5.286 -            break;
   5.287 -        }
   5.288 -    case SDL_TEXTINPUT:
   5.289 -        {
   5.290 -            /* FIXME: Generate an old style key repeat event if needed */
   5.291 -            //printf("TEXTINPUT: '%s'\n", event->text.text);
   5.292 -            break;
   5.293 -        }
   5.294 -    case SDL_MOUSEMOTION:
   5.295 -        {
   5.296 -            event->motion.x -= SDL_VideoViewport.x;
   5.297 -            event->motion.y -= SDL_VideoViewport.y;
   5.298 -            break;
   5.299 -        }
   5.300 -    case SDL_MOUSEBUTTONDOWN:
   5.301 -    case SDL_MOUSEBUTTONUP:
   5.302 -        {
   5.303 -            event->button.x -= SDL_VideoViewport.x;
   5.304 -            event->button.y -= SDL_VideoViewport.y;
   5.305 -            break;
   5.306 -        }
   5.307 -    case SDL_MOUSEWHEEL:
   5.308 -        {
   5.309 -            Uint8 button;
   5.310 -            int x, y;
   5.311 -
   5.312 -            if (event->wheel.y == 0) {
   5.313 -                break;
   5.314 -            }
   5.315 -
   5.316 -            SDL_GetMouseState(&x, &y);
   5.317 -
   5.318 -            if (event->wheel.y > 0) {
   5.319 -                button = SDL_BUTTON_WHEELUP;
   5.320 -            } else {
   5.321 -                button = SDL_BUTTON_WHEELDOWN;
   5.322 -            }
   5.323 -
   5.324 -            fake.button.button = button;
   5.325 -            fake.button.x = x;
   5.326 -            fake.button.y = y;
   5.327 -            fake.button.windowID = event->wheel.windowID;
   5.328 -
   5.329 -            fake.type = SDL_MOUSEBUTTONDOWN;
   5.330 -            fake.button.state = SDL_PRESSED;
   5.331 -            SDL_PushEvent(&fake);
   5.332 -
   5.333 -            fake.type = SDL_MOUSEBUTTONUP;
   5.334 -            fake.button.state = SDL_RELEASED;
   5.335 -            SDL_PushEvent(&fake);
   5.336 -            break;
   5.337 -        }
   5.338 -
   5.339 -    }
   5.340 -    return 1;
   5.341 -}
   5.342 -
   5.343 -static void
   5.344 -GetEnvironmentWindowPosition(int w, int h, int *x, int *y)
   5.345 -{
   5.346 -    int display = GetVideoDisplay();
   5.347 -    const char *window = SDL_getenv("SDL_VIDEO_WINDOW_POS");
   5.348 -    const char *center = SDL_getenv("SDL_VIDEO_CENTERED");
   5.349 -    if (window) {
   5.350 -        if (SDL_sscanf(window, "%d,%d", x, y) == 2) {
   5.351 -            return;
   5.352 -        }
   5.353 -        if (SDL_strcmp(window, "center") == 0) {
   5.354 -            center = window;
   5.355 -        }
   5.356 -    }
   5.357 -    if (center) {
   5.358 -        *x = SDL_WINDOWPOS_CENTERED_DISPLAY(display);
   5.359 -        *y = SDL_WINDOWPOS_CENTERED_DISPLAY(display);
   5.360 -    }
   5.361 -}
   5.362 -
   5.363 -static void
   5.364 -ClearVideoSurface()
   5.365 -{
   5.366 -    if (SDL_ShadowSurface) {
   5.367 -        SDL_FillRect(SDL_ShadowSurface, NULL,
   5.368 -            SDL_MapRGB(SDL_ShadowSurface->format, 0, 0, 0));
   5.369 -    }
   5.370 -    SDL_FillRect(SDL_WindowSurface, NULL, 0);
   5.371 -    SDL_UpdateWindowSurface(SDL_VideoWindow);
   5.372 -}
   5.373 -
   5.374 -static void
   5.375 -SetupScreenSaver(int flags)
   5.376 -{
   5.377 -    const char *env;
   5.378 -    SDL_bool allow_screensaver;
   5.379 -
   5.380 -    /* Allow environment override of screensaver disable */
   5.381 -    env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
   5.382 -    if (env) {
   5.383 -        allow_screensaver = SDL_atoi(env) ? SDL_TRUE : SDL_FALSE;
   5.384 -    } else if (flags & SDL_FULLSCREEN) {
   5.385 -        allow_screensaver = SDL_FALSE;
   5.386 -    } else {
   5.387 -        allow_screensaver = SDL_TRUE;
   5.388 -    }
   5.389 -    if (allow_screensaver) {
   5.390 -        SDL_EnableScreenSaver();
   5.391 -    } else {
   5.392 -        SDL_DisableScreenSaver();
   5.393 -    }
   5.394 -}
   5.395 -
   5.396 -static int
   5.397 -SDL_ResizeVideoMode(int width, int height, int bpp, Uint32 flags)
   5.398 -{
   5.399 -    int w, h;
   5.400 -
   5.401 -    /* We can't resize something we don't have... */
   5.402 -    if (!SDL_VideoSurface) {
   5.403 -        return -1;
   5.404 -    }
   5.405 -
   5.406 -    /* We probably have to recreate the window in fullscreen mode */
   5.407 -    if (flags & SDL_FULLSCREEN) {
   5.408 -        return -1;
   5.409 -    }
   5.410 -
   5.411 -    /* I don't think there's any change we can gracefully make in flags */
   5.412 -    if (flags != SDL_VideoFlags) {
   5.413 -        return -1;
   5.414 -    }
   5.415 -    if (bpp != SDL_VideoSurface->format->BitsPerPixel) {
   5.416 -        return -1;
   5.417 -    }
   5.418 -
   5.419 -    /* Resize the window */
   5.420 -    SDL_GetWindowSize(SDL_VideoWindow, &w, &h);
   5.421 -    if (w != width || h != height) {
   5.422 -        SDL_SetWindowSize(SDL_VideoWindow, width, height);
   5.423 -    }
   5.424 -
   5.425 -    /* If we're in OpenGL mode, just resize the stub surface and we're done! */
   5.426 -    if (flags & SDL_OPENGL) {
   5.427 -        SDL_VideoSurface->w = width;
   5.428 -        SDL_VideoSurface->h = height;
   5.429 -        return 0;
   5.430 -    }
   5.431 -
   5.432 -    SDL_WindowSurface = SDL_GetWindowSurface(SDL_VideoWindow);
   5.433 -    if (!SDL_WindowSurface) {
   5.434 -        return -1;
   5.435 -    }
   5.436 -    if (SDL_VideoSurface->format != SDL_WindowSurface->format) {
   5.437 -        return -1;
   5.438 -    }
   5.439 -    SDL_VideoSurface->w = width;
   5.440 -    SDL_VideoSurface->h = height;
   5.441 -    SDL_VideoSurface->pixels = SDL_WindowSurface->pixels;
   5.442 -    SDL_VideoSurface->pitch = SDL_WindowSurface->pitch;
   5.443 -    SDL_SetClipRect(SDL_VideoSurface, NULL);
   5.444 -
   5.445 -    if (SDL_ShadowSurface) {
   5.446 -        SDL_ShadowSurface->w = width;
   5.447 -        SDL_ShadowSurface->h = height;
   5.448 -        SDL_ShadowSurface->pitch = SDL_CalculatePitch(SDL_ShadowSurface);
   5.449 -        SDL_ShadowSurface->pixels =
   5.450 -            SDL_realloc(SDL_ShadowSurface->pixels,
   5.451 -                        SDL_ShadowSurface->h * SDL_ShadowSurface->pitch);
   5.452 -        SDL_SetClipRect(SDL_ShadowSurface, NULL);
   5.453 -        SDL_InvalidateMap(SDL_ShadowSurface->map);
   5.454 -    } else {
   5.455 -        SDL_PublicSurface = SDL_VideoSurface;
   5.456 -    }
   5.457 -
   5.458 -    ClearVideoSurface();
   5.459 -
   5.460 -    return 0;
   5.461 -}
   5.462 -
   5.463 -SDL_Surface *
   5.464 -SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
   5.465 -{
   5.466 -    SDL_DisplayMode desktop_mode;
   5.467 -    int display = GetVideoDisplay();
   5.468 -    int window_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(display);
   5.469 -    int window_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(display);
   5.470 -    int window_w;
   5.471 -    int window_h;
   5.472 -    Uint32 window_flags;
   5.473 -    Uint32 surface_flags;
   5.474 -
   5.475 -    if (!SDL_GetVideoDevice()) {
   5.476 -        if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) {
   5.477 -            return NULL;
   5.478 -        }
   5.479 -    }
   5.480 -
   5.481 -    SDL_GetDesktopDisplayMode(display, &desktop_mode);
   5.482 -
   5.483 -    if (width == 0) {
   5.484 -        width = desktop_mode.w;
   5.485 -    }
   5.486 -    if (height == 0) {
   5.487 -        height = desktop_mode.h;
   5.488 -    }
   5.489 -    if (bpp == 0) {
   5.490 -        bpp = SDL_BITSPERPIXEL(desktop_mode.format);
   5.491 -    }
   5.492 -
   5.493 -    /* See if we can simply resize the existing window and surface */
   5.494 -    if (SDL_ResizeVideoMode(width, height, bpp, flags) == 0) {
   5.495 -        return SDL_PublicSurface;
   5.496 -    }
   5.497 -
   5.498 -    /* Destroy existing window */
   5.499 -    SDL_PublicSurface = NULL;
   5.500 -    if (SDL_ShadowSurface) {
   5.501 -        SDL_ShadowSurface->flags &= ~SDL_DONTFREE;
   5.502 -        SDL_FreeSurface(SDL_ShadowSurface);
   5.503 -        SDL_ShadowSurface = NULL;
   5.504 -    }
   5.505 -    if (SDL_VideoSurface) {
   5.506 -        SDL_VideoSurface->flags &= ~SDL_DONTFREE;
   5.507 -        SDL_FreeSurface(SDL_VideoSurface);
   5.508 -        SDL_VideoSurface = NULL;
   5.509 -    }
   5.510 -    if (SDL_VideoContext) {
   5.511 -        /* SDL_GL_MakeCurrent(0, NULL); *//* Doesn't do anything */
   5.512 -        SDL_GL_DeleteContext(SDL_VideoContext);
   5.513 -        SDL_VideoContext = NULL;
   5.514 -    }
   5.515 -    if (SDL_VideoWindow) {
   5.516 -        SDL_GetWindowPosition(SDL_VideoWindow, &window_x, &window_y);
   5.517 -        SDL_DestroyWindow(SDL_VideoWindow);
   5.518 -    }
   5.519 -
   5.520 -    /* Set up the event filter */
   5.521 -    if (!SDL_GetEventFilter(NULL, NULL)) {
   5.522 -        SDL_SetEventFilter(SDL_CompatEventFilter, NULL);
   5.523 -    }
   5.524 -
   5.525 -    /* Create a new window */
   5.526 -    window_flags = SDL_WINDOW_SHOWN;
   5.527 -    if (flags & SDL_FULLSCREEN) {
   5.528 -        window_flags |= SDL_WINDOW_FULLSCREEN;
   5.529 -    }
   5.530 -    if (flags & SDL_OPENGL) {
   5.531 -        window_flags |= SDL_WINDOW_OPENGL;
   5.532 -    }
   5.533 -    if (flags & SDL_RESIZABLE) {
   5.534 -        window_flags |= SDL_WINDOW_RESIZABLE;
   5.535 -    }
   5.536 -    if (flags & SDL_NOFRAME) {
   5.537 -        window_flags |= SDL_WINDOW_BORDERLESS;
   5.538 -    }
   5.539 -    GetEnvironmentWindowPosition(width, height, &window_x, &window_y);
   5.540 -    SDL_VideoWindow =
   5.541 -        SDL_CreateWindow(wm_title, window_x, window_y, width, height,
   5.542 -                         window_flags);
   5.543 -    if (!SDL_VideoWindow) {
   5.544 -        return NULL;
   5.545 -    }
   5.546 -    SDL_SetWindowIcon(SDL_VideoWindow, SDL_VideoIcon);
   5.547 -
   5.548 -    SetupScreenSaver(flags);
   5.549 -
   5.550 -    window_flags = SDL_GetWindowFlags(SDL_VideoWindow);
   5.551 -    surface_flags = 0;
   5.552 -    if (window_flags & SDL_WINDOW_FULLSCREEN) {
   5.553 -        surface_flags |= SDL_FULLSCREEN;
   5.554 -    }
   5.555 -    if ((window_flags & SDL_WINDOW_OPENGL) && (flags & SDL_OPENGL)) {
   5.556 -        surface_flags |= SDL_OPENGL;
   5.557 -    }
   5.558 -    if (window_flags & SDL_WINDOW_RESIZABLE) {
   5.559 -        surface_flags |= SDL_RESIZABLE;
   5.560 -    }
   5.561 -    if (window_flags & SDL_WINDOW_BORDERLESS) {
   5.562 -        surface_flags |= SDL_NOFRAME;
   5.563 -    }
   5.564 -
   5.565 -    SDL_VideoFlags = flags;
   5.566 -
   5.567 -    /* If we're in OpenGL mode, just create a stub surface and we're done! */
   5.568 -    if (flags & SDL_OPENGL) {
   5.569 -        SDL_VideoContext = SDL_GL_CreateContext(SDL_VideoWindow);
   5.570 -        if (!SDL_VideoContext) {
   5.571 -            return NULL;
   5.572 -        }
   5.573 -        if (SDL_GL_MakeCurrent(SDL_VideoWindow, SDL_VideoContext) < 0) {
   5.574 -            return NULL;
   5.575 -        }
   5.576 -        SDL_VideoSurface =
   5.577 -            SDL_CreateRGBSurfaceFrom(NULL, width, height, bpp, 0, 0, 0, 0, 0);
   5.578 -        if (!SDL_VideoSurface) {
   5.579 -            return NULL;
   5.580 -        }
   5.581 -        SDL_VideoSurface->flags |= surface_flags;
   5.582 -        SDL_PublicSurface = SDL_VideoSurface;
   5.583 -        return SDL_PublicSurface;
   5.584 -    }
   5.585 -
   5.586 -    /* Create the screen surface */
   5.587 -    SDL_WindowSurface = SDL_GetWindowSurface(SDL_VideoWindow);
   5.588 -    if (!SDL_WindowSurface) {
   5.589 -        return NULL;
   5.590 -    }
   5.591 -
   5.592 -    /* Center the public surface in the window surface */
   5.593 -    SDL_GetWindowSize(SDL_VideoWindow, &window_w, &window_h);
   5.594 -    SDL_VideoViewport.x = (window_w - width)/2;
   5.595 -    SDL_VideoViewport.y = (window_h - height)/2;
   5.596 -    SDL_VideoViewport.w = width;
   5.597 -    SDL_VideoViewport.h = height;
   5.598 -
   5.599 -    SDL_VideoSurface = SDL_CreateRGBSurfaceFrom(NULL, 0, 0, 32, 0, 0, 0, 0, 0);
   5.600 -    SDL_VideoSurface->flags |= surface_flags;
   5.601 -    SDL_VideoSurface->flags |= SDL_DONTFREE;
   5.602 -    SDL_FreeFormat(SDL_VideoSurface->format);
   5.603 -    SDL_VideoSurface->format = SDL_WindowSurface->format;
   5.604 -    SDL_VideoSurface->format->refcount++;
   5.605 -    SDL_VideoSurface->w = width;
   5.606 -    SDL_VideoSurface->h = height;
   5.607 -    SDL_VideoSurface->pitch = SDL_WindowSurface->pitch;
   5.608 -    SDL_VideoSurface->pixels = (void *)((Uint8 *)SDL_WindowSurface->pixels +
   5.609 -        SDL_VideoViewport.y * SDL_VideoSurface->pitch +
   5.610 -        SDL_VideoViewport.x  * SDL_VideoSurface->format->BytesPerPixel);
   5.611 -    SDL_SetClipRect(SDL_VideoSurface, NULL);
   5.612 -
   5.613 -    /* Create a shadow surface if necessary */
   5.614 -    if ((bpp != SDL_VideoSurface->format->BitsPerPixel)
   5.615 -        && !(flags & SDL_ANYFORMAT)) {
   5.616 -        SDL_ShadowSurface =
   5.617 -            SDL_CreateRGBSurface(0, width, height, bpp, 0, 0, 0, 0);
   5.618 -        if (!SDL_ShadowSurface) {
   5.619 -            return NULL;
   5.620 -        }
   5.621 -        SDL_ShadowSurface->flags |= surface_flags;
   5.622 -        SDL_ShadowSurface->flags |= SDL_DONTFREE;
   5.623 -
   5.624 -        /* 8-bit SDL_ShadowSurface surfaces report that they have exclusive palette */
   5.625 -        if (SDL_ShadowSurface->format->palette) {
   5.626 -            SDL_ShadowSurface->flags |= SDL_HWPALETTE;
   5.627 -            SDL_DitherColors(SDL_ShadowSurface->format->palette->colors,
   5.628 -                             SDL_ShadowSurface->format->BitsPerPixel);
   5.629 -        }
   5.630 -        SDL_FillRect(SDL_ShadowSurface, NULL,
   5.631 -            SDL_MapRGB(SDL_ShadowSurface->format, 0, 0, 0));
   5.632 -    }
   5.633 -    SDL_PublicSurface =
   5.634 -        (SDL_ShadowSurface ? SDL_ShadowSurface : SDL_VideoSurface);
   5.635 -
   5.636 -    ClearVideoSurface();
   5.637 -
   5.638 -    /* We're finally done! */
   5.639 -    return SDL_PublicSurface;
   5.640 -}
   5.641 -
   5.642 -SDL_Surface *
   5.643 -SDL_GetVideoSurface(void)
   5.644 -{
   5.645 -    return SDL_PublicSurface;
   5.646 -}
   5.647 -
   5.648 -int
   5.649 -SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value)
   5.650 -{
   5.651 -    if (flag & SDL_SRCALPHA) {
   5.652 -        /* According to the docs, value is ignored for alpha surfaces */
   5.653 -        if (surface->format->Amask) {
   5.654 -            value = 0xFF;
   5.655 -        }
   5.656 -        SDL_SetSurfaceAlphaMod(surface, value);
   5.657 -        SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND);
   5.658 -    } else {
   5.659 -        SDL_SetSurfaceAlphaMod(surface, 0xFF);
   5.660 -        SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
   5.661 -    }
   5.662 -    SDL_SetSurfaceRLE(surface, (flag & SDL_RLEACCEL));
   5.663 -
   5.664 -    return 0;
   5.665 -}
   5.666 -
   5.667 -SDL_Surface *
   5.668 -SDL_DisplayFormat(SDL_Surface * surface)
   5.669 -{
   5.670 -    SDL_PixelFormat *format;
   5.671 -
   5.672 -    if (!SDL_PublicSurface) {
   5.673 -        SDL_SetError("No video mode has been set");
   5.674 -        return NULL;
   5.675 -    }
   5.676 -    format = SDL_PublicSurface->format;
   5.677 -
   5.678 -    /* Set the flags appropriate for copying to display surface */
   5.679 -    return SDL_ConvertSurface(surface, format, SDL_RLEACCEL);
   5.680 -}
   5.681 -
   5.682 -SDL_Surface *
   5.683 -SDL_DisplayFormatAlpha(SDL_Surface * surface)
   5.684 -{
   5.685 -    SDL_PixelFormat *vf;
   5.686 -    SDL_PixelFormat *format;
   5.687 -    SDL_Surface *converted;
   5.688 -    /* default to ARGB8888 */
   5.689 -    Uint32 amask = 0xff000000;
   5.690 -    Uint32 rmask = 0x00ff0000;
   5.691 -    Uint32 gmask = 0x0000ff00;
   5.692 -    Uint32 bmask = 0x000000ff;
   5.693 -
   5.694 -    if (!SDL_PublicSurface) {
   5.695 -        SDL_SetError("No video mode has been set");
   5.696 -        return NULL;
   5.697 -    }
   5.698 -    vf = SDL_PublicSurface->format;
   5.699 -
   5.700 -    switch (vf->BytesPerPixel) {
   5.701 -    case 2:
   5.702 -        /* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}.
   5.703 -           For anything else (like ARGB4444) it doesn't matter
   5.704 -           since we have no special code for it anyway */
   5.705 -        if ((vf->Rmask == 0x1f) &&
   5.706 -            (vf->Bmask == 0xf800 || vf->Bmask == 0x7c00)) {
   5.707 -            rmask = 0xff;
   5.708 -            bmask = 0xff0000;
   5.709 -        }
   5.710 -        break;
   5.711 -
   5.712 -    case 3:
   5.713 -    case 4:
   5.714 -        /* Keep the video format, as long as the high 8 bits are
   5.715 -           unused or alpha */
   5.716 -        if ((vf->Rmask == 0xff) && (vf->Bmask == 0xff0000)) {
   5.717 -            rmask = 0xff;
   5.718 -            bmask = 0xff0000;
   5.719 -        }
   5.720 -        break;
   5.721 -
   5.722 -    default:
   5.723 -        /* We have no other optimised formats right now. When/if a new
   5.724 -           optimised alpha format is written, add the converter here */
   5.725 -        break;
   5.726 -    }
   5.727 -    format = SDL_AllocFormat(SDL_MasksToPixelFormatEnum(32, rmask,
   5.728 -                                                            gmask,
   5.729 -                                                            bmask,
   5.730 -                                                            amask));
   5.731 -    if (!format) {
   5.732 -        return NULL;
   5.733 -    }
   5.734 -    converted = SDL_ConvertSurface(surface, format, SDL_RLEACCEL);
   5.735 -    SDL_FreeFormat(format);
   5.736 -    return converted;
   5.737 -}
   5.738 -
   5.739 -int
   5.740 -SDL_Flip(SDL_Surface * screen)
   5.741 -{
   5.742 -    SDL_UpdateRect(screen, 0, 0, 0, 0);
   5.743 -    return 0;
   5.744 -}
   5.745 -
   5.746 -void
   5.747 -SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
   5.748 -{
   5.749 -    if (screen) {
   5.750 -        SDL_Rect rect;
   5.751 -
   5.752 -        /* Fill the rectangle */
   5.753 -        rect.x = (int) x;
   5.754 -        rect.y = (int) y;
   5.755 -        rect.w = (int) (w ? w : screen->w);
   5.756 -        rect.h = (int) (h ? h : screen->h);
   5.757 -        SDL_UpdateRects(screen, 1, &rect);
   5.758 -    }
   5.759 -}
   5.760 -
   5.761 -void
   5.762 -SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects)
   5.763 -{
   5.764 -    int i;
   5.765 -
   5.766 -    if (screen == SDL_ShadowSurface) {
   5.767 -        for (i = 0; i < numrects; ++i) {
   5.768 -            SDL_BlitSurface(SDL_ShadowSurface, &rects[i], SDL_VideoSurface,
   5.769 -                            &rects[i]);
   5.770 -        }
   5.771 -
   5.772 -        /* Fall through to video surface update */
   5.773 -        screen = SDL_VideoSurface;
   5.774 -    }
   5.775 -    if (screen == SDL_VideoSurface) {
   5.776 -        if (SDL_VideoViewport.x || SDL_VideoViewport.y) {
   5.777 -            SDL_Rect *stackrects = SDL_stack_alloc(SDL_Rect, numrects);
   5.778 -            SDL_Rect *stackrect;
   5.779 -            const SDL_Rect *rect;
   5.780 -            
   5.781 -            /* Offset all the rectangles before updating */
   5.782 -            for (i = 0; i < numrects; ++i) {
   5.783 -                rect = &rects[i];
   5.784 -                stackrect = &stackrects[i];
   5.785 -                stackrect->x = SDL_VideoViewport.x + rect->x;
   5.786 -                stackrect->y = SDL_VideoViewport.y + rect->y;
   5.787 -                stackrect->w = rect->w;
   5.788 -                stackrect->h = rect->h;
   5.789 -            }
   5.790 -            SDL_UpdateWindowSurfaceRects(SDL_VideoWindow, stackrects, numrects);
   5.791 -            SDL_stack_free(stackrects);
   5.792 -        } else {
   5.793 -            SDL_UpdateWindowSurfaceRects(SDL_VideoWindow, rects, numrects);
   5.794 -        }
   5.795 -    }
   5.796 -}
   5.797 -
   5.798 -void
   5.799 -SDL_WM_SetCaption(const char *title, const char *icon)
   5.800 -{
   5.801 -    if (wm_title) {
   5.802 -        SDL_free(wm_title);
   5.803 -    }
   5.804 -    if (title) {
   5.805 -        wm_title = SDL_strdup(title);
   5.806 -    } else {
   5.807 -        wm_title = NULL;
   5.808 -    }
   5.809 -    SDL_SetWindowTitle(SDL_VideoWindow, wm_title);
   5.810 -}
   5.811 -
   5.812 -void
   5.813 -SDL_WM_GetCaption(const char **title, const char **icon)
   5.814 -{
   5.815 -    if (title) {
   5.816 -        *title = wm_title;
   5.817 -    }
   5.818 -    if (icon) {
   5.819 -        *icon = "";
   5.820 -    }
   5.821 -}
   5.822 -
   5.823 -void
   5.824 -SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask)
   5.825 -{
   5.826 -    SDL_VideoIcon = icon;
   5.827 -    ++SDL_VideoIcon->refcount;
   5.828 -}
   5.829 -
   5.830 -int
   5.831 -SDL_WM_IconifyWindow(void)
   5.832 -{
   5.833 -    SDL_MinimizeWindow(SDL_VideoWindow);
   5.834 -    return 0;
   5.835 -}
   5.836 -
   5.837 -int
   5.838 -SDL_WM_ToggleFullScreen(SDL_Surface * surface)
   5.839 -{
   5.840 -    int length;
   5.841 -    void *pixels;
   5.842 -    Uint8 *src, *dst;
   5.843 -    int row;
   5.844 -    int window_w;
   5.845 -    int window_h;
   5.846 -
   5.847 -    if (!SDL_PublicSurface) {
   5.848 -        SDL_SetError("SDL_SetVideoMode() hasn't been called");
   5.849 -        return 0;
   5.850 -    }
   5.851 -
   5.852 -    /* Copy the old bits out */
   5.853 -    length = SDL_PublicSurface->w * SDL_PublicSurface->format->BytesPerPixel;
   5.854 -    pixels = SDL_malloc(SDL_PublicSurface->h * length);
   5.855 -    if (pixels && SDL_PublicSurface->pixels) {
   5.856 -        src = (Uint8*)SDL_PublicSurface->pixels;
   5.857 -        dst = (Uint8*)pixels;
   5.858 -        for (row = 0; row < SDL_PublicSurface->h; ++row) {
   5.859 -            SDL_memcpy(dst, src, length);
   5.860 -            src += SDL_PublicSurface->pitch;
   5.861 -            dst += length;
   5.862 -        }
   5.863 -    }
   5.864 -
   5.865 -    /* Do the physical mode switch */
   5.866 -    if (SDL_GetWindowFlags(SDL_VideoWindow) & SDL_WINDOW_FULLSCREEN) {
   5.867 -        if (SDL_SetWindowFullscreen(SDL_VideoWindow, 0) < 0) {
   5.868 -            return 0;
   5.869 -        }
   5.870 -        SDL_PublicSurface->flags &= ~SDL_FULLSCREEN;
   5.871 -    } else {
   5.872 -        if (SDL_SetWindowFullscreen(SDL_VideoWindow, 1) < 0) {
   5.873 -            return 0;
   5.874 -        }
   5.875 -        SDL_PublicSurface->flags |= SDL_FULLSCREEN;
   5.876 -    }
   5.877 -
   5.878 -    /* Recreate the screen surface */
   5.879 -    SDL_WindowSurface = SDL_GetWindowSurface(SDL_VideoWindow);
   5.880 -    if (!SDL_WindowSurface) {
   5.881 -        /* We're totally hosed... */
   5.882 -        return 0;
   5.883 -    }
   5.884 -
   5.885 -    /* Center the public surface in the window surface */
   5.886 -    SDL_GetWindowSize(SDL_VideoWindow, &window_w, &window_h);
   5.887 -    SDL_VideoViewport.x = (window_w - SDL_VideoSurface->w)/2;
   5.888 -    SDL_VideoViewport.y = (window_h - SDL_VideoSurface->h)/2;
   5.889 -    SDL_VideoViewport.w = SDL_VideoSurface->w;
   5.890 -    SDL_VideoViewport.h = SDL_VideoSurface->h;
   5.891 -
   5.892 -    /* Do some shuffling behind the application's back if format changes */
   5.893 -    if (SDL_VideoSurface->format->format != SDL_WindowSurface->format->format) {
   5.894 -        if (SDL_ShadowSurface) {
   5.895 -            if (SDL_ShadowSurface->format->format == SDL_WindowSurface->format->format) {
   5.896 -                /* Whee!  We don't need a shadow surface anymore! */
   5.897 -                SDL_VideoSurface->flags &= ~SDL_DONTFREE;
   5.898 -                SDL_FreeSurface(SDL_VideoSurface);
   5.899 -                SDL_free(SDL_ShadowSurface->pixels);
   5.900 -                SDL_VideoSurface = SDL_ShadowSurface;
   5.901 -                SDL_VideoSurface->flags |= SDL_PREALLOC;
   5.902 -                SDL_ShadowSurface = NULL;
   5.903 -            } else {
   5.904 -                /* No problem, just change the video surface format */
   5.905 -                SDL_FreeFormat(SDL_VideoSurface->format);
   5.906 -                SDL_VideoSurface->format = SDL_WindowSurface->format;
   5.907 -                SDL_VideoSurface->format->refcount++;
   5.908 -                SDL_InvalidateMap(SDL_ShadowSurface->map);
   5.909 -            }
   5.910 -        } else {
   5.911 -            /* We can make the video surface the shadow surface */
   5.912 -            SDL_ShadowSurface = SDL_VideoSurface;
   5.913 -            SDL_ShadowSurface->pitch = SDL_CalculatePitch(SDL_ShadowSurface);
   5.914 -            SDL_ShadowSurface->pixels = SDL_malloc(SDL_ShadowSurface->h * SDL_ShadowSurface->pitch);
   5.915 -            if (!SDL_ShadowSurface->pixels) {
   5.916 -                /* Uh oh, we're hosed */
   5.917 -                SDL_ShadowSurface = NULL;
   5.918 -                return 0;
   5.919 -            }
   5.920 -            SDL_ShadowSurface->flags &= ~SDL_PREALLOC;
   5.921 -
   5.922 -            SDL_VideoSurface = SDL_CreateRGBSurfaceFrom(NULL, 0, 0, 32, 0, 0, 0, 0, 0);
   5.923 -            SDL_VideoSurface->flags = SDL_ShadowSurface->flags;
   5.924 -            SDL_VideoSurface->flags |= SDL_PREALLOC;
   5.925 -            SDL_FreeFormat(SDL_VideoSurface->format);
   5.926 -            SDL_VideoSurface->format = SDL_WindowSurface->format;
   5.927 -            SDL_VideoSurface->format->refcount++;
   5.928 -            SDL_VideoSurface->w = SDL_ShadowSurface->w;
   5.929 -            SDL_VideoSurface->h = SDL_ShadowSurface->h;
   5.930 -        }
   5.931 -    }
   5.932 -
   5.933 -    /* Update the video surface */
   5.934 -    SDL_VideoSurface->pitch = SDL_WindowSurface->pitch;
   5.935 -    SDL_VideoSurface->pixels = (void *)((Uint8 *)SDL_WindowSurface->pixels +
   5.936 -        SDL_VideoViewport.y * SDL_VideoSurface->pitch +
   5.937 -        SDL_VideoViewport.x  * SDL_VideoSurface->format->BytesPerPixel);
   5.938 -    SDL_SetClipRect(SDL_VideoSurface, NULL);
   5.939 -
   5.940 -    /* Copy the old bits back */
   5.941 -    if (pixels) {
   5.942 -        src = (Uint8*)pixels;
   5.943 -        dst = (Uint8*)SDL_PublicSurface->pixels;
   5.944 -        for (row = 0; row < SDL_PublicSurface->h; ++row) {
   5.945 -            SDL_memcpy(dst, src, length);
   5.946 -            src += length;
   5.947 -            dst += SDL_PublicSurface->pitch;
   5.948 -        }
   5.949 -        SDL_Flip(SDL_PublicSurface);
   5.950 -        SDL_free(pixels);
   5.951 -    }
   5.952 -
   5.953 -    /* We're done! */
   5.954 -    return 1;
   5.955 -}
   5.956 -
   5.957 -SDL_GrabMode
   5.958 -SDL_WM_GrabInput(SDL_GrabMode mode)
   5.959 -{
   5.960 -    if (mode != SDL_GRAB_QUERY) {
   5.961 -        SDL_SetWindowGrab(SDL_VideoWindow, mode);
   5.962 -    }
   5.963 -    return (SDL_GrabMode) SDL_GetWindowGrab(SDL_VideoWindow);
   5.964 -}
   5.965 -
   5.966 -void
   5.967 -SDL_WarpMouse(Uint16 x, Uint16 y)
   5.968 -{
   5.969 -    SDL_WarpMouseInWindow(SDL_VideoWindow, x, y);
   5.970 -}
   5.971 -
   5.972 -Uint8
   5.973 -SDL_GetAppState(void)
   5.974 -{
   5.975 -    Uint8 state = 0;
   5.976 -    Uint32 flags = 0;
   5.977 -
   5.978 -    flags = SDL_GetWindowFlags(SDL_VideoWindow);
   5.979 -    if ((flags & SDL_WINDOW_SHOWN) && !(flags & SDL_WINDOW_MINIMIZED)) {
   5.980 -        state |= SDL_APPACTIVE;
   5.981 -    }
   5.982 -    if (flags & SDL_WINDOW_INPUT_FOCUS) {
   5.983 -        state |= SDL_APPINPUTFOCUS;
   5.984 -    }
   5.985 -    if (flags & SDL_WINDOW_MOUSE_FOCUS) {
   5.986 -        state |= SDL_APPMOUSEFOCUS;
   5.987 -    }
   5.988 -    return state;
   5.989 -}
   5.990 -
   5.991 -const SDL_version *
   5.992 -SDL_Linked_Version(void)
   5.993 -{
   5.994 -    static SDL_version version;
   5.995 -    SDL_VERSION(&version);
   5.996 -    return &version;
   5.997 -}
   5.998 -
   5.999 -int
  5.1000 -SDL_SetPalette(SDL_Surface * surface, int flags, const SDL_Color * colors,
  5.1001 -               int firstcolor, int ncolors)
  5.1002 -{
  5.1003 -    return SDL_SetColors(surface, colors, firstcolor, ncolors);
  5.1004 -}
  5.1005 -
  5.1006 -int
  5.1007 -SDL_SetColors(SDL_Surface * surface, const SDL_Color * colors, int firstcolor,
  5.1008 -              int ncolors)
  5.1009 -{
  5.1010 -    if (SDL_SetPaletteColors
  5.1011 -        (surface->format->palette, colors, firstcolor, ncolors) == 0) {
  5.1012 -        return 1;
  5.1013 -    } else {
  5.1014 -        return 0;
  5.1015 -    }
  5.1016 -}
  5.1017 -
  5.1018 -int
  5.1019 -SDL_GetWMInfo(SDL_SysWMinfo * info)
  5.1020 -{
  5.1021 -    return SDL_GetWindowWMInfo(SDL_VideoWindow, info);
  5.1022 -}
  5.1023 -
  5.1024 -#if 0
  5.1025 -void
  5.1026 -SDL_MoveCursor(int x, int y)
  5.1027 -{
  5.1028 -    SDL_VideoDevice *_this = SDL_GetVideoDevice();
  5.1029 -
  5.1030 -    /* Erase and update the current mouse position */
  5.1031 -    if (SHOULD_DRAWCURSOR(SDL_cursorstate)) {
  5.1032 -        /* Erase and redraw mouse cursor in new position */
  5.1033 -        SDL_LockCursor();
  5.1034 -        SDL_EraseCursor(SDL_VideoSurface);
  5.1035 -        SDL_cursor->area.x = (x - SDL_cursor->hot_x);
  5.1036 -        SDL_cursor->area.y = (y - SDL_cursor->hot_y);
  5.1037 -        SDL_DrawCursor(SDL_VideoSurface);
  5.1038 -        SDL_UnlockCursor();
  5.1039 -    } else if (_this->MoveWMCursor) {
  5.1040 -        _this->MoveWMCursor(_this, x, y);
  5.1041 -    }
  5.1042 -}
  5.1043 -
  5.1044 -/* Keep track of the current cursor colors */
  5.1045 -static int palette_changed = 1;
  5.1046 -static Uint8 pixels8[2];
  5.1047 -
  5.1048 -void
  5.1049 -SDL_CursorPaletteChanged(void)
  5.1050 -{
  5.1051 -    palette_changed = 1;
  5.1052 -}
  5.1053 -
  5.1054 -void
  5.1055 -SDL_MouseRect(SDL_Rect * area)
  5.1056 -{
  5.1057 -    SDL_VideoDevice *_this = SDL_GetVideoDevice();
  5.1058 -    int clip_diff;
  5.1059 -
  5.1060 -    *area = SDL_cursor->area;
  5.1061 -    if (area->x < 0) {
  5.1062 -        area->w += area->x;
  5.1063 -        area->x = 0;
  5.1064 -    }
  5.1065 -    if (area->y < 0) {
  5.1066 -        area->h += area->y;
  5.1067 -        area->y = 0;
  5.1068 -    }
  5.1069 -    clip_diff = (area->x + area->w) - SDL_VideoSurface->w;
  5.1070 -    if (clip_diff > 0) {
  5.1071 -        area->w = area->w < clip_diff ? 0 : area->w - clip_diff;
  5.1072 -    }
  5.1073 -    clip_diff = (area->y + area->h) - SDL_VideoSurface->h;
  5.1074 -    if (clip_diff > 0) {
  5.1075 -        area->h = area->h < clip_diff ? 0 : area->h - clip_diff;
  5.1076 -    }
  5.1077 -}
  5.1078 -
  5.1079 -static void
  5.1080 -SDL_DrawCursorFast(SDL_Surface * screen, SDL_Rect * area)
  5.1081 -{
  5.1082 -    const Uint32 pixels[2] = { 0xFFFFFFFF, 0x00000000 };
  5.1083 -    int i, w, h;
  5.1084 -    Uint8 *data, datab;
  5.1085 -    Uint8 *mask, maskb;
  5.1086 -
  5.1087 -    data = SDL_cursor->data + area->y * SDL_cursor->area.w / 8;
  5.1088 -    mask = SDL_cursor->mask + area->y * SDL_cursor->area.w / 8;
  5.1089 -    switch (screen->format->BytesPerPixel) {
  5.1090 -
  5.1091 -    case 1:
  5.1092 -        {
  5.1093 -            Uint8 *dst;
  5.1094 -            int dstskip;
  5.1095 -
  5.1096 -            if (palette_changed) {
  5.1097 -                pixels8[0] =
  5.1098 -                    (Uint8) SDL_MapRGB(screen->format, 255, 255, 255);
  5.1099 -                pixels8[1] = (Uint8) SDL_MapRGB(screen->format, 0, 0, 0);
  5.1100 -                palette_changed = 0;
  5.1101 -            }
  5.1102 -            dst = (Uint8 *) screen->pixels +
  5.1103 -                (SDL_cursor->area.y + area->y) * screen->pitch +
  5.1104 -                SDL_cursor->area.x;
  5.1105 -            dstskip = screen->pitch - area->w;
  5.1106 -
  5.1107 -            for (h = area->h; h; h--) {
  5.1108 -                for (w = area->w / 8; w; w--) {
  5.1109 -                    maskb = *mask++;
  5.1110 -                    datab = *data++;
  5.1111 -                    for (i = 0; i < 8; ++i) {
  5.1112 -                        if (maskb & 0x80) {
  5.1113 -                            *dst = pixels8[datab >> 7];
  5.1114 -                        }
  5.1115 -                        maskb <<= 1;
  5.1116 -                        datab <<= 1;
  5.1117 -                        dst++;
  5.1118 -                    }
  5.1119 -                }
  5.1120 -                dst += dstskip;
  5.1121 -            }
  5.1122 -        }
  5.1123 -        break;
  5.1124 -
  5.1125 -    case 2:
  5.1126 -        {
  5.1127 -            Uint16 *dst;
  5.1128 -            int dstskip;
  5.1129 -
  5.1130 -            dst = (Uint16 *) screen->pixels +
  5.1131 -                (SDL_cursor->area.y + area->y) * screen->pitch / 2 +
  5.1132 -                SDL_cursor->area.x;
  5.1133 -            dstskip = (screen->pitch / 2) - area->w;
  5.1134 -
  5.1135 -            for (h = area->h; h; h--) {
  5.1136 -                for (w = area->w / 8; w; w--) {
  5.1137 -                    maskb = *mask++;
  5.1138 -                    datab = *data++;
  5.1139 -                    for (i = 0; i < 8; ++i) {
  5.1140 -                        if (maskb & 0x80) {
  5.1141 -                            *dst = (Uint16) pixels[datab >> 7];
  5.1142 -                        }
  5.1143 -                        maskb <<= 1;
  5.1144 -                        datab <<= 1;
  5.1145 -                        dst++;
  5.1146 -                    }
  5.1147 -                }
  5.1148 -                dst += dstskip;
  5.1149 -            }
  5.1150 -        }
  5.1151 -        break;
  5.1152 -
  5.1153 -    case 3:
  5.1154 -        {
  5.1155 -            Uint8 *dst;
  5.1156 -            int dstskip;
  5.1157 -
  5.1158 -            dst = (Uint8 *) screen->pixels +
  5.1159 -                (SDL_cursor->area.y + area->y) * screen->pitch +
  5.1160 -                SDL_cursor->area.x * 3;
  5.1161 -            dstskip = screen->pitch - area->w * 3;
  5.1162 -
  5.1163 -            for (h = area->h; h; h--) {
  5.1164 -                for (w = area->w / 8; w; w--) {
  5.1165 -                    maskb = *mask++;
  5.1166 -                    datab = *data++;
  5.1167 -                    for (i = 0; i < 8; ++i) {
  5.1168 -                        if (maskb & 0x80) {
  5.1169 -                            SDL_memset(dst, pixels[datab >> 7], 3);
  5.1170 -                        }
  5.1171 -                        maskb <<= 1;
  5.1172 -                        datab <<= 1;
  5.1173 -                        dst += 3;
  5.1174 -                    }
  5.1175 -                }
  5.1176 -                dst += dstskip;
  5.1177 -            }
  5.1178 -        }
  5.1179 -        break;
  5.1180 -
  5.1181 -    case 4:
  5.1182 -        {
  5.1183 -            Uint32 *dst;
  5.1184 -            int dstskip;
  5.1185 -
  5.1186 -            dst = (Uint32 *) screen->pixels +
  5.1187 -                (SDL_cursor->area.y + area->y) * screen->pitch / 4 +
  5.1188 -                SDL_cursor->area.x;
  5.1189 -            dstskip = (screen->pitch / 4) - area->w;
  5.1190 -
  5.1191 -            for (h = area->h; h; h--) {
  5.1192 -                for (w = area->w / 8; w; w--) {
  5.1193 -                    maskb = *mask++;
  5.1194 -                    datab = *data++;
  5.1195 -                    for (i = 0; i < 8; ++i) {
  5.1196 -                        if (maskb & 0x80) {
  5.1197 -                            *dst = pixels[datab >> 7];
  5.1198 -                        }
  5.1199 -                        maskb <<= 1;
  5.1200 -                        datab <<= 1;
  5.1201 -                        dst++;
  5.1202 -                    }
  5.1203 -                }
  5.1204 -                dst += dstskip;
  5.1205 -            }
  5.1206 -        }
  5.1207 -        break;
  5.1208 -    }
  5.1209 -}
  5.1210 -
  5.1211 -static void
  5.1212 -SDL_DrawCursorSlow(SDL_Surface * screen, SDL_Rect * area)
  5.1213 -{
  5.1214 -    const Uint32 pixels[2] = { 0xFFFFFF, 0x000000 };
  5.1215 -    int h;
  5.1216 -    int x, minx, maxx;
  5.1217 -    Uint8 *data, datab = 0;
  5.1218 -    Uint8 *mask, maskb = 0;
  5.1219 -    Uint8 *dst;
  5.1220 -    int dstbpp, dstskip;
  5.1221 -
  5.1222 -    data = SDL_cursor->data + area->y * SDL_cursor->area.w / 8;
  5.1223 -    mask = SDL_cursor->mask + area->y * SDL_cursor->area.w / 8;
  5.1224 -    dstbpp = screen->format->BytesPerPixel;
  5.1225 -    dst = (Uint8 *) screen->pixels +
  5.1226 -        (SDL_cursor->area.y + area->y) * screen->pitch +
  5.1227 -        SDL_cursor->area.x * dstbpp;
  5.1228 -    dstskip = screen->pitch - SDL_cursor->area.w * dstbpp;
  5.1229 -
  5.1230 -    minx = area->x;
  5.1231 -    maxx = area->x + area->w;
  5.1232 -    if (screen->format->BytesPerPixel == 1) {
  5.1233 -        if (palette_changed) {
  5.1234 -            pixels8[0] = (Uint8) SDL_MapRGB(screen->format, 255, 255, 255);
  5.1235 -            pixels8[1] = (Uint8) SDL_MapRGB(screen->format, 0, 0, 0);
  5.1236 -            palette_changed = 0;
  5.1237 -        }
  5.1238 -        for (h = area->h; h; h--) {
  5.1239 -            for (x = 0; x < SDL_cursor->area.w; ++x) {
  5.1240 -                if ((x % 8) == 0) {
  5.1241 -                    maskb = *mask++;
  5.1242 -                    datab = *data++;
  5.1243 -                }
  5.1244 -                if ((x >= minx) && (x < maxx)) {
  5.1245 -                    if (maskb & 0x80) {
  5.1246 -                        SDL_memset(dst, pixels8[datab >> 7], dstbpp);
  5.1247 -                    }
  5.1248 -                }
  5.1249 -                maskb <<= 1;
  5.1250 -                datab <<= 1;
  5.1251 -                dst += dstbpp;
  5.1252 -            }
  5.1253 -            dst += dstskip;
  5.1254 -        }
  5.1255 -    } else {
  5.1256 -        for (h = area->h; h; h--) {
  5.1257 -            for (x = 0; x < SDL_cursor->area.w; ++x) {
  5.1258 -                if ((x % 8) == 0) {
  5.1259 -                    maskb = *mask++;
  5.1260 -                    datab = *data++;
  5.1261 -                }
  5.1262 -                if ((x >= minx) && (x < maxx)) {
  5.1263 -                    if (maskb & 0x80) {
  5.1264 -                        SDL_memset(dst, pixels[datab >> 7], dstbpp);
  5.1265 -                    }
  5.1266 -                }
  5.1267 -                maskb <<= 1;
  5.1268 -                datab <<= 1;
  5.1269 -                dst += dstbpp;
  5.1270 -            }
  5.1271 -            dst += dstskip;
  5.1272 -        }
  5.1273 -    }
  5.1274 -}
  5.1275 -
  5.1276 -/* This handles the ugly work of converting the saved cursor background from
  5.1277 -   the pixel format of the shadow surface to that of the video surface.
  5.1278 -   This is only necessary when blitting from a shadow surface of a different
  5.1279 -   pixel format than the video surface, and using a software rendered cursor.
  5.1280 -*/
  5.1281 -static void
  5.1282 -SDL_ConvertCursorSave(SDL_Surface * screen, int w, int h)
  5.1283 -{
  5.1284 -    SDL_VideoDevice *_this = SDL_GetVideoDevice();
  5.1285 -    SDL_BlitInfo info;
  5.1286 -    SDL_loblit RunBlit;
  5.1287 -
  5.1288 -    /* Make sure we can steal the blit mapping */
  5.1289 -    if (screen->map->dst != SDL_VideoSurface) {
  5.1290 -        return;
  5.1291 -    }
  5.1292 -
  5.1293 -    /* Set up the blit information */
  5.1294 -    info.s_pixels = SDL_cursor->save[1];
  5.1295 -    info.s_width = w;
  5.1296 -    info.s_height = h;
  5.1297 -    info.s_skip = 0;
  5.1298 -    info.d_pixels = SDL_cursor->save[0];
  5.1299 -    info.d_width = w;
  5.1300 -    info.d_height = h;
  5.1301 -    info.d_skip = 0;
  5.1302 -    info.aux_data = screen->map->sw_data->aux_data;
  5.1303 -    info.src = screen->format;
  5.1304 -    info.table = screen->map->table;
  5.1305 -    info.dst = SDL_VideoSurface->format;
  5.1306 -    RunBlit = screen->map->sw_data->blit;
  5.1307 -
  5.1308 -    /* Run the actual software blit */
  5.1309 -    RunBlit(&info);
  5.1310 -}
  5.1311 -
  5.1312 -void
  5.1313 -SDL_DrawCursorNoLock(SDL_Surface * screen)
  5.1314 -{
  5.1315 -    SDL_VideoDevice *_this = SDL_GetVideoDevice();
  5.1316 -    SDL_Rect area;
  5.1317 -
  5.1318 -    /* Get the mouse rectangle, clipped to the screen */
  5.1319 -    SDL_MouseRect(&area);
  5.1320 -    if ((area.w == 0) || (area.h == 0)) {
  5.1321 -        return;
  5.1322 -    }
  5.1323 -
  5.1324 -    /* Copy mouse background */
  5.1325 -    {
  5.1326 -        int w, h, screenbpp;
  5.1327 -        Uint8 *src, *dst;
  5.1328 -
  5.1329 -        /* Set up the copy pointers */
  5.1330 -        screenbpp = screen->format->BytesPerPixel;
  5.1331 -        if ((screen == SDL_VideoSurface) ||
  5.1332 -            FORMAT_EQUAL(screen->format, SDL_VideoSurface->format)) {
  5.1333 -            dst = SDL_cursor->save[0];
  5.1334 -        } else {
  5.1335 -            dst = SDL_cursor->save[1];
  5.1336 -        }
  5.1337 -        src = (Uint8 *) screen->pixels + area.y * screen->pitch +
  5.1338 -            area.x * screenbpp;
  5.1339 -
  5.1340 -        /* Perform the copy */
  5.1341 -        w = area.w * screenbpp;
  5.1342 -        h = area.h;
  5.1343 -        while (h--) {
  5.1344 -            SDL_memcpy(dst, src, w);
  5.1345 -            dst += w;
  5.1346 -            src += screen->pitch;
  5.1347 -        }
  5.1348 -    }
  5.1349 -
  5.1350 -    /* Draw the mouse cursor */
  5.1351 -    area.x -= SDL_cursor->area.x;
  5.1352 -    area.y -= SDL_cursor->area.y;
  5.1353 -    if ((area.x == 0) && (area.w == SDL_cursor->area.w)) {
  5.1354 -        SDL_DrawCursorFast(screen, &area);
  5.1355 -    } else {
  5.1356 -        SDL_DrawCursorSlow(screen, &area);
  5.1357 -    }
  5.1358 -}
  5.1359 -
  5.1360 -void
  5.1361 -SDL_DrawCursor(SDL_Surface * screen)
  5.1362 -{
  5.1363 -    /* Lock the screen if necessary */
  5.1364 -    if (screen == NULL) {
  5.1365 -        return;
  5.1366 -    }
  5.1367 -    if (SDL_MUSTLOCK(screen)) {
  5.1368 -        if (SDL_LockSurface(screen) < 0) {
  5.1369 -            return;
  5.1370 -        }
  5.1371 -    }
  5.1372 -
  5.1373 -    SDL_DrawCursorNoLock(screen);
  5.1374 -
  5.1375 -    /* Unlock the screen and update if necessary */
  5.1376 -    if (SDL_MUSTLOCK(screen)) {
  5.1377 -        SDL_UnlockSurface(screen);
  5.1378 -    }
  5.1379 -    if (screen->flags & SDL_SCREEN_SURFACE) {
  5.1380 -        SDL_VideoDevice *_this = SDL_GetVideoDevice();
  5.1381 -        SDL_Window *window;
  5.1382 -        SDL_Rect area;
  5.1383 -
  5.1384 -        window = SDL_GetWindowFromSurface(screen);
  5.1385 -        if (!window) {
  5.1386 -            return;
  5.1387 -        }
  5.1388 -
  5.1389 -        SDL_MouseRect(&area);
  5.1390 -
  5.1391 -        if (_this->UpdateWindowSurface) {
  5.1392 -            _this->UpdateWindowSurface(_this, window, 1, &area);
  5.1393 -        }
  5.1394 -    }
  5.1395 -}
  5.1396 -
  5.1397 -void
  5.1398 -SDL_EraseCursorNoLock(SDL_Surface * screen)
  5.1399 -{
  5.1400 -    SDL_VideoDevice *_this = SDL_GetVideoDevice();
  5.1401 -    SDL_Window *window;
  5.1402 -    SDL_Rect area;
  5.1403 -
  5.1404 -    /* Get the window associated with the surface */
  5.1405 -    window = SDL_GetWindowFromSurface(screen);
  5.1406 -    if (!window || !window->surface) {
  5.1407 -        return;
  5.1408 -    }
  5.1409 -
  5.1410 -    /* Get the mouse rectangle, clipped to the screen */
  5.1411 -    SDL_MouseRect(&area);
  5.1412 -    if ((area.w == 0) || (area.h == 0)) {
  5.1413 -        return;
  5.1414 -    }
  5.1415 -
  5.1416 -    /* Copy mouse background */
  5.1417 -    {
  5.1418 -        int w, h, screenbpp;
  5.1419 -        Uint8 *src, *dst;
  5.1420 -
  5.1421 -        /* Set up the copy pointers */
  5.1422 -        screenbpp = screen->format->BytesPerPixel;
  5.1423 -        if ((screen->flags & SDL_SCREEN_SURFACE) ||
  5.1424 -            FORMAT_EQUAL(screen->format, window->surface->format)) {
  5.1425 -            src = SDL_cursor->save[0];
  5.1426 -        } else {
  5.1427 -            src = SDL_cursor->save[1];
  5.1428 -        }
  5.1429 -        dst = (Uint8 *) screen->pixels + area.y * screen->pitch +
  5.1430 -            area.x * screenbpp;
  5.1431 -
  5.1432 -        /* Perform the copy */
  5.1433 -        w = area.w * screenbpp;
  5.1434 -        h = area.h;
  5.1435 -        while (h--) {
  5.1436 -            SDL_memcpy(dst, src, w);
  5.1437 -            src += w;
  5.1438 -            dst += screen->pitch;
  5.1439 -        }
  5.1440 -
  5.1441 -        /* Perform pixel conversion on cursor background */
  5.1442 -        if (src > SDL_cursor->save[1]) {
  5.1443 -            SDL_ConvertCursorSave(screen, area.w, area.h);
  5.1444 -        }
  5.1445 -    }
  5.1446 -}
  5.1447 -
  5.1448 -void
  5.1449 -SDL_EraseCursor(SDL_Surface * screen)
  5.1450 -{
  5.1451 -    /* Lock the screen if necessary */
  5.1452 -    if (screen == NULL) {
  5.1453 -        return;
  5.1454 -    }
  5.1455 -    if (SDL_MUSTLOCK(screen)) {
  5.1456 -        if (SDL_LockSurface(screen) < 0) {
  5.1457 -            return;
  5.1458 -        }
  5.1459 -    }
  5.1460 -
  5.1461 -    SDL_EraseCursorNoLock(screen);
  5.1462 -
  5.1463 -    /* Unlock the screen and update if necessary */
  5.1464 -    if (SDL_MUSTLOCK(screen)) {
  5.1465 -        SDL_UnlockSurface(screen);
  5.1466 -    }
  5.1467 -    if (screen->flags & SDL_SCREEN_SURFACE) {
  5.1468 -        SDL_VideoDevice *_this = SDL_GetVideoDevice();
  5.1469 -        SDL_Window *window;
  5.1470 -        SDL_Rect area;
  5.1471 -
  5.1472 -        window = SDL_GetWindowFromSurface(screen);
  5.1473 -        if (!window) {
  5.1474 -            return;
  5.1475 -        }
  5.1476 -
  5.1477 -        SDL_MouseRect(&area);
  5.1478 -
  5.1479 -        if (_this->UpdateWindowSurface) {
  5.1480 -            _this->UpdateWindowSurface(_this, window, 1, &area);
  5.1481 -        }
  5.1482 -    }
  5.1483 -}
  5.1484 -
  5.1485 -/* Reset the cursor on video mode change
  5.1486 -   FIXME:  Keep track of all cursors, and reset them all.
  5.1487 - */
  5.1488 -void
  5.1489 -SDL_ResetCursor(void)
  5.1490 -{
  5.1491 -    int savelen;
  5.1492 -
  5.1493 -    if (SDL_cursor) {
  5.1494 -        savelen = SDL_cursor->area.w * 4 * SDL_cursor->area.h;
  5.1495 -        SDL_cursor->area.x = 0;
  5.1496 -        SDL_cursor->area.y = 0;
  5.1497 -        SDL_memset(SDL_cursor->save[0], 0, savelen);
  5.1498 -    }
  5.1499 -}
  5.1500 -#endif
  5.1501 -
  5.1502 -struct private_yuvhwdata
  5.1503 -{
  5.1504 -    SDL_SW_YUVTexture *texture;
  5.1505 -    SDL_Surface *display;
  5.1506 -    Uint32 display_format;
  5.1507 -};
  5.1508 -
  5.1509 -SDL_Overlay *
  5.1510 -SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display)
  5.1511 -{
  5.1512 -    SDL_Overlay *overlay;
  5.1513 -    Uint32 texture_format;
  5.1514 -    SDL_SW_YUVTexture *texture;
  5.1515 -
  5.1516 -    if ((display->flags & SDL_OPENGL) == SDL_OPENGL) {
  5.1517 -        SDL_SetError("YUV overlays are not supported in OpenGL mode");
  5.1518 -        return NULL;
  5.1519 -    }
  5.1520 -
  5.1521 -    if (display != SDL_PublicSurface) {
  5.1522 -        SDL_SetError("YUV display is only supported on the screen surface");
  5.1523 -        return NULL;
  5.1524 -    }
  5.1525 -
  5.1526 -    switch (format) {
  5.1527 -    case SDL_YV12_OVERLAY:
  5.1528 -        texture_format = SDL_PIXELFORMAT_YV12;
  5.1529 -        break;
  5.1530 -    case SDL_IYUV_OVERLAY:
  5.1531 -        texture_format = SDL_PIXELFORMAT_IYUV;
  5.1532 -        break;
  5.1533 -    case SDL_YUY2_OVERLAY:
  5.1534 -        texture_format = SDL_PIXELFORMAT_YUY2;
  5.1535 -        break;
  5.1536 -    case SDL_UYVY_OVERLAY:
  5.1537 -        texture_format = SDL_PIXELFORMAT_UYVY;
  5.1538 -        break;
  5.1539 -    case SDL_YVYU_OVERLAY:
  5.1540 -        texture_format = SDL_PIXELFORMAT_YVYU;
  5.1541 -        break;
  5.1542 -    default:
  5.1543 -        SDL_SetError("Unknown YUV format");
  5.1544 -        return NULL;
  5.1545 -    }
  5.1546 -
  5.1547 -    overlay = (SDL_Overlay *) SDL_malloc(sizeof(*overlay));
  5.1548 -    if (!overlay) {
  5.1549 -        SDL_OutOfMemory();
  5.1550 -        return NULL;
  5.1551 -    }
  5.1552 -    SDL_zerop(overlay);
  5.1553 -
  5.1554 -    overlay->hwdata =
  5.1555 -        (struct private_yuvhwdata *) SDL_malloc(sizeof(*overlay->hwdata));
  5.1556 -    if (!overlay->hwdata) {
  5.1557 -        SDL_free(overlay);
  5.1558 -        SDL_OutOfMemory();
  5.1559 -        return NULL;
  5.1560 -    }
  5.1561 -
  5.1562 -    texture = SDL_SW_CreateYUVTexture(texture_format, w, h);
  5.1563 -    if (!texture) {
  5.1564 -        SDL_free(overlay->hwdata);
  5.1565 -        SDL_free(overlay);
  5.1566 -        return NULL;
  5.1567 -    }
  5.1568 -    overlay->hwdata->texture = texture;
  5.1569 -    overlay->hwdata->display = NULL;
  5.1570 -    overlay->hwdata->display_format = SDL_PIXELFORMAT_UNKNOWN;
  5.1571 -
  5.1572 -    overlay->format = format;
  5.1573 -    overlay->w = w;
  5.1574 -    overlay->h = h;
  5.1575 -    if (format == SDL_YV12_OVERLAY || format == SDL_IYUV_OVERLAY) {
  5.1576 -        overlay->planes = 3;
  5.1577 -    } else {
  5.1578 -        overlay->planes = 1;
  5.1579 -    }
  5.1580 -    overlay->pitches = texture->pitches;
  5.1581 -    overlay->pixels = texture->planes;
  5.1582 -
  5.1583 -    return overlay;
  5.1584 -}
  5.1585 -
  5.1586 -int
  5.1587 -SDL_LockYUVOverlay(SDL_Overlay * overlay)
  5.1588 -{
  5.1589 -    SDL_Rect rect;
  5.1590 -    void *pixels;
  5.1591 -    int pitch;
  5.1592 -
  5.1593 -    if (!overlay) {
  5.1594 -        SDL_SetError("Passed a NULL overlay");
  5.1595 -        return -1;
  5.1596 -    }
  5.1597 -
  5.1598 -    rect.x = 0;
  5.1599 -    rect.y = 0;
  5.1600 -    rect.w = overlay->w;
  5.1601 -    rect.h = overlay->h;
  5.1602 -
  5.1603 -    if (SDL_SW_LockYUVTexture(overlay->hwdata->texture, &rect, &pixels, &pitch) < 0) {
  5.1604 -        return -1;
  5.1605 -    }
  5.1606 -
  5.1607 -    overlay->pixels[0] = (Uint8 *) pixels;
  5.1608 -    overlay->pitches[0] = pitch;
  5.1609 -    switch (overlay->format) {
  5.1610 -    case SDL_YV12_OVERLAY:
  5.1611 -    case SDL_IYUV_OVERLAY:
  5.1612 -        overlay->pitches[1] = pitch / 2;
  5.1613 -        overlay->pitches[2] = pitch / 2;
  5.1614 -        overlay->pixels[1] =
  5.1615 -            overlay->pixels[0] + overlay->pitches[0] * overlay->h;
  5.1616 -        overlay->pixels[2] =
  5.1617 -            overlay->pixels[1] + overlay->pitches[1] * overlay->h / 2;
  5.1618 -        break;
  5.1619 -    case SDL_YUY2_OVERLAY:
  5.1620 -    case SDL_UYVY_OVERLAY:
  5.1621 -    case SDL_YVYU_OVERLAY:
  5.1622 -        break;
  5.1623 -    }
  5.1624 -    return 0;
  5.1625 -}
  5.1626 -
  5.1627 -void
  5.1628 -SDL_UnlockYUVOverlay(SDL_Overlay * overlay)
  5.1629 -{
  5.1630 -    if (!overlay) {
  5.1631 -        return;
  5.1632 -    }
  5.1633 -
  5.1634 -    SDL_SW_UnlockYUVTexture(overlay->hwdata->texture);
  5.1635 -}
  5.1636 -
  5.1637 -int
  5.1638 -SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect)
  5.1639 -{
  5.1640 -    SDL_Surface *display;
  5.1641 -    SDL_Rect src_rect;
  5.1642 -    SDL_Rect dst_rect;
  5.1643 -    void *pixels;
  5.1644 -
  5.1645 -    if (!overlay || !dstrect) {
  5.1646 -        SDL_SetError("Passed a NULL overlay or dstrect");
  5.1647 -        return -1;
  5.1648 -    }
  5.1649 -
  5.1650 -    display = overlay->hwdata->display;
  5.1651 -    if (display != SDL_VideoSurface) {
  5.1652 -        overlay->hwdata->display = display = SDL_VideoSurface;
  5.1653 -        overlay->hwdata->display_format = SDL_MasksToPixelFormatEnum(
  5.1654 -                                                display->format->BitsPerPixel,
  5.1655 -                                                display->format->Rmask,
  5.1656 -                                                display->format->Gmask,
  5.1657 -                                                display->format->Bmask,
  5.1658 -                                                display->format->Amask);
  5.1659 -    }
  5.1660 -
  5.1661 -    src_rect.x = 0;
  5.1662 -    src_rect.y = 0;
  5.1663 -    src_rect.w = overlay->w;
  5.1664 -    src_rect.h = overlay->h;
  5.1665 -
  5.1666 -    if (!SDL_IntersectRect(&display->clip_rect, dstrect, &dst_rect)) {
  5.1667 -        return 0;
  5.1668 -    }
  5.1669 -     
  5.1670 -    pixels = (void *)((Uint8 *)display->pixels +
  5.1671 -                        dst_rect.y * display->pitch +
  5.1672 -                        dst_rect.x * display->format->BytesPerPixel);
  5.1673 -
  5.1674 -    if (SDL_SW_CopyYUVToRGB(overlay->hwdata->texture, &src_rect,
  5.1675 -                            overlay->hwdata->display_format,
  5.1676 -                            dst_rect.w, dst_rect.h,
  5.1677 -                            pixels, display->pitch) < 0) {
  5.1678 -        return -1;
  5.1679 -    }
  5.1680 -    SDL_UpdateWindowSurface(SDL_VideoWindow);
  5.1681 -    return 0;
  5.1682 -}
  5.1683 -
  5.1684 -void
  5.1685 -SDL_FreeYUVOverlay(SDL_Overlay * overlay)
  5.1686 -{
  5.1687 -    if (!overlay) {
  5.1688 -        return;
  5.1689 -    }
  5.1690 -    if (overlay->hwdata) {
  5.1691 -        if (overlay->hwdata->texture) {
  5.1692 -            SDL_SW_DestroyYUVTexture(overlay->hwdata->texture);
  5.1693 -        }
  5.1694 -        SDL_free(overlay->hwdata);
  5.1695 -    }
  5.1696 -    SDL_free(overlay);
  5.1697 -}
  5.1698 -
  5.1699 -void
  5.1700 -SDL_GL_SwapBuffers(void)
  5.1701 -{
  5.1702 -    SDL_GL_SwapWindow(SDL_VideoWindow);
  5.1703 -}
  5.1704 -
  5.1705 -int
  5.1706 -SDL_SetGamma(float red, float green, float blue)
  5.1707 -{
  5.1708 -    Uint16 red_ramp[256];
  5.1709 -    Uint16 green_ramp[256];
  5.1710 -    Uint16 blue_ramp[256];
  5.1711 -
  5.1712 -    SDL_CalculateGammaRamp(red, red_ramp);
  5.1713 -    if (green == red) {
  5.1714 -        SDL_memcpy(green_ramp, red_ramp, sizeof(red_ramp));
  5.1715 -    } else {
  5.1716 -        SDL_CalculateGammaRamp(green, green_ramp);
  5.1717 -    }
  5.1718 -    if (blue == red) {
  5.1719 -        SDL_memcpy(blue_ramp, red_ramp, sizeof(red_ramp));
  5.1720 -    } else {
  5.1721 -        SDL_CalculateGammaRamp(blue, blue_ramp);
  5.1722 -    }
  5.1723 -    return SDL_SetWindowGammaRamp(SDL_VideoWindow, red_ramp, green_ramp, blue_ramp);
  5.1724 -}
  5.1725 -
  5.1726 -int
  5.1727 -SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, const Uint16 * blue)
  5.1728 -{
  5.1729 -    return SDL_SetWindowGammaRamp(SDL_VideoWindow, red, green, blue);
  5.1730 -}
  5.1731 -
  5.1732 -int
  5.1733 -SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
  5.1734 -{
  5.1735 -    return SDL_GetWindowGammaRamp(SDL_VideoWindow, red, green, blue);
  5.1736 -}
  5.1737 -
  5.1738 -int
  5.1739 -SDL_EnableKeyRepeat(int delay, int interval)
  5.1740 -{
  5.1741 -    return 0;
  5.1742 -}
  5.1743 -
  5.1744 -void
  5.1745 -SDL_GetKeyRepeat(int *delay, int *interval)
  5.1746 -{
  5.1747 -    if (delay) {
  5.1748 -        *delay = SDL_DEFAULT_REPEAT_DELAY;
  5.1749 -    }
  5.1750 -    if (interval) {
  5.1751 -        *interval = SDL_DEFAULT_REPEAT_INTERVAL;
  5.1752 -    }
  5.1753 -}
  5.1754 -
  5.1755 -int
  5.1756 -SDL_EnableUNICODE(int enable)
  5.1757 -{
  5.1758 -    int previous = SDL_enabled_UNICODE;
  5.1759 -
  5.1760 -    switch (enable) {
  5.1761 -    case 1:
  5.1762 -        SDL_enabled_UNICODE = 1;
  5.1763 -        SDL_StartTextInput();
  5.1764 -        break;
  5.1765 -    case 0:
  5.1766 -        SDL_enabled_UNICODE = 0;
  5.1767 -        SDL_StopTextInput();
  5.1768 -        break;
  5.1769 -    }
  5.1770 -    return previous;
  5.1771 -}
  5.1772 -
  5.1773 -static Uint32
  5.1774 -SDL_SetTimerCallback(Uint32 interval, void* param)
  5.1775 -{
  5.1776 -    return ((SDL_OldTimerCallback)param)(interval);
  5.1777 -}
  5.1778 -
  5.1779 -int
  5.1780 -SDL_SetTimer(Uint32 interval, SDL_OldTimerCallback callback)
  5.1781 -{
  5.1782 -    static SDL_TimerID compat_timer;
  5.1783 -
  5.1784 -    if (compat_timer) {
  5.1785 -        SDL_RemoveTimer(compat_timer);
  5.1786 -        compat_timer = 0;
  5.1787 -    }
  5.1788 -
  5.1789 -    if (interval && callback) {
  5.1790 -        compat_timer = SDL_AddTimer(interval, SDL_SetTimerCallback, callback);
  5.1791 -        if (!compat_timer) {
  5.1792 -            return -1;
  5.1793 -        }
  5.1794 -    }
  5.1795 -    return 0;
  5.1796 -}
  5.1797 -
  5.1798 -int
  5.1799 -SDL_putenv(const char *_var)
  5.1800 -{
  5.1801 -    char *ptr = NULL;
  5.1802 -    char *var = SDL_strdup(_var);
  5.1803 -    if (var == NULL) {
  5.1804 -        return -1;  /* we don't set errno. */
  5.1805 -    }
  5.1806 -
  5.1807 -    ptr = SDL_strchr(var, '=');
  5.1808 -    if (ptr == NULL) {
  5.1809 -        SDL_free(var);
  5.1810 -        return -1;
  5.1811 -    }
  5.1812 -
  5.1813 -    *ptr = '\0';  /* split the string into name and value. */
  5.1814 -    SDL_setenv(var, ptr + 1, 1);
  5.1815 -    SDL_free(var);
  5.1816 -    return 0;
  5.1817 -}
  5.1818 -
  5.1819 -/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/video/SDL_surface.c	Sun Jan 22 17:50:35 2012 -0500
     6.2 +++ b/src/video/SDL_surface.c	Sun Jan 22 18:11:41 2012 -0500
     6.3 @@ -21,7 +21,6 @@
     6.4  #include "SDL_config.h"
     6.5  
     6.6  #include "SDL_video.h"
     6.7 -#include "SDL_compat.h"
     6.8  #include "SDL_sysvideo.h"
     6.9  #include "SDL_blit.h"
    6.10  #include "SDL_RLEaccel_c.h"
    6.11 @@ -195,13 +194,6 @@
    6.12          SDL_InvalidateMap(surface->map);
    6.13      }
    6.14  
    6.15 -    /* Compatibility mode */
    6.16 -    if (surface->map->info.flags & SDL_COPY_COLORKEY) {
    6.17 -        surface->flags |= SDL_SRCCOLORKEY;
    6.18 -    } else {
    6.19 -        surface->flags &= ~SDL_SRCCOLORKEY;
    6.20 -    }
    6.21 -
    6.22      return 0;
    6.23  }
    6.24  
    6.25 @@ -405,13 +397,6 @@
    6.26          SDL_InvalidateMap(surface->map);
    6.27      }
    6.28  
    6.29 -    /* Compatibility mode */
    6.30 -    if (surface->map->info.flags & SDL_COPY_BLEND) {
    6.31 -        surface->flags |= SDL_SRCALPHA;
    6.32 -    } else {
    6.33 -        surface->flags &= ~SDL_SRCALPHA;
    6.34 -    }
    6.35 -
    6.36      return status;
    6.37  }
    6.38  
     7.1 --- a/test/Makefile.in	Sun Jan 22 17:50:35 2012 -0500
     7.2 +++ b/test/Makefile.in	Sun Jan 22 18:11:41 2012 -0500
     7.3 @@ -9,23 +9,11 @@
     7.4  
     7.5  TARGETS = \
     7.6  	checkkeys$(EXE) \
     7.7 -	graywin$(EXE) \
     7.8  	loopwave$(EXE) \
     7.9 -	testalpha$(EXE) \
    7.10 -	testatomic$(EXE) \
    7.11 -	testaudioinfo$(EXE) \
    7.12 -	testbitmap$(EXE) \
    7.13 -	testblitspeed$(EXE) \
    7.14 -	testcursor$(EXE) \
    7.15  	testdraw2$(EXE) \
    7.16 -	testdyngl$(EXE) \
    7.17 -	testdyngles$(EXE) \
    7.18  	testerror$(EXE) \
    7.19  	testfile$(EXE) \
    7.20 -	testfill$(EXE) \
    7.21 -	testgamma$(EXE) \
    7.22  	testgesture$(EXE) \
    7.23 -	testgl$(EXE) \
    7.24  	testgl2$(EXE) \
    7.25  	testgles$(EXE) \
    7.26  	testhaptic$(EXE) \
    7.27 @@ -40,7 +28,6 @@
    7.28  	testlock$(EXE) \
    7.29  	testmultiaudio$(EXE) \
    7.30  	testnative$(EXE) \
    7.31 -	testoverlay$(EXE) \
    7.32  	testoverlay2$(EXE) \
    7.33  	testplatform$(EXE) \
    7.34  	testpower$(EXE) \
    7.35 @@ -50,17 +37,12 @@
    7.36  	testsem$(EXE) \
    7.37  	testshader$(EXE) \
    7.38  	testshape$(EXE) \
    7.39 -	testsprite$(EXE) \
    7.40  	testsprite2$(EXE) \
    7.41  	testspriteminimal$(EXE) \
    7.42  	teststreaming$(EXE) \
    7.43  	testtimer$(EXE) \
    7.44  	testver$(EXE) \
    7.45 -	testvidinfo$(EXE) \
    7.46 -	testwin$(EXE) \
    7.47 -	testwm$(EXE) \
    7.48  	testwm2$(EXE) \
    7.49 -	threadwin$(EXE) \
    7.50  	torturethread$(EXE) \
    7.51  
    7.52  all: Makefile $(TARGETS)
    7.53 @@ -71,9 +53,6 @@
    7.54  checkkeys$(EXE): $(srcdir)/checkkeys.c
    7.55  	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    7.56  
    7.57 -graywin$(EXE): $(srcdir)/graywin.c
    7.58 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    7.59 -
    7.60  loopwave$(EXE): $(srcdir)/loopwave.c
    7.61  	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    7.62  
    7.63 @@ -86,51 +65,24 @@
    7.64  testmultiaudio$(EXE): $(srcdir)/testmultiaudio.c
    7.65  	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    7.66  
    7.67 -testalpha$(EXE): $(srcdir)/testalpha.c
    7.68 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
    7.69 -
    7.70  testatomic$(EXE): $(srcdir)/testatomic.c
    7.71  	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    7.72  
    7.73 -testbitmap$(EXE): $(srcdir)/testbitmap.c
    7.74 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    7.75 -
    7.76 -testblitspeed$(EXE): $(srcdir)/testblitspeed.c
    7.77 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    7.78 -
    7.79 -testcursor$(EXE): $(srcdir)/testcursor.c
    7.80 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    7.81 -
    7.82  testintersections$(EXE): $(srcdir)/testintersections.c $(srcdir)/common.c
    7.83  	$(CC) -o $@ $(srcdir)/testintersections.c $(srcdir)/common.c $(CFLAGS) $(LIBS)
    7.84  
    7.85  testdraw2$(EXE): $(srcdir)/testdraw2.c $(srcdir)/common.c
    7.86  	$(CC) -o $@ $(srcdir)/testdraw2.c $(srcdir)/common.c $(CFLAGS) $(LIBS)
    7.87  
    7.88 -testdyngl$(EXE): $(srcdir)/testdyngl.c
    7.89 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    7.90 -
    7.91 -testdyngles$(EXE): $(srcdir)/testdyngles.c
    7.92 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    7.93 -
    7.94  testerror$(EXE): $(srcdir)/testerror.c
    7.95  	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    7.96  
    7.97  testfile$(EXE): $(srcdir)/testfile.c
    7.98  	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    7.99  
   7.100 -testfill$(EXE): $(srcdir)/testfill.c
   7.101 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   7.102 -
   7.103 -testgamma$(EXE): $(srcdir)/testgamma.c
   7.104 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   7.105 - 
   7.106  testgesture$(EXE): $(srcdir)/testgesture.c
   7.107  	$(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
   7.108   
   7.109 -testgl$(EXE): $(srcdir)/testgl.c
   7.110 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
   7.111 -
   7.112  testgl2$(EXE): $(srcdir)/testgl2.c $(srcdir)/common.c
   7.113  	$(CC) -o $@ $(srcdir)/testgl2.c $(srcdir)/common.c $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
   7.114  
   7.115 @@ -173,9 +125,6 @@
   7.116  testoverlay2$(EXE): $(srcdir)/testoverlay2.c
   7.117  	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   7.118  
   7.119 -testoverlay$(EXE): $(srcdir)/testoverlay.c
   7.120 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   7.121 -
   7.122  testplatform$(EXE): $(srcdir)/testplatform.c
   7.123  	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   7.124  
   7.125 @@ -197,9 +146,6 @@
   7.126  testshape$(EXE): $(srcdir)/testshape.c
   7.127  	$(CC) -o $@ $? -std=c99 $(CFLAGS) $(LIBS)
   7.128  
   7.129 -testsprite$(EXE): $(srcdir)/testsprite.c
   7.130 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
   7.131 -
   7.132  testsprite2$(EXE): $(srcdir)/testsprite2.c $(srcdir)/common.c
   7.133  	$(CC) -o $@ $(srcdir)/testsprite2.c $(srcdir)/common.c $(CFLAGS) $(LIBS) @MATHLIB@
   7.134  
   7.135 @@ -215,21 +161,9 @@
   7.136  testver$(EXE): $(srcdir)/testver.c
   7.137  	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   7.138  
   7.139 -testvidinfo$(EXE): $(srcdir)/testvidinfo.c
   7.140 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   7.141 -
   7.142 -testwin$(EXE): $(srcdir)/testwin.c
   7.143 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   7.144 -
   7.145 -testwm$(EXE): $(srcdir)/testwm.c
   7.146 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   7.147 -
   7.148  testwm2$(EXE): $(srcdir)/testwm2.c $(srcdir)/common.c
   7.149  	$(CC) -o $@ $(srcdir)/testwm2.c $(srcdir)/common.c $(CFLAGS) $(LIBS)
   7.150  
   7.151 -threadwin$(EXE): $(srcdir)/threadwin.c
   7.152 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   7.153 -
   7.154  torturethread$(EXE): $(srcdir)/torturethread.c
   7.155  	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   7.156  
     8.1 --- a/test/common.h	Sun Jan 22 17:50:35 2012 -0500
     8.2 +++ b/test/common.h	Sun Jan 22 18:11:41 2012 -0500
     8.3 @@ -12,7 +12,6 @@
     8.4  
     8.5  /* A simple test program framework */
     8.6  
     8.7 -#define SDL_NO_COMPAT
     8.8  #include "SDL.h"
     8.9  
    8.10  #ifdef __NDS__
     9.1 --- a/test/testalpha.c	Sun Jan 22 17:50:35 2012 -0500
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,552 +0,0 @@
     9.4 -/*
     9.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
     9.6 -
     9.7 -  This software is provided 'as-is', without any express or implied
     9.8 -  warranty.  In no event will the authors be held liable for any damages
     9.9 -  arising from the use of this software.
    9.10 -
    9.11 -  Permission is granted to anyone to use this software for any purpose,
    9.12 -  including commercial applications, and to alter it and redistribute it
    9.13 -  freely.
    9.14 -*/
    9.15 -
    9.16 -/* Simple program:  Fill a colormap with gray and stripe it down the screen,
    9.17 -		    Then move an alpha valued sprite around the screen.
    9.18 - */
    9.19 -
    9.20 -#include <stdio.h>
    9.21 -#include <stdlib.h>
    9.22 -#include <string.h>
    9.23 -#include <math.h>
    9.24 -
    9.25 -#include "SDL.h"
    9.26 -
    9.27 -#define FRAME_TICKS	(1000/30)       /* 30 frames/second */
    9.28 -
    9.29 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    9.30 -static void
    9.31 -quit(int rc)
    9.32 -{
    9.33 -    SDL_Quit();
    9.34 -    exit(rc);
    9.35 -}
    9.36 -
    9.37 -/* Fill the screen with a gradient */
    9.38 -static void
    9.39 -FillBackground(SDL_Surface * screen)
    9.40 -{
    9.41 -    Uint8 *buffer;
    9.42 -    Uint8 gradient;
    9.43 -    int i, k;
    9.44 -
    9.45 -    /* Set the surface pixels and refresh! */
    9.46 -    if (SDL_LockSurface(screen) < 0) {
    9.47 -        fprintf(stderr, "Couldn't lock the display surface: %s\n",
    9.48 -                SDL_GetError());
    9.49 -        quit(2);
    9.50 -    }
    9.51 -    buffer = (Uint8 *) screen->pixels;
    9.52 -    switch (screen->format->BytesPerPixel) {
    9.53 -    case 1:
    9.54 -    case 3:
    9.55 -        for (i = 0; i < screen->h; ++i) {
    9.56 -            memset(buffer, (i * 255) / screen->h,
    9.57 -                   screen->w * screen->format->BytesPerPixel);
    9.58 -            buffer += screen->pitch;
    9.59 -        }
    9.60 -        break;
    9.61 -    case 2:
    9.62 -        for (i = 0; i < screen->h; ++i) {
    9.63 -            Uint16 *buffer16;
    9.64 -            Uint16 color;
    9.65 -
    9.66 -            gradient = ((i * 255) / screen->h);
    9.67 -            color = (Uint16) SDL_MapRGB(screen->format,
    9.68 -                                        gradient, gradient, gradient);
    9.69 -            buffer16 = (Uint16 *) buffer;
    9.70 -            for (k = 0; k < screen->w; k++) {
    9.71 -                *buffer16++ = color;
    9.72 -            }
    9.73 -            buffer += screen->pitch;
    9.74 -        }
    9.75 -        break;
    9.76 -    case 4:
    9.77 -        for (i = 0; i < screen->h; ++i) {
    9.78 -            Uint32 *buffer32;
    9.79 -            Uint32 color;
    9.80 -
    9.81 -            gradient = ((i * 255) / screen->h);
    9.82 -            color = SDL_MapRGB(screen->format, gradient, gradient, gradient);
    9.83 -            buffer32 = (Uint32 *) buffer;
    9.84 -            for (k = 0; k < screen->w; k++) {
    9.85 -                *buffer32++ = color;
    9.86 -            }
    9.87 -            buffer += screen->pitch;
    9.88 -        }
    9.89 -        break;
    9.90 -    }
    9.91 -
    9.92 -    SDL_UnlockSurface(screen);
    9.93 -    SDL_UpdateRect(screen, 0, 0, 0, 0);
    9.94 -}
    9.95 -
    9.96 -/* Create a "light" -- a yellowish surface with variable alpha */
    9.97 -SDL_Surface *
    9.98 -CreateLight(int radius)
    9.99 -{
   9.100 -    Uint8 trans, alphamask;
   9.101 -    int range, addition;
   9.102 -    int xdist, ydist;
   9.103 -    Uint16 x, y;
   9.104 -    Uint16 skip;
   9.105 -    Uint32 pixel;
   9.106 -    SDL_Surface *light;
   9.107 -
   9.108 -#ifdef LIGHT_16BIT
   9.109 -    Uint16 *buf;
   9.110 -
   9.111 -    /* Create a 16 (4/4/4/4) bpp square with a full 4-bit alpha channel */
   9.112 -    /* Note: this isn't any faster than a 32 bit alpha surface */
   9.113 -    alphamask = 0x0000000F;
   9.114 -    light = SDL_CreateRGBSurface(SDL_SWSURFACE, 2 * radius, 2 * radius, 16,
   9.115 -                                 0x0000F000, 0x00000F00, 0x000000F0,
   9.116 -                                 alphamask);
   9.117 -#else
   9.118 -    Uint32 *buf;
   9.119 -
   9.120 -    /* Create a 32 (8/8/8/8) bpp square with a full 8-bit alpha channel */
   9.121 -    alphamask = 0x000000FF;
   9.122 -    light = SDL_CreateRGBSurface(SDL_SWSURFACE, 2 * radius, 2 * radius, 32,
   9.123 -                                 0xFF000000, 0x00FF0000, 0x0000FF00,
   9.124 -                                 alphamask);
   9.125 -    if (light == NULL) {
   9.126 -        fprintf(stderr, "Couldn't create light: %s\n", SDL_GetError());
   9.127 -        return (NULL);
   9.128 -    }
   9.129 -#endif
   9.130 -
   9.131 -    /* Fill with a light yellow-orange color */
   9.132 -    skip = light->pitch - (light->w * light->format->BytesPerPixel);
   9.133 -#ifdef LIGHT_16BIT
   9.134 -    buf = (Uint16 *) light->pixels;
   9.135 -#else
   9.136 -    buf = (Uint32 *) light->pixels;
   9.137 -#endif
   9.138 -    /* Get a tranparent pixel value - we'll add alpha later */
   9.139 -    pixel = SDL_MapRGBA(light->format, 0xFF, 0xDD, 0x88, 0);
   9.140 -    for (y = 0; y < light->h; ++y) {
   9.141 -        for (x = 0; x < light->w; ++x) {
   9.142 -            *buf++ = pixel;
   9.143 -        }
   9.144 -        buf += skip;            /* Almost always 0, but just in case... */
   9.145 -    }
   9.146 -
   9.147 -    /* Calculate alpha values for the surface. */
   9.148 -#ifdef LIGHT_16BIT
   9.149 -    buf = (Uint16 *) light->pixels;
   9.150 -#else
   9.151 -    buf = (Uint32 *) light->pixels;
   9.152 -#endif
   9.153 -    for (y = 0; y < light->h; ++y) {
   9.154 -        for (x = 0; x < light->w; ++x) {
   9.155 -            /* Slow distance formula (from center of light) */
   9.156 -            xdist = x - (light->w / 2);
   9.157 -            ydist = y - (light->h / 2);
   9.158 -            range = (int) sqrt(xdist * xdist + ydist * ydist);
   9.159 -
   9.160 -            /* Scale distance to range of transparency (0-255) */
   9.161 -            if (range > radius) {
   9.162 -                trans = alphamask;
   9.163 -            } else {
   9.164 -                /* Increasing transparency with distance */
   9.165 -                trans = (Uint8) ((range * alphamask) / radius);
   9.166 -
   9.167 -                /* Lights are very transparent */
   9.168 -                addition = (alphamask + 1) / 8;
   9.169 -                if ((int) trans + addition > alphamask) {
   9.170 -                    trans = alphamask;
   9.171 -                } else {
   9.172 -                    trans += addition;
   9.173 -                }
   9.174 -            }
   9.175 -            /* We set the alpha component as the right N bits */
   9.176 -            *buf++ |= (255 - trans);
   9.177 -        }
   9.178 -        buf += skip;            /* Almost always 0, but just in case... */
   9.179 -    }
   9.180 -    /* Enable RLE acceleration of this alpha surface */
   9.181 -    SDL_SetAlpha(light, SDL_SRCALPHA | SDL_RLEACCEL, 0);
   9.182 -
   9.183 -    /* We're done! */
   9.184 -    return (light);
   9.185 -}
   9.186 -
   9.187 -static Uint32 flashes = 0;
   9.188 -static Uint32 flashtime = 0;
   9.189 -
   9.190 -void
   9.191 -FlashLight(SDL_Surface * screen, SDL_Surface * light, int x, int y)
   9.192 -{
   9.193 -    SDL_Rect position;
   9.194 -    Uint32 ticks1;
   9.195 -    Uint32 ticks2;
   9.196 -
   9.197 -    /* Easy, center light */
   9.198 -    position.x = x - (light->w / 2);
   9.199 -    position.y = y - (light->h / 2);
   9.200 -    position.w = light->w;
   9.201 -    position.h = light->h;
   9.202 -    ticks1 = SDL_GetTicks();
   9.203 -    SDL_BlitSurface(light, NULL, screen, &position);
   9.204 -    ticks2 = SDL_GetTicks();
   9.205 -    SDL_UpdateRects(screen, 1, &position);
   9.206 -    ++flashes;
   9.207 -
   9.208 -    /* Update time spend doing alpha blitting */
   9.209 -    flashtime += (ticks2 - ticks1);
   9.210 -}
   9.211 -
   9.212 -static int sprite_visible = 0;
   9.213 -static SDL_Surface *sprite;
   9.214 -static SDL_Surface *backing;
   9.215 -static SDL_Rect position;
   9.216 -static int x_vel, y_vel;
   9.217 -static int alpha_vel;
   9.218 -
   9.219 -int
   9.220 -LoadSprite(SDL_Surface * screen, char *file)
   9.221 -{
   9.222 -    SDL_Surface *converted;
   9.223 -
   9.224 -    /* Load the sprite image */
   9.225 -    sprite = SDL_LoadBMP(file);
   9.226 -    if (sprite == NULL) {
   9.227 -        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
   9.228 -        return (-1);
   9.229 -    }
   9.230 -
   9.231 -    /* Set transparent pixel as the pixel at (0,0) */
   9.232 -    if (sprite->format->palette) {
   9.233 -        SDL_SetColorKey(sprite, SDL_SRCCOLORKEY, *(Uint8 *) sprite->pixels);
   9.234 -    }
   9.235 -
   9.236 -    /* Convert sprite to video format */
   9.237 -    converted = SDL_DisplayFormat(sprite);
   9.238 -    SDL_FreeSurface(sprite);
   9.239 -    if (converted == NULL) {
   9.240 -        fprintf(stderr, "Couldn't convert background: %s\n", SDL_GetError());
   9.241 -        return (-1);
   9.242 -    }
   9.243 -    sprite = converted;
   9.244 -
   9.245 -    /* Create the background */
   9.246 -    backing = SDL_CreateRGBSurface(SDL_SWSURFACE, sprite->w, sprite->h, 8,
   9.247 -                                   0, 0, 0, 0);
   9.248 -    if (backing == NULL) {
   9.249 -        fprintf(stderr, "Couldn't create background: %s\n", SDL_GetError());
   9.250 -        SDL_FreeSurface(sprite);
   9.251 -        return (-1);
   9.252 -    }
   9.253 -
   9.254 -    /* Convert background to video format */
   9.255 -    converted = SDL_DisplayFormat(backing);
   9.256 -    SDL_FreeSurface(backing);
   9.257 -    if (converted == NULL) {
   9.258 -        fprintf(stderr, "Couldn't convert background: %s\n", SDL_GetError());
   9.259 -        SDL_FreeSurface(sprite);
   9.260 -        return (-1);
   9.261 -    }
   9.262 -    backing = converted;
   9.263 -
   9.264 -    /* Set the initial position of the sprite */
   9.265 -    position.x = (screen->w - sprite->w) / 2;
   9.266 -    position.y = (screen->h - sprite->h) / 2;
   9.267 -    position.w = sprite->w;
   9.268 -    position.h = sprite->h;
   9.269 -    x_vel = 0;
   9.270 -    y_vel = 0;
   9.271 -    alpha_vel = 1;
   9.272 -
   9.273 -    /* We're ready to roll. :) */
   9.274 -    return (0);
   9.275 -}
   9.276 -
   9.277 -void
   9.278 -AttractSprite(Uint16 x, Uint16 y)
   9.279 -{
   9.280 -    x_vel = ((int) x - position.x) / 10;
   9.281 -    y_vel = ((int) y - position.y) / 10;
   9.282 -}
   9.283 -
   9.284 -void
   9.285 -MoveSprite(SDL_Surface * screen, SDL_Surface * light)
   9.286 -{
   9.287 -    SDL_Rect updates[2];
   9.288 -    Uint8 alpha;
   9.289 -
   9.290 -    /* Erase the sprite if it was visible */
   9.291 -    if (sprite_visible) {
   9.292 -        updates[0] = position;
   9.293 -        SDL_BlitSurface(backing, NULL, screen, &updates[0]);
   9.294 -    } else {
   9.295 -        updates[0].x = 0;
   9.296 -        updates[0].y = 0;
   9.297 -        updates[0].w = 0;
   9.298 -        updates[0].h = 0;
   9.299 -        sprite_visible = 1;
   9.300 -    }
   9.301 -
   9.302 -    /* Since the sprite is off the screen, we can do other drawing
   9.303 -       without being overwritten by the saved area behind the sprite.
   9.304 -     */
   9.305 -    if (light != NULL) {
   9.306 -        int x, y;
   9.307 -
   9.308 -        SDL_GetMouseState(&x, &y);
   9.309 -        FlashLight(screen, light, x, y);
   9.310 -    }
   9.311 -
   9.312 -    /* Move the sprite, bounce at the wall */
   9.313 -    position.x += x_vel;
   9.314 -    if ((position.x < 0) || (position.x >= screen->w)) {
   9.315 -        x_vel = -x_vel;
   9.316 -        position.x += x_vel;
   9.317 -    }
   9.318 -    position.y += y_vel;
   9.319 -    if ((position.y < 0) || (position.y >= screen->h)) {
   9.320 -        y_vel = -y_vel;
   9.321 -        position.y += y_vel;
   9.322 -    }
   9.323 -
   9.324 -    /* Update transparency (fade in and out) */
   9.325 -    SDL_GetSurfaceAlphaMod(sprite, &alpha);
   9.326 -    if (((int) alpha + alpha_vel) < 0) {
   9.327 -        alpha_vel = -alpha_vel;
   9.328 -    } else if (((int) alpha + alpha_vel) > 255) {
   9.329 -        alpha_vel = -alpha_vel;
   9.330 -    }
   9.331 -    SDL_SetAlpha(sprite, SDL_SRCALPHA, (Uint8) (alpha + alpha_vel));
   9.332 -
   9.333 -    /* Save the area behind the sprite */
   9.334 -    updates[1] = position;
   9.335 -    SDL_BlitSurface(screen, &updates[1], backing, NULL);
   9.336 -
   9.337 -    /* Blit the sprite onto the screen */
   9.338 -    updates[1] = position;
   9.339 -    SDL_BlitSurface(sprite, NULL, screen, &updates[1]);
   9.340 -
   9.341 -    /* Make it so! */
   9.342 -    SDL_UpdateRects(screen, 2, updates);
   9.343 -}
   9.344 -
   9.345 -int
   9.346 -main(int argc, char *argv[])
   9.347 -{
   9.348 -    const SDL_VideoInfo *info;
   9.349 -    SDL_Surface *screen;
   9.350 -    int w, h;
   9.351 -    Uint8 video_bpp;
   9.352 -    Uint32 videoflags;
   9.353 -    int i, done;
   9.354 -    SDL_Event event;
   9.355 -    SDL_Surface *light;
   9.356 -    int mouse_pressed;
   9.357 -    Uint32 ticks, lastticks;
   9.358 -
   9.359 -
   9.360 -    /* Initialize SDL */
   9.361 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   9.362 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   9.363 -        return (1);
   9.364 -    }
   9.365 -
   9.366 -    /* Alpha blending doesn't work well at 8-bit color */
   9.367 -#ifdef _WIN32_WCE
   9.368 -    /* Pocket PC */
   9.369 -    w = 240;
   9.370 -    h = 320;
   9.371 -#else
   9.372 -    w = 640;
   9.373 -    h = 480;
   9.374 -#endif
   9.375 -    info = SDL_GetVideoInfo();
   9.376 -    if (info->vfmt->BitsPerPixel > 8) {
   9.377 -        video_bpp = info->vfmt->BitsPerPixel;
   9.378 -    } else {
   9.379 -        video_bpp = 16;
   9.380 -        fprintf(stderr, "forced 16 bpp mode\n");
   9.381 -    }
   9.382 -    videoflags = SDL_SWSURFACE;
   9.383 -    for (i = 1; argv[i]; ++i) {
   9.384 -        if (strcmp(argv[i], "-bpp") == 0) {
   9.385 -            video_bpp = atoi(argv[++i]);
   9.386 -            if (video_bpp <= 8) {
   9.387 -                video_bpp = 16;
   9.388 -                fprintf(stderr, "forced 16 bpp mode\n");
   9.389 -            }
   9.390 -        } else if (strcmp(argv[i], "-hw") == 0) {
   9.391 -            videoflags |= SDL_HWSURFACE;
   9.392 -        } else if (strcmp(argv[i], "-warp") == 0) {
   9.393 -            videoflags |= SDL_HWPALETTE;
   9.394 -        } else if (strcmp(argv[i], "-width") == 0 && argv[i + 1]) {
   9.395 -            w = atoi(argv[++i]);
   9.396 -        } else if (strcmp(argv[i], "-height") == 0 && argv[i + 1]) {
   9.397 -            h = atoi(argv[++i]);
   9.398 -        } else if (strcmp(argv[i], "-resize") == 0) {
   9.399 -            videoflags |= SDL_RESIZABLE;
   9.400 -        } else if (strcmp(argv[i], "-noframe") == 0) {
   9.401 -            videoflags |= SDL_NOFRAME;
   9.402 -        } else if (strcmp(argv[i], "-fullscreen") == 0) {
   9.403 -            videoflags |= SDL_FULLSCREEN;
   9.404 -        } else {
   9.405 -            fprintf(stderr,
   9.406 -                    "Usage: %s [-width N] [-height N] [-bpp N] [-warp] [-hw] [-fullscreen]\n",
   9.407 -                    argv[0]);
   9.408 -            quit(1);
   9.409 -        }
   9.410 -    }
   9.411 -
   9.412 -    /* Set video mode */
   9.413 -    if ((screen = SDL_SetVideoMode(w, h, video_bpp, videoflags)) == NULL) {
   9.414 -        fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
   9.415 -                w, h, video_bpp, SDL_GetError());
   9.416 -        quit(2);
   9.417 -    }
   9.418 -    FillBackground(screen);
   9.419 -
   9.420 -    /* Create the light */
   9.421 -    light = CreateLight(82);
   9.422 -    if (light == NULL) {
   9.423 -        quit(1);
   9.424 -    }
   9.425 -
   9.426 -    /* Load the sprite */
   9.427 -    if (LoadSprite(screen, "icon.bmp") < 0) {
   9.428 -        SDL_FreeSurface(light);
   9.429 -        quit(1);
   9.430 -    }
   9.431 -
   9.432 -    /* Print out information about our surfaces */
   9.433 -    printf("Screen is at %d bits per pixel\n", screen->format->BitsPerPixel);
   9.434 -    if ((screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
   9.435 -        printf("Screen is in video memory\n");
   9.436 -    } else {
   9.437 -        printf("Screen is in system memory\n");
   9.438 -    }
   9.439 -    if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
   9.440 -        printf("Screen has double-buffering enabled\n");
   9.441 -    }
   9.442 -    if ((sprite->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
   9.443 -        printf("Sprite is in video memory\n");
   9.444 -    } else {
   9.445 -        printf("Sprite is in system memory\n");
   9.446 -    }
   9.447 -
   9.448 -    /* Run a sample blit to trigger blit acceleration */
   9.449 -    MoveSprite(screen, NULL);
   9.450 -    if ((sprite->flags & SDL_HWACCEL) == SDL_HWACCEL) {
   9.451 -        printf("Sprite blit uses hardware alpha acceleration\n");
   9.452 -    } else {
   9.453 -        printf("Sprite blit dosn't uses hardware alpha acceleration\n");
   9.454 -    }
   9.455 -
   9.456 -    /* Set a clipping rectangle to clip the outside edge of the screen */
   9.457 -    {
   9.458 -        SDL_Rect clip;
   9.459 -        clip.x = 32;
   9.460 -        clip.y = 32;
   9.461 -        clip.w = screen->w - (2 * 32);
   9.462 -        clip.h = screen->h - (2 * 32);
   9.463 -        SDL_SetClipRect(screen, &clip);
   9.464 -    }
   9.465 -
   9.466 -    /* Wait for a keystroke */
   9.467 -    lastticks = SDL_GetTicks();
   9.468 -    done = 0;
   9.469 -    mouse_pressed = 0;
   9.470 -    while (!done) {
   9.471 -        /* Update the frame -- move the sprite */
   9.472 -        if (mouse_pressed) {
   9.473 -            MoveSprite(screen, light);
   9.474 -            mouse_pressed = 0;
   9.475 -        } else {
   9.476 -            MoveSprite(screen, NULL);
   9.477 -        }
   9.478 -
   9.479 -        /* Slow down the loop to 30 frames/second */
   9.480 -        ticks = SDL_GetTicks();
   9.481 -        if ((ticks - lastticks) < FRAME_TICKS) {
   9.482 -#ifdef CHECK_SLEEP_GRANULARITY
   9.483 -            fprintf(stderr, "Sleeping %d ticks\n",
   9.484 -                    FRAME_TICKS - (ticks - lastticks));
   9.485 -#endif
   9.486 -            SDL_Delay(FRAME_TICKS - (ticks - lastticks));
   9.487 -#ifdef CHECK_SLEEP_GRANULARITY
   9.488 -            fprintf(stderr, "Slept %d ticks\n", (SDL_GetTicks() - ticks));
   9.489 -#endif
   9.490 -        }
   9.491 -        lastticks = ticks;
   9.492 -
   9.493 -        /* Check for events */
   9.494 -        while (SDL_PollEvent(&event)) {
   9.495 -            switch (event.type) {
   9.496 -            case SDL_VIDEORESIZE:
   9.497 -                screen =
   9.498 -                    SDL_SetVideoMode(event.resize.w, event.resize.h,
   9.499 -                                     video_bpp, videoflags);
   9.500 -                if (screen) {
   9.501 -                    FillBackground(screen);
   9.502 -                }
   9.503 -                break;
   9.504 -                /* Attract sprite while mouse is held down */
   9.505 -            case SDL_MOUSEMOTION:
   9.506 -                if (event.motion.state != 0) {
   9.507 -                    AttractSprite(event.motion.x, event.motion.y);
   9.508 -                    mouse_pressed = 1;
   9.509 -                }
   9.510 -                break;
   9.511 -            case SDL_MOUSEBUTTONDOWN:
   9.512 -                if (event.button.button == 1) {
   9.513 -                    AttractSprite(event.button.x, event.button.y);
   9.514 -                    mouse_pressed = 1;
   9.515 -                } else {
   9.516 -                    SDL_Rect area;
   9.517 -
   9.518 -                    area.x = event.button.x - 16;
   9.519 -                    area.y = event.button.y - 16;
   9.520 -                    area.w = 32;
   9.521 -                    area.h = 32;
   9.522 -                    SDL_FillRect(screen, &area,
   9.523 -                                 SDL_MapRGB(screen->format, 0, 0, 0));
   9.524 -                    SDL_UpdateRects(screen, 1, &area);
   9.525 -                }
   9.526 -                break;
   9.527 -            case SDL_KEYDOWN:
   9.528 -                if (event.key.keysym.sym == SDLK_ESCAPE) {
   9.529 -                    done = 1;
   9.530 -                }
   9.531 -                if (event.key.keysym.sym == SDLK_RETURN) {
   9.532 -                    SDL_WM_ToggleFullScreen(screen);
   9.533 -                }
   9.534 -                break;
   9.535 -            case SDL_QUIT:
   9.536 -                done = 1;
   9.537 -                break;
   9.538 -            default:
   9.539 -                break;
   9.540 -            }
   9.541 -        }
   9.542 -    }
   9.543 -    SDL_FreeSurface(light);
   9.544 -    SDL_FreeSurface(sprite);
   9.545 -    SDL_FreeSurface(backing);
   9.546 -
   9.547 -    /* Print out some timing information */
   9.548 -    if (flashes > 0) {
   9.549 -        printf("%d alpha blits, ~%4.4f ms per blit\n",
   9.550 -               flashes, (float) flashtime / flashes);
   9.551 -    }
   9.552 -
   9.553 -    SDL_Quit();
   9.554 -    return (0);
   9.555 -}
    10.1 --- a/test/testbitmap.c	Sun Jan 22 17:50:35 2012 -0500
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,203 +0,0 @@
    10.4 -/*
    10.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    10.6 -
    10.7 -  This software is provided 'as-is', without any express or implied
    10.8 -  warranty.  In no event will the authors be held liable for any damages
    10.9 -  arising from the use of this software.
   10.10 -
   10.11 -  Permission is granted to anyone to use this software for any purpose,
   10.12 -  including commercial applications, and to alter it and redistribute it
   10.13 -  freely.
   10.14 -*/
   10.15 -
   10.16 -/* Simple program:  Test bitmap blits */
   10.17 -
   10.18 -#include <stdio.h>
   10.19 -#include <stdlib.h>
   10.20 -#include <string.h>
   10.21 -
   10.22 -#include "SDL.h"
   10.23 -#include "picture.xbm"
   10.24 -
   10.25 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   10.26 -static void
   10.27 -quit(int rc)
   10.28 -{
   10.29 -    SDL_Quit();
   10.30 -    exit(rc);
   10.31 -}
   10.32 -
   10.33 -SDL_Surface *
   10.34 -LoadXBM(SDL_Surface * screen, int w, int h, Uint8 * bits)
   10.35 -{
   10.36 -    SDL_Surface *bitmap;
   10.37 -    Uint8 *line;
   10.38 -
   10.39 -    /* Allocate the bitmap */
   10.40 -    bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 1, 0, 0, 0, 0);
   10.41 -    if (bitmap == NULL) {
   10.42 -        fprintf(stderr, "Couldn't allocate bitmap: %s\n", SDL_GetError());
   10.43 -        return (NULL);
   10.44 -    }
   10.45 -
   10.46 -    /* Copy the pixels */
   10.47 -    line = (Uint8 *) bitmap->pixels;
   10.48 -    w = (w + 7) / 8;
   10.49 -    while (h--) {
   10.50 -        memcpy(line, bits, w);
   10.51 -        /* X11 Bitmap images have the bits reversed */
   10.52 -        {
   10.53 -            int i, j;
   10.54 -            Uint8 *buf, byte;
   10.55 -            for (buf = line, i = 0; i < w; ++i, ++buf) {
   10.56 -                byte = *buf;
   10.57 -                *buf = 0;
   10.58 -                for (j = 7; j >= 0; --j) {
   10.59 -                    *buf |= (byte & 0x01) << j;
   10.60 -                    byte >>= 1;
   10.61 -                }
   10.62 -            }
   10.63 -        }
   10.64 -        line += bitmap->pitch;
   10.65 -        bits += w;
   10.66 -    }
   10.67 -    return (bitmap);
   10.68 -}
   10.69 -
   10.70 -int
   10.71 -main(int argc, char *argv[])
   10.72 -{
   10.73 -    SDL_Surface *screen;
   10.74 -    SDL_Surface *bitmap;
   10.75 -    Uint8 video_bpp;
   10.76 -    Uint32 videoflags;
   10.77 -    Uint8 *buffer;
   10.78 -    int i, k, done;
   10.79 -    SDL_Event event;
   10.80 -    Uint16 *buffer16;
   10.81 -    Uint16 color;
   10.82 -    Uint8 gradient;
   10.83 -    SDL_Color palette[256];
   10.84 -
   10.85 -    int video_w, video_h;
   10.86 -
   10.87 -    /* Initialize SDL */
   10.88 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   10.89 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   10.90 -        return (1);
   10.91 -    }
   10.92 -
   10.93 -    video_bpp = 0;
   10.94 -    videoflags = SDL_SWSURFACE;
   10.95 -    while (argc > 1) {
   10.96 -        --argc;
   10.97 -        if (strcmp(argv[argc - 1], "-bpp") == 0) {
   10.98 -            video_bpp = atoi(argv[argc]);
   10.99 -            --argc;
  10.100 -        } else if (strcmp(argv[argc], "-warp") == 0) {
  10.101 -            videoflags |= SDL_HWPALETTE;
  10.102 -        } else if (strcmp(argv[argc], "-hw") == 0) {
  10.103 -            videoflags |= SDL_HWSURFACE;
  10.104 -        } else if (strcmp(argv[argc], "-fullscreen") == 0) {
  10.105 -            videoflags |= SDL_FULLSCREEN;
  10.106 -        } else {
  10.107 -            fprintf(stderr,
  10.108 -                    "Usage: %s [-bpp N] [-warp] [-hw] [-fullscreen]\n",
  10.109 -                    argv[0]);
  10.110 -            quit(1);
  10.111 -        }
  10.112 -    }
  10.113 -
  10.114 -#ifdef __IPHONEOS__
  10.115 -    video_w = 320;
  10.116 -    video_h = 480;
  10.117 -#else
  10.118 -    video_w = 640;
  10.119 -    video_h = 480;
  10.120 -#endif
  10.121 -
  10.122 -    /* Set 640x480 video mode */
  10.123 -    if ((screen =
  10.124 -         SDL_SetVideoMode(video_w, video_h, video_bpp, videoflags)) == NULL) {
  10.125 -        fprintf(stderr, "Couldn't set %dx%d %d video mode: %s\n", video_w,
  10.126 -                video_h, video_bpp, SDL_GetError());
  10.127 -        quit(2);
  10.128 -    }
  10.129 -
  10.130 -    if (video_bpp == 8) {
  10.131 -        /* Set a gray colormap, reverse order from white to black */
  10.132 -        for (i = 0; i < 256; ++i) {
  10.133 -            palette[i].r = 255 - i;
  10.134 -            palette[i].g = 255 - i;
  10.135 -            palette[i].b = 255 - i;
  10.136 -        }
  10.137 -        SDL_SetColors(screen, palette, 0, 256);
  10.138 -    }
  10.139 -
  10.140 -    /* Set the surface pixels and refresh! */
  10.141 -    if (SDL_LockSurface(screen) < 0) {
  10.142 -        fprintf(stderr, "Couldn't lock the display surface: %s\n",
  10.143 -                SDL_GetError());
  10.144 -        quit(2);
  10.145 -    }
  10.146 -    buffer = (Uint8 *) screen->pixels;
  10.147 -    if (screen->format->BytesPerPixel != 2) {
  10.148 -        for (i = 0; i < screen->h; ++i) {
  10.149 -            memset(buffer, (i * 255) / screen->h, screen->pitch);
  10.150 -            buffer += screen->pitch;
  10.151 -        }
  10.152 -    } else {
  10.153 -        for (i = 0; i < screen->h; ++i) {
  10.154 -            gradient = ((i * 255) / screen->h);
  10.155 -            color = SDL_MapRGB(screen->format, gradient, gradient, gradient);
  10.156 -            buffer16 = (Uint16 *) buffer;
  10.157 -            for (k = 0; k < screen->w; k++) {
  10.158 -                *(buffer16 + k) = color;
  10.159 -            }
  10.160 -            buffer += screen->pitch;
  10.161 -        }
  10.162 -    }
  10.163 -    SDL_UnlockSurface(screen);
  10.164 -    SDL_UpdateRect(screen, 0, 0, 0, 0);
  10.165 -
  10.166 -    /* Load the bitmap */
  10.167 -    bitmap = LoadXBM(screen, picture_width, picture_height,
  10.168 -                     (Uint8 *) picture_bits);
  10.169 -    if (bitmap == NULL) {
  10.170 -        quit(1);
  10.171 -    }
  10.172 -
  10.173 -    /* Wait for a keystroke */
  10.174 -    done = 0;
  10.175 -    while (!done) {
  10.176 -        /* Check for events */
  10.177 -        while (SDL_PollEvent(&event)) {
  10.178 -            switch (event.type) {
  10.179 -            case SDL_MOUSEBUTTONDOWN:
  10.180 -                {
  10.181 -                    SDL_Rect dst;
  10.182 -
  10.183 -                    dst.x = event.button.x - bitmap->w / 2;
  10.184 -                    dst.y = event.button.y - bitmap->h / 2;
  10.185 -                    dst.w = bitmap->w;
  10.186 -                    dst.h = bitmap->h;
  10.187 -                    SDL_BlitSurface(bitmap, NULL, screen, &dst);
  10.188 -                    SDL_UpdateRects(screen, 1, &dst);
  10.189 -                }
  10.190 -                break;
  10.191 -            case SDL_KEYDOWN:
  10.192 -                /* Any key press quits the app... */
  10.193 -                done = 1;
  10.194 -                break;
  10.195 -            case SDL_QUIT:
  10.196 -                done = 1;
  10.197 -                break;
  10.198 -            default:
  10.199 -                break;
  10.200 -            }
  10.201 -        }
  10.202 -    }
  10.203 -    SDL_FreeSurface(bitmap);
  10.204 -    SDL_Quit();
  10.205 -    return (0);
  10.206 -}
    11.1 --- a/test/testblitspeed.c	Sun Jan 22 17:50:35 2012 -0500
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,433 +0,0 @@
    11.4 -/*
    11.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    11.6 -
    11.7 -  This software is provided 'as-is', without any express or implied
    11.8 -  warranty.  In no event will the authors be held liable for any damages
    11.9 -  arising from the use of this software.
   11.10 -
   11.11 -  Permission is granted to anyone to use this software for any purpose,
   11.12 -  including commercial applications, and to alter it and redistribute it
   11.13 -  freely.
   11.14 -*/
   11.15 -/*
   11.16 - * Benchmarks surface-to-surface blits in various formats.
   11.17 - *
   11.18 - *  Written by Ryan C. Gordon.
   11.19 - */
   11.20 -
   11.21 -#include <stdio.h>
   11.22 -#include <stdlib.h>
   11.23 -#include <string.h>
   11.24 -
   11.25 -#include "SDL.h"
   11.26 -
   11.27 -static SDL_Surface *dest = NULL;
   11.28 -static SDL_Surface *src = NULL;
   11.29 -static int testSeconds = 10;
   11.30 -
   11.31 -
   11.32 -static int
   11.33 -percent(int val, int total)
   11.34 -{
   11.35 -    return ((int) ((((float) val) / ((float) total)) * 100.0f));
   11.36 -}
   11.37 -
   11.38 -static int
   11.39 -randRange(int lo, int hi)
   11.40 -{
   11.41 -    return (lo + (int) (((double) hi) * rand() / (RAND_MAX + 1.0)));
   11.42 -}
   11.43 -
   11.44 -static void
   11.45 -copy_trunc_str(char *str, size_t strsize, const char *flagstr)
   11.46 -{
   11.47 -    if ((strlen(str) + strlen(flagstr)) >= (strsize - 1))
   11.48 -        strcpy(str + (strsize - 5), " ...");
   11.49 -    else
   11.50 -        strcat(str, flagstr);
   11.51 -}
   11.52 -
   11.53 -static void
   11.54 -__append_sdl_surface_flag(SDL_Surface * _surface, char *str,
   11.55 -                          size_t strsize, Uint32 flag, const char *flagstr)
   11.56 -{
   11.57 -    if (_surface->flags & flag)
   11.58 -        copy_trunc_str(str, strsize, flagstr);
   11.59 -}
   11.60 -
   11.61 -
   11.62 -#define append_sdl_surface_flag(a, b, c, fl) __append_sdl_surface_flag(a, b, c, fl, " " #fl)
   11.63 -#define print_tf_state(str, val) printf("%s: {%s}\n", str, (val) ? "true" : "false" )
   11.64 -
   11.65 -static void
   11.66 -output_videoinfo_details(void)
   11.67 -{
   11.68 -    const SDL_VideoInfo *info = SDL_GetVideoInfo();
   11.69 -    printf("SDL_GetVideoInfo():\n");
   11.70 -    if (info == NULL)
   11.71 -        printf("  (null.)\n");
   11.72 -    else {
   11.73 -        print_tf_state("  hardware surface available", info->hw_available);
   11.74 -        print_tf_state("  window manager available", info->wm_available);
   11.75 -        print_tf_state("  accelerated hardware->hardware blits",
   11.76 -                       info->blit_hw);
   11.77 -        print_tf_state("  accelerated hardware->hardware colorkey blits",
   11.78 -                       info->blit_hw_CC);
   11.79 -        print_tf_state("  accelerated hardware->hardware alpha blits",
   11.80 -                       info->blit_hw_A);
   11.81 -        print_tf_state("  accelerated software->hardware blits",
   11.82 -                       info->blit_sw);
   11.83 -        print_tf_state("  accelerated software->hardware colorkey blits",
   11.84 -                       info->blit_sw_CC);
   11.85 -        print_tf_state("  accelerated software->hardware alpha blits",
   11.86 -                       info->blit_sw_A);
   11.87 -        print_tf_state("  accelerated color fills", info->blit_fill);
   11.88 -        printf("  video memory: (%d)\n", info->video_mem);
   11.89 -    }
   11.90 -
   11.91 -    printf("\n");
   11.92 -}
   11.93 -
   11.94 -static void
   11.95 -output_surface_details(const char *name, SDL_Surface * surface)
   11.96 -{
   11.97 -    printf("Details for %s:\n", name);
   11.98 -
   11.99 -    if (surface == NULL) {
  11.100 -        printf("-WARNING- You've got a NULL surface!");
  11.101 -    } else {
  11.102 -        char f[256];
  11.103 -        printf("  width      : %d\n", surface->w);
  11.104 -        printf("  height     : %d\n", surface->h);
  11.105 -        printf("  depth      : %d bits per pixel\n",
  11.106 -               surface->format->BitsPerPixel);
  11.107 -        printf("  pitch      : %d\n", (int) surface->pitch);
  11.108 -
  11.109 -        printf("  red bits   : 0x%08X mask, %d shift, %d loss\n",
  11.110 -               (int) surface->format->Rmask,
  11.111 -               (int) surface->format->Rshift, (int) surface->format->Rloss);
  11.112 -        printf("  green bits : 0x%08X mask, %d shift, %d loss\n",
  11.113 -               (int) surface->format->Gmask,
  11.114 -               (int) surface->format->Gshift, (int) surface->format->Gloss);
  11.115 -        printf("  blue bits  : 0x%08X mask, %d shift, %d loss\n",
  11.116 -               (int) surface->format->Bmask,
  11.117 -               (int) surface->format->Bshift, (int) surface->format->Bloss);
  11.118 -        printf("  alpha bits : 0x%08X mask, %d shift, %d loss\n",
  11.119 -               (int) surface->format->Amask,
  11.120 -               (int) surface->format->Ashift, (int) surface->format->Aloss);
  11.121 -
  11.122 -        f[0] = '\0';
  11.123 -
  11.124 -        /*append_sdl_surface_flag(surface, f, sizeof (f), SDL_SWSURFACE); */
  11.125 -        if ((surface->flags & SDL_HWSURFACE) == 0)
  11.126 -            copy_trunc_str(f, sizeof(f), " SDL_SWSURFACE");
  11.127 -
  11.128 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_HWSURFACE);
  11.129 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_ASYNCBLIT);
  11.130 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_ANYFORMAT);
  11.131 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_HWPALETTE);
  11.132 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_DOUBLEBUF);
  11.133 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_FULLSCREEN);
  11.134 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_OPENGL);
  11.135 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_RESIZABLE);
  11.136 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_NOFRAME);
  11.137 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_HWACCEL);
  11.138 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_SRCCOLORKEY);
  11.139 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_RLEACCELOK);
  11.140 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_RLEACCEL);
  11.141 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_SRCALPHA);
  11.142 -        append_sdl_surface_flag(surface, f, sizeof(f), SDL_PREALLOC);
  11.143 -
  11.144 -        if (f[0] == '\0')
  11.145 -            strcpy(f, " (none)");
  11.146 -
  11.147 -        printf("  flags      :%s\n", f);
  11.148 -    }
  11.149 -
  11.150 -    printf("\n");
  11.151 -}
  11.152 -
  11.153 -static void
  11.154 -output_details(void)
  11.155 -{
  11.156 -    output_videoinfo_details();
  11.157 -    output_surface_details("Source Surface", src);
  11.158 -    output_surface_details("Destination Surface", dest);
  11.159 -}
  11.160 -
  11.161 -static Uint32
  11.162 -blit(SDL_Surface * dst, SDL_Surface * src, int x, int y)
  11.163 -{
  11.164 -    Uint32 start = 0;
  11.165 -    SDL_Rect srcRect;
  11.166 -    SDL_Rect dstRect;
  11.167 -
  11.168 -    srcRect.x = 0;
  11.169 -    srcRect.y = 0;
  11.170 -    dstRect.x = x;
  11.171 -    dstRect.y = y;
  11.172 -    dstRect.w = srcRect.w = src->w;     /* SDL will clip as appropriate. */
  11.173 -    dstRect.h = srcRect.h = src->h;
  11.174 -
  11.175 -    start = SDL_GetTicks();
  11.176 -    SDL_BlitSurface(src, &srcRect, dst, &dstRect);
  11.177 -    return (SDL_GetTicks() - start);
  11.178 -}
  11.179 -
  11.180 -static void
  11.181 -blitCentered(SDL_Surface * dst, SDL_Surface * src)
  11.182 -{
  11.183 -    int x = (dst->w - src->w) / 2;
  11.184 -    int y = (dst->h - src->h) / 2;
  11.185 -    blit(dst, src, x, y);
  11.186 -}
  11.187 -
  11.188 -static int
  11.189 -atoi_hex(const char *str)
  11.190 -{
  11.191 -    if (str == NULL)
  11.192 -        return 0;
  11.193 -
  11.194 -    if (strlen(str) > 2) {
  11.195 -        int retval = 0;
  11.196 -        if ((str[0] == '0') && (str[1] == 'x'))
  11.197 -            sscanf(str + 2, "%X", &retval);
  11.198 -        return (retval);
  11.199 -    }
  11.200 -
  11.201 -    return (atoi(str));
  11.202 -}
  11.203 -
  11.204 -
  11.205 -static int
  11.206 -setup_test(int argc, char **argv)
  11.207 -{
  11.208 -    const char *dumpfile = NULL;
  11.209 -    SDL_Surface *bmp = NULL;
  11.210 -    Uint32 dstbpp = 32;
  11.211 -    Uint32 dstrmask = 0x00FF0000;
  11.212 -    Uint32 dstgmask = 0x0000FF00;
  11.213 -    Uint32 dstbmask = 0x000000FF;
  11.214 -    Uint32 dstamask = 0x00000000;
  11.215 -    Uint32 dstflags = 0;
  11.216 -    int dstw = 640;
  11.217 -    int dsth = 480;
  11.218 -    Uint32 srcbpp = 32;
  11.219 -    Uint32 srcrmask = 0x00FF0000;
  11.220 -    Uint32 srcgmask = 0x0000FF00;
  11.221 -    Uint32 srcbmask = 0x000000FF;
  11.222 -    Uint32 srcamask = 0x00000000;
  11.223 -    Uint32 srcflags = 0;
  11.224 -    int srcw = 640;
  11.225 -    int srch = 480;
  11.226 -    Uint32 origsrcalphaflags = 0;
  11.227 -    Uint32 origdstalphaflags = 0;
  11.228 -    Uint32 srcalphaflags = 0;
  11.229 -    Uint32 dstalphaflags = 0;
  11.230 -    Uint8 origsrcalpha = 255;
  11.231 -    Uint8 origdstalpha = 255;
  11.232 -    Uint8 srcalpha = 255;
  11.233 -    Uint8 dstalpha = 255;
  11.234 -    int screenSurface = 0;
  11.235 -    int i = 0;
  11.236 -
  11.237 -    for (i = 1; i < argc; i++) {
  11.238 -        const char *arg = argv[i];
  11.239 -
  11.240 -        if (strcmp(arg, "--dstbpp") == 0)
  11.241 -            dstbpp = atoi(argv[++i]);
  11.242 -        else if (strcmp(arg, "--dstrmask") == 0)
  11.243 -            dstrmask = atoi_hex(argv[++i]);
  11.244 -        else if (strcmp(arg, "--dstgmask") == 0)
  11.245 -            dstgmask = atoi_hex(argv[++i]);
  11.246 -        else if (strcmp(arg, "--dstbmask") == 0)
  11.247 -            dstbmask = atoi_hex(argv[++i]);
  11.248 -        else if (strcmp(arg, "--dstamask") == 0)
  11.249 -            dstamask = atoi_hex(argv[++i]);
  11.250 -        else if (strcmp(arg, "--dstwidth") == 0)
  11.251 -            dstw = atoi(argv[++i]);
  11.252 -        else if (strcmp(arg, "--dstheight") == 0)
  11.253 -            dsth = atoi(argv[++i]);
  11.254 -        else if (strcmp(arg, "--dsthwsurface") == 0)
  11.255 -            dstflags |= SDL_HWSURFACE;
  11.256 -        else if (strcmp(arg, "--srcbpp") == 0)
  11.257 -            srcbpp = atoi(argv[++i]);
  11.258 -        else if (strcmp(arg, "--srcrmask") == 0)
  11.259 -            srcrmask = atoi_hex(argv[++i]);
  11.260 -        else if (strcmp(arg, "--srcgmask") == 0)
  11.261 -            srcgmask = atoi_hex(argv[++i]);
  11.262 -        else if (strcmp(arg, "--srcbmask") == 0)
  11.263 -            srcbmask = atoi_hex(argv[++i]);
  11.264 -        else if (strcmp(arg, "--srcamask") == 0)
  11.265 -            srcamask = atoi_hex(argv[++i]);
  11.266 -        else if (strcmp(arg, "--srcwidth") == 0)
  11.267 -            srcw = atoi(argv[++i]);
  11.268 -        else if (strcmp(arg, "--srcheight") == 0)
  11.269 -            srch = atoi(argv[++i]);
  11.270 -        else if (strcmp(arg, "--srchwsurface") == 0)
  11.271 -            srcflags |= SDL_HWSURFACE;
  11.272 -        else if (strcmp(arg, "--seconds") == 0)
  11.273 -            testSeconds = atoi(argv[++i]);
  11.274 -        else if (strcmp(arg, "--screen") == 0)
  11.275 -            screenSurface = 1;
  11.276 -        else if (strcmp(arg, "--dumpfile") == 0)
  11.277 -            dumpfile = argv[++i];
  11.278 -        /* !!! FIXME: set colorkey. */
  11.279 -        else if (0) {           /* !!! FIXME: we handle some commandlines elsewhere now */
  11.280 -            fprintf(stderr, "Unknown commandline option: %s\n", arg);
  11.281 -            return (0);
  11.282 -        }
  11.283 -    }
  11.284 -
  11.285 -    if (SDL_Init(SDL_INIT_VIDEO) == -1) {
  11.286 -        fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
  11.287 -        return (0);
  11.288 -    }
  11.289 -
  11.290 -    bmp = SDL_LoadBMP("sample.bmp");
  11.291 -    if (bmp == NULL) {
  11.292 -        fprintf(stderr, "SDL_LoadBMP failed: %s\n", SDL_GetError());
  11.293 -        SDL_Quit();
  11.294 -        return (0);
  11.295 -    }
  11.296 -
  11.297 -    if ((dstflags & SDL_HWSURFACE) == 0)
  11.298 -        dstflags |= SDL_SWSURFACE;
  11.299 -    if ((srcflags & SDL_HWSURFACE) == 0)
  11.300 -        srcflags |= SDL_SWSURFACE;
  11.301 -
  11.302 -    if (screenSurface)
  11.303 -        dest = SDL_SetVideoMode(dstw, dsth, dstbpp, dstflags);
  11.304 -    else {
  11.305 -        dest = SDL_CreateRGBSurface(dstflags, dstw, dsth, dstbpp,
  11.306 -                                    dstrmask, dstgmask, dstbmask, dstamask);
  11.307 -    }
  11.308 -
  11.309 -    if (dest == NULL) {
  11.310 -        fprintf(stderr, "dest surface creation failed: %s\n", SDL_GetError());
  11.311 -        SDL_Quit();
  11.312 -        return (0);
  11.313 -    }
  11.314 -
  11.315 -    src = SDL_CreateRGBSurface(srcflags, srcw, srch, srcbpp,
  11.316 -                               srcrmask, srcgmask, srcbmask, srcamask);
  11.317 -    if (src == NULL) {
  11.318 -        fprintf(stderr, "src surface creation failed: %s\n", SDL_GetError());
  11.319 -        SDL_Quit();
  11.320 -        return (0);
  11.321 -    }
  11.322 -
  11.323 -    /* handle alpha settings... */
  11.324 -    srcalphaflags = (src->flags & SDL_SRCALPHA) | (src->flags & SDL_RLEACCEL);
  11.325 -    dstalphaflags =
  11.326 -        (dest->flags & SDL_SRCALPHA) | (dest->flags & SDL_RLEACCEL);
  11.327 -    origsrcalphaflags = srcalphaflags;
  11.328 -    origdstalphaflags = dstalphaflags;
  11.329 -    SDL_GetSurfaceAlphaMod(src, &srcalpha);
  11.330 -    SDL_GetSurfaceAlphaMod(dest, &dstalpha);
  11.331 -    origsrcalpha = srcalpha;
  11.332 -    origdstalpha = dstalpha;
  11.333 -    for (i = 1; i < argc; i++) {
  11.334 -        const char *arg = argv[i];
  11.335 -
  11.336 -        if (strcmp(arg, "--srcalpha") == 0)
  11.337 -            srcalpha = atoi(argv[++i]);
  11.338 -        else if (strcmp(arg, "--dstalpha") == 0)
  11.339 -            dstalpha = atoi(argv[++i]);
  11.340 -        else if (strcmp(arg, "--srcsrcalpha") == 0)
  11.341 -            srcalphaflags |= SDL_SRCALPHA;
  11.342 -        else if (strcmp(arg, "--srcnosrcalpha") == 0)
  11.343 -            srcalphaflags &= ~SDL_SRCALPHA;
  11.344 -        else if (strcmp(arg, "--srcrleaccel") == 0)
  11.345 -            srcalphaflags |= SDL_RLEACCEL;
  11.346 -        else if (strcmp(arg, "--srcnorleaccel") == 0)
  11.347 -            srcalphaflags &= ~SDL_RLEACCEL;
  11.348 -        else if (strcmp(arg, "--dstsrcalpha") == 0)
  11.349 -            dstalphaflags |= SDL_SRCALPHA;
  11.350 -        else if (strcmp(arg, "--dstnosrcalpha") == 0)
  11.351 -            dstalphaflags &= ~SDL_SRCALPHA;
  11.352 -        else if (strcmp(arg, "--dstrleaccel") == 0)
  11.353 -            dstalphaflags |= SDL_RLEACCEL;
  11.354 -        else if (strcmp(arg, "--dstnorleaccel") == 0)
  11.355 -            dstalphaflags &= ~SDL_RLEACCEL;
  11.356 -    }
  11.357 -    if ((dstalphaflags != origdstalphaflags) || (origdstalpha != dstalpha))
  11.358 -        SDL_SetAlpha(dest, dstalphaflags, dstalpha);
  11.359 -    if ((srcalphaflags != origsrcalphaflags) || (origsrcalpha != srcalpha))
  11.360 -        SDL_SetAlpha(src, srcalphaflags, srcalpha);
  11.361 -
  11.362 -    /* set some sane defaults so we can see if the blit code is broken... */
  11.363 -    SDL_FillRect(dest, NULL, SDL_MapRGB(dest->format, 0, 0, 0));
  11.364 -    SDL_FillRect(src, NULL, SDL_MapRGB(src->format, 0, 0, 0));
  11.365 -
  11.366 -    blitCentered(src, bmp);
  11.367 -    SDL_FreeSurface(bmp);
  11.368 -
  11.369 -    if (dumpfile)
  11.370 -        SDL_SaveBMP(src, dumpfile);     /* make sure initial convert is sane. */
  11.371 -
  11.372 -    output_details();
  11.373 -
  11.374 -    return (1);
  11.375 -}
  11.376 -
  11.377 -
  11.378 -static void
  11.379 -test_blit_speed(void)
  11.380 -{
  11.381 -    Uint32 clearColor = SDL_MapRGB(dest->format, 0, 0, 0);
  11.382 -    Uint32 iterations = 0;
  11.383 -    Uint32 elasped = 0;
  11.384 -    Uint32 end = 0;
  11.385 -    Uint32 now = 0;
  11.386 -    Uint32 last = 0;
  11.387 -    int testms = testSeconds * 1000;
  11.388 -    int wmax = (dest->w - src->w);
  11.389 -    int hmax = (dest->h - src->h);
  11.390 -    int isScreen = (SDL_GetVideoSurface() == dest);
  11.391 -    SDL_Event event;
  11.392 -
  11.393 -    printf("Testing blit speed for %d seconds...\n", testSeconds);
  11.394 -
  11.395 -    now = SDL_GetTicks();
  11.396 -    end = now + testms;
  11.397 -
  11.398 -    do {
  11.399 -        /* pump the event queue occasionally to keep OS happy... */
  11.400 -        if (now - last > 1000) {
  11.401 -            last = now;
  11.402 -            while (SDL_PollEvent(&event)) {     /* no-op. */
  11.403 -            }
  11.404 -        }
  11.405 -
  11.406 -        iterations++;
  11.407 -        elasped += blit(dest, src, randRange(0, wmax), randRange(0, hmax));
  11.408 -        if (isScreen) {
  11.409 -            SDL_Flip(dest);     /* show it! */
  11.410 -            SDL_FillRect(dest, NULL, clearColor);       /* blank it for next time! */
  11.411 -        }
  11.412 -
  11.413 -        now = SDL_GetTicks();
  11.414 -    } while (now < end);
  11.415 -
  11.416 -    printf("Non-blitting crap accounted for %d percent of this run.\n",
  11.417 -           percent(testms - elasped, testms));
  11.418 -
  11.419 -    printf("%d blits took %d ms (%d fps).\n",
  11.420 -           (int) iterations,
  11.421 -           (int) elasped,
  11.422 -           (int) (((float) iterations) / (((float) elasped) / 1000.0f)));
  11.423 -}
  11.424 -
  11.425 -int
  11.426 -main(int argc, char **argv)
  11.427 -{
  11.428 -    int initialized = setup_test(argc, argv);
  11.429 -    if (initialized) {
  11.430 -        test_blit_speed();
  11.431 -        SDL_Quit();
  11.432 -    }
  11.433 -    return (!initialized);
  11.434 -}
  11.435 -
  11.436 -/* end of testblitspeed.c ... */
    12.1 --- a/test/testcursor.c	Sun Jan 22 17:50:35 2012 -0500
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,260 +0,0 @@
    12.4 -/*
    12.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    12.6 -
    12.7 -  This software is provided 'as-is', without any express or implied
    12.8 -  warranty.  In no event will the authors be held liable for any damages
    12.9 -  arising from the use of this software.
   12.10 -
   12.11 -  Permission is granted to anyone to use this software for any purpose,
   12.12 -  including commercial applications, and to alter it and redistribute it
   12.13 -  freely.
   12.14 -*/
   12.15 -#include <stdio.h>
   12.16 -#include <stdlib.h>
   12.17 -
   12.18 -#include "SDL.h"
   12.19 -
   12.20 -/* This is an example 16x16 cursor
   12.21 -	top left :	black
   12.22 -	top right : inverted color or black
   12.23 -	bottom left: white
   12.24 -	bottom right: transparent
   12.25 -	(swap left and right for different endianness)
   12.26 -*/
   12.27 -
   12.28 -Uint16 cursor_data[16] = {
   12.29 -    0xffff,
   12.30 -    0xffff,
   12.31 -    0xffff,
   12.32 -    0xffff,
   12.33 -
   12.34 -    0xffff,
   12.35 -    0xffff,
   12.36 -    0xffff,
   12.37 -    0xffff,
   12.38 -
   12.39 -    0x0000,
   12.40 -    0x0000,
   12.41 -    0x0000,
   12.42 -    0x0000,
   12.43 -
   12.44 -    0x0000,
   12.45 -    0x0000,
   12.46 -    0x0000,
   12.47 -    0x0000
   12.48 -};
   12.49 -
   12.50 -Uint16 cursor_mask[16] = {
   12.51 -    0xff00,
   12.52 -    0xff00,
   12.53 -    0xff00,
   12.54 -    0xff00,
   12.55 -
   12.56 -    0xff00,
   12.57 -    0xff00,
   12.58 -    0xff00,
   12.59 -    0xff00,
   12.60 -
   12.61 -    0xff00,
   12.62 -    0xff00,
   12.63 -    0xff00,
   12.64 -    0xff00,
   12.65 -
   12.66 -    0xff00,
   12.67 -    0xff00,
   12.68 -    0xff00,
   12.69 -    0xff00
   12.70 -};
   12.71 -
   12.72 -/* another test cursor: smaller than 16x16, and with an odd height */
   12.73 -
   12.74 -Uint8 small_cursor_data[11] =
   12.75 -    { 0x00, 0x18, 0x08, 0x38, 0x44, 0x54, 0x44, 0x38, 0x20, 0x20, 0x00 };
   12.76 -Uint8 small_cursor_mask[11] =
   12.77 -    { 0x3C, 0x3C, 0x3C, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x78, 0x70, 0x70 };
   12.78 -
   12.79 -/* XPM */
   12.80 -static const char *arrow[] = {
   12.81 -    /* width height num_colors chars_per_pixel */
   12.82 -    "    32    32        3            1",
   12.83 -    /* colors */
   12.84 -    "X c #000000",
   12.85 -    ". c #ffffff",
   12.86 -    "  c None",
   12.87 -    /* pixels */
   12.88 -    "X                               ",
   12.89 -    "XX                              ",
   12.90 -    "X.X                             ",
   12.91 -    "X..X                            ",
   12.92 -    "X...X                           ",
   12.93 -    "X....X                          ",
   12.94 -    "X.....X                         ",
   12.95 -    "X......X                        ",
   12.96 -    "X.......X                       ",
   12.97 -    "X........X                      ",
   12.98 -    "X.....XXXXX                     ",
   12.99 -    "X..X..X                         ",
  12.100 -    "X.X X..X                        ",
  12.101 -    "XX  X..X                        ",
  12.102 -    "X    X..X                       ",
  12.103 -    "     X..X                       ",
  12.104 -    "      X..X                      ",
  12.105 -    "      X..X                      ",
  12.106 -    "       XX                       ",
  12.107 -    "                                ",
  12.108 -    "                                ",
  12.109 -    "                                ",
  12.110 -    "                                ",
  12.111 -    "                                ",
  12.112 -    "                                ",
  12.113 -    "                                ",
  12.114 -    "                                ",
  12.115 -    "                                ",
  12.116 -    "                                ",
  12.117 -    "                                ",
  12.118 -    "                                ",
  12.119 -    "                                ",
  12.120 -    "0,0"
  12.121 -};
  12.122 -
  12.123 -static SDL_Cursor *
  12.124 -create_arrow_cursor()
  12.125 -{
  12.126 -    int i, row, col;
  12.127 -    Uint8 data[4 * 32];
  12.128 -    Uint8 mask[4 * 32];
  12.129 -    int hot_x, hot_y;
  12.130 -
  12.131 -    i = -1;
  12.132 -    for (row = 0; row < 32; ++row) {
  12.133 -        for (col = 0; col < 32; ++col) {
  12.134 -            if (col % 8) {
  12.135 -                data[i] <<= 1;
  12.136 -                mask[i] <<= 1;
  12.137 -            } else {
  12.138 -                ++i;
  12.139 -                data[i] = mask[i] = 0;
  12.140 -            }
  12.141 -            switch (arrow[4 + row][col]) {
  12.142 -            case 'X':
  12.143 -                data[i] |= 0x01;
  12.144 -                mask[i] |= 0x01;
  12.145 -                break;
  12.146 -            case '.':
  12.147 -                mask[i] |= 0x01;
  12.148 -                break;
  12.149 -            case ' ':
  12.150 -                break;
  12.151 -            }
  12.152 -        }
  12.153 -    }
  12.154 -    SDL_sscanf(arrow[4 + row], "%d,%d", &hot_x, &hot_y);
  12.155 -    return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
  12.156 -}
  12.157 -
  12.158 -SDL_Surface *
  12.159 -LoadSprite(char *file)
  12.160 -{
  12.161 -    SDL_Surface *sprite;
  12.162 -
  12.163 -    /* Load the sprite image */
  12.164 -    sprite = SDL_LoadBMP(file);
  12.165 -    if (sprite == NULL) {
  12.166 -        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
  12.167 -        return NULL;
  12.168 -    }
  12.169 -
  12.170 -    /* Set transparent pixel as the pixel at (0,0) */
  12.171 -    if (sprite->format->palette) {
  12.172 -        SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY | SDL_RLEACCEL),
  12.173 -                        *(Uint8 *) sprite->pixels);
  12.174 -    }
  12.175 -
  12.176 -    /* We're ready to roll. :) */
  12.177 -    return sprite;
  12.178 -}
  12.179 -
  12.180 -int
  12.181 -main(int argc, char *argv[])
  12.182 -{
  12.183 -    SDL_Surface *screen;
  12.184 -    SDL_bool quit = SDL_FALSE, first_time = SDL_TRUE;
  12.185 -    SDL_Cursor *cursor[5];
  12.186 -    int current;
  12.187 -
  12.188 -    /* Load the SDL library */
  12.189 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  12.190 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
  12.191 -        return (1);
  12.192 -    }
  12.193 -
  12.194 -    screen = SDL_SetVideoMode(640, 480, 8, SDL_ANYFORMAT);
  12.195 -    if (screen == NULL) {
  12.196 -        fprintf(stderr, "Couldn't initialize video mode: %s\n",
  12.197 -                SDL_GetError());
  12.198 -        return (1);
  12.199 -    }
  12.200 -
  12.201 -    SDL_FillRect(screen, NULL, 0x664422);
  12.202 -
  12.203 -    cursor[0] = SDL_CreateCursor((Uint8 *) cursor_data, (Uint8 *) cursor_mask,
  12.204 -                                 16, 16, 8, 8);
  12.205 -    if (cursor[0] == NULL) {
  12.206 -        fprintf(stderr, "Couldn't initialize test cursor: %s\n",
  12.207 -                SDL_GetError());
  12.208 -        SDL_Quit();
  12.209 -        return (1);
  12.210 -    }
  12.211 -    cursor[1] = create_arrow_cursor();
  12.212 -    if (cursor[1] == NULL) {
  12.213 -        fprintf(stderr, "Couldn't initialize arrow cursor: %s\n",
  12.214 -                SDL_GetError());
  12.215 -        SDL_FreeCursor(cursor[0]);
  12.216 -        SDL_Quit();
  12.217 -        return (1);
  12.218 -    }
  12.219 -    cursor[2] = SDL_CreateCursor(small_cursor_data, small_cursor_mask,
  12.220 -                                 8, 11, 3, 5);
  12.221 -    if (cursor[2] == NULL) {
  12.222 -        fprintf(stderr, "Couldn't initialize test cursor: %s\n",
  12.223 -                SDL_GetError());
  12.224 -        SDL_Quit();
  12.225 -        return (1);
  12.226 -    }
  12.227 -    cursor[3] = SDL_CreateColorCursor(LoadSprite("icon.bmp"), 0, 0);
  12.228 -    cursor[4] = SDL_GetCursor();
  12.229 -
  12.230 -    current = SDL_arraysize(cursor)-1;
  12.231 -    SDL_SetCursor(cursor[current]);
  12.232 -
  12.233 -    while (!quit) {
  12.234 -        SDL_Event event;
  12.235 -        while (SDL_PollEvent(&event)) {
  12.236 -            switch (event.type) {
  12.237 -            case SDL_MOUSEBUTTONDOWN:
  12.238 -                current = (current + 1) % SDL_arraysize(cursor);
  12.239 -                SDL_SetCursor(cursor[current]);
  12.240 -                break;
  12.241 -            case SDL_KEYDOWN:
  12.242 -                if (event.key.keysym.sym == SDLK_ESCAPE) {
  12.243 -                    quit = SDL_TRUE;
  12.244 -                }
  12.245 -                break;
  12.246 -            case SDL_QUIT:
  12.247 -                quit = SDL_TRUE;
  12.248 -                break;
  12.249 -            }
  12.250 -        }
  12.251 -        SDL_Flip(screen);
  12.252 -        SDL_Delay(1);
  12.253 -    }
  12.254 -
  12.255 -    for (current = 0; current < SDL_arraysize(cursor); ++current) {
  12.256 -        SDL_FreeCursor(cursor[current]);
  12.257 -    }
  12.258 -
  12.259 -    SDL_Quit();
  12.260 -    return (0);
  12.261 -}
  12.262 -
  12.263 -/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/test/testdyngl.c	Sun Jan 22 17:50:35 2012 -0500
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,221 +0,0 @@
    13.4 -/*
    13.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    13.6 -
    13.7 -  This software is provided 'as-is', without any express or implied
    13.8 -  warranty.  In no event will the authors be held liable for any damages
    13.9 -  arising from the use of this software.
   13.10 -
   13.11 -  Permission is granted to anyone to use this software for any purpose,
   13.12 -  including commercial applications, and to alter it and redistribute it
   13.13 -  freely.
   13.14 -*/
   13.15 -/*
   13.16 - * Small SDL example to demonstrate dynamically loading 
   13.17 - * OpenGL lib and functions
   13.18 - *
   13.19 - * (FYI it was supposed to look like snow in the wind or something...)
   13.20 - *
   13.21 - * Compile with :
   13.22 - * gcc testdyngl.c `sdl-config --libs --cflags` -o testdyngl -DHAVE_OPENGL
   13.23 - *
   13.24 - * You can specify a different OpenGL lib on the command line, i.e. :
   13.25 - * ./testdyngl  /usr/X11R6/lib/libGL.so.1.2
   13.26 - * or
   13.27 - * ./testdyngl  /usr/lib/libGL.so.1.0.4496
   13.28 - *
   13.29 - */
   13.30 -
   13.31 -#include <stdio.h>
   13.32 -#include <stdlib.h>
   13.33 -
   13.34 -#include "SDL.h"
   13.35 -
   13.36 -#ifdef __MACOS__
   13.37 -#define HAVE_OPENGL
   13.38 -#endif
   13.39 -
   13.40 -#ifdef HAVE_OPENGL
   13.41 -
   13.42 -#include "SDL_opengl.h"
   13.43 -
   13.44 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   13.45 -static void
   13.46 -quit(int rc)
   13.47 -{
   13.48 -    SDL_Quit();
   13.49 -    exit(rc);
   13.50 -}
   13.51 -
   13.52 -void *
   13.53 -get_funcaddr(const char *p)
   13.54 -{
   13.55 -    void *f = SDL_GL_GetProcAddress(p);
   13.56 -    if (f) {
   13.57 -        return f;
   13.58 -    } else {
   13.59 -        printf("Unable to get function pointer for %s\n", p);
   13.60 -        quit(1);
   13.61 -    }
   13.62 -    return NULL;
   13.63 -}
   13.64 -
   13.65 -typedef struct
   13.66 -{
   13.67 -    void (APIENTRY * glBegin) (GLenum);
   13.68 -    void (APIENTRY * glEnd) ();
   13.69 -    void (APIENTRY * glVertex3f) (GLfloat, GLfloat, GLfloat);
   13.70 -    void (APIENTRY * glClearColor) (GLfloat, GLfloat, GLfloat, GLfloat);
   13.71 -    void (APIENTRY * glClear) (GLbitfield);
   13.72 -    void (APIENTRY * glDisable) (GLenum);
   13.73 -    void (APIENTRY * glEnable) (GLenum);
   13.74 -    void (APIENTRY * glColor4ub) (GLubyte, GLubyte, GLubyte, GLubyte);
   13.75 -    void (APIENTRY * glPointSize) (GLfloat);
   13.76 -    void (APIENTRY * glHint) (GLenum, GLenum);
   13.77 -    void (APIENTRY * glBlendFunc) (GLenum, GLenum);
   13.78 -    void (APIENTRY * glMatrixMode) (GLenum);
   13.79 -    void (APIENTRY * glLoadIdentity) ();
   13.80 -    void (APIENTRY * glOrtho) (GLdouble, GLdouble, GLdouble, GLdouble,
   13.81 -                               GLdouble, GLdouble);
   13.82 -    void (APIENTRY * glRotatef) (GLfloat, GLfloat, GLfloat, GLfloat);
   13.83 -    void (APIENTRY * glViewport) (GLint, GLint, GLsizei, GLsizei);
   13.84 -    void (APIENTRY * glFogf) (GLenum, GLfloat);
   13.85 -    const GLubyte* (APIENTRY * glGetString) (GLenum);
   13.86 -}
   13.87 -glfuncs;
   13.88 -
   13.89 -void
   13.90 -init_glfuncs(glfuncs * f)
   13.91 -{
   13.92 -    f->glBegin = get_funcaddr("glBegin");
   13.93 -    f->glEnd = get_funcaddr("glEnd");
   13.94 -    f->glVertex3f = get_funcaddr("glVertex3f");
   13.95 -    f->glClearColor = get_funcaddr("glClearColor");
   13.96 -    f->glClear = get_funcaddr("glClear");
   13.97 -    f->glDisable = get_funcaddr("glDisable");
   13.98 -    f->glEnable = get_funcaddr("glEnable");
   13.99 -    f->glColor4ub = get_funcaddr("glColor4ub");
  13.100 -    f->glPointSize = get_funcaddr("glPointSize");
  13.101 -    f->glHint = get_funcaddr("glHint");
  13.102 -    f->glBlendFunc = get_funcaddr("glBlendFunc");
  13.103 -    f->glMatrixMode = get_funcaddr("glMatrixMode");
  13.104 -    f->glLoadIdentity = get_funcaddr("glLoadIdentity");
  13.105 -    f->glOrtho = get_funcaddr("glOrtho");
  13.106 -    f->glRotatef = get_funcaddr("glRotatef");
  13.107 -    f->glViewport = get_funcaddr("glViewport");
  13.108 -    f->glFogf = get_funcaddr("glFogf");
  13.109 -    f->glGetString = get_funcaddr("glGetString");
  13.110 -
  13.111 -    printf("Vendor     : %s\n", f->glGetString(GL_VENDOR));
  13.112 -    printf("Renderer   : %s\n", f->glGetString(GL_RENDERER));
  13.113 -    printf("Version    : %s\n", f->glGetString(GL_VERSION));
  13.114 -    printf("Extensions : %s\n", f->glGetString(GL_EXTENSIONS));
  13.115 -}
  13.116 -
  13.117 -#define NB_PIXELS 1000
  13.118 -
  13.119 -int
  13.120 -main(int argc, char *argv[])
  13.121 -{
  13.122 -    glfuncs f;
  13.123 -    int i;
  13.124 -    SDL_Event event;
  13.125 -    int done = 0;
  13.126 -    GLfloat pixels[NB_PIXELS * 3];
  13.127 -    const char *gl_library = NULL;      /* Use the default GL library */
  13.128 -
  13.129 -    if (argv[1]) {
  13.130 -        gl_library = argv[1];
  13.131 -    }
  13.132 -
  13.133 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  13.134 -        printf("Unable to init SDL : %s\n", SDL_GetError());
  13.135 -        return (1);
  13.136 -    }
  13.137 -
  13.138 -    if (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) < 0) {
  13.139 -        printf("Unable to set GL attribute : %s\n", SDL_GetError());
  13.140 -        quit(1);
  13.141 -    }
  13.142 -
  13.143 -    if (SDL_GL_LoadLibrary(gl_library) < 0) {
  13.144 -        printf("Unable to dynamically open GL lib : %s\n", SDL_GetError());
  13.145 -        quit(1);
  13.146 -    }
  13.147 -
  13.148 -    if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL) {
  13.149 -        printf("Unable to open video mode : %s\n", SDL_GetError());
  13.150 -        quit(1);
  13.151 -    }
  13.152 -
  13.153 -    /* Set the window manager title bar */
  13.154 -    SDL_WM_SetCaption("SDL Dynamic OpenGL Loading Test", "testdyngl");
  13.155 -
  13.156 -    init_glfuncs(&f);
  13.157 -
  13.158 -    for (i = 0; i < NB_PIXELS; i++) {
  13.159 -        pixels[3 * i] = rand() % 250 - 125;
  13.160 -        pixels[3 * i + 1] = rand() % 250 - 125;
  13.161 -        pixels[3 * i + 2] = rand() % 250 - 125;
  13.162 -    }
  13.163 -
  13.164 -    f.glViewport(0, 0, 640, 480);
  13.165 -
  13.166 -    f.glMatrixMode(GL_PROJECTION);
  13.167 -    f.glLoadIdentity();
  13.168 -    f.glOrtho(-100, 100, -100, 100, -500, 500);
  13.169 -
  13.170 -    f.glMatrixMode(GL_MODELVIEW);
  13.171 -    f.glLoadIdentity();
  13.172 -
  13.173 -    f.glEnable(GL_DEPTH_TEST);
  13.174 -    f.glDisable(GL_TEXTURE_2D);
  13.175 -    f.glEnable(GL_BLEND);
  13.176 -    f.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  13.177 -
  13.178 -    f.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  13.179 -    f.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  13.180 -
  13.181 -    f.glEnable(GL_POINT_SMOOTH);
  13.182 -    f.glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
  13.183 -    f.glPointSize(5.0f);
  13.184 -    f.glEnable(GL_FOG);
  13.185 -    f.glFogf(GL_FOG_START, -500);
  13.186 -    f.glFogf(GL_FOG_END, 500);
  13.187 -    f.glFogf(GL_FOG_DENSITY, 0.005);
  13.188 -
  13.189 -    do {
  13.190 -        f.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  13.191 -
  13.192 -        f.glRotatef(2.0, 1.0, 1.0, 1.0);
  13.193 -        f.glRotatef(1.0, 0.0, 1.0, 1.0);
  13.194 -
  13.195 -        f.glColor4ub(255, 255, 255, 255);
  13.196 -        f.glBegin(GL_POINTS);
  13.197 -        for (i = 0; i < NB_PIXELS; i++) {
  13.198 -            f.glVertex3f(pixels[3 * i], pixels[3 * i + 1], pixels[3 * i + 2]);
  13.199 -        }
  13.200 -        f.glEnd();
  13.201 -        SDL_GL_SwapBuffers();
  13.202 -
  13.203 -        while (SDL_PollEvent(&event)) {
  13.204 -            if (event.type == SDL_KEYDOWN)
  13.205 -                done = 1;
  13.206 -        }
  13.207 -
  13.208 -        SDL_Delay(20);
  13.209 -    } while (!done);
  13.210 -
  13.211 -    SDL_Quit();
  13.212 -    return 0;
  13.213 -}
  13.214 -
  13.215 -#else /* HAVE_OPENGL */
  13.216 -
  13.217 -int
  13.218 -main(int argc, char *argv[])
  13.219 -{
  13.220 -    printf("No OpenGL support on this system\n");
  13.221 -    return 1;
  13.222 -}
  13.223 -
  13.224 -#endif /* HAVE_OPENGL */
    14.1 --- a/test/testdyngles.c	Sun Jan 22 17:50:35 2012 -0500
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,226 +0,0 @@
    14.4 -/*
    14.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    14.6 -
    14.7 -  This software is provided 'as-is', without any express or implied
    14.8 -  warranty.  In no event will the authors be held liable for any damages
    14.9 -  arising from the use of this software.
   14.10 -
   14.11 -  Permission is granted to anyone to use this software for any purpose,
   14.12 -  including commercial applications, and to alter it and redistribute it
   14.13 -  freely.
   14.14 -*/
   14.15 -/*
   14.16 - * Small SDL example to demonstrate dynamically loading 
   14.17 - * OpenGL lib and functions
   14.18 - *
   14.19 - * (FYI it was supposed to look like snow in the wind or something...)
   14.20 - *
   14.21 - * Compile with :
   14.22 - * gcc testdyngl.c `sdl-config --libs --cflags` -o testdyngl -DHAVE_OPENGL
   14.23 - *
   14.24 - * You can specify a different OpenGL lib on the command line, i.e. :
   14.25 - * ./testdyngl  /usr/X11R6/lib/libGL.so.1.2
   14.26 - * or
   14.27 - * ./testdyngl  /usr/lib/libGL.so.1.0.4496
   14.28 - *
   14.29 - */
   14.30 -
   14.31 -#include <stdio.h>
   14.32 -#include <stdlib.h>
   14.33 -
   14.34 -#include "SDL.h"
   14.35 -
   14.36 -#ifdef __IPHONEOS__
   14.37 -#define HAVE_OPENGLES
   14.38 -#endif
   14.39 -
   14.40 -#ifdef HAVE_OPENGLES
   14.41 -
   14.42 -#include "SDL_opengles.h"
   14.43 -
   14.44 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   14.45 -static void
   14.46 -quit(int rc)
   14.47 -{
   14.48 -    SDL_Quit();
   14.49 -    exit(rc);
   14.50 -}
   14.51 -
   14.52 -void *
   14.53 -get_funcaddr(const char *p)
   14.54 -{
   14.55 -    void *f = SDL_GL_GetProcAddress(p);
   14.56 -    if (f) {
   14.57 -        return f;
   14.58 -    } else {
   14.59 -        printf("Unable to get function pointer for %s\n", p);
   14.60 -        quit(1);
   14.61 -    }
   14.62 -    return NULL;
   14.63 -}
   14.64 -
   14.65 -typedef struct
   14.66 -{
   14.67 -    void (APIENTRY * glEnableClientState) (GLenum array);
   14.68 -    void (APIENTRY * glDisableClientState) (GLenum array);
   14.69 -    void (APIENTRY * glVertexPointer) (GLint size, GLenum type,
   14.70 -                                       GLsizei stride,
   14.71 -                                       const GLvoid * pointer);
   14.72 -    void (APIENTRY * glDrawArrays) (GLenum mode, GLint first, GLsizei count);
   14.73 -
   14.74 -
   14.75 -    void (APIENTRY * glClearColor) (GLfloat, GLfloat, GLfloat, GLfloat);
   14.76 -    void (APIENTRY * glClear) (GLbitfield);
   14.77 -    void (APIENTRY * glDisable) (GLenum);
   14.78 -    void (APIENTRY * glEnable) (GLenum);
   14.79 -    void (APIENTRY * glColor4f) (GLfloat, GLfloat, GLfloat, GLfloat);
   14.80 -    void (APIENTRY * glPointSize) (GLfloat);
   14.81 -    void (APIENTRY * glHint) (GLenum, GLenum);
   14.82 -    void (APIENTRY * glBlendFunc) (GLenum, GLenum);
   14.83 -    void (APIENTRY * glMatrixMode) (GLenum);
   14.84 -    void (APIENTRY * glLoadIdentity) ();
   14.85 -    void (APIENTRY * glOrthof) (GLfloat, GLfloat, GLfloat, GLfloat,
   14.86 -                                GLfloat, GLfloat);
   14.87 -    void (APIENTRY * glRotatef) (GLfloat, GLfloat, GLfloat, GLfloat);
   14.88 -    void (APIENTRY * glViewport) (GLint, GLint, GLsizei, GLsizei);
   14.89 -    void (APIENTRY * glFogf) (GLenum, GLfloat);
   14.90 -}
   14.91 -glfuncs;
   14.92 -
   14.93 -void
   14.94 -init_glfuncs(glfuncs * f)
   14.95 -{
   14.96 -    f->glEnableClientState = get_funcaddr("glEnableClientState");
   14.97 -    f->glDisableClientState = get_funcaddr("glDisableClientState");
   14.98 -    f->glVertexPointer = get_funcaddr("glVertexPointer");
   14.99 -    f->glDrawArrays = get_funcaddr("glDrawArrays");
  14.100 -    f->glClearColor = get_funcaddr("glClearColor");
  14.101 -    f->glClear = get_funcaddr("glClear");
  14.102 -    f->glDisable = get_funcaddr("glDisable");
  14.103 -    f->glEnable = get_funcaddr("glEnable");
  14.104 -    f->glColor4f = get_funcaddr("glColor4f");
  14.105 -    f->glPointSize = get_funcaddr("glPointSize");
  14.106 -    f->glHint = get_funcaddr("glHint");
  14.107 -    f->glBlendFunc = get_funcaddr("glBlendFunc");
  14.108 -    f->glMatrixMode = get_funcaddr("glMatrixMode");
  14.109 -    f->glLoadIdentity = get_funcaddr("glLoadIdentity");
  14.110 -    f->glOrthof = get_funcaddr("glOrthof");
  14.111 -    f->glRotatef = get_funcaddr("glRotatef");
  14.112 -    f->glViewport = get_funcaddr("glViewport");
  14.113 -    f->glFogf = get_funcaddr("glFogf");
  14.114 -}
  14.115 -
  14.116 -#define NB_PIXELS 1000
  14.117 -
  14.118 -int
  14.119 -main(int argc, char *argv[])
  14.120 -{
  14.121 -    glfuncs f;
  14.122 -    int i;
  14.123 -    SDL_Event event;
  14.124 -    int done = 0;
  14.125 -    GLfloat pixels[NB_PIXELS * 3];
  14.126 -    const char *gl_library = NULL;      /* Use the default GL library */
  14.127 -
  14.128 -    int video_w, video_h;
  14.129 -
  14.130 -    /* you may want to change these according to the platform */
  14.131 -    video_w = 320;
  14.132 -    video_h = 480;
  14.133 -
  14.134 -    if (argv[1]) {
  14.135 -        gl_library = argv[1];
  14.136 -    }
  14.137 -
  14.138 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  14.139 -        printf("Unable to init SDL : %s\n", SDL_GetError());
  14.140 -        return (1);
  14.141 -    }
  14.142 -
  14.143 -    if (SDL_GL_LoadLibrary(gl_library) < 0) {
  14.144 -        printf("Unable to dynamically open GL ES lib : %s\n", SDL_GetError());
  14.145 -        quit(1);
  14.146 -    }
  14.147 -
  14.148 -    if (SDL_SetVideoMode(video_h, video_w, 0, SDL_OPENGL) == NULL) {
  14.149 -        printf("Unable to open video mode : %s\n", SDL_GetError());
  14.150 -        quit(1);
  14.151 -    }
  14.152 -
  14.153 -    /* Set the window manager title bar */
  14.154 -    SDL_WM_SetCaption("SDL Dynamic OpenGL ES Loading Test", "testdyngles");
  14.155 -
  14.156 -    init_glfuncs(&f);
  14.157 -
  14.158 -    for (i = 0; i < NB_PIXELS; i++) {
  14.159 -        pixels[3 * i] = rand() % 250 - 125;
  14.160 -        pixels[3 * i + 1] = rand() % 250 - 125;
  14.161 -        pixels[3 * i + 2] = rand() % 250 - 125;
  14.162 -    }
  14.163 -
  14.164 -    f.glViewport(0, 0, video_w, video_h);
  14.165 -    f.glMatrixMode(GL_PROJECTION);
  14.166 -    f.glLoadIdentity();
  14.167 -    f.glOrthof(-100, 100, -100, 100, -500, 500);
  14.168 -
  14.169 -    f.glMatrixMode(GL_MODELVIEW);
  14.170 -    f.glLoadIdentity();
  14.171 -
  14.172 -    f.glEnable(GL_DEPTH_TEST);
  14.173 -    f.glDisable(GL_TEXTURE_2D);
  14.174 -    f.glEnable(GL_BLEND);
  14.175 -    f.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  14.176 -
  14.177 -    f.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  14.178 -    f.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  14.179 -
  14.180 -    f.glEnable(GL_POINT_SMOOTH);
  14.181 -    f.glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
  14.182 -    f.glPointSize(1.0f);
  14.183 -    f.glEnable(GL_FOG);
  14.184 -    f.glFogf(GL_FOG_START, -500);
  14.185 -    f.glFogf(GL_FOG_END, 500);
  14.186 -    f.glFogf(GL_FOG_DENSITY, 0.005);
  14.187 -
  14.188 -    f.glVertexPointer(3, GL_FLOAT, 0, pixels);
  14.189 -    f.glEnableClientState(GL_VERTEX_ARRAY);
  14.190 -
  14.191 -    do {
  14.192 -        f.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  14.193 -
  14.194 -        f.glRotatef(2.0, 1.0, 1.0, 1.0);
  14.195 -        f.glRotatef(1.0, 0.0, 1.0, 1.0);
  14.196 -
  14.197 -        f.glColor4f(1.0, 1.0, 1.0, 1.0);
  14.198 -
  14.199 -        f.glDrawArrays(GL_POINTS, 0, NB_PIXELS);
  14.200 -
  14.201 -        SDL_GL_SwapBuffers();
  14.202 -
  14.203 -        while (SDL_PollEvent(&event)) {
  14.204 -            if (event.type == SDL_QUIT)
  14.205 -                done = 1;
  14.206 -            if (event.type == SDL_KEYDOWN)
  14.207 -                done = 1;
  14.208 -        }
  14.209 -
  14.210 -        SDL_Delay(20);
  14.211 -    }
  14.212 -    while (!done);
  14.213 -
  14.214 -    f.glDisableClientState(GL_VERTEX_ARRAY);
  14.215 -
  14.216 -    SDL_Quit();
  14.217 -    return 0;
  14.218 -}
  14.219 -
  14.220 -#else /* HAVE_OPENGLES */
  14.221 -
  14.222 -int
  14.223 -main(int argc, char *argv[])
  14.224 -{
  14.225 -    printf("No OpenGL ES support on this system\n");
  14.226 -    return 1;
  14.227 -}
  14.228 -
  14.229 -#endif /* HAVE_OPENGLES */
    15.1 --- a/test/testfill.c	Sun Jan 22 17:50:35 2012 -0500
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,118 +0,0 @@
    15.4 -/*
    15.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    15.6 -
    15.7 -  This software is provided 'as-is', without any express or implied
    15.8 -  warranty.  In no event will the authors be held liable for any damages
    15.9 -  arising from the use of this software.
   15.10 -
   15.11 -  Permission is granted to anyone to use this software for any purpose,
   15.12 -  including commercial applications, and to alter it and redistribute it
   15.13 -  freely.
   15.14 -*/
   15.15 -/* Simple program:  Fill the screen with colors as fast as possible */
   15.16 -
   15.17 -#include <stdlib.h>
   15.18 -#include <stdio.h>
   15.19 -#include <string.h>
   15.20 -#include <time.h>
   15.21 -
   15.22 -#include "SDL.h"
   15.23 -
   15.24 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   15.25 -static void
   15.26 -quit(int rc)
   15.27 -{
   15.28 -    SDL_Quit();
   15.29 -    exit(rc);
   15.30 -}
   15.31 -
   15.32 -int
   15.33 -main(int argc, char *argv[])
   15.34 -{
   15.35 -    SDL_Surface *screen;
   15.36 -    int width, height;
   15.37 -    Uint8 video_bpp;
   15.38 -    Uint32 videoflags;
   15.39 -    Uint32 colors[3];
   15.40 -    int i, done;
   15.41 -    SDL_Event event;
   15.42 -    Uint32 then, now, frames;
   15.43 -
   15.44 -    /* Initialize SDL */
   15.45 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   15.46 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   15.47 -        return (1);
   15.48 -    }
   15.49 -
   15.50 -    width = 640;
   15.51 -    height = 480;
   15.52 -    video_bpp = 8;
   15.53 -    videoflags = 0;
   15.54 -    while (argc > 1) {
   15.55 -        --argc;
   15.56 -        if (strcmp(argv[argc - 1], "-width") == 0) {
   15.57 -            width = atoi(argv[argc]);
   15.58 -            --argc;
   15.59 -        } else if (strcmp(argv[argc - 1], "-height") == 0) {
   15.60 -            height = atoi(argv[argc]);
   15.61 -            --argc;
   15.62 -        } else if (strcmp(argv[argc - 1], "-bpp") == 0) {
   15.63 -            video_bpp = atoi(argv[argc]);
   15.64 -            --argc;
   15.65 -        } else if (strcmp(argv[argc], "-fullscreen") == 0) {
   15.66 -            videoflags ^= SDL_FULLSCREEN;
   15.67 -        } else {
   15.68 -            fprintf(stderr,
   15.69 -                    "Usage: %s [-width N] [-height N] [-bpp N] [-fullscreen]\n",
   15.70 -                    argv[0]);
   15.71 -            quit(1);
   15.72 -        }
   15.73 -    }
   15.74 -
   15.75 -    /* Set video mode */
   15.76 -    screen = SDL_SetVideoMode(width, height, video_bpp, 0);
   15.77 -    if (!screen) {
   15.78 -        fprintf(stderr, "Couldn't set %dx%d video mode: %s\n",
   15.79 -                width, height, SDL_GetError());
   15.80 -        quit(2);
   15.81 -    }
   15.82 -
   15.83 -    /* Get the colors */
   15.84 -    colors[0] = SDL_MapRGB(screen->format, 0xFF, 0x00, 0x00);
   15.85 -    colors[1] = SDL_MapRGB(screen->format, 0x00, 0xFF, 0x00);
   15.86 -    colors[2] = SDL_MapRGB(screen->format, 0x00, 0x00, 0xFF);
   15.87 -
   15.88 -    /* Loop, filling and waiting for a keystroke */
   15.89 -    frames = 0;
   15.90 -    then = SDL_GetTicks();
   15.91 -    done = 0;
   15.92 -    while (!done) {
   15.93 -        /* Check for events */
   15.94 -        ++frames;
   15.95 -        while (SDL_PollEvent(&event)) {
   15.96 -            switch (event.type) {
   15.97 -            case SDL_MOUSEBUTTONDOWN:
   15.98 -                SDL_WarpMouse(screen->w / 2, screen->h / 2);
   15.99 -                break;
  15.100 -            case SDL_KEYDOWN:
  15.101 -                /* Any keypress quits the app... */
  15.102 -            case SDL_QUIT:
  15.103 -                done = 1;
  15.104 -                break;
  15.105 -            default:
  15.106 -                break;
  15.107 -            }
  15.108 -        }
  15.109 -        SDL_FillRect(screen, NULL, colors[frames%3]);
  15.110 -        SDL_Flip(screen);
  15.111 -    }
  15.112 -
  15.113 -    /* Print out some timing information */
  15.114 -    now = SDL_GetTicks();
  15.115 -    if (now > then) {
  15.116 -        double fps = ((double) frames * 1000) / (now - then);
  15.117 -        printf("%2.2f frames per second\n", fps);
  15.118 -    }
  15.119 -    SDL_Quit();
  15.120 -    return (0);
  15.121 -}
    16.1 --- a/test/testgamma.c	Sun Jan 22 17:50:35 2012 -0500
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,179 +0,0 @@
    16.4 -/*
    16.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    16.6 -
    16.7 -  This software is provided 'as-is', without any express or implied
    16.8 -  warranty.  In no event will the authors be held liable for any damages
    16.9 -  arising from the use of this software.
   16.10 -
   16.11 -  Permission is granted to anyone to use this software for any purpose,
   16.12 -  including commercial applications, and to alter it and redistribute it
   16.13 -  freely.
   16.14 -*/
   16.15 -
   16.16 -/* Bring up a window and manipulate the gamma on it */
   16.17 -
   16.18 -#include <stdlib.h>
   16.19 -#include <stdio.h>
   16.20 -#include <string.h>
   16.21 -#include <math.h>
   16.22 -
   16.23 -#include "SDL.h"
   16.24 -
   16.25 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   16.26 -static void
   16.27 -quit(int rc)
   16.28 -{
   16.29 -    SDL_Quit();
   16.30 -    exit(rc);
   16.31 -}
   16.32 -
   16.33 -/* This can be used as a general routine for all of the test programs */
   16.34 -int
   16.35 -get_video_args(char *argv[], int *w, int *h, int *bpp, Uint32 * flags)
   16.36 -{
   16.37 -    int i;
   16.38 -
   16.39 -    *w = 640;
   16.40 -    *h = 480;
   16.41 -    *bpp = 0;
   16.42 -    *flags = SDL_SWSURFACE;
   16.43 -
   16.44 -    for (i = 1; argv[i]; ++i) {
   16.45 -        if (strcmp(argv[i], "-width") == 0) {
   16.46 -            if (argv[i + 1]) {
   16.47 -                *w = atoi(argv[++i]);
   16.48 -            }
   16.49 -        } else if (strcmp(argv[i], "-height") == 0) {
   16.50 -            if (argv[i + 1]) {
   16.51 -                *h = atoi(argv[++i]);
   16.52 -            }
   16.53 -        } else if (strcmp(argv[i], "-bpp") == 0) {
   16.54 -            if (argv[i + 1]) {
   16.55 -                *bpp = atoi(argv[++i]);
   16.56 -            }
   16.57 -        } else if (strcmp(argv[i], "-fullscreen") == 0) {
   16.58 -            *flags |= SDL_FULLSCREEN;
   16.59 -        } else if (strcmp(argv[i], "-hw") == 0) {
   16.60 -            *flags |= SDL_HWSURFACE;
   16.61 -        } else if (strcmp(argv[i], "-hwpalette") == 0) {
   16.62 -            *flags |= SDL_HWPALETTE;
   16.63 -        } else
   16.64 -            break;
   16.65 -    }
   16.66 -    return i;
   16.67 -}
   16.68 -
   16.69 -int
   16.70 -main(int argc, char *argv[])
   16.71 -{
   16.72 -    SDL_Surface *screen;
   16.73 -    SDL_Surface *image;
   16.74 -    float gamma;
   16.75 -    int i;
   16.76 -    int w, h, bpp;
   16.77 -    Uint32 flags;
   16.78 -    Uint16 ramp[256];
   16.79 -    Uint16 red_ramp[256];
   16.80 -    Uint32 then, timeout;
   16.81 -
   16.82 -    /* Check command line arguments */
   16.83 -    argv += get_video_args(argv, &w, &h, &bpp, &flags);
   16.84 -
   16.85 -    /* Initialize SDL */
   16.86 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   16.87 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   16.88 -        return (1);
   16.89 -    }
   16.90 -
   16.91 -    /* Initialize the display, always use hardware palette */
   16.92 -    screen = SDL_SetVideoMode(w, h, bpp, flags | SDL_HWPALETTE);
   16.93 -    if (screen == NULL) {
   16.94 -        fprintf(stderr, "Couldn't set %dx%d video mode: %s\n",
   16.95 -                w, h, SDL_GetError());
   16.96 -        quit(1);
   16.97 -    }
   16.98 -
   16.99 -    /* Set the window manager title bar */
  16.100 -    SDL_WM_SetCaption("SDL gamma test", "testgamma");
  16.101 -
  16.102 -    /* Set the desired gamma, if any */
  16.103 -    gamma = 1.0f;
  16.104 -    if (*argv) {
  16.105 -        gamma = (float) atof(*argv);
  16.106 -    }
  16.107 -    if (SDL_SetGamma(gamma, gamma, gamma) < 0) {
  16.108 -        fprintf(stderr, "Unable to set gamma: %s\n", SDL_GetError());
  16.109 -        quit(1);
  16.110 -    }
  16.111 -
  16.112 -    /* Do all the drawing work */
  16.113 -    image = SDL_LoadBMP("sample.bmp");
  16.114 -    if (image) {
  16.115 -        SDL_Rect dst;
  16.116 -
  16.117 -        dst.x = (screen->w - image->w) / 2;
  16.118 -        dst.y = (screen->h - image->h) / 2;
  16.119 -        dst.w = image->w;
  16.120 -        dst.h = image->h;
  16.121 -        SDL_BlitSurface(image, NULL, screen, &dst);
  16.122 -        SDL_UpdateRects(screen, 1, &dst);
  16.123 -    }
  16.124 -
  16.125 -    /* Wait a bit, handling events */
  16.126 -    then = SDL_GetTicks();
  16.127 -    timeout = (5 * 1000);
  16.128 -    while ((SDL_GetTicks() - then) < timeout) {
  16.129 -        SDL_Event event;
  16.130 -
  16.131 -        while (SDL_PollEvent(&event)) {
  16.132 -            switch (event.type) {
  16.133 -            case SDL_QUIT:     /* Quit now */
  16.134 -                timeout = 0;
  16.135 -                break;
  16.136 -            case SDL_KEYDOWN:
  16.137 -                switch (event.key.keysym.sym) {
  16.138 -                case SDLK_SPACE:       /* Go longer.. */
  16.139 -                    timeout += (5 * 1000);
  16.140 -                    break;
  16.141 -                case SDLK_UP:
  16.142 -                    gamma += 0.2f;
  16.143 -                    SDL_SetGamma(gamma, gamma, gamma);
  16.144 -                    break;
  16.145 -                case SDLK_DOWN:
  16.146 -                    gamma -= 0.2f;
  16.147 -                    SDL_SetGamma(gamma, gamma, gamma);
  16.148 -                    break;
  16.149 -                case SDLK_ESCAPE:
  16.150 -                    timeout = 0;
  16.151 -                    break;
  16.152 -                default:
  16.153 -                    break;
  16.154 -                }
  16.155 -                break;
  16.156 -            }
  16.157 -        }
  16.158 -    }
  16.159 -
  16.160 -    /* Perform a gamma flash to red using color ramps */
  16.161 -    while (gamma < 10.0) {
  16.162 -        /* Increase the red gamma and decrease everything else... */
  16.163 -        gamma += 0.1f;
  16.164 -        SDL_CalculateGammaRamp(gamma, red_ramp);
  16.165 -        SDL_CalculateGammaRamp(1.0f / gamma, ramp);
  16.166 -        SDL_SetGammaRamp(red_ramp, ramp, ramp);
  16.167 -    }
  16.168 -    /* Finish completely red */
  16.169 -    memset(red_ramp, 255, sizeof(red_ramp));
  16.170 -    memset(ramp, 0, sizeof(ramp));
  16.171 -    SDL_SetGammaRamp(red_ramp, ramp, ramp);
  16.172 -
  16.173 -    /* Now fade out to black */
  16.174 -    for (i = (red_ramp[0] >> 8); i >= 0; --i) {
  16.175 -        memset(red_ramp, i, sizeof(red_ramp));
  16.176 -        SDL_SetGammaRamp(red_ramp, NULL, NULL);
  16.177 -    }
  16.178 -    SDL_Delay(1 * 1000);
  16.179 -
  16.180 -    SDL_Quit();
  16.181 -    return (0);
  16.182 -}
    17.1 --- a/test/testgl.c	Sun Jan 22 17:50:35 2012 -0500
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,782 +0,0 @@
    17.4 -/*
    17.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    17.6 -
    17.7 -  This software is provided 'as-is', without any express or implied
    17.8 -  warranty.  In no event will the authors be held liable for any damages
    17.9 -  arising from the use of this software.
   17.10 -
   17.11 -  Permission is granted to anyone to use this software for any purpose,
   17.12 -  including commercial applications, and to alter it and redistribute it
   17.13 -  freely.
   17.14 -*/
   17.15 -#include <stdlib.h>
   17.16 -#include <stdio.h>
   17.17 -#include <string.h>
   17.18 -#include <math.h>
   17.19 -
   17.20 -#include "SDL.h"
   17.21 -
   17.22 -#ifdef __MACOS__
   17.23 -#define HAVE_OPENGL
   17.24 -#endif
   17.25 -
   17.26 -#ifdef HAVE_OPENGL
   17.27 -
   17.28 -#include "SDL_opengl.h"
   17.29 -
   17.30 -/* Undefine this if you want a flat cube instead of a rainbow cube */
   17.31 -#define SHADED_CUBE
   17.32 -
   17.33 -/* Define this to be the name of the logo image to use with -logo */
   17.34 -#define LOGO_FILE	"icon.bmp"
   17.35 -
   17.36 -static SDL_Surface *global_image = NULL;
   17.37 -static GLuint global_texture = 0;
   17.38 -static GLuint cursor_texture = 0;
   17.39 -
   17.40 -/**********************************************************************/
   17.41 -
   17.42 -void
   17.43 -HotKey_ToggleFullScreen(void)
   17.44 -{
   17.45 -    SDL_Surface *screen;
   17.46 -
   17.47 -    screen = SDL_GetVideoSurface();
   17.48 -    if (SDL_WM_ToggleFullScreen(screen)) {
   17.49 -        printf("Toggled fullscreen mode - now %s\n",
   17.50 -               (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed");
   17.51 -    } else {
   17.52 -        printf("Unable to toggle fullscreen mode\n");
   17.53 -    }
   17.54 -}
   17.55 -
   17.56 -void
   17.57 -HotKey_ToggleGrab(void)
   17.58 -{
   17.59 -    SDL_GrabMode mode;
   17.60 -
   17.61 -    printf("Ctrl-G: toggling input grab!\n");
   17.62 -    mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
   17.63 -    if (mode == SDL_GRAB_ON) {
   17.64 -        printf("Grab was on\n");
   17.65 -    } else {
   17.66 -        printf("Grab was off\n");
   17.67 -    }
   17.68 -    mode = SDL_WM_GrabInput(!mode);
   17.69 -    if (mode == SDL_GRAB_ON) {
   17.70 -        printf("Grab is now on\n");
   17.71 -    } else {
   17.72 -        printf("Grab is now off\n");
   17.73 -    }
   17.74 -}
   17.75 -
   17.76 -void
   17.77 -HotKey_Iconify(void)
   17.78 -{
   17.79 -    printf("Ctrl-Z: iconifying window!\n");
   17.80 -    SDL_WM_IconifyWindow();
   17.81 -}
   17.82 -
   17.83 -int
   17.84 -HandleEvent(SDL_Event * event)
   17.85 -{
   17.86 -    int done;
   17.87 -
   17.88 -    done = 0;
   17.89 -    switch (event->type) {
   17.90 -    case SDL_ACTIVEEVENT:
   17.91 -        /* See what happened */
   17.92 -        printf("app %s ", event->active.gain ? "gained" : "lost");
   17.93 -        if (event->active.state & SDL_APPACTIVE) {
   17.94 -            printf("active ");
   17.95 -        } else if (event->active.state & SDL_APPMOUSEFOCUS) {
   17.96 -            printf("mouse ");
   17.97 -        } else if (event->active.state & SDL_APPINPUTFOCUS) {
   17.98 -            printf("input ");
   17.99 -        }
  17.100 -        printf("focus\n");
  17.101 -        break;
  17.102 -
  17.103 -
  17.104 -    case SDL_KEYDOWN:
  17.105 -        if (event->key.keysym.sym == SDLK_ESCAPE) {
  17.106 -            done = 1;
  17.107 -        }
  17.108 -        if ((event->key.keysym.sym == SDLK_g) &&
  17.109 -            (event->key.keysym.mod & KMOD_CTRL)) {
  17.110 -            HotKey_ToggleGrab();
  17.111 -        }
  17.112 -        if ((event->key.keysym.sym == SDLK_z) &&
  17.113 -            (event->key.keysym.mod & KMOD_CTRL)) {
  17.114 -            HotKey_Iconify();
  17.115 -        }
  17.116 -        if ((event->key.keysym.sym == SDLK_RETURN) &&
  17.117 -            (event->key.keysym.mod & KMOD_ALT)) {
  17.118 -            HotKey_ToggleFullScreen();
  17.119 -        }
  17.120 -        printf("key '%s' pressed\n", SDL_GetKeyName(event->key.keysym.sym));
  17.121 -        break;
  17.122 -    case SDL_QUIT:
  17.123 -        done = 1;
  17.124 -        break;
  17.125 -    }
  17.126 -    return (done);
  17.127 -}
  17.128 -
  17.129 -void
  17.130 -SDL_GL_Enter2DMode()
  17.131 -{
  17.132 -    SDL_Surface *screen = SDL_GetVideoSurface();
  17.133 -
  17.134 -    /* Note, there may be other things you need to change,
  17.135 -       depending on how you have your OpenGL state set up.
  17.136 -     */
  17.137 -    glPushAttrib(GL_ENABLE_BIT);
  17.138 -    glDisable(GL_DEPTH_TEST);
  17.139 -    glDisable(GL_CULL_FACE);
  17.140 -    glEnable(GL_TEXTURE_2D);
  17.141 -
  17.142 -    /* This allows alpha blending of 2D textures with the scene */
  17.143 -    glEnable(GL_BLEND);
  17.144 -    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  17.145 -
  17.146 -    glViewport(0, 0, screen->w, screen->h);
  17.147 -
  17.148 -    glMatrixMode(GL_PROJECTION);
  17.149 -    glPushMatrix();
  17.150 -    glLoadIdentity();
  17.151 -
  17.152 -    glOrtho(0.0, (GLdouble) screen->w, (GLdouble) screen->h, 0.0, 0.0, 1.0);
  17.153 -
  17.154 -    glMatrixMode(GL_MODELVIEW);
  17.155 -    glPushMatrix();
  17.156 -    glLoadIdentity();
  17.157 -
  17.158 -    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
  17.159 -}
  17.160 -
  17.161 -void
  17.162 -SDL_GL_Leave2DMode()
  17.163 -{
  17.164 -    glMatrixMode(GL_MODELVIEW);
  17.165 -    glPopMatrix();
  17.166 -
  17.167 -    glMatrixMode(GL_PROJECTION);
  17.168 -    glPopMatrix();
  17.169 -
  17.170 -    glPopAttrib();
  17.171 -}
  17.172 -
  17.173 -/* Quick utility function for texture creation */
  17.174 -static int
  17.175 -power_of_two(int input)
  17.176 -{
  17.177 -    int value = 1;
  17.178 -
  17.179 -    while (value < input) {
  17.180 -        value <<= 1;
  17.181 -    }
  17.182 -    return value;
  17.183 -}
  17.184 -
  17.185 -GLuint
  17.186 -SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord)
  17.187 -{
  17.188 -    GLuint texture;
  17.189 -    int w, h;
  17.190 -    SDL_Surface *image;
  17.191 -    SDL_Rect area;
  17.192 -    Uint32 saved_flags;
  17.193 -    Uint8 saved_alpha;
  17.194 -
  17.195 -    /* Use the surface width and height expanded to powers of 2 */
  17.196 -    w = power_of_two(surface->w);
  17.197 -    h = power_of_two(surface->h);
  17.198 -    texcoord[0] = 0.0f;         /* Min X */
  17.199 -    texcoord[1] = 0.0f;         /* Min Y */
  17.200 -    texcoord[2] = (GLfloat) surface->w / w;     /* Max X */
  17.201 -    texcoord[3] = (GLfloat) surface->h / h;     /* Max Y */
  17.202 -
  17.203 -    image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
  17.204 -#if SDL_BYTEORDER == SDL_LIL_ENDIAN     /* OpenGL RGBA masks */
  17.205 -                                 0x000000FF,
  17.206 -                                 0x0000FF00, 0x00FF0000, 0xFF000000
  17.207 -#else
  17.208 -                                 0xFF000000,
  17.209 -                                 0x00FF0000, 0x0000FF00, 0x000000FF
  17.210 -#endif
  17.211 -        );
  17.212 -    if (image == NULL) {
  17.213 -        return 0;
  17.214 -    }
  17.215 -
  17.216 -    /* Save the alpha blending attributes */
  17.217 -    saved_flags = surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
  17.218 -    SDL_GetSurfaceAlphaMod(surface, &saved_alpha);
  17.219 -    if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
  17.220 -        SDL_SetAlpha(surface, 0, 0);
  17.221 -    }
  17.222 -
  17.223 -    /* Copy the surface into the GL texture image */
  17.224 -    area.x = 0;
  17.225 -    area.y = 0;
  17.226 -    area.w = surface->w;
  17.227 -    area.h = surface->h;
  17.228 -    SDL_BlitSurface(surface, &area, image, &area);
  17.229 -
  17.230 -    /* Restore the alpha blending attributes */
  17.231 -    if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
  17.232 -        SDL_SetAlpha(surface, saved_flags, saved_alpha);
  17.233 -    }
  17.234 -
  17.235 -    /* Create an OpenGL texture for the image */
  17.236 -    glGenTextures(1, &texture);
  17.237 -    glBindTexture(GL_TEXTURE_2D, texture);
  17.238 -    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  17.239 -    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  17.240 -    glTexImage2D(GL_TEXTURE_2D,
  17.241 -                 0,
  17.242 -                 GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels);
  17.243 -    SDL_FreeSurface(image);     /* No longer needed */
  17.244 -
  17.245 -    return texture;
  17.246 -}
  17.247 -
  17.248 -void
  17.249 -DrawLogoCursor(void)
  17.250 -{
  17.251 -    static GLfloat texMinX, texMinY;
  17.252 -    static GLfloat texMaxX, texMaxY;
  17.253 -    static int w, h;
  17.254 -    int x, y;
  17.255 -
  17.256 -    if (!cursor_texture) {
  17.257 -        SDL_Surface *image;
  17.258 -        GLfloat texcoord[4];
  17.259 -
  17.260 -        /* Load the image (could use SDL_image library here) */
  17.261 -        image = SDL_LoadBMP(LOGO_FILE);
  17.262 -        if (image == NULL) {
  17.263 -            return;
  17.264 -        }
  17.265 -        w = image->w;
  17.266 -        h = image->h;
  17.267 -
  17.268 -        /* Convert the image into an OpenGL texture */
  17.269 -        cursor_texture = SDL_GL_LoadTexture(image, texcoord);
  17.270 -
  17.271 -        /* Make texture coordinates easy to understand */
  17.272 -        texMinX = texcoord[0];
  17.273 -        texMinY = texcoord[1];
  17.274 -        texMaxX = texcoord[2];
  17.275 -        texMaxY = texcoord[3];
  17.276 -
  17.277 -        /* We don't need the original image anymore */
  17.278 -        SDL_FreeSurface(image);
  17.279 -
  17.280 -        /* Make sure that the texture conversion is okay */
  17.281 -        if (!cursor_texture) {
  17.282 -            return;
  17.283 -        }
  17.284 -    }
  17.285 -
  17.286 -    /* Move the image around */
  17.287 -    SDL_GetMouseState(&x, &y);
  17.288 -    x -= w / 2;
  17.289 -    y -= h / 2;
  17.290 -
  17.291 -    /* Show the image on the screen */
  17.292 -    SDL_GL_Enter2DMode();
  17.293 -    glBindTexture(GL_TEXTURE_2D, cursor_texture);
  17.294 -    glBegin(GL_TRIANGLE_STRIP);
  17.295 -    glTexCoord2f(texMinX, texMinY);
  17.296 -    glVertex2i(x, y);
  17.297 -    glTexCoord2f(texMaxX, texMinY);
  17.298 -    glVertex2i(x + w, y);
  17.299 -    glTexCoord2f(texMinX, texMaxY);
  17.300 -    glVertex2i(x, y + h);
  17.301 -    glTexCoord2f(texMaxX, texMaxY);
  17.302 -    glVertex2i(x + w, y + h);
  17.303 -    glEnd();
  17.304 -    SDL_GL_Leave2DMode();
  17.305 -}
  17.306 -
  17.307 -void
  17.308 -DrawLogoTexture(void)
  17.309 -{
  17.310 -    static GLfloat texMinX, texMinY;
  17.311 -    static GLfloat texMaxX, texMaxY;
  17.312 -    static int x = 0;
  17.313 -    static int y = 0;
  17.314 -    static int w, h;
  17.315 -    static int delta_x = 1;
  17.316 -    static int delta_y = 1;
  17.317 -
  17.318 -    SDL_Surface *screen = SDL_GetVideoSurface();
  17.319 -
  17.320 -    if (!global_texture) {
  17.321 -        SDL_Surface *image;
  17.322 -        GLfloat texcoord[4];
  17.323 -
  17.324 -        /* Load the image (could use SDL_image library here) */
  17.325 -        image = SDL_LoadBMP(LOGO_FILE);
  17.326 -        if (image == NULL) {
  17.327 -            return;
  17.328 -        }
  17.329 -        w = image->w;
  17.330 -        h = image->h;
  17.331 -
  17.332 -        /* Convert the image into an OpenGL texture */
  17.333 -        global_texture = SDL_GL_LoadTexture(image, texcoord);
  17.334 -
  17.335 -        /* Make texture coordinates easy to understand */
  17.336 -        texMinX = texcoord[0];
  17.337 -        texMinY = texcoord[1];
  17.338 -        texMaxX = texcoord[2];
  17.339 -        texMaxY = texcoord[3];
  17.340 -
  17.341 -        /* We don't need the original image anymore */
  17.342 -        SDL_FreeSurface(image);
  17.343 -
  17.344 -        /* Make sure that the texture conversion is okay */
  17.345 -        if (!global_texture) {
  17.346 -            return;
  17.347 -        }
  17.348 -    }
  17.349 -
  17.350 -    /* Move the image around */
  17.351 -    x += delta_x;
  17.352 -    if (x < 0) {
  17.353 -        x = 0;
  17.354 -        delta_x = -delta_x;
  17.355 -    } else if ((x + w) > screen->w) {
  17.356 -        x = screen->w - w;
  17.357 -        delta_x = -delta_x;
  17.358 -    }
  17.359 -    y += delta_y;
  17.360 -    if (y < 0) {
  17.361 -        y = 0;
  17.362 -        delta_y = -delta_y;
  17.363 -    } else if ((y + h) > screen->h) {
  17.364 -        y = screen->h - h;
  17.365 -        delta_y = -delta_y;
  17.366 -    }
  17.367 -
  17.368 -    /* Show the image on the screen */
  17.369 -    SDL_GL_Enter2DMode();
  17.370 -    glBindTexture(GL_TEXTURE_2D, global_texture);
  17.371 -    glBegin(GL_TRIANGLE_STRIP);
  17.372 -    glTexCoord2f(texMinX, texMinY);
  17.373 -    glVertex2i(x, y);
  17.374 -    glTexCoord2f(texMaxX, texMinY);
  17.375 -    glVertex2i(x + w, y);
  17.376 -    glTexCoord2f(texMinX, texMaxY);
  17.377 -    glVertex2i(x, y + h);
  17.378 -    glTexCoord2f(texMaxX, texMaxY);
  17.379 -    glVertex2i(x + w, y + h);
  17.380 -    glEnd();
  17.381 -    SDL_GL_Leave2DMode();
  17.382 -}
  17.383 -
  17.384 -int
  17.385 -RunGLTest(int argc, char *argv[],
  17.386 -          int logo, int logocursor, int slowly, int bpp, float gamma,
  17.387 -          int noframe, int fsaa, int sync, int accel)
  17.388 -{
  17.389 -    int i;
  17.390 -    int rgb_size[3];
  17.391 -    int w = 640;
  17.392 -    int h = 480;
  17.393 -    int done = 0;
  17.394 -    int frames;
  17.395 -    Uint32 start_time, this_time;
  17.396 -    float color[8][3] = { {1.0, 1.0, 0.0},
  17.397 -    {1.0, 0.0, 0.0},
  17.398 -    {0.0, 0.0, 0.0},
  17.399 -    {0.0, 1.0, 0.0},
  17.400 -    {0.0, 1.0, 1.0},
  17.401 -    {1.0, 1.0, 1.0},
  17.402 -    {1.0, 0.0, 1.0},
  17.403 -    {0.0, 0.0, 1.0}
  17.404 -    };
  17.405 -    float cube[8][3] = { {0.5, 0.5, -0.5},
  17.406 -    {0.5, -0.5, -0.5},
  17.407 -    {-0.5, -0.5, -0.5},
  17.408 -    {-0.5, 0.5, -0.5},
  17.409 -    {-0.5, 0.5, 0.5},
  17.410 -    {0.5, 0.5, 0.5},
  17.411 -    {0.5, -0.5, 0.5},
  17.412 -    {-0.5, -0.5, 0.5}
  17.413 -    };
  17.414 -    Uint32 video_flags;
  17.415 -    int value;
  17.416 -
  17.417 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  17.418 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
  17.419 -        exit(1);
  17.420 -    }
  17.421 -
  17.422 -    /* See if we should detect the display depth */
  17.423 -    if (bpp == 0) {
  17.424 -        if (SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8) {
  17.425 -            bpp = 8;
  17.426 -        } else {
  17.427 -            bpp = 16;           /* More doesn't seem to work */
  17.428 -        }
  17.429 -    }
  17.430 -
  17.431 -    /* Set the flags we want to use for setting the video mode */
  17.432 -    video_flags = SDL_OPENGL;
  17.433 -    for (i = 1; argv[i]; ++i) {
  17.434 -        if (strcmp(argv[i], "-fullscreen") == 0) {
  17.435 -            video_flags |= SDL_FULLSCREEN;
  17.436 -        }
  17.437 -    }
  17.438 -
  17.439 -    if (noframe) {
  17.440 -        video_flags |= SDL_NOFRAME;
  17.441 -    }
  17.442 -
  17.443 -    /* Initialize the display */
  17.444 -    switch (bpp) {
  17.445 -    case 8:
  17.446 -        rgb_size[0] = 3;
  17.447 -        rgb_size[1] = 3;
  17.448 -        rgb_size[2] = 2;
  17.449 -        break;
  17.450 -    case 15:
  17.451 -    case 16:
  17.452 -        rgb_size[0] = 5;
  17.453 -        rgb_size[1] = 5;
  17.454 -        rgb_size[2] = 5;
  17.455 -        break;
  17.456 -    default:
  17.457 -        rgb_size[0] = 8;
  17.458 -        rgb_size[1] = 8;
  17.459 -        rgb_size[2] = 8;
  17.460 -        break;
  17.461 -    }
  17.462 -    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, rgb_size[0]);
  17.463 -    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, rgb_size[1]);
  17.464 -    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, rgb_size[2]);
  17.465 -    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
  17.466 -    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  17.467 -    if (fsaa) {
  17.468 -        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
  17.469 -        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
  17.470 -    }
  17.471 -    if (accel >= 0) {
  17.472 -        SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, accel);
  17.473 -    }
  17.474 -    if (SDL_SetVideoMode(w, h, bpp, video_flags) == NULL) {
  17.475 -        fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
  17.476 -        SDL_Quit();
  17.477 -        exit(1);
  17.478 -    }
  17.479 -    if (sync) {
  17.480 -        SDL_GL_SetSwapInterval(1);
  17.481 -    } else {
  17.482 -        SDL_GL_SetSwapInterval(0);
  17.483 -    }
  17.484 -
  17.485 -    printf("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
  17.486 -    printf("\n");
  17.487 -    printf("Vendor     : %s\n", glGetString(GL_VENDOR));
  17.488 -    printf("Renderer   : %s\n", glGetString(GL_RENDERER));
  17.489 -    printf("Version    : %s\n", glGetString(GL_VERSION));
  17.490 -    printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
  17.491 -    printf("\n");
  17.492 -
  17.493 -    SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
  17.494 -    printf("SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0], value);
  17.495 -    SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
  17.496 -    printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1], value);
  17.497 -    SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
  17.498 -    printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2], value);
  17.499 -    SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
  17.500 -    printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value);
  17.501 -    SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &value);
  17.502 -    printf("SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value);
  17.503 -    if (fsaa) {
  17.504 -        SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
  17.505 -        printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
  17.506 -        SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
  17.507 -        printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
  17.508 -               value);
  17.509 -    }
  17.510 -    if (accel >= 0) {
  17.511 -        SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
  17.512 -        printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
  17.513 -               value);
  17.514 -    }
  17.515 -    if (sync) {
  17.516 -        printf("Buffer swap interval: requested 1, got %d\n",
  17.517 -               SDL_GL_GetSwapInterval());
  17.518 -    }
  17.519 -
  17.520 -    /* Set the window manager title bar */
  17.521 -    SDL_WM_SetCaption("SDL GL test", "testgl");
  17.522 -
  17.523 -    /* Set the gamma for the window */
  17.524 -    if (gamma != 0.0) {
  17.525 -        SDL_SetGamma(gamma, gamma, gamma);
  17.526 -    }
  17.527 -
  17.528 -    glViewport(0, 0, w, h);
  17.529 -    glMatrixMode(GL_PROJECTION);
  17.530 -    glLoadIdentity();
  17.531 -
  17.532 -    glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);
  17.533 -
  17.534 -    glMatrixMode(GL_MODELVIEW);
  17.535 -    glLoadIdentity();
  17.536 -
  17.537 -    glEnable(GL_DEPTH_TEST);
  17.538 -
  17.539 -    glDepthFunc(GL_LESS);
  17.540 -
  17.541 -    glShadeModel(GL_SMOOTH);
  17.542 -
  17.543 -    /* Loop until done. */
  17.544 -    start_time = SDL_GetTicks();
  17.545 -    frames = 0;
  17.546 -    while (!done) {
  17.547 -        GLenum gl_error;
  17.548 -        char *sdl_error;
  17.549 -        SDL_Event event;
  17.550 -
  17.551 -        /* Do our drawing, too. */
  17.552 -        glClearColor(0.0, 0.0, 0.0, 1.0);
  17.553 -        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  17.554 -
  17.555 -        glBegin(GL_QUADS);
  17.556 -
  17.557 -#ifdef SHADED_CUBE
  17.558 -        glColor3fv(color[0]);
  17.559 -        glVertex3fv(cube[0]);
  17.560 -        glColor3fv(color[1]);
  17.561 -        glVertex3fv(cube[1]);
  17.562 -        glColor3fv(color[2]);
  17.563 -        glVertex3fv(cube[2]);
  17.564 -        glColor3fv(color[3]);
  17.565 -        glVertex3fv(cube[3]);
  17.566 -
  17.567 -        glColor3fv(color[3]);
  17.568 -        glVertex3fv(cube[3]);
  17.569 -        glColor3fv(color[4]);
  17.570 -        glVertex3fv(cube[4]);
  17.571 -        glColor3fv(color[7]);
  17.572 -        glVertex3fv(cube[7]);
  17.573 -        glColor3fv(color[2]);
  17.574 -        glVertex3fv(cube[2]);
  17.575 -
  17.576 -        glColor3fv(color[0]);
  17.577 -        glVertex3fv(cube[0]);
  17.578 -        glColor3fv(color[5]);
  17.579 -        glVertex3fv(cube[5]);
  17.580 -        glColor3fv(color[6]);
  17.581 -        glVertex3fv(cube[6]);
  17.582 -        glColor3fv(color[1]);
  17.583 -        glVertex3fv(cube[1]);
  17.584 -
  17.585 -        glColor3fv(color[5]);
  17.586 -        glVertex3fv(cube[5]);
  17.587 -        glColor3fv(color[4]);
  17.588 -        glVertex3fv(cube[4]);
  17.589 -        glColor3fv(color[7]);
  17.590 -        glVertex3fv(cube[7]);
  17.591 -        glColor3fv(color[6]);
  17.592 -        glVertex3fv(cube[6]);
  17.593 -
  17.594 -        glColor3fv(color[5]);
  17.595 -        glVertex3fv(cube[5]);
  17.596 -        glColor3fv(color[0]);
  17.597 -        glVertex3fv(cube[0]);
  17.598 -        glColor3fv(color[3]);
  17.599 -        glVertex3fv(cube[3]);
  17.600 -        glColor3fv(color[4]);
  17.601 -        glVertex3fv(cube[4]);
  17.602 -
  17.603 -        glColor3fv(color[6]);
  17.604 -        glVertex3fv(cube[6]);
  17.605 -        glColor3fv(color[1]);
  17.606 -        glVertex3fv(cube[1]);
  17.607 -        glColor3fv(color[2]);
  17.608 -        glVertex3fv(cube[2]);
  17.609 -        glColor3fv(color[7]);
  17.610 -        glVertex3fv(cube[7]);
  17.611 -#else /* flat cube */
  17.612 -        glColor3f(1.0, 0.0, 0.0);
  17.613 -        glVertex3fv(cube[0]);
  17.614 -        glVertex3fv(cube[1]);
  17.615 -        glVertex3fv(cube[2]);
  17.616 -        glVertex3fv(cube[3]);
  17.617 -
  17.618 -        glColor3f(0.0, 1.0, 0.0);
  17.619 -        glVertex3fv(cube[3]);
  17.620 -        glVertex3fv(cube[4]);
  17.621 -        glVertex3fv(cube[7]);
  17.622 -        glVertex3fv(cube[2]);
  17.623 -
  17.624 -        glColor3f(0.0, 0.0, 1.0);
  17.625 -        glVertex3fv(cube[0]);
  17.626 -        glVertex3fv(cube[5]);
  17.627 -        glVertex3fv(cube[6]);
  17.628 -        glVertex3fv(cube[1]);
  17.629 -
  17.630 -        glColor3f(0.0, 1.0, 1.0);
  17.631 -        glVertex3fv(cube[5]);
  17.632 -        glVertex3fv(cube[4]);
  17.633 -        glVertex3fv(cube[7]);
  17.634 -        glVertex3fv(cube[6]);
  17.635 -
  17.636 -        glColor3f(1.0, 1.0, 0.0);
  17.637 -        glVertex3fv(cube[5]);
  17.638 -        glVertex3fv(cube[0]);
  17.639 -        glVertex3fv(cube[3]);
  17.640 -        glVertex3fv(cube[4]);
  17.641 -
  17.642 -        glColor3f(1.0, 0.0, 1.0);
  17.643 -        glVertex3fv(cube[6]);
  17.644 -        glVertex3fv(cube[1]);
  17.645 -        glVertex3fv(cube[2]);
  17.646 -        glVertex3fv(cube[7]);
  17.647 -#endif /* SHADED_CUBE */
  17.648 -
  17.649 -        glEnd();
  17.650 -
  17.651 -        glMatrixMode(GL_MODELVIEW);
  17.652 -        glRotatef(5.0, 1.0, 1.0, 1.0);
  17.653 -
  17.654 -        /* Draw 2D logo onto the 3D display */
  17.655 -        if (logo) {
  17.656 -            DrawLogoTexture();
  17.657 -        }
  17.658 -        if (logocursor) {
  17.659 -            DrawLogoCursor();
  17.660 -        }
  17.661 -
  17.662 -        SDL_GL_SwapBuffers();
  17.663 -
  17.664 -        /* Check for error conditions. */
  17.665 -        gl_error = glGetError();
  17.666 -
  17.667 -        if (gl_error != GL_NO_ERROR) {
  17.668 -            fprintf(stderr, "testgl: OpenGL error: %d\n", gl_error);
  17.669 -        }
  17.670 -
  17.671 -        sdl_error = (char *)SDL_GetError();
  17.672 -
  17.673 -        if (sdl_error[0] != '\0') {
  17.674 -            fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error);
  17.675 -            SDL_ClearError();
  17.676 -        }
  17.677 -
  17.678 -        /* Allow the user to see what's happening */
  17.679 -        if (slowly) {
  17.680 -            SDL_Delay(20);
  17.681 -        }
  17.682 -
  17.683 -        /* Check if there's a pending event. */
  17.684 -        while (SDL_PollEvent(&event)) {
  17.685 -            done |= HandleEvent(&event);
  17.686 -        }
  17.687 -        ++frames;
  17.688 -    }
  17.689 -
  17.690 -    /* Print out the frames per second */
  17.691 -    this_time = SDL_GetTicks();
  17.692 -    if (this_time != start_time) {
  17.693 -        printf("%2.2f FPS\n",
  17.694 -               ((float) frames / (this_time - start_time)) * 1000.0);
  17.695 -    }
  17.696 -
  17.697 -    if (global_image) {
  17.698 -        SDL_FreeSurface(global_image);
  17.699 -        global_image = NULL;
  17.700 -    }
  17.701 -    if (global_texture) {
  17.702 -        glDeleteTextures(1, &global_texture);
  17.703 -        global_texture = 0;
  17.704 -    }
  17.705 -    if (cursor_texture) {
  17.706 -        glDeleteTextures(1, &cursor_texture);
  17.707 -        cursor_texture = 0;
  17.708 -    }
  17.709 -
  17.710 -    /* Destroy our GL context, etc. */
  17.711 -    SDL_Quit();
  17.712 -    return (0);
  17.713 -}
  17.714 -
  17.715 -int
  17.716 -main(int argc, char *argv[])
  17.717 -{
  17.718 -    int i, logo, logocursor = 0;
  17.719 -    int numtests;
  17.720 -    int bpp = 0;
  17.721 -    int slowly;
  17.722 -    float gamma = 0.0;
  17.723 -    int noframe = 0;
  17.724 -    int fsaa = 0;
  17.725 -    int accel = -1;
  17.726 -    int sync = 0;
  17.727 -
  17.728 -    logo = 0;
  17.729 -    slowly = 0;
  17.730 -    numtests = 1;
  17.731 -    for (i = 1; argv[i]; ++i) {
  17.732 -        if (strcmp(argv[i], "-twice") == 0) {
  17.733 -            ++numtests;
  17.734 -        }
  17.735 -        if (strcmp(argv[i], "-logo") == 0) {
  17.736 -            logo = 1;
  17.737 -        }
  17.738 -        if (strcmp(argv[i], "-logocursor") == 0) {
  17.739 -            logocursor = 1;
  17.740 -        }
  17.741 -        if (strcmp(argv[i], "-slow") == 0) {
  17.742 -            slowly = 1;
  17.743 -        }
  17.744 -        if (strcmp(argv[i], "-bpp") == 0) {
  17.745 -            bpp = atoi(argv[++i]);
  17.746 -        }
  17.747 -        if (strcmp(argv[i], "-gamma") == 0) {
  17.748 -            gamma = (float) atof(argv[++i]);
  17.749 -        }
  17.750 -        if (strcmp(argv[i], "-noframe") == 0) {
  17.751 -            noframe = 1;
  17.752 -        }
  17.753 -        if (strcmp(argv[i], "-fsaa") == 0) {
  17.754 -            ++fsaa;
  17.755 -        }
  17.756 -        if (strcmp(argv[i], "-accel") == 0) {
  17.757 -            accel = atoi(argv[++i]);
  17.758 -        }
  17.759 -        if (strcmp(argv[i], "-sync") == 0) {
  17.760 -            ++sync;
  17.761 -        }
  17.762 -        if (strncmp(argv[i], "-h", 2) == 0) {
  17.763 -            printf
  17.764 -                ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-accel n] [-sync] [-fullscreen]\n",
  17.765 -                 argv[0]);
  17.766 -            exit(0);
  17.767 -        }
  17.768 -    }
  17.769 -    for (i = 0; i < numtests; ++i) {
  17.770 -        RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma,
  17.771 -                  noframe, fsaa, sync, accel);
  17.772 -    }
  17.773 -    return 0;
  17.774 -}
  17.775 -
  17.776 -#else /* HAVE_OPENGL */
  17.777 -
  17.778 -int
  17.779 -main(int argc, char *argv[])
  17.780 -{
  17.781 -    printf("No OpenGL support on this system\n");
  17.782 -    return 1;
  17.783 -}
  17.784 -
  17.785 -#endif /* HAVE_OPENGL */
    18.1 --- a/test/testime.c	Sun Jan 22 17:50:35 2012 -0500
    18.2 +++ b/test/testime.c	Sun Jan 22 18:11:41 2012 -0500
    18.3 @@ -11,6 +11,15 @@
    18.4  */
    18.5  /* A simple program to test the Input Method support in the SDL library (2.0+) */
    18.6  
    18.7 +#if 1 /* FIXME: Rework this using the 2.0 API */
    18.8 +#include <stdio.h>
    18.9 +
   18.10 +int main(int argc, char *argv[])
   18.11 +{
   18.12 +    printf("FIXME\n");
   18.13 +    return 0;
   18.14 +}
   18.15 +#else
   18.16  #include <stdlib.h>
   18.17  #include <stdio.h>
   18.18  #include <string.h>
   18.19 @@ -383,5 +392,6 @@
   18.20      CleanupVideo();
   18.21      return 0;
   18.22  }
   18.23 +#endif
   18.24  
   18.25  /* vi: set ts=4 sw=4 expandtab: */
    19.1 --- a/test/testjoystick.c	Sun Jan 22 17:50:35 2012 -0500
    19.2 +++ b/test/testjoystick.c	Sun Jan 22 18:11:41 2012 -0500
    19.3 @@ -12,6 +12,15 @@
    19.4  
    19.5  /* Simple program to test the SDL joystick routines */
    19.6  
    19.7 +#if 1 /* FIXME: Rework this using the 2.0 API */
    19.8 +#include <stdio.h>
    19.9 +
   19.10 +int main(int argc, char *argv[])
   19.11 +{
   19.12 +    printf("FIXME\n");
   19.13 +    return 0;
   19.14 +}
   19.15 +#else
   19.16  #include <stdio.h>
   19.17  #include <stdlib.h>
   19.18  #include <string.h>
   19.19 @@ -202,3 +211,4 @@
   19.20  
   19.21      return (0);
   19.22  }
   19.23 +#endif
    20.1 --- a/test/testnative.c	Sun Jan 22 17:50:35 2012 -0500
    20.2 +++ b/test/testnative.c	Sun Jan 22 18:11:41 2012 -0500
    20.3 @@ -62,7 +62,7 @@
    20.4  
    20.5      /* Set transparent pixel as the pixel at (0,0) */
    20.6      if (temp->format->palette) {
    20.7 -        SDL_SetColorKey(temp, SDL_SRCCOLORKEY, *(Uint8 *) temp->pixels);
    20.8 +        SDL_SetColorKey(temp, 1, *(Uint8 *) temp->pixels);
    20.9      }
   20.10  
   20.11      /* Create textures from the image */
    21.1 --- a/test/testoverlay.c	Sun Jan 22 17:50:35 2012 -0500
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,571 +0,0 @@
    21.4 -/*
    21.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    21.6 -
    21.7 -  This software is provided 'as-is', without any express or implied
    21.8 -  warranty.  In no event will the authors be held liable for any damages
    21.9 -  arising from the use of this software.
   21.10 -
   21.11 -  Permission is granted to anyone to use this software for any purpose,
   21.12 -  including commercial applications, and to alter it and redistribute it
   21.13 -  freely.
   21.14 -*/
   21.15 -
   21.16 -/* Bring up a window and play with it */
   21.17 -
   21.18 -#include <stdlib.h>
   21.19 -#include <stdio.h>
   21.20 -#include <string.h>
   21.21 -
   21.22 -#define BENCHMARK_SDL
   21.23 -
   21.24 -#define NOTICE(X)	printf("%s", X);
   21.25 -
   21.26 -#define WINDOW_WIDTH  640
   21.27 -#define WINDOW_HEIGHT 480
   21.28 -
   21.29 -#include "SDL.h"
   21.30 -
   21.31 -SDL_Surface *screen, *pic;
   21.32 -SDL_Overlay *overlay;
   21.33 -int scale;
   21.34 -int monochrome;
   21.35 -int luminance;
   21.36 -int w, h;
   21.37 -
   21.38 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   21.39 -static void
   21.40 -quit(int rc)
   21.41 -{
   21.42 -    SDL_Quit();
   21.43 -    exit(rc);
   21.44 -}
   21.45 -
   21.46 -/* NOTE: These RGB conversion functions are not intended for speed,
   21.47 -         only as examples.
   21.48 -*/
   21.49 -
   21.50 -void
   21.51 -RGBtoYUV(Uint8 * rgb, int *yuv, int monochrome, int luminance)
   21.52 -{
   21.53 -    if (monochrome) {
   21.54 -#if 1                           /* these are the two formulas that I found on the FourCC site... */
   21.55 -        yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
   21.56 -        yuv[1] = 128;
   21.57 -        yuv[2] = 128;
   21.58 -#else
   21.59 -        yuv[0] = (int)((0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16);
   21.60 -        yuv[1] = 128;
   21.61 -        yuv[2] = 128;
   21.62 -#endif
   21.63 -    } else {
   21.64 -#if 1                           /* these are the two formulas that I found on the FourCC site... */
   21.65 -        yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
   21.66 -        yuv[1] = (int)((rgb[2] - yuv[0]) * 0.565 + 128);
   21.67 -        yuv[2] = (int)((rgb[0] - yuv[0]) * 0.713 + 128);
   21.68 -#else
   21.69 -        yuv[0] = (int)((0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16);
   21.70 -        yuv[1] = (int)(128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]));
   21.71 -        yuv[2] = (int)(128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]));
   21.72 -#endif
   21.73 -    }
   21.74 -
   21.75 -    if (luminance != 100) {
   21.76 -        yuv[0] = yuv[0] * luminance / 100;
   21.77 -        if (yuv[0] > 255)
   21.78 -            yuv[0] = 255;
   21.79 -    }
   21.80 -
   21.81 -    /* clamp values...if you need to, we don't seem to have a need */
   21.82 -    /*
   21.83 -       for(i=0;i<3;i++)
   21.84 -       {
   21.85 -       if(yuv[i]<0)
   21.86 -       yuv[i]=0;
   21.87 -       if(yuv[i]>255)
   21.88 -       yuv[i]=255;
   21.89 -       }
   21.90 -     */
   21.91 -}
   21.92 -
   21.93 -void
   21.94 -ConvertRGBtoYV12(SDL_Surface * s, SDL_Overlay * o, int monochrome,
   21.95 -                 int luminance)
   21.96 -{
   21.97 -    int x, y;
   21.98 -    int yuv[3];
   21.99 -    Uint8 *p, *op[3];
  21.100 -
  21.101 -    SDL_LockSurface(s);
  21.102 -    SDL_LockYUVOverlay(o);
  21.103 -
  21.104 -    /* Black initialization */
  21.105 -    /*
  21.106 -       memset(o->pixels[0],0,o->pitches[0]*o->h);
  21.107 -       memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2));
  21.108 -       memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
  21.109 -     */
  21.110 -
  21.111 -    /* Convert */
  21.112 -    for (y = 0; y < s->h && y < o->h; y++) {
  21.113 -        p = ((Uint8 *) s->pixels) + s->pitch * y;
  21.114 -        op[0] = o->pixels[0] + o->pitches[0] * y;
  21.115 -        op[1] = o->pixels[1] + o->pitches[1] * (y / 2);
  21.116 -        op[2] = o->pixels[2] + o->pitches[2] * (y / 2);
  21.117 -        for (x = 0; x < s->w && x < o->w; x++) {
  21.118 -            RGBtoYUV(p, yuv, monochrome, luminance);
  21.119 -            *(op[0]++) = yuv[0];
  21.120 -            if (x % 2 == 0 && y % 2 == 0) {
  21.121 -                *(op[1]++) = yuv[2];
  21.122 -                *(op[2]++) = yuv[1];
  21.123 -            }
  21.124 -            p += s->format->BytesPerPixel;
  21.125 -        }
  21.126 -    }
  21.127 -
  21.128 -    SDL_UnlockYUVOverlay(o);
  21.129 -    SDL_UnlockSurface(s);
  21.130 -}
  21.131 -
  21.132 -void
  21.133 -ConvertRGBtoIYUV(SDL_Surface * s, SDL_Overlay * o, int monochrome,
  21.134 -                 int luminance)
  21.135 -{
  21.136 -    int x, y;
  21.137 -    int yuv[3];
  21.138 -    Uint8 *p, *op[3];
  21.139 -
  21.140 -    SDL_LockSurface(s);
  21.141 -    SDL_LockYUVOverlay(o);
  21.142 -
  21.143 -    /* Black initialization */
  21.144 -    /*
  21.145 -       memset(o->pixels[0],0,o->pitches[0]*o->h);
  21.146 -       memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2));
  21.147 -       memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
  21.148 -     */
  21.149 -
  21.150 -    /* Convert */
  21.151 -    for (y = 0; y < s->h && y < o->h; y++) {
  21.152 -        p = ((Uint8 *) s->pixels) + s->pitch * y;
  21.153 -        op[0] = o->pixels[0] + o->pitches[0] * y;
  21.154 -        op[1] = o->pixels[1] + o->pitches[1] * (y / 2);
  21.155 -        op[2] = o->pixels[2] + o->pitches[2] * (y / 2);
  21.156 -        for (x = 0; x < s->w && x < o->w; x++) {
  21.157 -            RGBtoYUV(p, yuv, monochrome, luminance);
  21.158 -            *(op[0]++) = yuv[0];
  21.159 -            if (x % 2 == 0 && y % 2 == 0) {
  21.160 -                *(op[1]++) = yuv[1];
  21.161 -                *(op[2]++) = yuv[2];
  21.162 -            }
  21.163 -            p += s->format->BytesPerPixel;
  21.164 -        }
  21.165 -    }
  21.166 -
  21.167 -    SDL_UnlockYUVOverlay(o);
  21.168 -    SDL_UnlockSurface(s);
  21.169 -}
  21.170 -
  21.171 -void
  21.172 -ConvertRGBtoUYVY(SDL_Surface * s, SDL_Overlay * o, int monochrome,
  21.173 -                 int luminance)
  21.174 -{
  21.175 -    int x, y;
  21.176 -    int yuv[3];
  21.177 -    Uint8 *p, *op;
  21.178 -
  21.179 -    SDL_LockSurface(s);
  21.180 -    SDL_LockYUVOverlay(o);
  21.181 -
  21.182 -    for (y = 0; y < s->h && y < o->h; y++) {
  21.183 -        p = ((Uint8 *) s->pixels) + s->pitch * y;
  21.184 -        op = o->pixels[0] + o->pitches[0] * y;
  21.185 -        for (x = 0; x < s->w && x < o->w; x++) {
  21.186 -            RGBtoYUV(p, yuv, monochrome, luminance);
  21.187 -            if (x % 2 == 0) {
  21.188 -                *(op++) = yuv[1];
  21.189 -                *(op++) = yuv[0];
  21.190 -                *(op++) = yuv[2];
  21.191 -            } else
  21.192 -                *(op++) = yuv[0];
  21.193 -
  21.194 -            p += s->format->BytesPerPixel;
  21.195 -        }
  21.196 -    }
  21.197 -
  21.198 -    SDL_UnlockYUVOverlay(o);
  21.199 -    SDL_UnlockSurface(s);
  21.200 -}
  21.201 -
  21.202 -void
  21.203 -ConvertRGBtoYVYU(SDL_Surface * s, SDL_Overlay * o, int monochrome,
  21.204 -                 int luminance)
  21.205 -{
  21.206 -    int x, y;
  21.207 -    int yuv[3];
  21.208 -    Uint8 *p, *op;
  21.209 -
  21.210 -    SDL_LockSurface(s);
  21.211 -    SDL_LockYUVOverlay(o);
  21.212 -
  21.213 -    for (y = 0; y < s->h && y < o->h; y++) {
  21.214 -        p = ((Uint8 *) s->pixels) + s->pitch * y;
  21.215 -        op = o->pixels[0] + o->pitches[0] * y;
  21.216 -        for (x = 0; x < s->w && x < o->w; x++) {
  21.217 -            RGBtoYUV(p, yuv, monochrome, luminance);
  21.218 -            if (x % 2 == 0) {
  21.219 -                *(op++) = yuv[0];
  21.220 -                *(op++) = yuv[2];
  21.221 -                op[1] = yuv[1];
  21.222 -            } else {
  21.223 -                *op = yuv[0];
  21.224 -                op += 2;
  21.225 -            }
  21.226 -
  21.227 -            p += s->format->BytesPerPixel;
  21.228 -        }
  21.229 -    }
  21.230 -
  21.231 -    SDL_UnlockYUVOverlay(o);
  21.232 -    SDL_UnlockSurface(s);
  21.233 -}
  21.234 -
  21.235 -void
  21.236 -ConvertRGBtoYUY2(SDL_Surface * s, SDL_Overlay * o, int monochrome,
  21.237 -                 int luminance)
  21.238 -{
  21.239 -    int x, y;
  21.240 -    int yuv[3];
  21.241 -    Uint8 *p, *op;
  21.242 -
  21.243 -    SDL_LockSurface(s);
  21.244 -    SDL_LockYUVOverlay(o);
  21.245 -
  21.246 -    for (y = 0; y < s->h && y < o->h; y++) {
  21.247 -        p = ((Uint8 *) s->pixels) + s->pitch * y;
  21.248 -        op = o->pixels[0] + o->pitches[0] * y;
  21.249 -        for (x = 0; x < s->w && x < o->w; x++) {
  21.250 -            RGBtoYUV(p, yuv, monochrome, luminance);
  21.251 -            if (x % 2 == 0) {
  21.252 -                *(op++) = yuv[0];
  21.253 -                *(op++) = yuv[1];
  21.254 -                op[1] = yuv[2];
  21.255 -            } else {
  21.256 -                *op = yuv[0];
  21.257 -                op += 2;
  21.258 -            }
  21.259 -
  21.260 -            p += s->format->BytesPerPixel;
  21.261 -        }
  21.262 -    }
  21.263 -
  21.264 -    SDL_UnlockYUVOverlay(o);
  21.265 -    SDL_UnlockSurface(s);
  21.266 -}
  21.267 -
  21.268 -void
  21.269 -Draw()
  21.270 -{
  21.271 -    SDL_Rect rect;
  21.272 -    int i;
  21.273 -    int disp;
  21.274 -
  21.275 -    if (!scale) {
  21.276 -        rect.w = overlay->w;
  21.277 -        rect.h = overlay->h;
  21.278 -        for (i = 0; i < h - rect.h && i < w - rect.w; i++) {
  21.279 -            rect.x = i;
  21.280 -            rect.y = i;
  21.281 -            SDL_DisplayYUVOverlay(overlay, &rect);
  21.282 -        }
  21.283 -    } else {
  21.284 -        rect.w = overlay->w / 2;
  21.285 -        rect.h = overlay->h / 2;
  21.286 -        rect.x = (w - rect.w) / 2;
  21.287 -        rect.y = (h - rect.h) / 2;
  21.288 -        disp = rect.y - 1;
  21.289 -        for (i = 0; i < disp; i++) {
  21.290 -            rect.w += 2;
  21.291 -            rect.h += 2;
  21.292 -            rect.x--;
  21.293 -            rect.y--;
  21.294 -            SDL_DisplayYUVOverlay(overlay, &rect);
  21.295 -        }
  21.296 -    }
  21.297 -    printf("Displayed %d times.\n", i);
  21.298 -}
  21.299 -
  21.300 -static void
  21.301 -PrintUsage(char *argv0)
  21.302 -{
  21.303 -    fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0);
  21.304 -    fprintf(stderr, "Where 'arg' is one of:\n");
  21.305 -    fprintf(stderr, "	-delay <seconds>\n");
  21.306 -    fprintf(stderr, "	-width <pixels>\n");
  21.307 -    fprintf(stderr, "	-height <pixels>\n");
  21.308 -    fprintf(stderr, "	-bpp <bits>\n");
  21.309 -    fprintf(stderr,
  21.310 -            "	-format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
  21.311 -    fprintf(stderr, "	-hw\n");
  21.312 -    fprintf(stderr, "	-flip\n");
  21.313 -    fprintf(stderr,
  21.314 -            "	-scale (test scaling features, from 50%% upto window size)\n");
  21.315 -    fprintf(stderr, "	-mono (use monochromatic RGB2YUV conversion)\n");
  21.316 -    fprintf(stderr,
  21.317 -            "	-lum <perc> (use luminance correction during RGB2YUV conversion,\n");
  21.318 -    fprintf(stderr,
  21.319 -            "	             from 0%% to unlimited, normal is 100%%)\n");
  21.320 -    fprintf(stderr, "	-help (shows this help)\n");
  21.321 -    fprintf(stderr, "	-fullscreen (test overlay in fullscreen mode)\n");
  21.322 -}
  21.323 -
  21.324 -int
  21.325 -main(int argc, char **argv)
  21.326 -{
  21.327 -    char *argv0 = argv[0];
  21.328 -    int flip;
  21.329 -    int delay;
  21.330 -    int desired_bpp;
  21.331 -    Uint32 video_flags, overlay_format;
  21.332 -    char *bmpfile;
  21.333 -#ifdef BENCHMARK_SDL
  21.334 -    Uint32 then, now;
  21.335 -#endif
  21.336 -    int i;
  21.337 -
  21.338 -    /* Set default options and check command-line */
  21.339 -    flip = 0;
  21.340 -    scale = 0;
  21.341 -    monochrome = 0;
  21.342 -    luminance = 100;
  21.343 -    delay = 1;
  21.344 -    w = WINDOW_WIDTH;
  21.345 -    h = WINDOW_HEIGHT;
  21.346 -    desired_bpp = 0;
  21.347 -    video_flags = 0;
  21.348 -    overlay_format = SDL_YV12_OVERLAY;
  21.349 -
  21.350 -    while (argc > 1) {
  21.351 -        if (strcmp(argv[1], "-delay") == 0) {
  21.352 -            if (argv[2]) {
  21.353 -                delay = atoi(argv[2]);
  21.354 -                argv += 2;
  21.355 -                argc -= 2;
  21.356 -            } else {
  21.357 -                fprintf(stderr, "The -delay option requires an argument\n");
  21.358 -                return (1);
  21.359 -            }
  21.360 -        } else if (strcmp(argv[1], "-width") == 0) {
  21.361 -            if (argv[2] && ((w = atoi(argv[2])) > 0)) {
  21.362 -                argv += 2;
  21.363 -                argc -= 2;
  21.364 -            } else {
  21.365 -                fprintf(stderr, "The -width option requires an argument\n");
  21.366 -                return (1);
  21.367 -            }
  21.368 -        } else if (strcmp(argv[1], "-height") == 0) {
  21.369 -            if (argv[2] && ((h = atoi(argv[2])) > 0)) {
  21.370 -                argv += 2;
  21.371 -                argc -= 2;
  21.372 -            } else {
  21.373 -                fprintf(stderr, "The -height option requires an argument\n");
  21.374 -                return (1);
  21.375 -            }
  21.376 -        } else if (strcmp(argv[1], "-bpp") == 0) {
  21.377 -            if (argv[2]) {
  21.378 -                desired_bpp = atoi(argv[2]);
  21.379 -                argv += 2;
  21.380 -                argc -= 2;
  21.381 -            } else {
  21.382 -                fprintf(stderr, "The -bpp option requires an argument\n");
  21.383 -                return (1);
  21.384 -            }
  21.385 -        } else if (strcmp(argv[1], "-lum") == 0) {
  21.386 -            if (argv[2]) {
  21.387 -                luminance = atoi(argv[2]);
  21.388 -                argv += 2;
  21.389 -                argc -= 2;
  21.390 -            } else {
  21.391 -                fprintf(stderr, "The -lum option requires an argument\n");
  21.392 -                return (1);
  21.393 -            }
  21.394 -        } else if (strcmp(argv[1], "-format") == 0) {
  21.395 -            if (argv[2]) {
  21.396 -                if (!strcmp(argv[2], "YV12"))
  21.397 -                    overlay_format = SDL_YV12_OVERLAY;
  21.398 -                else if (!strcmp(argv[2], "IYUV"))
  21.399 -                    overlay_format = SDL_IYUV_OVERLAY;
  21.400 -                else if (!strcmp(argv[2], "YUY2"))
  21.401 -                    overlay_format = SDL_YUY2_OVERLAY;
  21.402 -                else if (!strcmp(argv[2], "UYVY"))
  21.403 -                    overlay_format = SDL_UYVY_OVERLAY;
  21.404 -                else if (!strcmp(argv[2], "YVYU"))
  21.405 -                    overlay_format = SDL_YVYU_OVERLAY;
  21.406 -                else {
  21.407 -                    fprintf(stderr,
  21.408 -                            "The -format option %s is not recognized\n",
  21.409 -                            argv[2]);
  21.410 -                    return (1);
  21.411 -                }
  21.412 -                argv += 2;
  21.413 -                argc -= 2;
  21.414 -            } else {
  21.415 -                fprintf(stderr, "The -format option requires an argument\n");
  21.416 -                return (1);
  21.417 -            }
  21.418 -        } else if (strcmp(argv[1], "-hw") == 0) {
  21.419 -            video_flags |= SDL_HWSURFACE;
  21.420 -            argv += 1;
  21.421 -            argc -= 1;
  21.422 -        } else if (strcmp(argv[1], "-flip") == 0) {
  21.423 -            video_flags |= SDL_DOUBLEBUF;
  21.424 -            argv += 1;
  21.425 -            argc -= 1;
  21.426 -        } else if (strcmp(argv[1], "-scale") == 0) {
  21.427 -            scale = 1;
  21.428 -            argv += 1;
  21.429 -            argc -= 1;
  21.430 -        } else if (strcmp(argv[1], "-mono") == 0) {
  21.431 -            monochrome = 1;
  21.432 -            argv += 1;
  21.433 -            argc -= 1;
  21.434 -        } else if ((strcmp(argv[1], "-help") == 0)
  21.435 -                   || (strcmp(argv[1], "-h") == 0)) {
  21.436 -            PrintUsage(argv0);
  21.437 -            return (1);
  21.438 -        } else if (strcmp(argv[1], "-fullscreen") == 0) {
  21.439 -            video_flags |= SDL_FULLSCREEN;
  21.440 -            argv += 1;
  21.441 -            argc -= 1;
  21.442 -        } else
  21.443 -            break;
  21.444 -    }
  21.445 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  21.446 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
  21.447 -        return (1);
  21.448 -    }
  21.449 -
  21.450 -    /* Initialize the display */
  21.451 -    screen = SDL_SetVideoMode(w, h, desired_bpp, video_flags);
  21.452 -    if (screen == NULL) {
  21.453 -        fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
  21.454 -                w, h, desired_bpp, SDL_GetError());
  21.455 -        quit(1);
  21.456 -    }
  21.457 -    printf("Set%s %dx%dx%d mode\n",
  21.458 -           screen->flags & SDL_FULLSCREEN ? " fullscreen" : "",
  21.459 -           screen->w, screen->h, screen->format->BitsPerPixel);
  21.460 -    printf("(video surface located in %s memory)\n",
  21.461 -           (screen->flags & SDL_HWSURFACE) ? "video" : "system");
  21.462 -    if (screen->flags & SDL_DOUBLEBUF) {
  21.463 -        printf("Double-buffering enabled\n");
  21.464 -        flip = 1;
  21.465 -    }
  21.466 -
  21.467 -    /* Set the window manager title bar */
  21.468 -    SDL_WM_SetCaption("SDL test overlay", "testoverlay");
  21.469 -
  21.470 -    /* Load picture */
  21.471 -    bmpfile = (argv[1] ? argv[1] : "sample.bmp");
  21.472 -    pic = SDL_LoadBMP(bmpfile);
  21.473 -    if (pic == NULL) {
  21.474 -        fprintf(stderr, "Couldn't load %s: %s\n", bmpfile, SDL_GetError());
  21.475 -        quit(1);
  21.476 -    }
  21.477 -
  21.478 -    /* Convert the picture to 32bits, for easy conversion */
  21.479 -    {
  21.480 -        SDL_Surface *newsurf;
  21.481 -        SDL_PixelFormat format;
  21.482 -
  21.483 -        format.palette = NULL;
  21.484 -        format.BitsPerPixel = 32;
  21.485 -        format.BytesPerPixel = 4;
  21.486 -#if SDL_BYTEORDER == SDL_LIL_ENDIAN
  21.487 -        format.Rshift = 0;
  21.488 -        format.Gshift = 8;
  21.489 -        format.Bshift = 16;
  21.490 -#else
  21.491 -        format.Rshift = 24;
  21.492 -        format.Gshift = 16;
  21.493 -        format.Bshift = 8;
  21.494 -#endif
  21.495 -        format.Ashift = 0;
  21.496 -        format.Rmask = 0xff << format.Rshift;
  21.497 -        format.Gmask = 0xff << format.Gshift;
  21.498 -        format.Bmask = 0xff << format.Bshift;
  21.499 -        format.Amask = 0;
  21.500 -        format.Rloss = 0;
  21.501 -        format.Gloss = 0;
  21.502 -        format.Bloss = 0;
  21.503 -        format.Aloss = 8;
  21.504 -
  21.505 -        newsurf = SDL_ConvertSurface(pic, &format, SDL_SWSURFACE);
  21.506 -        if (!newsurf) {
  21.507 -            fprintf(stderr, "Couldn't convert picture to 32bits RGB: %s\n",
  21.508 -                    SDL_GetError());
  21.509 -            quit(1);
  21.510 -        }
  21.511 -        SDL_FreeSurface(pic);
  21.512 -        pic = newsurf;
  21.513 -    }
  21.514 -
  21.515 -    /* Create the overlay */
  21.516 -    overlay = SDL_CreateYUVOverlay(pic->w, pic->h, overlay_format, screen);
  21.517 -    if (overlay == NULL) {
  21.518 -        fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError());
  21.519 -        quit(1);
  21.520 -    }
  21.521 -    printf("Created %dx%dx%d %s %s overlay\n", overlay->w, overlay->h,
  21.522 -           overlay->planes, overlay->hw_overlay ? "hardware" : "software",
  21.523 -           overlay->format == SDL_YV12_OVERLAY ? "YV12" : overlay->format ==
  21.524 -           SDL_IYUV_OVERLAY ? "IYUV" : overlay->format ==
  21.525 -           SDL_YUY2_OVERLAY ? "YUY2" : overlay->format ==
  21.526 -           SDL_UYVY_OVERLAY ? "UYVY" : overlay->format ==
  21.527 -           SDL_YVYU_OVERLAY ? "YVYU" : "Unknown");
  21.528 -    for (i = 0; i < overlay->planes; i++) {
  21.529 -        printf("  plane %d: pitch=%d\n", i, overlay->pitches[i]);
  21.530 -    }
  21.531 -
  21.532 -    /* Convert to YUV, and draw to the overlay */
  21.533 -#ifdef BENCHMARK_SDL
  21.534 -    then = SDL_GetTicks();
  21.535 -#endif
  21.536 -    switch (overlay->format) {
  21.537 -    case SDL_YV12_OVERLAY:
  21.538 -        ConvertRGBtoYV12(pic, overlay, monochrome, luminance);
  21.539 -        break;
  21.540 -    case SDL_UYVY_OVERLAY:
  21.541 -        ConvertRGBtoUYVY(pic, overlay, monochrome, luminance);
  21.542 -        break;
  21.543 -    case SDL_YVYU_OVERLAY:
  21.544 -        ConvertRGBtoYVYU(pic, overlay, monochrome, luminance);
  21.545 -        break;
  21.546 -    case SDL_YUY2_OVERLAY:
  21.547 -        ConvertRGBtoYUY2(pic, overlay, monochrome, luminance);
  21.548 -        break;
  21.549 -    case SDL_IYUV_OVERLAY:
  21.550 -        ConvertRGBtoIYUV(pic, overlay, monochrome, luminance);
  21.551 -        break;
  21.552 -    default:
  21.553 -        printf("cannot convert RGB picture to obtained YUV format!\n");
  21.554 -        quit(1);
  21.555 -        break;
  21.556 -    }
  21.557 -#ifdef BENCHMARK_SDL
  21.558 -    now = SDL_GetTicks();
  21.559 -    printf("Conversion Time: %d milliseconds\n", now - then);
  21.560 -#endif
  21.561 -
  21.562 -    /* Do all the drawing work */
  21.563 -#ifdef BENCHMARK_SDL
  21.564 -    then = SDL_GetTicks();
  21.565 -#endif
  21.566 -    Draw();
  21.567 -#ifdef BENCHMARK_SDL
  21.568 -    now = SDL_GetTicks();
  21.569 -    printf("Time: %d milliseconds\n", now - then);
  21.570 -#endif
  21.571 -    SDL_Delay(delay * 1000);
  21.572 -    SDL_Quit();
  21.573 -    return (0);
  21.574 -}
    22.1 --- a/test/testoverlay2.c	Sun Jan 22 17:50:35 2012 -0500
    22.2 +++ b/test/testoverlay2.c	Sun Jan 22 18:11:41 2012 -0500
    22.3 @@ -16,6 +16,15 @@
    22.4   *                                                                              *
    22.5   ********************************************************************************/
    22.6  
    22.7 +#if 1 /* FIXME: Rework this using the 2.0 API */
    22.8 +#include <stdio.h>
    22.9 +
   22.10 +int main(int argc, char *argv[])
   22.11 +{
   22.12 +    printf("FIXME\n");
   22.13 +    return 0;
   22.14 +}
   22.15 +#else
   22.16  #include <stdlib.h>
   22.17  #include <stdio.h>
   22.18  #include <string.h>
   22.19 @@ -591,5 +600,6 @@
   22.20      quit(0);
   22.21      return 0;
   22.22  }
   22.23 +#endif
   22.24  
   22.25  /* vi: set ts=4 sw=4 expandtab: */
    23.1 --- a/test/testshader.c	Sun Jan 22 17:50:35 2012 -0500
    23.2 +++ b/test/testshader.c	Sun Jan 22 18:11:41 2012 -0500
    23.3 @@ -11,6 +11,15 @@
    23.4  */
    23.5  /* This is a simple example of using GLSL shaders with SDL */
    23.6  
    23.7 +#if 1 /* FIXME: Rework this using the 2.0 API */
    23.8 +#include <stdio.h>
    23.9 +
   23.10 +int main(int argc, char *argv[])
   23.11 +{
   23.12 +    printf("FIXME\n");
   23.13 +    return 0;
   23.14 +}
   23.15 +#else
   23.16  #include "SDL.h"
   23.17  
   23.18  #ifdef HAVE_OPENGL
   23.19 @@ -494,5 +503,6 @@
   23.20  }
   23.21  
   23.22  #endif /* HAVE_OPENGL */
   23.23 +#endif
   23.24  
   23.25  /* vi: set ts=4 sw=4 expandtab: */
    24.1 --- a/test/testsprite.c	Sun Jan 22 17:50:35 2012 -0500
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,339 +0,0 @@
    24.4 -/*
    24.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    24.6 -
    24.7 -  This software is provided 'as-is', without any express or implied
    24.8 -  warranty.  In no event will the authors be held liable for any damages
    24.9 -  arising from the use of this software.
   24.10 -
   24.11 -  Permission is granted to anyone to use this software for any purpose,
   24.12 -  including commercial applications, and to alter it and redistribute it
   24.13 -  freely.
   24.14 -*/
   24.15 -/* Simple program:  Move N sprites around on the screen as fast as possible */
   24.16 -
   24.17 -#include <stdlib.h>
   24.18 -#include <stdio.h>
   24.19 -#include <string.h>
   24.20 -#include <ctype.h>
   24.21 -#include <time.h>
   24.22 -#include <math.h>
   24.23 -
   24.24 -#include "SDL.h"
   24.25 -
   24.26 -#define NUM_SPRITES	100
   24.27 -#define MAX_SPEED 	1
   24.28 -
   24.29 -SDL_Surface *sprite;
   24.30 -int numsprites;
   24.31 -SDL_Rect *sprite_rects;
   24.32 -SDL_Rect *positions;
   24.33 -SDL_Rect *velocities;
   24.34 -int sprites_visible;
   24.35 -int debug_flip;
   24.36 -Uint16 sprite_w, sprite_h;
   24.37 -
   24.38 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   24.39 -static void
   24.40 -quit(int rc)
   24.41 -{
   24.42 -    SDL_Quit();
   24.43 -    exit(rc);
   24.44 -}
   24.45 -
   24.46 -int
   24.47 -LoadSprite(char *file)
   24.48 -{
   24.49 -    SDL_Surface *temp;
   24.50 -
   24.51 -    /* Load the sprite image */
   24.52 -    sprite = SDL_LoadBMP(file);
   24.53 -    if (sprite == NULL) {
   24.54 -        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
   24.55 -        return (-1);
   24.56 -    }
   24.57 -
   24.58 -    /* Set transparent pixel as the pixel at (0,0) */
   24.59 -    if (sprite->format->palette) {
   24.60 -        SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY | SDL_RLEACCEL),
   24.61 -                        *(Uint8 *) sprite->pixels);
   24.62 -    }
   24.63 -
   24.64 -    /* Convert sprite to video format */
   24.65 -    temp = SDL_DisplayFormat(sprite);
   24.66 -    SDL_FreeSurface(sprite);
   24.67 -    if (temp == NULL) {
   24.68 -        fprintf(stderr, "Couldn't convert background: %s\n", SDL_GetError());
   24.69 -        return (-1);
   24.70 -    }
   24.71 -    sprite = temp;
   24.72 -
   24.73 -    /* We're ready to roll. :) */
   24.74 -    return (0);
   24.75 -}
   24.76 -
   24.77 -void
   24.78 -MoveSprites(SDL_Surface * screen, Uint32 background)
   24.79 -{
   24.80 -    int i, nupdates;
   24.81 -    SDL_Rect area, *position, *velocity;
   24.82 -
   24.83 -    nupdates = 0;
   24.84 -    /* Erase all the sprites if necessary */
   24.85 -    if (sprites_visible) {
   24.86 -        SDL_FillRect(screen, NULL, background);
   24.87 -    }
   24.88 -
   24.89 -    /* Move the sprite, bounce at the wall, and draw */
   24.90 -    for (i = 0; i < numsprites; ++i) {
   24.91 -        position = &positions[i];
   24.92 -        velocity = &velocities[i];
   24.93 -        position->x += velocity->x;
   24.94 -        if ((position->x < 0) || (position->x >= (screen->w - sprite_w))) {
   24.95 -            velocity->x = -velocity->x;
   24.96 -            position->x += velocity->x;
   24.97 -        }
   24.98 -        position->y += velocity->y;
   24.99 -        if ((position->y < 0) || (position->y >= (screen->h - sprite_w))) {
  24.100 -            velocity->y = -velocity->y;
  24.101 -            position->y += velocity->y;
  24.102 -        }
  24.103 -
  24.104 -        /* Blit the sprite onto the screen */
  24.105 -        area = *position;
  24.106 -        SDL_BlitSurface(sprite, NULL, screen, &area);
  24.107 -        sprite_rects[nupdates++] = area;
  24.108 -    }
  24.109 -
  24.110 -    if (debug_flip) {
  24.111 -        if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
  24.112 -            static int t = 0;
  24.113 -
  24.114 -            Uint32 color = SDL_MapRGB(screen->format, 255, 0, 0);
  24.115 -            SDL_Rect r;
  24.116 -            r.x =
  24.117 -                (int)((sin((float) t * 2 * 3.1459) + 1.0) / 2.0 * (screen->w - 20));
  24.118 -            r.y = 0;
  24.119 -            r.w = 20;
  24.120 -            r.h = screen->h;
  24.121 -
  24.122 -            SDL_FillRect(screen, &r, color);
  24.123 -            t += 2;
  24.124 -        }
  24.125 -    }
  24.126 -
  24.127 -    /* Update the screen! */
  24.128 -    if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
  24.129 -        SDL_Flip(screen);
  24.130 -    } else {
  24.131 -        SDL_UpdateRects(screen, nupdates, sprite_rects);
  24.132 -    }
  24.133 -    sprites_visible = 1;
  24.134 -}
  24.135 -
  24.136 -/* This is a way of telling whether or not to use hardware surfaces */
  24.137 -Uint32
  24.138 -FastestFlags(Uint32 flags, int width, int height, int bpp)
  24.139 -{
  24.140 -    const SDL_VideoInfo *info;
  24.141 -
  24.142 -    /* Hardware acceleration is only used in fullscreen mode */
  24.143 -    flags |= SDL_FULLSCREEN;
  24.144 -
  24.145 -    /* Check for various video capabilities */
  24.146 -    info = SDL_GetVideoInfo();
  24.147 -    if (info->blit_hw_CC && info->blit_fill) {
  24.148 -        /* We use accelerated colorkeying and color filling */
  24.149 -        flags |= SDL_HWSURFACE;
  24.150 -    }
  24.151 -    /* If we have enough video memory, and will use accelerated
  24.152 -       blits directly to it, then use page flipping.
  24.153 -     */
  24.154 -    if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
  24.155 -        /* Direct hardware blitting without double-buffering
  24.156 -           causes really bad flickering.
  24.157 -         */
  24.158 -        if (info->video_mem * 1024 > (Uint32)(height * width * bpp / 8)) {
  24.159 -            flags |= SDL_DOUBLEBUF;
  24.160 -        } else {
  24.161 -            flags &= ~SDL_HWSURFACE;
  24.162 -        }
  24.163 -    }
  24.164 -
  24.165 -    /* Return the flags */
  24.166 -    return (flags);
  24.167 -}
  24.168 -
  24.169 -int
  24.170 -main(int argc, char *argv[])
  24.171 -{
  24.172 -    SDL_Surface *screen;
  24.173 -    Uint8 *mem;
  24.174 -    int width, height;
  24.175 -    Uint8 video_bpp;
  24.176 -    Uint32 videoflags;
  24.177 -    Uint32 background;
  24.178 -    int i, done;
  24.179 -    SDL_Event event;
  24.180 -    Uint32 then, now, frames;
  24.181 -
  24.182 -    /* Initialize SDL */
  24.183 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  24.184 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
  24.185 -        return (1);
  24.186 -    }
  24.187 -
  24.188 -    numsprites = NUM_SPRITES;
  24.189 -    videoflags = SDL_SWSURFACE | SDL_ANYFORMAT | SDL_RESIZABLE;
  24.190 -    width = 640;
  24.191 -    height = 480;
  24.192 -    video_bpp = 8;
  24.193 -    debug_flip = 0;
  24.194 -    while (argc > 1) {
  24.195 -        --argc;
  24.196 -        if (strcmp(argv[argc - 1], "-width") == 0) {
  24.197 -            width = atoi(argv[argc]);
  24.198 -            --argc;
  24.199 -        } else if (strcmp(argv[argc - 1], "-height") == 0) {
  24.200 -            height = atoi(argv[argc]);
  24.201 -            --argc;
  24.202 -        } else if (strcmp(argv[argc - 1], "-bpp") == 0) {
  24.203 -            video_bpp = atoi(argv[argc]);
  24.204 -            videoflags &= ~SDL_ANYFORMAT;
  24.205 -            --argc;
  24.206 -        } else if (strcmp(argv[argc], "-fast") == 0) {
  24.207 -            videoflags = FastestFlags(videoflags, width, height, video_bpp);
  24.208 -        } else if (strcmp(argv[argc], "-hw") == 0) {
  24.209 -            videoflags ^= SDL_HWSURFACE;
  24.210 -        } else if (strcmp(argv[argc], "-flip") == 0) {
  24.211 -            videoflags ^= SDL_DOUBLEBUF;
  24.212 -        } else if (strcmp(argv[argc], "-debugflip") == 0) {
  24.213 -            debug_flip ^= 1;
  24.214 -        } else if (strcmp(argv[argc], "-fullscreen") == 0) {
  24.215 -            videoflags ^= SDL_FULLSCREEN;
  24.216 -        } else if (isdigit(argv[argc][0])) {
  24.217 -            numsprites = atoi(argv[argc]);
  24.218 -        } else {
  24.219 -            fprintf(stderr,
  24.220 -                    "Usage: %s [-bpp N] [-hw] [-flip] [-fast] [-fullscreen] [numsprites]\n",
  24.221 -                    argv[0]);
  24.222 -            quit(1);
  24.223 -        }
  24.224 -    }
  24.225 -
  24.226 -    /* Set video mode */
  24.227 -    screen = SDL_SetVideoMode(width, height, video_bpp, videoflags);
  24.228 -    if (!screen) {
  24.229 -        fprintf(stderr, "Couldn't set %dx%d video mode: %s\n",
  24.230 -                width, height, SDL_GetError());
  24.231 -        quit(2);
  24.232 -    }
  24.233 -
  24.234 -    /* Load the sprite */
  24.235 -    if (LoadSprite("icon.bmp") < 0) {
  24.236 -        quit(1);
  24.237 -    }
  24.238 -
  24.239 -    /* Allocate memory for the sprite info */
  24.240 -    mem = (Uint8 *) malloc(4 * sizeof(SDL_Rect) * numsprites);
  24.241 -    if (mem == NULL) {
  24.242 -        SDL_FreeSurface(sprite);
  24.243 -        fprintf(stderr, "Out of memory!\n");
  24.244 -        quit(2);
  24.245 -    }
  24.246 -    sprite_rects = (SDL_Rect *) mem;
  24.247 -    positions = sprite_rects;
  24.248 -    sprite_rects += numsprites;
  24.249 -    velocities = sprite_rects;
  24.250 -    sprite_rects += numsprites;
  24.251 -    sprite_w = sprite->w;
  24.252 -    sprite_h = sprite->h;
  24.253 -    srand((unsigned int)time(NULL));
  24.254 -    for (i = 0; i < numsprites; ++i) {
  24.255 -        positions[i].x = rand() % (screen->w - sprite_w);
  24.256 -        positions[i].y = rand() % (screen->h - sprite_h);
  24.257 -        positions[i].w = sprite->w;
  24.258 -        positions[i].h = sprite->h;
  24.259 -        velocities[i].x = 0;
  24.260 -        velocities[i].y = 0;
  24.261 -        while (!velocities[i].x && !velocities[i].y) {
  24.262 -            velocities[i].x = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
  24.263 -            velocities[i].y = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
  24.264 -        }
  24.265 -    }
  24.266 -
  24.267 -    /* Clear the background to grey */
  24.268 -    background = SDL_MapRGB(screen->format, 0xA0, 0xA0, 0xA0);
  24.269 -    SDL_FillRect(screen, NULL, background);
  24.270 -    SDL_Flip(screen);
  24.271 -
  24.272 -    /* Print out information about our surfaces */
  24.273 -    printf("Screen is at %d bits per pixel\n", screen->format->BitsPerPixel);
  24.274 -    if ((screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
  24.275 -        printf("Screen is in video memory\n");
  24.276 -    } else {
  24.277 -        printf("Screen is in system memory\n");
  24.278 -    }
  24.279 -    if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
  24.280 -        printf("Screen has double-buffering enabled\n");
  24.281 -    }
  24.282 -    if ((sprite->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
  24.283 -        printf("Sprite is in video memory\n");
  24.284 -    } else {
  24.285 -        printf("Sprite is in system memory\n");
  24.286 -    }
  24.287 -    /* Run a sample blit to trigger blit acceleration */
  24.288 -    {
  24.289 -        SDL_Rect dst;
  24.290 -        dst.x = 0;
  24.291 -        dst.y = 0;
  24.292 -        dst.w = sprite->w;
  24.293 -        dst.h = sprite->h;
  24.294 -        SDL_BlitSurface(sprite, NULL, screen, &dst);
  24.295 -        SDL_FillRect(screen, &dst, background);
  24.296 -    }
  24.297 -    if ((sprite->flags & SDL_HWACCEL) == SDL_HWACCEL) {
  24.298 -        printf("Sprite blit uses hardware acceleration\n");
  24.299 -    }
  24.300 -    if ((sprite->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
  24.301 -        printf("Sprite blit uses RLE acceleration\n");
  24.302 -    }
  24.303 -
  24.304 -    /* Loop, blitting sprites and waiting for a keystroke */
  24.305 -    frames = 0;
  24.306 -    then = SDL_GetTicks();
  24.307 -    done = 0;
  24.308 -    sprites_visible = 0;
  24.309 -    while (!done) {
  24.310 -        /* Check for events */
  24.311 -        ++frames;
  24.312 -        while (SDL_PollEvent(&event)) {
  24.313 -            switch (event.type) {
  24.314 -            case SDL_VIDEORESIZE:
  24.315 -                screen = SDL_SetVideoMode(event.resize.w, event.resize.h, video_bpp, videoflags);
  24.316 -                break;
  24.317 -            case SDL_MOUSEBUTTONDOWN:
  24.318 -                SDL_WarpMouse(screen->w / 2, screen->h / 2);
  24.319 -                break;
  24.320 -            case SDL_KEYDOWN:
  24.321 -                /* Any keypress quits the app... */
  24.322 -            case SDL_QUIT:
  24.323 -                done = 1;
  24.324 -                break;
  24.325 -            default:
  24.326 -                break;
  24.327 -            }
  24.328 -        }
  24.329 -        MoveSprites(screen, background);
  24.330 -    }
  24.331 -    SDL_FreeSurface(sprite);
  24.332 -    free(mem);
  24.333 -
  24.334 -    /* Print out some timing information */
  24.335 -    now = SDL_GetTicks();
  24.336 -    if (now > then) {
  24.337 -        double fps = ((double) frames * 1000) / (now - then);
  24.338 -        printf("%2.2f frames per second\n", fps);
  24.339 -    }
  24.340 -    SDL_Quit();
  24.341 -    return (0);
  24.342 -}
    25.1 --- a/test/testtimer.c	Sun Jan 22 17:50:35 2012 -0500
    25.2 +++ b/test/testtimer.c	Sun Jan 22 18:11:41 2012 -0500
    25.3 @@ -14,6 +14,15 @@
    25.4     platform
    25.5  */
    25.6  
    25.7 +#if 1 /* FIXME: Rework this using the 2.0 API */
    25.8 +#include <stdio.h>
    25.9 +
   25.10 +int main(int argc, char *argv[])
   25.11 +{
   25.12 +    printf("FIXME\n");
   25.13 +    return 0;
   25.14 +}
   25.15 +#else
   25.16  #include <stdlib.h>
   25.17  #include <stdio.h>
   25.18  
   25.19 @@ -107,5 +116,6 @@
   25.20      SDL_Quit();
   25.21      return (0);
   25.22  }
   25.23 +#endif
   25.24  
   25.25  /* vi: set ts=4 sw=4 expandtab: */
    26.1 --- a/test/testvidinfo.c	Sun Jan 22 17:50:35 2012 -0500
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,546 +0,0 @@
    26.4 -/*
    26.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    26.6 -
    26.7 -  This software is provided 'as-is', without any express or implied
    26.8 -  warranty.  In no event will the authors be held liable for any damages
    26.9 -  arising from the use of this software.
   26.10 -
   26.11 -  Permission is granted to anyone to use this software for any purpose,
   26.12 -  including commercial applications, and to alter it and redistribute it
   26.13 -  freely.
   26.14 -*/
   26.15 -
   26.16 -/* Simple program -- figure out what kind of video display we have */
   26.17 -
   26.18 -#include <stdlib.h>
   26.19 -#include <stdio.h>
   26.20 -#include <stdlib.h>
   26.21 -#include <string.h>
   26.22 -
   26.23 -#include "SDL.h"
   26.24 -
   26.25 -#define NUM_BLITS	10
   26.26 -#define NUM_UPDATES	500
   26.27 -
   26.28 -#define FLAG_MASK	(SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF | \
   26.29 -                         SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCEL  | \
   26.30 -                         SDL_RLEACCELOK)
   26.31 -
   26.32 -#if 0
   26.33 -void
   26.34 -PrintFlags(Uint32 flags)
   26.35 -{
   26.36 -    printf("0x%8.8x", (flags & FLAG_MASK));
   26.37 -    if (flags & SDL_HWSURFACE) {
   26.38 -        printf(" SDL_HWSURFACE");
   26.39 -    } else {
   26.40 -        printf(" SDL_SWSURFACE");
   26.41 -    }
   26.42 -    if (flags & SDL_FULLSCREEN) {
   26.43 -        printf(" | SDL_FULLSCREEN");
   26.44 -    }
   26.45 -    if (flags & SDL_DOUBLEBUF) {
   26.46 -        printf(" | SDL_DOUBLEBUF");
   26.47 -    }
   26.48 -    if (flags & SDL_SRCCOLORKEY) {
   26.49 -        printf(" | SDL_SRCCOLORKEY");
   26.50 -    }
   26.51 -    if (flags & SDL_SRCALPHA) {
   26.52 -        printf(" | SDL_SRCALPHA");
   26.53 -    }
   26.54 -    if (flags & SDL_RLEACCEL) {
   26.55 -        printf(" | SDL_RLEACCEL");
   26.56 -    }
   26.57 -    if (flags & SDL_RLEACCELOK) {
   26.58 -        printf(" | SDL_RLEACCELOK");
   26.59 -    }
   26.60 -}
   26.61 -
   26.62 -int
   26.63 -RunBlitTests(SDL_Surface * screen, SDL_Surface * bmp, int blitcount)
   26.64 -{
   26.65 -    int i, j;
   26.66 -    int maxx;
   26.67 -    int maxy;
   26.68 -    SDL_Rect dst;
   26.69 -
   26.70 -    maxx = (int) screen->w - bmp->w + 1;
   26.71 -    maxy = (int) screen->h - bmp->h + 1;
   26.72 -    for (i = 0; i < NUM_UPDATES; ++i) {
   26.73 -        for (j = 0; j < blitcount; ++j) {
   26.74 -            if (maxx) {
   26.75 -                dst.x = rand() % maxx;
   26.76 -            } else {
   26.77 -                dst.x = 0;
   26.78 -            }
   26.79 -            if (maxy) {
   26.80 -                dst.y = rand() % maxy;
   26.81 -            } else {
   26.82 -                dst.y = 0;
   26.83 -            }
   26.84 -            dst.w = bmp->w;
   26.85 -            dst.h = bmp->h;
   26.86 -            SDL_BlitSurface(bmp, NULL, screen, &dst);
   26.87 -        }
   26.88 -        SDL_Flip(screen);
   26.89 -    }
   26.90 -
   26.91 -    return i;
   26.92 -}
   26.93 -
   26.94 -int
   26.95 -RunModeTests(SDL_Surface * screen)
   26.96 -{
   26.97 -    Uint32 then, now;
   26.98 -    Uint32 frames;
   26.99 -    float seconds;
  26.100 -    int i;
  26.101 -    Uint8 r, g, b;
  26.102 -    SDL_Surface *bmp, *bmpcc, *tmp;
  26.103 -    SDL_Event event;
  26.104 -
  26.105 -    while (SDL_PollEvent(&event)) {
  26.106 -        if (event.type == SDL_KEYDOWN)
  26.107 -            return 0;
  26.108 -    }
  26.109 -
  26.110 -    /* First test fills and screen update speed */
  26.111 -    printf("Running color fill and fullscreen update test\n");
  26.112 -    then = SDL_GetTicks();
  26.113 -    frames = 0;
  26.114 -    for (i = 0; i < 256; ++i) {
  26.115 -        r = i;
  26.116 -        g = 0;
  26.117 -        b = 0;
  26.118 -        SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b));
  26.119 -        SDL_Flip(screen);
  26.120 -        ++frames;
  26.121 -    }
  26.122 -    for (i = 0; i < 256; ++i) {
  26.123 -        r = 0;
  26.124 -        g = i;
  26.125 -        b = 0;
  26.126 -        SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b));
  26.127 -        SDL_Flip(screen);
  26.128 -        ++frames;
  26.129 -    }
  26.130 -    for (i = 0; i < 256; ++i) {
  26.131 -        r = 0;
  26.132 -        g = 0;
  26.133 -        b = i;
  26.134 -        SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b));
  26.135 -        SDL_Flip(screen);
  26.136 -        ++frames;
  26.137 -    }
  26.138 -    now = SDL_GetTicks();
  26.139 -    seconds = (float) (now - then) / 1000.0f;
  26.140 -    if (seconds > 0.0f) {
  26.141 -        printf("%d fills and flips in %2.2f seconds, %2.2f FPS\n", frames,
  26.142 -               seconds, (float) frames / seconds);
  26.143 -    } else {
  26.144 -        printf("%d fills and flips in zero seconds!n", frames);
  26.145 -    }
  26.146 -
  26.147 -    /* clear the screen after fill test */
  26.148 -    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
  26.149 -    SDL_Flip(screen);
  26.150 -
  26.151 -    while (SDL_PollEvent(&event)) {
  26.152 -        if (event.type == SDL_KEYDOWN)
  26.153 -            return 0;
  26.154 -    }
  26.155 -
  26.156 -    /* run the generic blit test */
  26.157 -    bmp = SDL_LoadBMP("sample.bmp");
  26.158 -    if (!bmp) {
  26.159 -        printf("Couldn't load sample.bmp: %s\n", SDL_GetError());
  26.160 -        return 0;
  26.161 -    }
  26.162 -    printf("Running freshly loaded blit test: %dx%d at %d bpp, flags: ",
  26.163 -           bmp->w, bmp->h, bmp->format->BitsPerPixel);
  26.164 -    PrintFlags(bmp->flags);
  26.165 -    printf("\n");
  26.166 -    then = SDL_GetTicks();
  26.167 -    frames = RunBlitTests(screen, bmp, NUM_BLITS);
  26.168 -    now = SDL_GetTicks();
  26.169 -    seconds = (float) (now - then) / 1000.0f;
  26.170 -    if (seconds > 0.0f) {
  26.171 -        printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n",
  26.172 -               NUM_BLITS * frames, frames, seconds, (float) frames / seconds);
  26.173 -    } else {
  26.174 -        printf("%d blits / %d updates in zero seconds!\n",
  26.175 -               NUM_BLITS * frames, frames);
  26.176 -    }
  26.177 -
  26.178 -    /* clear the screen after blit test */
  26.179 -    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
  26.180 -    SDL_Flip(screen);
  26.181 -
  26.182 -    while (SDL_PollEvent(&event)) {
  26.183 -        if (event.type == SDL_KEYDOWN)
  26.184 -            return 0;
  26.185 -    }
  26.186 -
  26.187 -    /* run the colorkeyed blit test */
  26.188 -    bmpcc = SDL_LoadBMP("sample.bmp");
  26.189 -    if (!bmpcc) {
  26.190 -        printf("Couldn't load sample.bmp: %s\n", SDL_GetError());
  26.191 -        return 0;
  26.192 -    }
  26.193 -    printf("Running freshly loaded cc blit test: %dx%d at %d bpp, flags: ",
  26.194 -           bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel);
  26.195 -    SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL,
  26.196 -                    *(Uint8 *) bmpcc->pixels);
  26.197 -
  26.198 -    PrintFlags(bmpcc->flags);
  26.199 -    printf("\n");
  26.200 -    then = SDL_GetTicks();
  26.201 -    frames = RunBlitTests(screen, bmpcc, NUM_BLITS);
  26.202 -    now = SDL_GetTicks();
  26.203 -    seconds = (float) (now - then) / 1000.0f;
  26.204 -    if (seconds > 0.0f) {
  26.205 -        printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n",
  26.206 -               NUM_BLITS * frames, frames, seconds, (float) frames / seconds);
  26.207 -    } else {
  26.208 -        printf("%d cc blits / %d updates in zero seconds!\n",
  26.209 -               NUM_BLITS * frames, frames);
  26.210 -    }
  26.211 -
  26.212 -    /* clear the screen after cc blit test */
  26.213 -    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
  26.214 -    SDL_Flip(screen);
  26.215 -
  26.216 -    while (SDL_PollEvent(&event)) {
  26.217 -        if (event.type == SDL_KEYDOWN)
  26.218 -            return 0;
  26.219 -    }
  26.220 -
  26.221 -    /* run the generic blit test */
  26.222 -    tmp = bmp;
  26.223 -    bmp = SDL_DisplayFormat(bmp);
  26.224 -    SDL_FreeSurface(tmp);
  26.225 -    if (!bmp) {
  26.226 -        printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
  26.227 -        return 0;
  26.228 -    }
  26.229 -    printf("Running display format blit test: %dx%d at %d bpp, flags: ",
  26.230 -           bmp->w, bmp->h, bmp->format->BitsPerPixel);
  26.231 -    PrintFlags(bmp->flags);
  26.232 -    printf("\n");
  26.233 -    then = SDL_GetTicks();
  26.234 -    frames = RunBlitTests(screen, bmp, NUM_BLITS);
  26.235 -    now = SDL_GetTicks();
  26.236 -    seconds = (float) (now - then) / 1000.0f;
  26.237 -    if (seconds > 0.0f) {
  26.238 -        printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n",
  26.239 -               NUM_BLITS * frames, frames, seconds, (float) frames / seconds);
  26.240 -    } else {
  26.241 -        printf("%d blits / %d updates in zero seconds!\n",
  26.242 -               NUM_BLITS * frames, frames);
  26.243 -    }
  26.244 -
  26.245 -    /* clear the screen after blit test */
  26.246 -    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
  26.247 -    SDL_Flip(screen);
  26.248 -
  26.249 -    while (SDL_PollEvent(&event)) {
  26.250 -        if (event.type == SDL_KEYDOWN)
  26.251 -            return 0;
  26.252 -    }
  26.253 -
  26.254 -    /* run the colorkeyed blit test */
  26.255 -    tmp = bmpcc;
  26.256 -    bmpcc = SDL_DisplayFormat(bmpcc);
  26.257 -    SDL_FreeSurface(tmp);
  26.258 -    if (!bmpcc) {
  26.259 -        printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
  26.260 -        return 0;
  26.261 -    }
  26.262 -    printf("Running display format cc blit test: %dx%d at %d bpp, flags: ",
  26.263 -           bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel);
  26.264 -    PrintFlags(bmpcc->flags);
  26.265 -    printf("\n");
  26.266 -    then = SDL_GetTicks();
  26.267 -    frames = RunBlitTests(screen, bmpcc, NUM_BLITS);
  26.268 -    now = SDL_GetTicks();
  26.269 -    seconds = (float) (now - then) / 1000.0f;
  26.270 -    if (seconds > 0.0f) {
  26.271 -        printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n",
  26.272 -               NUM_BLITS * frames, frames, seconds, (float) frames / seconds);
  26.273 -    } else {
  26.274 -        printf("%d cc blits / %d updates in zero seconds!\n",
  26.275 -               NUM_BLITS * frames, frames);
  26.276 -    }
  26.277 -
  26.278 -    /* clear the screen after cc blit test */
  26.279 -    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
  26.280 -    SDL_Flip(screen);
  26.281 -
  26.282 -    while (SDL_PollEvent(&event)) {
  26.283 -        if (event.type == SDL_KEYDOWN)
  26.284 -            return 0;
  26.285 -    }
  26.286 -
  26.287 -    /* run the alpha blit test only if screen bpp>8 */
  26.288 -    if (bmp->format->BitsPerPixel > 8) {
  26.289 -        SDL_FreeSurface(bmp);
  26.290 -        bmp = SDL_LoadBMP("sample.bmp");
  26.291 -        SDL_SetAlpha(bmp, SDL_SRCALPHA, 85);    /* 85 - 33% alpha */
  26.292 -        tmp = bmp;
  26.293 -        bmp = SDL_DisplayFormat(bmp);
  26.294 -        SDL_FreeSurface(tmp);
  26.295 -        if (!bmp) {
  26.296 -            printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
  26.297 -            return 0;
  26.298 -        }
  26.299 -        printf
  26.300 -            ("Running display format alpha blit test: %dx%d at %d bpp, flags: ",
  26.301 -             bmp->w, bmp->h, bmp->format->BitsPerPixel);
  26.302 -        PrintFlags(bmp->flags);
  26.303 -        printf("\n");
  26.304 -        then = SDL_GetTicks();
  26.305 -        frames = RunBlitTests(screen, bmp, NUM_BLITS);
  26.306 -        now = SDL_GetTicks();
  26.307 -        seconds = (float) (now - then) / 1000.0f;
  26.308 -        if (seconds > 0.0f) {
  26.309 -            printf
  26.310 -                ("%d alpha blits / %d updates in %2.2f seconds, %2.2f FPS\n",
  26.311 -                 NUM_BLITS * frames, frames, seconds,
  26.312 -                 (float) frames / seconds);
  26.313 -        } else {
  26.314 -            printf("%d alpha blits / %d updates in zero seconds!\n",
  26.315 -                   NUM_BLITS * frames, frames);
  26.316 -        }
  26.317 -    }
  26.318 -
  26.319 -    /* clear the screen after alpha blit test */
  26.320 -    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
  26.321 -    SDL_Flip(screen);
  26.322 -
  26.323 -    while (SDL_PollEvent(&event)) {
  26.324 -        if (event.type == SDL_KEYDOWN)
  26.325 -            return 0;
  26.326 -    }
  26.327 -
  26.328 -    /* run the cc+alpha blit test only if screen bpp>8 */
  26.329 -    if (bmp->format->BitsPerPixel > 8) {
  26.330 -        SDL_FreeSurface(bmpcc);
  26.331 -        bmpcc = SDL_LoadBMP("sample.bmp");
  26.332 -        SDL_SetAlpha(bmpcc, SDL_SRCALPHA, 85);  /* 85 - 33% alpha */
  26.333 -        SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL,
  26.334 -                        *(Uint8 *) bmpcc->pixels);
  26.335 -        tmp = bmpcc;
  26.336 -        bmpcc = SDL_DisplayFormat(bmpcc);
  26.337 -        SDL_FreeSurface(tmp);
  26.338 -        if (!bmpcc) {
  26.339 -            printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
  26.340 -            return 0;
  26.341 -        }
  26.342 -        printf
  26.343 -            ("Running display format cc+alpha blit test: %dx%d at %d bpp, flags: ",
  26.344 -             bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel);
  26.345 -        PrintFlags(bmpcc->flags);
  26.346 -        printf("\n");
  26.347 -        then = SDL_GetTicks();
  26.348 -        frames = RunBlitTests(screen, bmpcc, NUM_BLITS);
  26.349 -        now = SDL_GetTicks();
  26.350 -        seconds = (float) (now - then) / 1000.0f;
  26.351 -        if (seconds > 0.0f) {
  26.352 -            printf
  26.353 -                ("%d cc+alpha blits / %d updates in %2.2f seconds, %2.2f FPS\n",
  26.354 -                 NUM_BLITS * frames, frames, seconds,
  26.355 -                 (float) frames / seconds);
  26.356 -        } else {
  26.357 -            printf("%d cc+alpha blits / %d updates in zero seconds!\n",
  26.358 -                   NUM_BLITS * frames, frames);
  26.359 -        }
  26.360 -    }
  26.361 -
  26.362 -    SDL_FreeSurface(bmpcc);
  26.363 -    SDL_FreeSurface(bmp);
  26.364 -
  26.365 -    while (SDL_PollEvent(&event)) {
  26.366 -        if (event.type == SDL_KEYDOWN)
  26.367 -            return 0;
  26.368 -    }
  26.369 -    return 1;
  26.370 -}
  26.371 -
  26.372 -void
  26.373 -RunVideoTests()
  26.374 -{
  26.375 -    static const struct
  26.376 -    {
  26.377 -        int w, h, bpp;
  26.378 -    } mode_list[] = {
  26.379 -        {
  26.380 -        640, 480, 8}, {
  26.381 -        640, 480, 16}, {
  26.382 -        640, 480, 32}, {
  26.383 -        800, 600, 8}, {
  26.384 -        800, 600, 16}, {
  26.385 -        800, 600, 32}, {
  26.386 -        1024, 768, 8}, {
  26.387 -        1024, 768, 16}, {
  26.388 -        1024, 768, 32}
  26.389 -    };
  26.390 -    static const Uint32 flags[] = {
  26.391 -        (SDL_SWSURFACE),
  26.392 -        (SDL_SWSURFACE | SDL_FULLSCREEN),
  26.393 -        (SDL_HWSURFACE | SDL_FULLSCREEN),
  26.394 -        (SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF)
  26.395 -    };
  26.396 -    int i, j;
  26.397 -    SDL_Surface *screen;
  26.398 -
  26.399 -    /* Test out several different video mode combinations */
  26.400 -    SDL_WM_SetCaption("SDL Video Benchmark", "vidtest");
  26.401 -    SDL_ShowCursor(0);
  26.402 -    for (i = 0; i < SDL_TABLESIZE(mode_list); ++i) {
  26.403 -        for (j = 0; j < SDL_TABLESIZE(flags); ++j) {
  26.404 -            printf("===================================\n");
  26.405 -            printf("Setting video mode: %dx%d at %d bpp, flags: ",
  26.406 -                   mode_list[i].w, mode_list[i].h, mode_list[i].bpp);
  26.407 -            PrintFlags(flags[j]);
  26.408 -            printf("\n");
  26.409 -            screen = SDL_SetVideoMode(mode_list[i].w,
  26.410 -                                      mode_list[i].h,
  26.411 -                                      mode_list[i].bpp, flags[j]);
  26.412 -            if (!screen) {
  26.413 -                printf("Setting video mode failed: %s\n", SDL_GetError());
  26.414 -                continue;
  26.415 -            }
  26.416 -            if ((screen->flags & FLAG_MASK) != flags[j]) {
  26.417 -                printf("Flags didn't match: ");
  26.418 -                PrintFlags(screen->flags);
  26.419 -                printf("\n");
  26.420 -                continue;
  26.421 -            }
  26.422 -            if (!RunModeTests(screen)) {
  26.423 -                return;
  26.424 -            }
  26.425 -        }
  26.426 -    }
  26.427 -}
  26.428 -#endif
  26.429 -
  26.430 -int
  26.431 -main(int argc, char *argv[])
  26.432 -{
  26.433 -    const SDL_VideoInfo *info;
  26.434 -    int i, d, n;
  26.435 -    const char *driver;
  26.436 -    SDL_DisplayMode mode;
  26.437 -    int bpp;
  26.438 -    Uint32 Rmask, Gmask, Bmask, Amask;
  26.439 -    int nmodes;
  26.440 -
  26.441 -    /* Print available video drivers */
  26.442 -    n = SDL_GetNumVideoDrivers();
  26.443 -    if (n == 0) {
  26.444 -        printf("No built-in video drivers\n");
  26.445 -    } else {
  26.446 -        printf("Built-in video drivers:");
  26.447 -        for (i = 0; i < n; ++i) {
  26.448 -            if (i > 0) {
  26.449 -                printf(",");
  26.450 -            }
  26.451 -            printf(" %s", SDL_GetVideoDriver(i));
  26.452 -        }
  26.453 -        printf("\n");
  26.454 -    }
  26.455 -
  26.456 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  26.457 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
  26.458 -        exit(1);
  26.459 -    }
  26.460 -    driver = SDL_GetCurrentVideoDriver();
  26.461 -    if (driver) {
  26.462 -        printf("Video driver: %s\n", driver);
  26.463 -    }
  26.464 -    printf("Number of displays: %d\n", SDL_GetNumVideoDisplays());
  26.465 -    for (d = 0; d < SDL_GetNumVideoDisplays(); ++d) {
  26.466 -        SDL_Rect bounds;
  26.467 -
  26.468 -        SDL_GetDisplayBounds(d, &bounds);
  26.469 -        printf("Display %d: %dx%d at %d,%d\n", d,
  26.470 -               bounds.w, bounds.h, bounds.x, bounds.y);
  26.471 -
  26.472 -        SDL_GetDesktopDisplayMode(d, &mode);
  26.473 -        SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask, &Bmask,
  26.474 -                                   &Amask);
  26.475 -        printf("  Current mode: %dx%d@%dHz, %d bits-per-pixel\n", mode.w,
  26.476 -               mode.h, mode.refresh_rate, bpp);
  26.477 -        if (Rmask || Gmask || Bmask) {
  26.478 -            printf("      Red Mask = 0x%.8x\n", Rmask);
  26.479 -            printf("      Green Mask = 0x%.8x\n", Gmask);
  26.480 -            printf("      Blue Mask = 0x%.8x\n", Bmask);
  26.481 -            if (Amask)
  26.482 -                printf("      Alpha Mask = 0x%.8x\n", Amask);
  26.483 -        }
  26.484 -
  26.485 -        /* Print available fullscreen video modes */
  26.486 -        nmodes = SDL_GetNumDisplayModes(d);
  26.487 -        if (nmodes == 0) {
  26.488 -            printf("No available fullscreen video modes\n");
  26.489 -        } else {
  26.490 -            printf("  Fullscreen video modes:\n");
  26.491 -            for (i = 0; i < nmodes; ++i) {
  26.492 -                SDL_GetDisplayMode(d, i, &mode);
  26.493 -                SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask,
  26.494 -                                           &Gmask, &Bmask, &Amask);
  26.495 -                printf("    Mode %d: %dx%d@%dHz, %d bits-per-pixel\n", i,
  26.496 -                       mode.w, mode.h, mode.refresh_rate, bpp);
  26.497 -                if (Rmask || Gmask || Bmask) {
  26.498 -                    printf("        Red Mask = 0x%.8x\n", Rmask);
  26.499 -                    printf("        Green Mask = 0x%.8x\n", Gmask);
  26.500 -                    printf("        Blue Mask = 0x%.8x\n", Bmask);
  26.501 -                    if (Amask)
  26.502 -                        printf("        Alpha Mask = 0x%.8x\n", Amask);
  26.503 -                }
  26.504 -            }
  26.505 -        }
  26.506 -    }
  26.507 -
  26.508 -    info = SDL_GetVideoInfo();
  26.509 -    if (info->wm_available) {
  26.510 -        printf("A window manager is available\n");
  26.511 -    }
  26.512 -    if (info->hw_available) {
  26.513 -        printf("Hardware surfaces are available (%dK video memory)\n",
  26.514 -               info->video_mem);
  26.515 -    }
  26.516 -    if (info->blit_hw) {
  26.517 -        printf("Copy blits between hardware surfaces are accelerated\n");
  26.518 -    }
  26.519 -    if (info->blit_hw_CC) {
  26.520 -        printf("Colorkey blits between hardware surfaces are accelerated\n");
  26.521 -    }
  26.522 -    if (info->blit_hw_A) {
  26.523 -        printf("Alpha blits between hardware surfaces are accelerated\n");
  26.524 -    }
  26.525 -    if (info->blit_sw) {
  26.526 -        printf
  26.527 -            ("Copy blits from software surfaces to hardware surfaces are accelerated\n");
  26.528 -    }
  26.529 -    if (info->blit_sw_CC) {
  26.530 -        printf
  26.531 -            ("Colorkey blits from software surfaces to hardware surfaces are accelerated\n");
  26.532 -    }
  26.533 -    if (info->blit_sw_A) {
  26.534 -        printf
  26.535 -            ("Alpha blits from software surfaces to hardware surfaces are accelerated\n");
  26.536 -    }
  26.537 -    if (info->blit_fill) {
  26.538 -        printf("Color fills on hardware surfaces are accelerated\n");
  26.539 -    }
  26.540 -    printf("Current resolution: %dx%d\n", info->current_w, info->current_h);
  26.541 -#if 0
  26.542 -    if (argv[1] && (strcmp(argv[1], "-benchmark") == 0)) {
  26.543 -        RunVideoTests();
  26.544 -    }
  26.545 -#endif
  26.546 -
  26.547 -    SDL_Quit();
  26.548 -    return (0);
  26.549 -}
    27.1 --- a/test/testwin.c	Sun Jan 22 17:50:35 2012 -0500
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,351 +0,0 @@
    27.4 -/*
    27.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    27.6 -
    27.7 -  This software is provided 'as-is', without any express or implied
    27.8 -  warranty.  In no event will the authors be held liable for any damages
    27.9 -  arising from the use of this software.
   27.10 -
   27.11 -  Permission is granted to anyone to use this software for any purpose,
   27.12 -  including commercial applications, and to alter it and redistribute it
   27.13 -  freely.
   27.14 -*/
   27.15 -
   27.16 -/* Bring up a window and play with it */
   27.17 -
   27.18 -#include <stdlib.h>
   27.19 -#include <stdio.h>
   27.20 -#include <string.h>
   27.21 -
   27.22 -#define BENCHMARK_SDL
   27.23 -
   27.24 -#define NOTICE(X)	printf("%s", X);
   27.25 -
   27.26 -#include "SDL.h"
   27.27 -
   27.28 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   27.29 -static void
   27.30 -quit(int rc)
   27.31 -{
   27.32 -    SDL_Quit();
   27.33 -    exit(rc);
   27.34 -}
   27.35 -
   27.36 -void
   27.37 -DrawPict(SDL_Surface * screen, char *bmpfile,
   27.38 -         int speedy, int flip, int nofade)
   27.39 -{
   27.40 -    SDL_Surface *picture;
   27.41 -    SDL_Rect dest, update;
   27.42 -    int i, centered;
   27.43 -    int ncolors;
   27.44 -    SDL_Color *colors, *cmap;
   27.45 -
   27.46 -    /* Load the image into a surface */
   27.47 -    if (bmpfile == NULL) {
   27.48 -        bmpfile = "sample.bmp"; /* Sample image */
   27.49 -    }
   27.50 -    fprintf(stderr, "Loading picture: %s\n", bmpfile);
   27.51 -    picture = SDL_LoadBMP(bmpfile);
   27.52 -    if (picture == NULL) {
   27.53 -        fprintf(stderr, "Couldn't load %s: %s\n", bmpfile, SDL_GetError());
   27.54 -        return;
   27.55 -    }
   27.56 -
   27.57 -    /* Set the display colors -- on a hicolor display this is a no-op */
   27.58 -    if (picture->format->palette) {
   27.59 -        ncolors = picture->format->palette->ncolors;
   27.60 -        colors = (SDL_Color *) malloc(ncolors * sizeof(SDL_Color));
   27.61 -        cmap = (SDL_Color *) malloc(ncolors * sizeof(SDL_Color));
   27.62 -        memcpy(colors, picture->format->palette->colors,
   27.63 -               ncolors * sizeof(SDL_Color));
   27.64 -    } else {
   27.65 -        int r, g, b;
   27.66 -
   27.67 -        /* Allocate 256 color palette */
   27.68 -        ncolors = 256;
   27.69 -        colors = (SDL_Color *) malloc(ncolors * sizeof(SDL_Color));
   27.70 -        cmap = (SDL_Color *) malloc(ncolors * sizeof(SDL_Color));
   27.71 -
   27.72 -        /* Set a 3,3,2 color cube */
   27.73 -        for (r = 0; r < 8; ++r) {
   27.74 -            for (g = 0; g < 8; ++g) {
   27.75 -                for (b = 0; b < 4; ++b) {
   27.76 -                    i = ((r << 5) | (g << 2) | b);
   27.77 -                    colors[i].r = r << 5;
   27.78 -                    colors[i].g = g << 5;
   27.79 -                    colors[i].b = b << 6;
   27.80 -                }
   27.81 -            }
   27.82 -        }
   27.83 -    }
   27.84 -    NOTICE("testwin: setting colors\n");
   27.85 -    if (!SDL_SetColors(screen, colors, 0, ncolors) &&
   27.86 -        (screen->format->palette != NULL)) {
   27.87 -        fprintf(stderr,
   27.88 -                "Warning: Couldn't set all of the colors, but SDL will map the image\n"
   27.89 -                "         (colormap fading will suffer - try the -warp option)\n");
   27.90 -    }
   27.91 -
   27.92 -    /* Display the picture */
   27.93 -    if (speedy) {
   27.94 -        SDL_Surface *displayfmt;
   27.95 -
   27.96 -        fprintf(stderr, "Converting picture\n");
   27.97 -        displayfmt = SDL_DisplayFormat(picture);
   27.98 -        if (displayfmt == NULL) {
   27.99 -            fprintf(stderr, "Couldn't convert image: %s\n", SDL_GetError());
  27.100 -            goto done;
  27.101 -        }
  27.102 -        SDL_FreeSurface(picture);
  27.103 -        picture = displayfmt;
  27.104 -    }
  27.105 -    printf("(image surface located in %s memory)\n",
  27.106 -           (picture->flags & SDL_HWSURFACE) ? "video" : "system");
  27.107 -    centered = (screen->w - picture->w) / 2;
  27.108 -    if (centered < 0) {
  27.109 -        centered = 0;
  27.110 -    }
  27.111 -    dest.y = (screen->h - picture->h) / 2;
  27.112 -    dest.w = picture->w;
  27.113 -    dest.h = picture->h;
  27.114 -    NOTICE("testwin: moving image\n");
  27.115 -    for (i = 0; i <= centered; ++i) {
  27.116 -        dest.x = i;
  27.117 -        update = dest;
  27.118 -        if (SDL_BlitSurface(picture, NULL, screen, &update) < 0) {
  27.119 -            fprintf(stderr, "Blit failed: %s\n", SDL_GetError());
  27.120 -            break;
  27.121 -        }
  27.122 -        if (flip) {
  27.123 -            SDL_Flip(screen);
  27.124 -        } else {
  27.125 -            SDL_UpdateRects(screen, 1, &update);
  27.126 -        }
  27.127 -    }
  27.128 -
  27.129 -#ifdef SCREENSHOT
  27.130 -    if (SDL_SaveBMP(screen, "screen.bmp") < 0)
  27.131 -        printf("Couldn't save screen: %s\n", SDL_GetError());
  27.132 -#endif
  27.133 -
  27.134 -#ifndef BENCHMARK_SDL
  27.135 -    /* Let it sit there for a while */
  27.136 -    SDL_Delay(5 * 1000);
  27.137 -#endif
  27.138 -    /* Fade the colormap */
  27.139 -    if (!nofade) {
  27.140 -        int maxstep;
  27.141 -        SDL_Color final;
  27.142 -        SDL_Color palcolors[256];
  27.143 -        struct
  27.144 -        {
  27.145 -            Sint16 r, g, b;
  27.146 -        } cdist[256];
  27.147 -
  27.148 -        NOTICE("testwin: fading out...\n");
  27.149 -        memcpy(cmap, colors, ncolors * sizeof(SDL_Color));
  27.150 -        maxstep = 32 - 1;
  27.151 -        final.r = 0xFF;
  27.152 -        final.g = 0x00;
  27.153 -        final.b = 0x00;
  27.154 -        memcpy(palcolors, colors, ncolors * sizeof(SDL_Color));
  27.155 -        for (i = 0; i < ncolors; ++i) {
  27.156 -            cdist[i].r = final.r - palcolors[i].r;
  27.157 -            cdist[i].g = final.g - palcolors[i].g;
  27.158 -            cdist[i].b = final.b - palcolors[i].b;
  27.159 -        }
  27.160 -        for (i = 0; i <= maxstep / 2; ++i) {    /* halfway fade */
  27.161 -            int c;
  27.162 -            for (c = 0; c < ncolors; ++c) {
  27.163 -                colors[c].r = palcolors[c].r + ((cdist[c].r * i)) / maxstep;
  27.164 -                colors[c].g = palcolors[c].g + ((cdist[c].g * i)) / maxstep;
  27.165 -                colors[c].b = palcolors[c].b + ((cdist[c].b * i)) / maxstep;
  27.166 -            }
  27.167 -            SDL_SetColors(screen, colors, 0, ncolors);
  27.168 -            SDL_Delay(1);
  27.169 -        }
  27.170 -        final.r = 0x00;
  27.171 -        final.g = 0x00;
  27.172 -        final.b = 0x00;
  27.173 -        memcpy(palcolors, colors, ncolors * sizeof(SDL_Color));
  27.174 -        for (i = 0; i < ncolors; ++i) {
  27.175 -            cdist[i].r = final.r - palcolors[i].r;
  27.176 -            cdist[i].g = final.g - palcolors[i].g;
  27.177 -            cdist[i].b = final.b - palcolors[i].b;
  27.178 -        }
  27.179 -        maxstep /= 2;
  27.180 -        for (i = 0; i <= maxstep; ++i) {        /* finish fade out */
  27.181 -            int c;
  27.182 -            for (c = 0; c < ncolors; ++c) {
  27.183 -                colors[c].r = palcolors[c].r + ((cdist[c].r * i)) / maxstep;
  27.184 -                colors[c].g = palcolors[c].g + ((cdist[c].g * i)) / maxstep;
  27.185 -                colors[c].b = palcolors[c].b + ((cdist[c].b * i)) / maxstep;
  27.186 -            }
  27.187 -            SDL_SetColors(screen, colors, 0, ncolors);
  27.188 -            SDL_Delay(1);
  27.189 -        }
  27.190 -        for (i = 0; i < ncolors; ++i) {
  27.191 -            colors[i].r = final.r;
  27.192 -            colors[i].g = final.g;
  27.193 -            colors[i].b = final.b;
  27.194 -        }
  27.195 -        SDL_SetColors(screen, colors, 0, ncolors);
  27.196 -        NOTICE("testwin: fading in...\n");
  27.197 -        memcpy(palcolors, colors, ncolors * sizeof(SDL_Color));
  27.198 -        for (i = 0; i < ncolors; ++i) {
  27.199 -            cdist[i].r = cmap[i].r - palcolors[i].r;
  27.200 -            cdist[i].g = cmap[i].g - palcolors[i].g;
  27.201 -            cdist[i].b = cmap[i].b - palcolors[i].b;
  27.202 -        }
  27.203 -        for (i = 0; i <= maxstep; ++i) {        /* 32 step fade in */
  27.204 -            int c;
  27.205 -            for (c = 0; c < ncolors; ++c) {
  27.206 -                colors[c].r = palcolors[c].r + ((cdist[c].r * i)) / maxstep;
  27.207 -                colors[c].g = palcolors[c].g + ((cdist[c].g * i)) / maxstep;
  27.208 -                colors[c].b = palcolors[c].b + ((cdist[c].b * i)) / maxstep;
  27.209 -            }
  27.210 -            SDL_SetColors(screen, colors, 0, ncolors);
  27.211 -            SDL_Delay(1);
  27.212 -        }
  27.213 -        NOTICE("testwin: fading over\n");
  27.214 -    }
  27.215 -
  27.216 -  done:
  27.217 -    /* Free the picture and return */
  27.218 -    SDL_FreeSurface(picture);
  27.219 -    free(colors);
  27.220 -    free(cmap);
  27.221 -    return;
  27.222 -}
  27.223 -
  27.224 -int
  27.225 -main(int argc, char *argv[])
  27.226 -{
  27.227 -    SDL_Surface *screen;
  27.228 -    /* Options */
  27.229 -    int speedy, flip, nofade;
  27.230 -    int delay;
  27.231 -    int w, h;
  27.232 -    int desired_bpp;
  27.233 -    Uint32 video_flags;
  27.234 -#ifdef BENCHMARK_SDL
  27.235 -    Uint32 then, now;
  27.236 -#endif
  27.237 -    /* Set default options and check command-line */
  27.238 -    speedy = 0;
  27.239 -    flip = 0;
  27.240 -    nofade = 0;
  27.241 -    delay = 1;
  27.242 -
  27.243 -#ifdef _WIN32_WCE
  27.244 -    w = 240;
  27.245 -    h = 320;
  27.246 -    desired_bpp = 8;
  27.247 -    video_flags = SDL_FULLSCREEN;
  27.248 -#else
  27.249 -    w = 640;
  27.250 -    h = 480;
  27.251 -    desired_bpp = 0;
  27.252 -    video_flags = 0;
  27.253 -#endif
  27.254 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  27.255 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
  27.256 -        return (1);
  27.257 -    }
  27.258 -
  27.259 -    while (argc > 1) {
  27.260 -        if (strcmp(argv[1], "-speedy") == 0) {
  27.261 -            speedy = 1;
  27.262 -            argv += 1;
  27.263 -            argc -= 1;
  27.264 -        } else if (strcmp(argv[1], "-nofade") == 0) {
  27.265 -            nofade = 1;
  27.266 -            argv += 1;
  27.267 -            argc -= 1;
  27.268 -        } else if (strcmp(argv[1], "-delay") == 0) {
  27.269 -            if (argv[2]) {
  27.270 -                delay = atoi(argv[2]);
  27.271 -                argv += 2;
  27.272 -                argc -= 2;
  27.273 -            } else {
  27.274 -                fprintf(stderr, "The -delay option requires an argument\n");
  27.275 -                quit(1);
  27.276 -            }
  27.277 -        } else if (strcmp(argv[1], "-width") == 0) {
  27.278 -            if (argv[2] && ((w = atoi(argv[2])) > 0)) {
  27.279 -                argv += 2;
  27.280 -                argc -= 2;
  27.281 -            } else {
  27.282 -                fprintf(stderr, "The -width option requires an argument\n");
  27.283 -                quit(1);
  27.284 -            }
  27.285 -        } else if (strcmp(argv[1], "-height") == 0) {
  27.286 -            if (argv[2] && ((h = atoi(argv[2])) > 0)) {
  27.287 -                argv += 2;
  27.288 -                argc -= 2;
  27.289 -            } else {
  27.290 -                fprintf(stderr, "The -height option requires an argument\n");
  27.291 -                quit(1);
  27.292 -            }
  27.293 -        } else if (strcmp(argv[1], "-bpp") == 0) {
  27.294 -            if (argv[2]) {
  27.295 -                desired_bpp = atoi(argv[2]);
  27.296 -                argv += 2;
  27.297 -                argc -= 2;
  27.298 -            } else {
  27.299 -                fprintf(stderr, "The -bpp option requires an argument\n");
  27.300 -                quit(1);
  27.301 -            }
  27.302 -        } else if (strcmp(argv[1], "-warp") == 0) {
  27.303 -            video_flags |= SDL_HWPALETTE;
  27.304 -            argv += 1;
  27.305 -            argc -= 1;
  27.306 -        } else if (strcmp(argv[1], "-hw") == 0) {
  27.307 -            video_flags |= SDL_HWSURFACE;
  27.308 -            argv += 1;
  27.309 -            argc -= 1;
  27.310 -        } else if (strcmp(argv[1], "-flip") == 0) {
  27.311 -            video_flags |= SDL_DOUBLEBUF;
  27.312 -            argv += 1;
  27.313 -            argc -= 1;
  27.314 -        } else if (strcmp(argv[1], "-fullscreen") == 0) {
  27.315 -            video_flags |= SDL_FULLSCREEN;
  27.316 -            argv += 1;
  27.317 -            argc -= 1;
  27.318 -        } else
  27.319 -            break;
  27.320 -    }
  27.321 -
  27.322 -    /* Initialize the display */
  27.323 -    screen = SDL_SetVideoMode(w, h, desired_bpp, video_flags);
  27.324 -    if (screen == NULL) {
  27.325 -        fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
  27.326 -                w, h, desired_bpp, SDL_GetError());
  27.327 -        quit(1);
  27.328 -    }
  27.329 -    printf("Set%s %dx%dx%d mode\n",
  27.330 -           screen->flags & SDL_FULLSCREEN ? " fullscreen" : "",
  27.331 -           screen->w, screen->h, screen->format->BitsPerPixel);
  27.332 -    printf("(video surface located in %s memory)\n",
  27.333 -           (screen->flags & SDL_HWSURFACE) ? "video" : "system");
  27.334 -    if (screen->flags & SDL_DOUBLEBUF) {
  27.335 -        printf("Double-buffering enabled\n");
  27.336 -        flip = 1;
  27.337 -    }
  27.338 -
  27.339 -    /* Set the window manager title bar */
  27.340 -    SDL_WM_SetCaption("SDL test window", "testwin");
  27.341 -
  27.342 -    /* Do all the drawing work */
  27.343 -#ifdef BENCHMARK_SDL
  27.344 -    then = SDL_GetTicks();
  27.345 -    DrawPict(screen, argv[1], speedy, flip, nofade);
  27.346 -    now = SDL_GetTicks();
  27.347 -    printf("Time: %d milliseconds\n", now - then);
  27.348 -#else
  27.349 -    DrawPict(screen, argv[1], speedy, flip, nofade);
  27.350 -#endif
  27.351 -    SDL_Delay(delay * 1000);
  27.352 -    SDL_Quit();
  27.353 -    return (0);
  27.354 -}
    28.1 --- a/test/testwm.c	Sun Jan 22 17:50:35 2012 -0500
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,465 +0,0 @@
    28.4 -/*
    28.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    28.6 -
    28.7 -  This software is provided 'as-is', without any express or implied
    28.8 -  warranty.  In no event will the authors be held liable for any damages
    28.9 -  arising from the use of this software.
   28.10 -
   28.11 -  Permission is granted to anyone to use this software for any purpose,
   28.12 -  including commercial applications, and to alter it and redistribute it
   28.13 -  freely.
   28.14 -*/
   28.15 -
   28.16 -/* Test out the window manager interaction functions */
   28.17 -
   28.18 -#include <stdio.h>
   28.19 -#include <stdlib.h>
   28.20 -#include <string.h>
   28.21 -
   28.22 -#include "SDL.h"
   28.23 -
   28.24 -/* Is the cursor visible? */
   28.25 -static int visible = 1;
   28.26 -
   28.27 -static Uint8 video_bpp;
   28.28 -static Uint32 video_flags;
   28.29 -
   28.30 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   28.31 -static void
   28.32 -quit(int rc)
   28.33 -{
   28.34 -    SDL_Quit();
   28.35 -    exit(rc);
   28.36 -}
   28.37 -
   28.38 -int
   28.39 -SetVideoMode(int w, int h)
   28.40 -{
   28.41 -    SDL_Surface *screen;
   28.42 -    int i;
   28.43 -    Uint8 *buffer;
   28.44 -    SDL_Color palette[256];
   28.45 -
   28.46 -    screen = SDL_SetVideoMode(w, h, video_bpp, video_flags);
   28.47 -    if (screen == NULL) {
   28.48 -        fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
   28.49 -                w, h, video_bpp, SDL_GetError());
   28.50 -        return (-1);
   28.51 -    }
   28.52 -    printf("Running in %s mode\n", screen->flags & SDL_FULLSCREEN ?
   28.53 -           "fullscreen" : "windowed");
   28.54 -
   28.55 -    /* Set the surface pixels and refresh! */
   28.56 -    for (i = 0; i < 256; ++i) {
   28.57 -        palette[i].r = 255 - i;
   28.58 -        palette[i].g = 255 - i;
   28.59 -        palette[i].b = 255 - i;
   28.60 -    }
   28.61 -    SDL_SetColors(screen, palette, 0, 256);
   28.62 -    if (SDL_LockSurface(screen) < 0) {
   28.63 -        fprintf(stderr, "Couldn't lock display surface: %s\n",
   28.64 -                SDL_GetError());
   28.65 -        return (-1);
   28.66 -    }
   28.67 -    buffer = (Uint8 *) screen->pixels;
   28.68 -    for (i = 0; i < screen->h; ++i) {
   28.69 -        memset(buffer, (i * 255) / screen->h,
   28.70 -               screen->w * screen->format->BytesPerPixel);
   28.71 -        buffer += screen->pitch;
   28.72 -    }
   28.73 -    SDL_UnlockSurface(screen);
   28.74 -    SDL_UpdateRect(screen, 0, 0, 0, 0);
   28.75 -
   28.76 -    return (0);
   28.77 -}
   28.78 -
   28.79 -SDL_Surface *
   28.80 -LoadIconSurface(char *file, Uint8 ** maskp)
   28.81 -{
   28.82 -    SDL_Surface *icon;
   28.83 -    Uint8 *pixels;
   28.84 -    Uint8 *mask;
   28.85 -    int mlen, i, j;
   28.86 -
   28.87 -    *maskp = NULL;
   28.88 -
   28.89 -    /* Load the icon surface */
   28.90 -    icon = SDL_LoadBMP(file);
   28.91 -    if (icon == NULL) {
   28.92 -        fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
   28.93 -        return (NULL);
   28.94 -    }
   28.95 -
   28.96 -    /* Check width and height 
   28.97 -       if ( (icon->w%8) != 0 ) {
   28.98 -       fprintf(stderr, "Icon width must be a multiple of 8!\n");
   28.99 -       SDL_FreeSurface(icon);
  28.100 -       return(NULL);
  28.101 -       }
  28.102 -     */
  28.103 -
  28.104 -
  28.105 -    if (icon->format->palette == NULL) {
  28.106 -        fprintf(stderr, "Icon must have a palette!\n");
  28.107 -        SDL_FreeSurface(icon);
  28.108 -        return (NULL);
  28.109 -    }
  28.110 -
  28.111 -    /* Set the colorkey */
  28.112 -    SDL_SetColorKey(icon, SDL_SRCCOLORKEY, *((Uint8 *) icon->pixels));
  28.113 -
  28.114 -    /* Create the mask */
  28.115 -    pixels = (Uint8 *) icon->pixels;
  28.116 -    printf("Transparent pixel: (%d,%d,%d)\n",
  28.117 -           icon->format->palette->colors[*pixels].r,
  28.118 -           icon->format->palette->colors[*pixels].g,
  28.119 -           icon->format->palette->colors[*pixels].b);
  28.120 -    mlen = (icon->w * icon->h + 7) / 8;
  28.121 -    mask = (Uint8 *) malloc(mlen);
  28.122 -    if (mask == NULL) {
  28.123 -        fprintf(stderr, "Out of memory!\n");
  28.124 -        SDL_FreeSurface(icon);
  28.125 -        return (NULL);
  28.126 -    }
  28.127 -    memset(mask, 0, mlen);
  28.128 -    for (i = 0; i < icon->h; i++)
  28.129 -        for (j = 0; j < icon->w; j++) {
  28.130 -            int pindex = i * icon->pitch + j;
  28.131 -            int mindex = i * icon->w + j;
  28.132 -            if (pixels[pindex] != *pixels)
  28.133 -                mask[mindex >> 3] |= 1 << (7 - (mindex & 7));
  28.134 -        }
  28.135 -    *maskp = mask;
  28.136 -    return (icon);
  28.137 -}
  28.138 -
  28.139 -void
  28.140 -HotKey_ToggleFullScreen(void)
  28.141 -{
  28.142 -    SDL_Surface *screen;
  28.143 -
  28.144 -    screen = SDL_GetVideoSurface();
  28.145 -    if (SDL_WM_ToggleFullScreen(screen)) {
  28.146 -        printf("Toggled fullscreen mode - now %s\n",
  28.147 -               (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed");
  28.148 -    } else {
  28.149 -        printf("Unable to toggle fullscreen mode\n");
  28.150 -        video_flags ^= SDL_FULLSCREEN;
  28.151 -        SetVideoMode(screen->w, screen->h);
  28.152 -    }
  28.153 -}
  28.154 -
  28.155 -void
  28.156 -HotKey_ToggleGrab(void)
  28.157 -{
  28.158 -    SDL_GrabMode mode;
  28.159 -
  28.160 -    printf("Ctrl-G: toggling input grab!\n");
  28.161 -    mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
  28.162 -    if (mode == SDL_GRAB_ON) {
  28.163 -        printf("Grab was on\n");
  28.164 -    } else {
  28.165 -        printf("Grab was off\n");
  28.166 -    }
  28.167 -    mode = SDL_WM_GrabInput(mode ? SDL_GRAB_OFF : SDL_GRAB_ON);
  28.168 -    if (mode == SDL_GRAB_ON) {
  28.169 -        printf("Grab is now on\n");
  28.170 -    } else {
  28.171 -        printf("Grab is now off\n");
  28.172 -    }
  28.173 -}
  28.174 -
  28.175 -void
  28.176 -HotKey_Iconify(void)
  28.177 -{
  28.178 -    printf("Ctrl-Z: iconifying window!\n");
  28.179 -    SDL_WM_IconifyWindow();
  28.180 -}
  28.181 -
  28.182 -void
  28.183 -HotKey_Quit(void)
  28.184 -{
  28.185 -    SDL_Event event;
  28.186 -
  28.187 -    printf("Posting internal quit request\n");
  28.188 -    event.type = SDL_USEREVENT;
  28.189 -    SDL_PushEvent(&event);
  28.190 -}
  28.191 -
  28.192 -
  28.193 -static void
  28.194 -print_modifiers(void)
  28.195 -{
  28.196 -    int mod;
  28.197 -    printf(" modifiers:");
  28.198 -    mod = SDL_GetModState();
  28.199 -    if(!mod) {
  28.200 -        printf(" (none)");
  28.201 -        return;
  28.202 -    }
  28.203 -    if(mod & KMOD_LSHIFT)
  28.204 -        printf(" LSHIFT");
  28.205 -    if(mod & KMOD_RSHIFT)
  28.206 -        printf(" RSHIFT");
  28.207 -    if(mod & KMOD_LCTRL)
  28.208 -        printf(" LCTRL");
  28.209 -    if(mod & KMOD_RCTRL)
  28.210 -        printf(" RCTRL");
  28.211 -    if(mod & KMOD_LALT)
  28.212 -        printf(" LALT");
  28.213 -    if(mod & KMOD_RALT)
  28.214 -        printf(" RALT");
  28.215 -    if(mod & KMOD_LMETA)
  28.216 -        printf(" LMETA");
  28.217 -    if(mod & KMOD_RMETA)
  28.218 -        printf(" RMETA");
  28.219 -    if(mod & KMOD_NUM)
  28.220 -        printf(" NUM");
  28.221 -    if(mod & KMOD_CAPS)
  28.222 -        printf(" CAPS");
  28.223 -    if(mod & KMOD_MODE)
  28.224 -        printf(" MODE");
  28.225 -}
  28.226 -
  28.227 -static void PrintKey(const SDL_Keysym *sym, int pressed)
  28.228 -{
  28.229 -    /* Print the keycode, name and state */
  28.230 -    if ( sym->sym ) {
  28.231 -        printf("Key %s:  %d-%s ", pressed ?  "pressed" : "released",
  28.232 -                    sym->sym, SDL_GetKeyName(sym->sym));
  28.233 -    } else {
  28.234 -        printf("Unknown Key (scancode = %d) %s ", sym->scancode,
  28.235 -                    pressed ?  "pressed" : "released");
  28.236 -    }
  28.237 -
  28.238 -    /* Print the translated character, if one exists */
  28.239 -    if ( sym->unicode ) {
  28.240 -        /* Is it a control-character? */
  28.241 -        if ( sym->unicode < ' ' ) {
  28.242 -            printf(" (^%c)", sym->unicode+'@');
  28.243 -        } else {
  28.244 -#ifdef UNICODE
  28.245 -            printf(" (%c)", sym->unicode);
  28.246 -#else
  28.247 -            /* This is a Latin-1 program, so only show 8-bits */
  28.248 -            if ( !(sym->unicode & 0xFF00) )
  28.249 -                printf(" (%c)", sym->unicode);
  28.250 -            else
  28.251 -                printf(" (0x%X)", sym->unicode);
  28.252 -#endif
  28.253 -        }
  28.254 -    }
  28.255 -    print_modifiers();
  28.256 -    printf("\n");
  28.257 -}
  28.258 -
  28.259 -
  28.260 -static int (SDLCALL * old_filterfunc) (void *, SDL_Event *);
  28.261 -static void *old_filterdata;
  28.262 -
  28.263 -int SDLCALL
  28.264 -FilterEvents(void *userdata, SDL_Event * event)
  28.265 -{
  28.266 -    static int reallyquit = 0;
  28.267 -
  28.268 -    if (old_filterfunc) {
  28.269 -        old_filterfunc(old_filterdata, event);
  28.270 -    }
  28.271 -
  28.272 -    switch (event->type) {
  28.273 -
  28.274 -    case SDL_ACTIVEEVENT:
  28.275 -        /* See what happened */
  28.276 -        printf("App %s ", event->active.gain ? "gained" : "lost");
  28.277 -        if (event->active.state & SDL_APPACTIVE)
  28.278 -            printf("active ");
  28.279 -        if (event->active.state & SDL_APPINPUTFOCUS)
  28.280 -            printf("input ");
  28.281 -        if (event->active.state & SDL_APPMOUSEFOCUS)
  28.282 -            printf("mouse ");
  28.283 -        printf("focus\n");
  28.284 -
  28.285 -        /* See if we are iconified or restored */
  28.286 -        if (event->active.state & SDL_APPACTIVE) {
  28.287 -            printf("App has been %s\n",
  28.288 -                   event->active.gain ? "restored" : "iconified");
  28.289 -        }
  28.290 -        return (0);
  28.291 -
  28.292 -        /* We want to toggle visibility on buttonpress */
  28.293 -    case SDL_MOUSEBUTTONDOWN:
  28.294 -    case SDL_MOUSEBUTTONUP:
  28.295 -        if (event->button.state == SDL_PRESSED) {
  28.296 -            visible = !visible;
  28.297 -            SDL_ShowCursor(visible);
  28.298 -        }
  28.299 -        printf("Mouse button %d has been %s at %d,%d\n",
  28.300 -               event->button.button,
  28.301 -               (event->button.state == SDL_PRESSED) ? "pressed" : "released",
  28.302 -               event->button.x, event->button.y);
  28.303 -        return (0);
  28.304 -
  28.305 -        /* Show relative mouse motion */
  28.306 -    case SDL_MOUSEMOTION:
  28.307 -#if 0
  28.308 -        printf("Mouse motion: {%d,%d} (%d,%d)\n",
  28.309 -               event->motion.x, event->motion.y,
  28.310 -               event->motion.xrel, event->motion.yrel);
  28.311 -#endif
  28.312 -        return (0);
  28.313 -
  28.314 -    case SDL_KEYDOWN:
  28.315 -        PrintKey(&event->key.keysym, 1);
  28.316 -        if (event->key.keysym.sym == SDLK_ESCAPE) {
  28.317 -            HotKey_Quit();
  28.318 -        }
  28.319 -        if ((event->key.keysym.sym == SDLK_g) &&
  28.320 -            (event->key.keysym.mod & KMOD_CTRL)) {
  28.321 -            HotKey_ToggleGrab();
  28.322 -        }
  28.323 -        if ((event->key.keysym.sym == SDLK_z) &&
  28.324 -            (event->key.keysym.mod & KMOD_CTRL)) {
  28.325 -            HotKey_Iconify();
  28.326 -        }
  28.327 -        if ((event->key.keysym.sym == SDLK_RETURN) &&
  28.328 -            (event->key.keysym.mod & (KMOD_ALT|KMOD_META))) {
  28.329 -            HotKey_ToggleFullScreen();
  28.330 -        }
  28.331 -        return (0);
  28.332 -
  28.333 -	case SDL_KEYUP:
  28.334 -		PrintKey(&event->key.keysym, 0);
  28.335 -		return(0);
  28.336 -
  28.337 -        /* Pass the video resize event through .. */
  28.338 -    case SDL_VIDEORESIZE:
  28.339 -        return (1);
  28.340 -
  28.341 -        /* This is important!  Queue it if we want to quit. */
  28.342 -    case SDL_QUIT:
  28.343 -        if (!reallyquit) {
  28.344 -            reallyquit = 1;
  28.345 -            printf("Quit requested\n");
  28.346 -            return (0);
  28.347 -        }
  28.348 -        printf("Quit demanded\n");
  28.349 -        return (1);
  28.350 -
  28.351 -        /* This will never happen because events queued directly
  28.352 -           to the event queue are not filtered.
  28.353 -         */
  28.354 -    case SDL_USEREVENT:
  28.355 -        return (1);
  28.356 -
  28.357 -        /* Drop all other events */
  28.358 -    default:
  28.359 -        return (0);
  28.360 -    }
  28.361 -}
  28.362 -
  28.363 -int
  28.364 -main(int argc, char *argv[])
  28.365 -{
  28.366 -    SDL_Event event;
  28.367 -    const char *title;
  28.368 -    SDL_Surface *icon;
  28.369 -    Uint8 *icon_mask;
  28.370 -    int parsed;
  28.371 -    int w, h;
  28.372 -
  28.373 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  28.374 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
  28.375 -        return (1);
  28.376 -    }
  28.377 -
  28.378 -    /* Check command line arguments */
  28.379 -    w = 640;
  28.380 -    h = 480;
  28.381 -    video_bpp = 8;
  28.382 -    video_flags = SDL_SWSURFACE;
  28.383 -    parsed = 1;
  28.384 -    while (parsed) {
  28.385 -        if ((argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0)) {
  28.386 -            video_flags |= SDL_FULLSCREEN;
  28.387 -            argc -= 1;
  28.388 -            argv += 1;
  28.389 -        } else if ((argc >= 2) && (strcmp(argv[1], "-resize") == 0)) {
  28.390 -            video_flags |= SDL_RESIZABLE;
  28.391 -            argc -= 1;
  28.392 -            argv += 1;
  28.393 -        } else if ((argc >= 2) && (strcmp(argv[1], "-noframe") == 0)) {
  28.394 -            video_flags |= SDL_NOFRAME;
  28.395 -            argc -= 1;
  28.396 -            argv += 1;
  28.397 -        } else if ((argc >= 3) && (strcmp(argv[1], "-width") == 0)) {
  28.398 -            w = atoi(argv[2]);
  28.399 -            argc -= 2;
  28.400 -            argv += 2;
  28.401 -        } else if ((argc >= 3) && (strcmp(argv[1], "-height") == 0)) {
  28.402 -            h = atoi(argv[2]);
  28.403 -            argc -= 2;
  28.404 -            argv += 2;
  28.405 -        } else if ((argc >= 3) && (strcmp(argv[1], "-bpp") == 0)) {
  28.406 -            video_bpp = atoi(argv[2]);
  28.407 -            argc -= 2;
  28.408 -            argv += 2;
  28.409 -        } else {
  28.410 -            parsed = 0;
  28.411 -        }
  28.412 -    }
  28.413 -
  28.414 -    /* Set the icon -- this must be done before the first mode set */
  28.415 -    icon = LoadIconSurface("icon.bmp", &icon_mask);
  28.416 -    if (icon != NULL) {
  28.417 -        SDL_WM_SetIcon(icon, icon_mask);
  28.418 -    }
  28.419 -    if (icon_mask != NULL)
  28.420 -        free(icon_mask);
  28.421 -
  28.422 -    /* Set the title bar */
  28.423 -    if (argv[1] == NULL)
  28.424 -        title = "Testing  1.. 2.. 3...";
  28.425 -    else
  28.426 -        title = argv[1];
  28.427 -    SDL_WM_SetCaption(title, "testwm");
  28.428 -
  28.429 -    /* See if it's really set */
  28.430 -    SDL_WM_GetCaption(&title, NULL);
  28.431 -    if (title)
  28.432 -        printf("Title was set to: %s\n", title);
  28.433 -    else
  28.434 -        printf("No window title was set!\n");
  28.435 -
  28.436 -    /* Initialize the display */
  28.437 -    if (SetVideoMode(w, h) < 0) {
  28.438 -        quit(1);
  28.439 -    }
  28.440 -
  28.441 -    /* Set an event filter that discards everything but QUIT */
  28.442 -    SDL_GetEventFilter(&old_filterfunc, &old_filterdata);
  28.443 -    SDL_SetEventFilter(FilterEvents, NULL);
  28.444 -
  28.445 -    /* Loop, waiting for QUIT */
  28.446 -    while (SDL_WaitEvent(&event)) {
  28.447 -        switch (event.type) {
  28.448 -        case SDL_VIDEORESIZE:
  28.449 -            printf("Got a resize event: %dx%d\n",
  28.450 -                   event.resize.w, event.resize.h);
  28.451 -            SetVideoMode(event.resize.w, event.resize.h);
  28.452 -            break;
  28.453 -        case SDL_USEREVENT:
  28.454 -            printf("Handling internal quit request\n");
  28.455 -            /* Fall through to the quit handler */
  28.456 -        case SDL_QUIT:
  28.457 -            printf("Bye bye..\n");
  28.458 -            quit(0);
  28.459 -        default:
  28.460 -            /* This should never happen */
  28.461 -            printf("Warning: Event %d wasn't filtered\n", event.type);
  28.462 -            break;
  28.463 -        }
  28.464 -    }
  28.465 -    printf("SDL_WaitEvent() error: %s\n", SDL_GetError());
  28.466 -    SDL_Quit();
  28.467 -    return (255);
  28.468 -}
    29.1 --- a/test/threadwin.c	Sun Jan 22 17:50:35 2012 -0500
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,337 +0,0 @@
    29.4 -/*
    29.5 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    29.6 -
    29.7 -  This software is provided 'as-is', without any express or implied
    29.8 -  warranty.  In no event will the authors be held liable for any damages
    29.9 -  arising from the use of this software.
   29.10 -
   29.11 -  Permission is granted to anyone to use this software for any purpose,
   29.12 -  including commercial applications, and to alter it and redistribute it
   29.13 -  freely.
   29.14 -*/
   29.15 -
   29.16 -/* Test out the multi-threaded event handling functions */
   29.17 -
   29.18 -#include <stdlib.h>
   29.19 -#include <stdio.h>
   29.20 -#include <string.h>
   29.21 -
   29.22 -#include "SDL.h"
   29.23 -#include "SDL_thread.h"
   29.24 -
   29.25 -/* Are we done yet? */
   29.26 -static int done = 0;
   29.27 -
   29.28 -/* Is the cursor visible? */
   29.29 -static int visible = 1;
   29.30 -
   29.31 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   29.32 -static void
   29.33 -quit(int rc)
   29.34 -{
   29.35 -    SDL_Quit();
   29.36 -    exit(rc);
   29.37 -}
   29.38 -
   29.39 -SDL_Surface *
   29.40 -LoadIconSurface(char *file, Uint8 ** maskp)
   29.41 -{
   29.42 -    SDL_Surface *icon;
   29.43 -    Uint8 *pixels;
   29.44 -    Uint8 *mask;
   29.45 -    int mlen, i;
   29.46 -
   29.47 -    *maskp = NULL;
   29.48 -
   29.49 -    /* Load the icon surface */
   29.50 -    icon = SDL_LoadBMP(file);
   29.51 -    if (icon == NULL) {
   29.52 -        fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
   29.53 -        return (NULL);
   29.54 -    }
   29.55 -
   29.56 -    /* Check width and height */
   29.57 -    if ((icon->w % 8) != 0) {
   29.58 -        fprintf(stderr, "Icon width must be a multiple of 8!\n");
   29.59 -        SDL_FreeSurface(icon);
   29.60 -        return (NULL);
   29.61 -    }
   29.62 -    if (icon->format->palette == NULL) {
   29.63 -        fprintf(stderr, "Icon must have a palette!\n");
   29.64 -        SDL_FreeSurface(icon);
   29.65 -        return (NULL);
   29.66 -    }
   29.67 -
   29.68 -    /* Set the colorkey */
   29.69 -    SDL_SetColorKey(icon, SDL_SRCCOLORKEY, *((Uint8 *) icon->pixels));
   29.70 -
   29.71 -    /* Create the mask */
   29.72 -    pixels = (Uint8 *) icon->pixels;
   29.73 -    printf("Transparent pixel: (%d,%d,%d)\n",
   29.74 -           icon->format->palette->colors[*pixels].r,
   29.75 -           icon->format->palette->colors[*pixels].g,
   29.76 -           icon->format->palette->colors[*pixels].b);
   29.77 -    mlen = icon->w * icon->h;
   29.78 -    mask = (Uint8 *) malloc(mlen / 8);
   29.79 -    if (mask == NULL) {
   29.80 -        fprintf(stderr, "Out of memory!\n");
   29.81 -        SDL_FreeSurface(icon);
   29.82 -        return (NULL);
   29.83 -    }
   29.84 -    memset(mask, 0, mlen / 8);
   29.85 -    for (i = 0; i < mlen;) {
   29.86 -        if (pixels[i] != *pixels)
   29.87 -            mask[i / 8] |= 0x01;
   29.88 -        ++i;
   29.89 -        if ((i % 8) != 0)
   29.90 -            mask[i / 8] <<= 1;
   29.91 -    }
   29.92 -    *maskp = mask;
   29.93 -    return (icon);
   29.94 -}
   29.95 -
   29.96 -int SDLCALL
   29.97 -FilterEvents(void *userdata, SDL_Event * event)
   29.98 -{
   29.99 -    static int reallyquit = 0;
  29.100 -
  29.101 -    switch (event->type) {
  29.102 -
  29.103 -    case SDL_ACTIVEEVENT:
  29.104 -        /* See what happened */
  29.105 -        printf("App %s ", event->active.gain ? "gained" : "lost");
  29.106 -        if (event->active.state & SDL_APPACTIVE)
  29.107 -            printf("active ");
  29.108 -        if (event->active.state & SDL_APPMOUSEFOCUS)
  29.109 -            printf("mouse ");
  29.110 -        if (event->active.state & SDL_APPINPUTFOCUS)
  29.111 -            printf("input ");
  29.112 -        printf("focus\n");
  29.113 -
  29.114 -        /* See if we are iconified or restored */
  29.115 -        if (event->active.state & SDL_APPACTIVE) {
  29.116 -            printf("App has been %s\n",
  29.117 -                   event->active.gain ? "restored" : "iconified");
  29.118 -        }
  29.119 -        return (0);
  29.120 -
  29.121 -        /* This is important!  Queue it if we want to quit. */
  29.122 -    case SDL_QUIT:
  29.123 -        if (!reallyquit) {
  29.124 -            reallyquit = 1;
  29.125 -            printf("Quit requested\n");
  29.126 -            return (0);
  29.127 -        }
  29.128 -        printf("Quit demanded\n");
  29.129 -        return (1);
  29.130 -
  29.131 -        /* Mouse and keyboard events go to threads */
  29.132 -    case SDL_MOUSEMOTION:
  29.133 -    case SDL_MOUSEBUTTONDOWN:
  29.134 -    case SDL_MOUSEBUTTONUP:
  29.135 -    case SDL_KEYDOWN:
  29.136 -    case SDL_KEYUP:
  29.137 -        return (1);
  29.138 -
  29.139 -        /* Drop all other events */
  29.140 -    default:
  29.141 -        return (0);
  29.142 -    }
  29.143 -}
  29.144 -
  29.145 -int SDLCALL
  29.146 -HandleMouse(void *unused)
  29.147 -{
  29.148 -    SDL_Event events[10];
  29.149 -    int i, found;
  29.150 -
  29.151 -    /* Handle mouse events here */
  29.152 -    while (!done) {
  29.153 -        found = SDL_PeepEvents(events, 10, SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
  29.154 -        for (i = 0; i < found; ++i) {
  29.155 -            switch (events[i].type) {
  29.156 -                /* We want to toggle visibility on buttonpress */
  29.157 -            case SDL_MOUSEBUTTONDOWN:
  29.158 -            case SDL_MOUSEBUTTONUP:
  29.159 -                if (events[i].button.state == SDL_PRESSED) {
  29.160 -                    visible = !visible;
  29.161 -                    SDL_ShowCursor(visible);
  29.162 -                }
  29.163 -                printf("Mouse button %d has been %s\n",
  29.164 -                       events[i].button.button,
  29.165 -                       (events[i].button.state == SDL_PRESSED) ?
  29.166 -                       "pressed" : "released");
  29.167 -                break;
  29.168 -                /* Show relative mouse motion */
  29.169 -            case SDL_MOUSEMOTION:
  29.170 -                printf("Mouse relative motion: {%d,%d}\n",
  29.171 -                       events[i].motion.xrel, events[i].motion.yrel);
  29.172 -                break;
  29.173 -            }
  29.174 -        }
  29.175 -        /* Give up some CPU to allow events to arrive */
  29.176 -        SDL_Delay(20);
  29.177 -    }
  29.178 -    return (0);
  29.179 -}
  29.180 -
  29.181 -int SDLCALL
  29.182 -HandleKeyboard(void *unused)
  29.183 -{
  29.184 -    SDL_Event events[10];
  29.185 -    int i, found;
  29.186 -
  29.187 -    /* Handle mouse events here */
  29.188 -    while (!done) {
  29.189 -        found = SDL_PeepEvents(events, 10, SDL_GETEVENT, SDL_KEYDOWN, SDL_KEYUP);
  29.190 -        for (i = 0; i < found; ++i) {
  29.191 -            switch (events[i].type) {
  29.192 -                /* We want to toggle visibility on buttonpress */
  29.193 -            case SDL_KEYDOWN:
  29.194 -            case SDL_KEYUP:
  29.195 -                printf("Key '%c' (keysym==%d) has been %s\n",
  29.196 -                       events[i].key.keysym.unicode,
  29.197 -                       (int) events[i].key.keysym.sym,
  29.198 -                       (events[i].key.state == SDL_PRESSED) ?
  29.199 -                       "pressed" : "released");
  29.200 -
  29.201 -                /* Allow hitting <ESC> to quit the app */
  29.202 -                if (events[i].key.keysym.sym == SDLK_ESCAPE) {
  29.203 -                    done = 1;
  29.204 -                }
  29.205 -
  29.206 -                /* skip events now that aren't KEYUPs... */
  29.207 -                if (events[i].key.state == SDL_PRESSED)
  29.208 -                    break;
  29.209 -
  29.210 -                if (events[i].key.keysym.sym == SDLK_f) {
  29.211 -                    int rc = 0;
  29.212 -                    printf("attempting to toggle fullscreen...\n");
  29.213 -                    rc = SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
  29.214 -                    printf("SDL_WM_ToggleFullScreen returned %d.\n", rc);
  29.215 -                }
  29.216 -
  29.217 -                if (events[i].key.keysym.sym == SDLK_g) {
  29.218 -                    SDL_GrabMode m;
  29.219 -                    m = SDL_WM_GrabInput(SDL_GRAB_QUERY) ==
  29.220 -                        SDL_GRAB_ON ? SDL_GRAB_OFF : SDL_GRAB_ON;
  29.221 -                    printf
  29.222 -                        ("attempting to toggle input grab to %s...\n",
  29.223 -                         m == SDL_GRAB_ON ? "ON" : "OFF");
  29.224 -                    SDL_WM_GrabInput(m);
  29.225 -                    printf("attempt finished.\n");
  29.226 -                }
  29.227 -
  29.228 -                break;
  29.229 -            }
  29.230 -        }
  29.231 -        /* Give up some CPU to allow events to arrive */
  29.232 -        SDL_Delay(20);
  29.233 -    }
  29.234 -    return (0);
  29.235 -}
  29.236 -
  29.237 -int
  29.238 -main(int argc, char *argv[])
  29.239 -{
  29.240 -    SDL_Surface *screen;
  29.241 -    SDL_Surface *icon;
  29.242 -    Uint8 *icon_mask;
  29.243 -    int i, parsed;
  29.244 -    Uint8 *buffer;
  29.245 -    SDL_Color palette[256];
  29.246 -    Uint32 init_flags;
  29.247 -    Uint8 video_bpp;
  29.248 -    Uint32 video_flags;
  29.249 -    SDL_Thread *mouse_thread;
  29.250 -    SDL_Thread *keybd_thread;
  29.251 -
  29.252 -    /* Set the options, based on command line arguments */
  29.253 -    init_flags = SDL_INIT_VIDEO;
  29.254 -    video_bpp = 8;
  29.255 -    video_flags = SDL_SWSURFACE;
  29.256 -    parsed = 1;
  29.257 -    while (parsed) {
  29.258 -        if ((argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0)) {
  29.259 -            video_flags |= SDL_FULLSCREEN;
  29.260 -            argc -= 1;
  29.261 -            argv += 1;
  29.262 -        } else if ((argc >= 3) && (strcmp(argv[1], "-bpp") == 0)) {
  29.263 -            video_bpp = atoi(argv[2]);
  29.264 -            argc -= 2;
  29.265 -            argv += 2;
  29.266 -        } else {
  29.267 -            parsed = 0;
  29.268 -        }
  29.269 -    }
  29.270 -
  29.271 -    /* Initialize SDL with the requested flags */
  29.272 -    if (SDL_Init(init_flags) < 0) {
  29.273 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
  29.274 -        return (1);
  29.275 -    }
  29.276 -
  29.277 -    /* Set the icon -- this must be done before the first mode set */
  29.278 -    icon = LoadIconSurface("icon.bmp", &icon_mask);
  29.279 -    if (icon != NULL) {
  29.280 -        SDL_WM_SetIcon(icon, icon_mask);
  29.281 -    }
  29.282 -    if (icon_mask != NULL)
  29.283 -        free(icon_mask);
  29.284 -
  29.285 -    /* Initialize the display */
  29.286 -    screen = SDL_SetVideoMode(640, 480, video_bpp, video_flags);
  29.287 -    if (screen == NULL) {
  29.288 -        fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
  29.289 -                video_bpp, SDL_GetError());
  29.290 -        quit(1);
  29.291 -    }
  29.292 -    printf("Running in %s mode\n", screen->flags & SDL_FULLSCREEN ?
  29.293 -           "fullscreen" : "windowed");
  29.294 -
  29.295 -    /* Enable printable characters */
  29.296 -    SDL_EnableUNICODE(1);
  29.297 -
  29.298 -    /* Set an event filter that discards everything but QUIT */
  29.299 -    SDL_SetEventFilter(FilterEvents, NULL);
  29.300 -
  29.301 -    /* Create the event handling threads */
  29.302 -    mouse_thread = SDL_CreateThread(HandleMouse, "MouseHandler", NULL);
  29.303 -    keybd_thread = SDL_CreateThread(HandleKeyboard, "KeyboardHandler", NULL);
  29.304 -
  29.305 -    /* Set the surface pixels and refresh! */
  29.306 -    for (i = 0; i < 256; ++i) {
  29.307 -        palette[i].r = 255 - i;
  29.308 -        palette[i].g = 255 - i;
  29.309 -        palette[i].b = 255 - i;
  29.310 -    }
  29.311 -    SDL_SetColors(screen, palette, 0, 256);
  29.312 -    if (SDL_LockSurface(screen) < 0) {
  29.313 -        fprintf(stderr, "Couldn't lock display surface: %s\n",
  29.314 -                SDL_GetError());
  29.315 -        quit(2);
  29.316 -    }
  29.317 -    buffer = (Uint8 *) screen->pixels;
  29.318 -    for (i = 0; i < screen->h; ++i) {
  29.319 -        memset(buffer, (i * 255) / screen->h,
  29.320 -               screen->w * screen->format->BytesPerPixel);
  29.321 -        buffer += screen->pitch;
  29.322 -    }
  29.323 -    SDL_UnlockSurface(screen);
  29.324 -    SDL_UpdateRect(screen, 0, 0, 0, 0);
  29.325 -
  29.326 -    /* Loop, waiting for QUIT */
  29.327 -    while (!done) {