參考:
Using the Object-oriented Input System Library with OGRE
http://www.ogre3d.org/tikiwiki/Using+OIS&structure=Libraries
本地目錄:
x:\GameDev\opensource\OGRE\tutorial\misc\Using the Object-oriented Input System Library with OGRE
游戲框架入口
1. 加載資源
2. 設(shè)定配置
3. 創(chuàng)建輸入管理器
4. 添加鼠標(biāo)監(jiān)聽(tīng)、添加按鍵監(jiān)聽(tīng)
5. 設(shè)置初始狀態(tài),這里是Introstate
6. 進(jìn)入主循環(huán):
unsigned long lTimeLastFrame = 0;
// Main while-loop
while( !bShutdown ) {
// Calculate time since last frame and remember current time for next frame
unsigned long lTimeCurrentFrame = mRoot->getTimer()->getMilliseconds();
unsigned long lTimeSinceLastFrame = lTimeCurrentFrame - lTimeLastFrame;
lTimeLastFrame = lTimeCurrentFrame;
// Update inputmanager
mInputMgr->capture();
// Update current state
mStates.back()->update( lTimeSinceLastFrame );
// Render next frame
mRoot->renderOneFrame();
// Deal with platform specific issues
//PlatformManager::getSingletonPtr()->messagePump( mRenderWindow );
Ogre::WindowEventUtilities::messagePump();
}
主循環(huán)步驟:
1. 計(jì)算幀時(shí)間差
2. 檢測(cè)輸入設(shè)備
3. 執(zhí)行狀態(tài)機(jī)更新操作
4. 執(zhí)行幀渲染
5. 輪詢WINDOWS系統(tǒng)消息(不執(zhí)行此窗口操作會(huì)出現(xiàn)一些莫名其妙的無(wú)法解釋的現(xiàn)象)
此框架是開(kāi)源游戲TankWar的原型