Page 1 of 1

Using custom config with ApplicationContext?

Posted: Wed Aug 14, 2019 2:14 pm
by mrgrumpy
I'm currently updating an old project to 1.12, and love the new simplified structure using ApplicationContext. However, my previous project was using a custom config file, replacing resources.cfg and ogre.cfg. This was implemented at runtime by creating a new root with no file paths, and setting the config options on the render system and adding resource locations to the resource group manager manually.

I'm afraid I'm a little lost on how something like this should be achieved using the ApplicationContext, and I feel like I'm missing something. I realise it's not possible to create a new root after calling:

Code: Select all

OgreBites::ApplicationContext::setup();
I've been exploring the reconfigure function, but can't find any way to prevent it from trying to use the usual .cfg files.

After spending the day on this, I thought it's time to ask for help - apologies if I'm missing something obvious.

Thanks in advance!

Ogre Version: :1.12:
Operating System: :Ubuntu:
Render System: :GL:

Re: Using custom config with ApplicationContext?

Posted: Thu Aug 15, 2019 11:10 am
by paroj
To achieve what you want, you should overload

- ApplicationContextBase::createRoot
- ApplicationContextBase::oneTimeConfig
- ApplicationContextBase::locateResources

take a look at ApplicationContextBase::initApp and ApplicationContextBase::setup to see the order in which these functions are called.

Re: Using custom config with ApplicationContext?

Posted: Thu Aug 15, 2019 3:44 pm
by mrgrumpy
Great, thanks! This looks like exactly what I was needing.

Thanks a bunch!