參考:
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. 設定配置
3. 創建輸入管理器
4. 添加鼠標監聽、添加按鍵監聽
5. 設置初始狀態,這里是Introstate
6. 進入主循環:
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();
}
主循環步驟:
1. 計算幀時間差
2. 檢測輸入設備
3. 執行狀態機更新操作
4. 執行幀渲染
5. 輪詢WINDOWS系統消息(不執行此窗口操作會出現一些莫名其妙的無法解釋的現象)
此框架是開源游戲TankWar的原型