[SOLVED] Letting Qt draw on top of Ogre RenderWindow Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
gabbsson
Gnoblar
Posts: 20
Joined: Wed Aug 08, 2018 9:03 am
x 3

[SOLVED] Letting Qt draw on top of Ogre RenderWindow

Post by gabbsson » Fri Sep 14, 2018 12:53 pm

Ogre Version: 2.1
Qt Version: 5.11
Operating System: Linux
Render System: GL3Plus

I have managed to integrate Ogre into a QWindow as suggested in the wiki:http://wiki.ogre3d.org/tiki-index.php?p ... e+into+QT5 with some tweaks to make it work with Ogre 2.1 (Hlms mostly).

The problem is after passing the window id in the parameters of the render window ogre takes over and nothing can paint over it.
Something as simple as placing a button on top seems impossible, Qt no longer controls the order/depth.

Example:
Image
The label and button have both been "brought to front" and the Ogre Widget has been lowered.

I have tested two alternatives:

Use a QPainter to draw into a pixelbuffer and draw in Ogre, as in:viewtopic.php?t=70171. This method does not really do what I want nor did it really work. After using the pixelbuffer to create a datablock and then drawing it using an overlay 3D models were still drawn on top of it.

Use RTT as a rendertarget instead of a renderwindow and then let Qt draw the image (passing the pixelbuffer into a QImage). I used a method similar to: http://wiki.ogre3d.org/Render+Target+to+QImage+%5BQT%5D
While this did have the effect I wanted for depth, instead I can no longer resize easily. Most posts about this have no replies or they are 10 years old. The best I found was this: viewtopic.php?t=82701
It seems it just isn't really an intended use.

All I want to achieve is to have the widget rendering Ogre behave as any other widget, allowing me to place other widgets on top of it.
I'm more or less stuck, either trying to figure out how to make renderwindows play nice or how to dynamically resize a rendertexture. There are plenty of forum posts asking about how to resize a texture but none of them have led me to a solution unfortunately (I could not find one that was marked solved).

Has anyone had any success with this?
The next thing I plan on testing is sharing/separating glContexts between Qt and Ogre, other than that I have no leads.

tl;dr: Is there a way to let Qt "paint" other QWidgets etc. on top of a QWidget in which Ogre is rendering?
Last edited by gabbsson on Tue Sep 25, 2018 7:22 am, edited 1 time in total.
0 x

nqdev
Gnoblar
Posts: 2
Joined: Sun Sep 09, 2018 12:59 am

Re: Letting Qt draw on top of Ogre RenderWindow

Post by nqdev » Sat Sep 15, 2018 3:08 am

The issue I had with what's in the QT5+2.1 wiki is that it's not really 2.1 in the way that 2.1 Samples are written (as so many have already pointed out). It's still in the 1.x style which inherits from FrameListener. Though I did get it working like that, I abandoned the setup because I really wanted to clean things up by separating the logic and rendering and get better performance. I.e., Logic, Graphics, and EntityManagers. But I did have to remove SDL2. It's not quite there yet, but at least I get the window in Qt5.

I have the code backed up somewhere which is in the style that you're doing it, I'll see if I can find it and pass that part on over the weekend.
0 x

nqdev
Gnoblar
Posts: 2
Joined: Sun Sep 09, 2018 12:59 am

Re: Letting Qt draw on top of Ogre RenderWindow

Post by nqdev » Sat Sep 15, 2018 10:19 pm

On second thought, after reading your post in more detail, I'm not sure I understand what you're saying. It seems you're trying put a widget over the Ogre render window, which doesn't make a lot of sense. I wouldn't expect to be able to place a widget on a GL container.
0 x

gabbsson
Gnoblar
Posts: 20
Joined: Wed Aug 08, 2018 9:03 am
x 3

Re: Letting Qt draw on top of Ogre RenderWindow

Post by gabbsson » Mon Sep 17, 2018 7:46 am

I have very little intuition for how GL works in this case and what to expect from it. I would be surprised but if it is simply not possible (in a clean way), then perhaps I should be looking into other rendering alternatives.

I want the widget rendering Ogre/GL to behave as any other widget, allowing Qt to decide what draws on top.
Usually one can call the .raise() and .lower() methods to bring widgets forward or backward in drawing order.

I'm working on updating some software that currently uses old GL code fro '97, and my current task is simply to replicate the functionality of that old software. In the current old software it is possible to draw on top of the window which renders using GL.
For example its using a QPainter to draw overlays and show QFrames etc. on top of the rendering window, thats what I would like to replicate.
I don't have detailed information on how GL and QPainter work together currently, but I realize now it could be valuable information so I will look into it.

I mentioned trying to simply "import" the drawing of those objects into Ogre and use the OgreOverlays instead. While I may have given up early, the method didn't show great results. The best case would be to re-use the current QPainter overlay system and simply let it draw on top of the Ogre window.
0 x

gabbsson
Gnoblar
Posts: 20
Joined: Wed Aug 08, 2018 9:03 am
x 3

Re: Letting Qt draw on top of Ogre RenderWindow

Post by gabbsson » Tue Sep 18, 2018 3:43 pm

It turns out that this problem was quite simple. I don't know why but it seems to be an issue with Qt.

As mentioned in my original post my so called OgreWindow is based on QWindow and later used with QWidget::createWindowContainer to handle as a widget. By simply changing the inheritance directly to a QWidget Qt is able to use it as any other widget.

I'm a little mad at myself for not considering this earlier. Using QWidget::createWindowContainer must make something else that Qt does not handle in the same way as other objects.

So to summarize: To allow Qt to handle a widget rendering Ogre, use a QWidget, not a QWindow (even though it supposedly has less overhead and is better).
0 x

Post Reply