因为SDL_PollEvent(&event)没有消息会直接返回-1,不会等待
应写为:
if(SDL_PollEvent(&event))
//if(SDL_WaitEvent(&event))
{
//处理消息
}
else
{
on_idle();
}
void on_idle()
{
Sleep(10);
}
本文详细介绍了如何使用SDL_PollEvent进行事件处理,并解释了为何不推荐使用SDL_WaitEvent。通过示例代码展示了如何在没有事件时调用空闲处理函数。
因为SDL_PollEvent(&event)没有消息会直接返回-1,不会等待
应写为:
if(SDL_PollEvent(&event))
//if(SDL_WaitEvent(&event))
{
//处理消息
}
else
{
on_idle();
}
void on_idle()
{
Sleep(10);
}
6523
785
1786

被折叠的 条评论
为什么被折叠?
