Page 1 of 1
Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Sun Apr 05, 2009 5:54 pm
by PolyVox
Hi guys,
Has anyone here sucessfully embedded an Ogre window into an application built with Qt 4.5? I'd heard my QtOgre framework had problems with it, and today I upgraded and saw the problem for myself. The image only appears in 'bands' which move up and down very quickly. Hence you do see the whole image, but there is a lot of flickering.
It occurs with all Qt graphics systems ('native', 'raster', and 'opengl') and with both Ogre's OpenGL and Direct3D rendersystems.
Actually the flickering does go away if I pass Ogre a 'parentWindowHandle' rather than an 'externalWindowHandle', but then the image is offset by a few hundred pixels. Does anyone know the conceptual difference between these flags?
I don't really know how to fix it, so I'll be reverting to Qt 4.4 unless anyone has any ideas...
Re: Anyone using Ogre with Qt 4.5?
Posted: Mon Apr 06, 2009 10:10 am
by rtlpixy
I have just fixed it now !
You have simply to override the paintEngine method on the OgreWidget and return 0.
Code: Select all
QPaintEngine *OgreWidget:: paintEngine() const
{
return 0;
}
On Windows works, if you can test on other platforms it is better.
Best,
Angelo
Re: Anyone using Ogre with Qt 4.5?
Posted: Mon Apr 06, 2009 12:38 pm
by nikki
Or you could just tell the users it's a 'feature' and forget about it.

Re: Anyone using Ogre with Qt 4.5?
Posted: Mon Apr 06, 2009 6:07 pm
by PolyVox
rtlpixy wrote:I have just fixed it now !
You have simply to override the paintEngine method on the OgreWidget and return 0.
Excellent work! I just tested it and it seems good. You just saved me a lot of pain - thanks a lot! I will add this fix to SVN.
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Wed Aug 26, 2009 4:15 pm
by Mans
Hi,
Has anyone managed to make it work on a Mac ?? I had an application that worked with Qt 4.4.0 and I added the exact same fix to make it work with 4.5 (override paintEngine to make it return 0), but I have a blank widget on Mac... It works fine on Linux&Windows though.
I am using Qt 4.5.2 and Ogre 1.4.9. Any help will be more than welcome...

Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Wed Aug 26, 2009 5:18 pm
by jacmoe
qtOgitor runs on the Mac.
I am not sure if it does using Ogre 1.4.9, but it does using Ogre trunk and Qt 4.5.

Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Thu Aug 27, 2009 9:31 am
by Mans
Ok, thanks ! I am going to try to compare our sources then. I'll post something here if I manage to make it work !
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Thu Aug 27, 2009 10:41 am
by Mans
Unfortunately QtOgitor is using Ogre >= 1.7. And I tried to compare our code, the widget initialization and painting are identical... Maybe I will try to upgrade my Ogre version, but I am quite afraid of the time I will spend on making it compile

.
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Thu Aug 27, 2009 2:30 pm
by jacmoe
I told you we were using trunk.
I think it's definitely worth your while to upgrade.
Especially since Masterfalcon joined the team we should see much improved support for the Mac.

Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Thu Aug 27, 2009 2:47 pm
by Mans
Oups, sorry I read your post too quickly

.
I just passed Ogre from 1.4.3 to 1.6.3 (latest SDK released), but I still got the same problem : my widget that should display Ogre is all blank !!
I wasn't doing all the hiddenparam stuff at OgreWidget initialization (and the creation of another OgreRenderWindow), but even by doing so it does not work... I am quite stuck here, especially because I am a windows developper and don't know very well MacOSX

Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Thu Aug 27, 2009 3:50 pm
by joew
Try doing what Jacmoe said and grab the source from trunk, I am using it with Qt 4.5 on the mac and have no problems.
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Thu Aug 27, 2009 4:16 pm
by Mans
Yes I don't see any other option at the moment. I am going to try to compare a little more thoroughly the way we wrote our OgreWidget class before that though.
I don't see why it will work with a more recent version of Ogre though, as it is a change in Qt that causes the regression... But I will test it anyway

Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Fri Aug 28, 2009 4:21 pm
by Mans
Unfortunately, I didn't manage to compile Ogre from the trunk... It seems like I am going to spend hours on it...
Is there anyone that could explain to me the code of Qt Ogitor ? Because I don't understand why you need to create a "hiddenparams" stuff, and initialize a second Ogre::RenderWindow with it. I tried to do that as well, but it does not change anything...
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Fri Aug 28, 2009 7:24 pm
by jacmoe
'hiddenParams' is used for the primary, hidden window. It passes the handle of the grand-parent window.
Do not worry about that.
Code: Select all
Ogre::NameValuePairList params;
params["externalWindowHandle"] = Ogre::StringConverter::toString((size_t) (this->winId()));
mWhateverRenderWindow = mWhateverOgreRoot->createRenderWindow( "WhateverRenderWindow",
this->width(),
this->height(),
false,
¶ms );
Provided you've got the latest Ogre, that code should work.

Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Mon Aug 31, 2009 8:45 am
by Mans
Hi,
Thanks for your answer

!
Is it a known problem that the latest Ogre is needed with Qt 4.5 ? My problem is the following : we are about to release a new version of a professional tool. And I don't really feel comfortable releasing something with Ogre trunk. I'd rather use an official SDK from a stable branch (1.4.x or 1.6.x)...
Sorry to be so painful...

Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Mon Aug 31, 2009 10:53 pm
by jacmoe
The only thing I can think of is .. try and use parentWindowHandle instead.
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Tue Sep 01, 2009 8:02 am
by Mans
Hi,
Thanks for the suggestion ! I just tried to do so and something odd happens : my ogreWidget is still all blank. However, I have another floating QWidget (named after my renderwidget "View"). And this widget is correctly resized when I resize my ogrewidget. Quite strange actually. But I do see some Ogre rendering, which seems good !
The only other way I found to see something from Ogre was to set the "fullscreen" param to true when creating the renderwindow. What I see then is crazy, but I can distinguish some part from Ogre...
Well I don't really know what to do next, besides crying under my desk

Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Posted: Wed Nov 04, 2009 3:29 pm
by Mans
Hi,
I just solved my problem after crying for some months. I post the solution here, as it may save some lives of a future generation ^^.
My problem was that I initialized all the Ogre stuff too soon (before any QWidget was displayed), and it seems that the window handle returned by Qt was not valid yet. I now call the Ogre initialization when my mainwindow is about to be displayed for the first time, and it works... Thanks for all the help above !