使用SDL库之前需要装载各个子系统,就像要放电影,必须给播放器提供影片一样,程序退出的时候,应该先退出子系统,释放资源。
1. 初始化SDL函数
该函数必须是在程序开始的地方调用
int SDL_Init(Uint32 flags)
flags参数的取值:
/* As of version 0.5, SDL is loaded dynamically into the application */
/* These are the flags which may be passed to SDL_Init() -- you should
specify the subsystems which you will be using in your application.
*/
#define SDL_INIT_TIMER 0x00000001<span > </span>//定时器
#define SDL_INIT_AUDIO 0x00000010 //音频
#define SDL_INIT_VIDEO 0x00000020 //视频
#define SDL_INIT_CDROM 0x00000100 //光驱
#define SDL_INIT_JOYSTICK 0x00000200 //游戏摇杆
#define SDL_INIT_NOPARACHUTE 0x00100000 /* Don't catch fatal signals */ //过滤异常信号
#define SDL_INIT_EVENTTHREAD 0x01000000 /* Not supported on all OS's */
#define SDL_INIT_EVERYTHING 0x0000FFFF //初始化全部子系统