去掉ogre引擎设置的窗口

转载自:http://blog.163.com/chenkangapple@126/blog/static/12807484720098173383407/

每次运行前总会出现讨厌的Ogre界面,那怎么去除它呢?这个需要了解当初第一节时建立一个Ogre窗口的原理。

每次用Ogre时总会包含ExampleApplication.h,在这个头文件中定义了一个ExampleApplication类,其中有个这样的方法.

virtual bool configure(void)
{
    // Show the configuration dialog and initialise the system
    // You can skip this and use root.restoreConfig() to load configuration
    // settings if you were sure there are valid ones saved in ogre.cfg
    if(mRoot->showConfigDialog())    //这是关键地方
    {
        // If returned true, user clicked OK so initialise
        // Here we choose to let the system create a default rendering window by passing 'true'
        mWindow = mRoot->initialise(true);
        return true;
    }
    else
    {
        return false;
    }
}

仔细看这段代码,发现有个

if(mRoot->showConfigDialog()){}

这就话的意思就是显示Ogre对话框,既然知道问题是他,那怎么修改?
在OgreRoot.h中我们可以看到有这样的方法

Root::restoreConfig(void){}

这个是干什么的? 不难发现,仔细观察这段代码,发现原来这个是“恢复设置”的,既然这样,那么回到原来的地方咱们把ExampleApplication.h中的那个方法修改一下:

virtual bool configure(void)
{
    // Show the configuration dialog and initialise the system
    // You can skip this and use root.restoreConfig() to load configuration
    // settings if you were sure there are valid ones saved in ogre.cfg
    // if(mRoot->showConfigDialog())    //原来的地方
    if(mRoot->restoreConfig())          //现在修改后的地方
    {
        // If returned true, user clicked OK so initialise
        // Here we choose to let the system create a default rendering window by passing 'true'
        mWindow = mRoot->initialise(true);
        return true;
    }
    else
    {
        return false;
    }
}

运行自己原来写的程序,呵呵,讨厌的Ogre对话框没有了。

不过这个有个前提,你必须运行一次那个带配置窗口的示例才会有效果,为什么呢?
因为在运行那个带配置的对话框之后会生成一个ogre.cfg文件,如果没有这个文件的话,会提示有错的,因为咱们这样一改是通过这个配置文件进入到Ogre窗口的。没有铁定会报错。

如果想以后制作自己的配置窗口建议看一下restoreConfig(),saveconfig()的工作机制。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值