Ogre::Root initialise and extra params
Posted: Thu Jan 31, 2013 2:31 am
So admittedly I'm relatively new to Ogre. But I have lots of experience in both 2D/3D games. As of late, my focus really has been iOS and a bit of Mac. One thing that isn't too uncommon is having your own UIWindow/NSWindow and views. For example, one could already have a XIB which has these things in it.
I know the documentation and forum posts talk about createRenderWindow, but I was curious about the thoughts of expanding initialise to take in the extra params. My rationale is that with the extra params, any config done by the normal initialise function will get picked up. For example OgreOSXGLSupport.m, sets things based on config before instantiating the window.
If you call createRenderWindow, but don't have the same miscParams, then you may get different "default" config for the given platform. This way, it seems to me you can minimize on-boarding by having defaults which work. It is a little frustrating that you need to have a ogre.cfg versus it being able to know its target and at least pick a vanilla version that runs. Please note this probably does not affect those that are further in dev with Ogre or have had previous experience.
In either case, I did make a mod like this already. The function looks like:
Invocation looks something like (note a little messy since is just test code)
externalViewControllerHandle was something I added to make things play nice.
Crazy? Better way to do this? I'm hear to learn if there is!
BTW, I also see that having extraParams could be convenient later on if there are some other initialization elements that are desired from the call.
Thanks!
I know the documentation and forum posts talk about createRenderWindow, but I was curious about the thoughts of expanding initialise to take in the extra params. My rationale is that with the extra params, any config done by the normal initialise function will get picked up. For example OgreOSXGLSupport.m, sets things based on config before instantiating the window.
If you call createRenderWindow, but don't have the same miscParams, then you may get different "default" config for the given platform. This way, it seems to me you can minimize on-boarding by having defaults which work. It is a little frustrating that you need to have a ogre.cfg versus it being able to know its target and at least pick a vanilla version that runs. Please note this probably does not affect those that are further in dev with Ogre or have had previous experience.
In either case, I did make a mod like this already. The function looks like:
Code: Select all
RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window",
const String& customCapabilitiesConfig = StringUtil::BLANK, const NameValuePairList& extraParams = NameValuePairList());
Code: Select all
Ogre::NameValuePairList pairList;
OgreSampleAppDelegate* delegate;
#if TARGET_OS_IPHONE
OgreSampleViewController* viewController;
delegate = (OgreSampleAppDelegate*) [[UIApplication sharedApplication] delegate];
viewController = (OgreSampleViewController*) delegate.window.rootViewController;
EAGL2View* view = viewController.view2;
pairList["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned long)delegate.window);
pairList["externalViewHandle"] = Ogre::StringConverter::toString((unsigned long)view);
#else
delegate = (OgreSampleAppDelegate*) [[NSApplication sharedApplication] delegate];
OgreView* view = [delegate.window contentView];
pairList["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned long)view);
#endif
#if TARGET_OS_IPHONE
pairList["externalViewControllerHandle"] = Ogre::StringConverter::toString((unsigned long)viewController);
#endif
mWindow = mRoot->initialise(true, "TutorialApplication Render Window", Ogre::StringUtil::BLANK, pairList);Crazy? Better way to do this? I'm hear to learn if there is!
BTW, I also see that having extraParams could be convenient later on if there are some other initialization elements that are desired from the call.
Thanks!