SDL_Init函数
函数 init SDL
2023-09-14 09:16:24 时间
SDL_Init函数:
用来初始化SDL库,必须在使用SDL其它函数之前调用此函数。
int SDL_Init(Uint32 flags)
其中,flags可以取下列值:
SDL_INIT_TIMER:定时器
SDL_INIT_AUDIO:音频
SDL_INIT_VIDEO:视频
SDL_INIT_JOYSTICK:摇杆
SDL_INIT_HAPTIC:触摸屏
SDL_INIT_GAMECONTROLLER:游戏控制器
SDL_INIT_EVENTS:事件
SDL_INIT_NOPARACHUTE:不捕获关键信号(这个不理解)
SDL_INIT_EVERYTHING:包含上述所有选项
http://blog.csdn.net/leixiaohua1020/article/details/40680907
#include <exception>
#include <string>
#include "SDL.h"
class InitError: public std::exception {
public:
InitError();
InitError(const std::string&);
virtual ~InitError() throw();
virtual const char* what() const throw();
private:
std::string msg;
};
InitError::InitError():
exception(), msg(SDL_GetError()) {}
InitError::InitError(const std::string& m):
exception(), msg(m) {}
InitError::~InitError() throw() {}
const char* InitError::what() const throw() {
return msg.c_str();
}
class SDL {
public:
SDL(Uint32 flags = 0) throw(InitError);
virtual ~SDL();
};
SDL::SDL(Uint32 flags) throw(InitError) {
if (SDL_Init(flags) != 0)
throw InitError();
}
SDL::~SDL() {
SDL_Quit();
}
/* ... */
#include <iostream>
int main(int argc, char **argv) {
try {
SDL sdl(SDL_INIT_VIDEO|SDL_INIT_TIMER);
/* ... */
return 0;
}
catch (const InitError& err) {
std::cerr
<< "Error while initializing SDL: "
<< err.what() << std::endl;
}
return 1;
}
蔡军生
相关文章
- python中merge函数「建议收藏」
- JS实现只能调用一次的函数
- Python_字符串常用函数和方法(5)_Python自学第十七节
- Oracle新建函数实战指南(oracle新建函数)
- 利用Linux钩子函数实现编程的动态性(linux钩子函数)
- Linux 中的 Init:管理系统启动的核心因素(linux 中init)
- PHP中的mysqlselect函数使用方法详解(mysql_select)
- MySQLInit函数的定义及其作用(mysql_init定义)
- MySQL 文件上传学习实践(mysql上传文件函数)
- Oracle中所有CHR函数的实战使用(oracle中所有chr)
- vl函数利用Oracle中的NVL函数实现数据空值替换(oracle中n)
- 收集asp的常用函数
- aspChr函数数字转字母的方法
- Javascript检测、添加、移除样式(className)函数代码
- js函数的引用,关于内存的开销
- phpcurl_init函数用法
- JavaScript中的console.assert()函数介绍