mailao
日历
网志分类
· 所有网志 (183)
· 我乱写的 (3)
· Graphics & Engine (4)
· Learn DFA (112)
· 抄的 (60)
· 未分类 (4)
站内搜索
友情链接
· 我的歪酷 非非共享界

订阅 RSS

0071862

歪酷博客

不超越惰性的防线,信念将在彷徨中夭折。
« 上一篇: 今天发现了三个有趣的事情 下一篇: Some About vfw vedio compression »
mailao @ 2007-07-21 09:44

 

Games are very different applications than traditional Windows applications, such as office type applications and web browsers. Games are not typically event driven in the usual sense, and they must be updated constantly. For this reason, when we actually start writing our 3D programs we will, for the most part, not deal with Windows messages. Therefore, we will want to modify the message loop so that if there is a message, we will process it. But if there is not a message, then we want to run our game code. Our new message loop is as follows:

int Run()
{
     MSG msg;

     while(true)
     {
          if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
          {
               if(msg.message == WM_QUIT)
                    break;

               ::TranslateMessage(&msg);
               ::DispatchMessage(&msg);
          }
          else
               // run game code
     }
     return msg.wParam;
}

After we instantiate msg, we enter into an endless loop. We first call the API function PeekMessage, which checks the message queue for a message. See MSDN for the argument descriptions. If there is a message, it returns true and we handle the message. If PeekMessage returns false, then we handle our own specific game code.





评论 / 个人网页 / 扔小纸条
* 昵称

已经注册过? 请登录

新用户请先注册 以便能显示头像及追踪评论回复

Email
网址
* 评论
表情
 


 

分类小组论坛
杂谈 , 娱乐、八卦 , 文学、艺术 , 体育 , 旅游、同城 , 象牙塔 , 情感 , 时尚、生活 , 星座 , 科技

请注意遵守中华人民共和国法律法规, 如威胁到本站生存, 将依法向有关部门报告, 同时本站的相关记录可能成为对您不利的证据.

相关法律法规
全国人大常委会关于维护互联网安全的决定
中华人民共和国计算机信息系统安全保护条例
中华人民共和国计算机信息网络国际联网管理暂行规定
计算机信息网络国际联网安全保护管理办法
计算机信息系统国际联网保密管理规定