Multiple Render Windows in Qt application

Problems building or running the engine, queries about how to use features etc.
Post Reply
MMI
Gnoblar
Posts: 8
Joined: Thu Aug 10, 2017 10:25 am

Multiple Render Windows in Qt application

Post by MMI » Thu Feb 01, 2018 6:20 pm

I'm currently trying to debug a problem with an Ogre 1.10 app using Qt5 and several render widgets. Everything works fine until I'm deleting certain widgets, any subsequent call to create a Renderable on other windows fail on some systems (Apple, Windows and Ubuntu with certain drivers confirmed, other systems run fine).

In short, I get an exception e.g. here:

https://github.com/OGRECave/ogre/blob/0 ... er.cpp#L46

Debugging the problem, I can see that "mBufferId" is really 0, which as far as I can tell will only really happen when the OpenGL context is somehow gone. Apart from whatever Qt does, the code under my control is single-threaded.

- To confirm my suspicion, is there a possibility to ask Ogre whether it currently has a context? I could in principle modify Ogre's code, but I can't get a call such as wglGetCurrentContext() to link properly.
- If the context is really lost, I guess there are some errors in the interplay between Ogre and Qt. Does there exist documentation/best practices on how to make a Qt-Ogre app with widgets and several render windows which can be opened and closed ad libitum? I found some bits of information here and there, but most of it outdated.
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 573
Joined: Sun Mar 30, 2014 2:51 pm
x 83
Contact:

Re: Multiple Render Windows in Qt application

Post by paroj » Thu Feb 01, 2018 7:26 pm

ogre has the notion of a "main" context. It is used to share OpenGL resources between contexts. See:
https://github.com/OGRECave/ogre/blob/m ... xt.cpp#L43

while using multiple contexts does work, it is much easier just to use the same context for all your windows. This is what Bites does:
https://github.com/OGRECave/ogre/blob/m ... t.cpp#L350

However in both cases you must pay attention not to delete your main context ("destroy" the main window).
Probably this is what is causing the issues for you.
0 x

MMI
Gnoblar
Posts: 8
Joined: Thu Aug 10, 2017 10:25 am

Re: Multiple Render Windows in Qt application

Post by MMI » Mon Feb 05, 2018 2:39 pm

Thank you very much, that helped clear up some things.

With that, I could find the problem. The code didn't destroy the second Ogre::RenderWindow properly, it just called "delete" to the pointer. When calling destroy() first, everything works as expected.
0 x

Post Reply