Trouble integrating QuickGUI into Ogre project

majorconfusion

09-12-2010 03:46:57

Dear QuickGUI'ers

I'm having great difficulty understanding how to integrate QuickGUI into my existing project which uses Ogre to render. I've just downloaded the latest QuickGUI trunk from SVN, and I'm using the Ogre binary SDK download for Windows (1.7.1).

My GUI initialisation code follows (pinched from the demo). Ogre has already been initialised by the time this runs.

This code is failing at the 'm_scene = new QuickGUIOgrePlatform::Scene...' line, with an Ogre::InvalidParametersException "Can't create another viewport for OGRE Render Window with Z-Order 0 because a viewport exists with this Z-Order already.".

Delving a little into the QuickGUIOgrePlatform code (the Scene constructor), it appears it is trying to create another scene manager, camera and viewport - using the same name as my existing one.

So... am I initialising QuickGUI and its OgrePlatform in the right manner? If so, does QuickGUI's OgrePlatform want to control the creation of the Ogre scene manager, or does QuickGUI utilise an internal scene manager for its own rendering purposes?

Any help appreciated.

PS. It appears that missing skin files will cause a crash in the loadSkins function. Happy to put together a patch to handle this more gracefully with an exception - if it will be accepted?


try {
m_gui_resource_manager = new QuickGUIOgrePlatform::ResourceManager();

m_gui = new QuickGUI::Core(m_gui_resource_manager);

// Register all Skins we plan on using

QuickGUI::SkinManager* skinMgr = QuickGUI::SkinManager::getSingletonPtr();
skinMgr->loadSkins("skins/Button.skin");
skinMgr->loadSkins("skins/CheckBox.skin");
skinMgr->loadSkins("skins/Graphic.skin");
skinMgr->loadSkins("skins/HScrollBar.skin");
skinMgr->loadSkins("skins/Label.skin");
skinMgr->loadSkins("skins/MouseCursor.skin");
skinMgr->loadSkins("skins/Panel.skin");
skinMgr->loadSkins("skins/ProgressBar.skin");
skinMgr->loadSkins("skins/RadioButton.skin");
skinMgr->loadSkins("skins/TextCursor.skin");
skinMgr->loadSkins("skins/TitleBar.skin");
skinMgr->loadSkins("skins/TextBox.skin");
skinMgr->loadSkins("skins/VScrollBar.skin");
skinMgr->loadSkins("skins/Window.skin");
skinMgr->loadSkins("skins/Ogre.skin");

Ogre::Root* root = Ogre::Root::getSingletonPtr();
m_scene = new QuickGUIOgrePlatform::Scene(root->getAutoCreatedWindow());
QuickGUI::Interface* mInterface = QuickGUI::Core::getSingletonPtr()->createInterface("MainWindow",m_scene);
mInterface->getMouseCursor()->setSkin(QuickGUI::SkinManager::getSingletonPtr()->getSkin("MouseCursor"));


QuickGUI::Size winSize(250,250);

QuickGUI::Window* newWin = mInterface->createWindow("Test");
newWin->setSize(winSize);
newWin->setSkin(QuickGUI::SkinManager::getSingletonPtr()->getSkin("Window"));
newWin->setResizable(true);
newWin->setMaxSize(QuickGUI::Size(400,400));
newWin->setMinSize(QuickGUI::Size(100,100));
} catch (Ogre::Exception e) {
throw GuiManagerException(e.what());
} catch (...) {
throw GuiManagerException("Failed to initialise GUI");
}

Calder

09-12-2010 05:50:08

Haha, wow, thanks for sleuthing!

After an hour of trying to figure out how the hell KFM had this working, I've come to the conclusion that the QGOP::Scene class is horribly deficient. :? I have a few more days of work to put in on my own project before I turn to QuickGUI, but after that the first thing I'll do is rewrite this class. If you're feeling particularly adventurous or are just overflowing with holiday patching spirit, it wouldn't be too hard to do yourself, and I'd certainly appreciate the help! :D All you'd need to implement for a 2D GUI is QuickGUI::Scene's createOverlay(), destroyOverlay(), getOverlay() and findOverlay() methods. Otherwise, if you wait a week or so I'll probably have it done.

Sorry for the inconvenience of all this! The QGOP library was basically me asking KFM "we can haz convenience library?" and then taking the code out of the demo and plopping it into its own library. A bit more complex than that, but that's basically it. :P Add to that mess the fact that the Demo files were just copy-pastes from KFM's own game with a bunch of stuff taken out, (hence the commented out Gaia code), and you've got a recipe for disaster. I've been meaning to rewrite the darned whole thing for a while now, but haven't gotten to it yet... and this is the result. To make a long story short: sorry! :) *sheepish look*

The loadSkins() checking it sounds like a good idea!

noobOmat

09-12-2010 10:50:47

As for a quick'n'dirty hack to get the scene class working: It was safe for me to delete all code from the Scene class constructor, as the Ogre camera etc. are never referenced in the class.

So if you already have a working Ogre scene, just pass your Ogre::RenderWindow to the Scene Construcor and everything should be fine. At least that worked for me. ;)

Edit: Stupid me. Of course you have to set the mOgreSceneManager of the Scene class to your scene manager. :roll:

majorconfusion

09-12-2010 20:49:11

Thanks guys. I was a little hesitant to start changing the QuickGUI platform code, not enough experience with it to appreciate the impact of any changes.

I'll take a look tomorrow and post back the results.

Calder

09-12-2010 21:11:37

The SceneManager isn't referenced either, which is what was confusing the hell out of me! :P I'll email KFM and see if we can get a word from him on this.

noobOmat

09-12-2010 22:32:02

The SceneManager isn't referenced either, which is what was confusing the hell out of me! :P I'll email KFM and see if we can get a word from him on this.
Doh, I mixed up my IDE projects (one using the QuickGUI static lib - I haven't given up hope yet) and 'my' compiled version. And of course your right: The SceneManager is not needed. One can just clean out the Scene class constructor.

Sorry for that one. :(

Note to myself: Check things better before posting. ;)

Calder

10-12-2010 00:06:43

Sorry noob0, you were actually incredibly right! :P While the SceneManager isn't currently used, that's only because the current QGOP::Scene class doesn't support the 3D (UIPanel) operations! The other thing that I'm beating myself up for not looking up before is Overlay's strange behavior. Overlays are displayed in all viewports unless explicitly disabled by the viewport, and yet are not managed by any central Manager. This seems rather weird to me, but ok... :D Doesn't it seem like that would cause trouble in multi-window apps?

EDIT: Speaking of checking things before posting, there is actually an OverlayManager, QGOP::createOverlay just doesn't use it. Add that to the list of things to change. :) But it still seems weird that Overlays render in all viewports unless the viewport disables ALL Overlays altogether.