参考:
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的原型