Page 1 of 1

How to use TrayManager?

Posted: Mon Jul 16, 2018 8:00 am
by Zemtriz
Ogre Version: 1.11.1
Operating System: Linux marek-pc 4.16.18-1-MANJARO #1 SMP PREEMPT Tue Jun 26 15:27:59 UTC 2018 x86_64 GNU/Linux
Render System: OpenGL 3+ Render Subsystem

Hello there,

I've got troubles implementing TrayManager. Followed tutorials on: https://ogrecave.github.io/ogre/api/latest/trays.html
But I can't figure out what exactly to write in place of mWindow or how to use rendersystem.
Trying to modify bootstrap.cpp and add there only traymanager.
I have added only this line into code:
OgreBites::TrayManager* mTrayMgr = new OgreBites::TrayManager("InterfaceName", mWindow, this);
and also included ogretrays.h
but how to modify Window?

Error during compiling:

Code: Select all

[marek@marek-pc build]$ make
[ 33%] Built target 2_CamerasAndShadows
[ 50%] Building CXX object CMakeFiles/0_Bootstrap.dir/Bootstrap.cpp.o
/run/media/marek/cd998326-6c5a-4cd3-b3ff-d425a0c06ae4/OgreSDK/Tutorials/Bootstrap.cpp: In member function ‘virtual void MyTestApp::setup()’:
/run/media/marek/cd998326-6c5a-4cd3-b3ff-d425a0c06ae4/OgreSDK/Tutorials/Bootstrap.cpp:72:84: error: ‘mWindow’ was not declared in this scope
     OgreBites::TrayManager* mTrayMgr = new OgreBites::TrayManager("InterfaceName", mWindow, this);
                                                                                    ^~~~~~~
/run/media/marek/cd998326-6c5a-4cd3-b3ff-d425a0c06ae4/OgreSDK/Tutorials/Bootstrap.cpp:72:84: note: suggested alternative: ‘mWindows’
     OgreBites::TrayManager* mTrayMgr = new OgreBites::TrayManager("InterfaceName", mWindow, this);
                                                                                    ^~~~~~~
                                                                                    mWindows
make[2]: *** [CMakeFiles/0_Bootstrap.dir/build.make:63: CMakeFiles/0_Bootstrap.dir/Bootstrap.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/0_Bootstrap.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
[marek@marek-pc build]$ 
Thank you for any suggestions

Re: How to use TrayManager?

Posted: Mon Jul 16, 2018 11:03 am
by paroj
you can take a look at the python sample which uses the tray manager:
https://github.com/OGRECave/ogre/blob/v ... _sample.py

Re: How to use TrayManager?

Posted: Mon Jul 16, 2018 1:31 pm
by Zemtriz
paroj wrote:
Mon Jul 16, 2018 11:03 am
you can take a look at the python sample which uses the tray manager:
https://github.com/OGRECave/ogre/blob/v ... _sample.py
Thanks for a reply, but still doesn't work :(

Updated it to the following:

Code: Select all

OgreBites::TrayManager* mTrayMgr = new OgreBites::TrayManager("InterfaceName", OgreBites::ApplicationContext::getRenderWindow(), this);

Re: How to use TrayManager?

Posted: Mon Jul 16, 2018 4:29 pm
by palsofchaos
Did you initialise your mWindow under your Root node? Just a shot in the dark here.

(Edit) My mistake this suggestion is for an older version of Ogre.

Re: How to use TrayManager?

Posted: Mon Jul 16, 2018 5:17 pm
by paroj
Zemtriz wrote:
Mon Jul 16, 2018 1:31 pm
paroj wrote:
Mon Jul 16, 2018 11:03 am
you can take a look at the python sample which uses the tray manager:
https://github.com/OGRECave/ogre/blob/v ... _sample.py
Thanks for a reply, but still doesn't work :(

Updated it to the following:

Code: Select all

OgreBites::TrayManager* mTrayMgr = new OgreBites::TrayManager("InterfaceName", OgreBites::ApplicationContext::getRenderWindow(), this);
how did you arrive there, given that the sample says this:

Code: Select all

self.trays = OgreBites.TrayManager("Interface", self.getRenderWindow())

Re: How to use TrayManager?

Posted: Tue Jul 17, 2018 11:39 am
by Zemtriz
Ok guys, I have figured out what I was doing wrong.
This is how it works:

Code: Select all

OgreBites::TrayManager* mTrayMgr = new OgreBites::TrayManager("InterfaceName", getRenderWindow());
As I am new into Ogre, I want to be careful and do everything step by step.
I wanted to initialize trayManager without input listener. Just show something on the screen. And previously I used after getRenderWindow or mWindow ",this)". I had three attributes and the last one "this" was for tray listener that I didn't use and that's why I had errors while compiling.

Re: How to use TrayManager?

Posted: Tue Jul 17, 2018 10:13 pm
by Zemtriz
Hello again,

I'm sorry, but my button is not visible and would like to ask for your help till this topic is not closed as solved.

I'm using bootstrap.cpp in samples/tutorials and still want to implement trays.
What I've got so far, is:
+added "#include <OgreTrays.h>" at the top
+added "public OgreBites::TrayListener" into MyTestApp class
+added

Code: Select all

    OgreBites::TrayManager* mTrayMgr = new OgreBites::TrayManager("InterfaceName", getRenderWindow(), this);
    OgreBites::Button* b = mTrayMgr->OgreBites::TrayManager::createButton(OgreBites::TrayLocation::TL_TOPLEFT, "MyButton", "Click Me!");
at the bottom of setup function

If I use "OgreBites::TrayLocation::TL_TOPLEFT" or "OgreBites::TL_TOPLEFT" none shows error during compilation but still I do not see a button.

EDIT:
If I use this:

Code: Select all

    OgreBites::TrayManager* mTrayMgr = new OgreBites::TrayManager("InterfaceName", OgreBites::ApplicationContext::getRenderWindow(), this);
    //OgreBites::Button* b = mTrayMgr->OgreBites::TrayManager::createButton(OgreBites::TrayLocation::TL_TOPLEFT, "MyButton", "Click Me!");
    OgreBites::TextBox* t = mTrayMgr->OgreBites::TrayManager::createTextBox(OgreBites::TrayLocation::TL_LEFT, "MyTextBox", "TextBox", 120, 100);
or this:

Code: Select all

    OgreBites::TrayManager* mTrayMgr = new OgreBites::TrayManager("InterfaceName", OgreBites::ApplicationContext::getRenderWindow(), this);
    //OgreBites::Button* b = mTrayMgr->OgreBites::TrayManager::createButton(OgreBites::TrayLocation::TL_TOPLEFT, "MyButton", "Click Me!");
    OgreBites::TextBox* t = mTrayMgr->createTextBox(OgreBites::TL_LEFT, "MyTextBox", "TextBox", 120, 100);
both I can compile without errors but doesn't show anything

Re: How to use TrayManager?

Posted: Thu Aug 02, 2018 8:16 pm
by Fighter19
Today I stumbled upon the same problem.
After 4 hours of trial and error I found the culprit.
You need to add the Overlay System to the render queue at some point.

Calling this:

Code: Select all

scnMgr->addRenderQueueListener(mOverlaySystem);
After the scene manager has been created, made my button appear.