Ogre::Root initialise and extra params

What it says on the tin: a place to discuss proposed new features.
mobileben
Gnoblar
Posts: 13
Joined: Fri Dec 21, 2012 11:34 pm

Ogre::Root initialise and extra params

Post by mobileben »

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:

Code: Select all

	    RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window",
                                 const String& customCapabilitiesConfig = StringUtil::BLANK, const NameValuePairList& extraParams = NameValuePairList());
Invocation looks something like (note a little messy since is just test code)

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);
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!
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Ogre::Root initialise and extra params

Post by masterfalcon »

Why not just call initialise(false) then use createRenderWindow with the miscParams of your choice each time?
mobileben
Gnoblar
Posts: 13
Joined: Fri Dec 21, 2012 11:34 pm

Re: Ogre::Root initialise and extra params

Post by mobileben »

Okay, I just went over Basic Tutorial 6. Got a better grasp on how to initialize it different ways. Makes sense. Crazy and dumb idea!