QtOgre Application Framework - Now using Qt 4.5

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
Post Reply
Cha
Gnoblar
Posts: 14
Joined: Wed Apr 15, 2009 10:49 am
Location: France, Lille

Re: QtOgre Application Framework - Now using Qt 4.5

Post by Cha »

(Edited)
Hi

Your application is really really great, and easy to use. Thanks a lot, it helps me so much :)

Now, questions time. If it's not the good place to ask, tell me and I'll move it in another subject.
Well, I'm using your application with a scene that i've exported with OFusion. The scene runs correctly if I run it in Ogre, not QtOgre.
I've two problems with QtOgre :
- First, the shadows aren't displayed. Lights are in the scene manager, I can set them invisible. But the method setCastShadows doesn't do anything. Do someone know why ?
- And second, animations. Again, in a basic Ogre application, they run fine, but in QtOgre, nothing moves*. Where you normally call the function "addTime" for your Jaiqua or Robot entities, I call a function updateAnimations(float timeElapsedInSeconds) with the code given by OFusion to run animations.

Here is this code :

Code: Select all

	void DemoGameLogic::updateAnimations(float timeElapsedInSeconds)
	{
		static Ogre::Real currentTime = 0;

		// We update all loaded animations each frame
		Ogre::SceneManager::AnimationIterator animationIt = mSceneManager->getAnimationIterator();

		while(animationIt.hasMoreElements())
		{
			Ogre::Animation* animation = animationIt.getNext();

			const Ogre::Animation::NodeTrackList& trackList = animation->_getNodeTrackList();

			Ogre::Animation::NodeTrackList::const_iterator it = trackList.begin();
			Ogre::Animation::NodeTrackList::const_iterator iend = trackList.end();
			for(; it != iend; ++it)
			{
				const Ogre::NodeAnimationTrack* track = it->second;
				track->getAssociatedNode()->resetToInitialState();
			}

			currentTime += timeElapsedInSeconds/1000;
			animation->apply(currentTime);
		}
	}
Can someone help ?

* Edit : Well, I've deleted the division by 1000 for the timeElapsedInSeconds. And I've noticed that animations moved every time I click or resize the render window, or the log window too. That's really strange, I keep searching.

Anyway, thanks again for this framework :)
Cha
User avatar
PolyVox
OGRE Contributor
OGRE Contributor
Posts: 1316
Joined: Tue Nov 21, 2006 11:28 am
Location: Groningen, The Netherlands
x 18
Contact:

Re: QtOgre Application Framework - Now using Qt 4.5

Post by PolyVox »

Hi, sorry for the slow reply...

Ok, the first thing to point out is that the .scene loader is rather incomplete - I've only implemented handling of the XML nodes which I need for my own project, and only to the extent that I have needed them. So the first question is whether the scene is being loaded properly. To verify this you might find it useful to just set up an animated entity in code, to see how it behaves.

The second thing is that I do remember having problems to get animations to work when I first implemented them in QtOgre. I hadn't used them before, and I vaguely recall that I wasn't calling one of the required functions once per frame. I think this was in OgreWidget::paintEvent(), and it's always possible that there's some other function I'm supposed to call once per frame or something.

However, your observation that timeElapsedInSeconds is most interesting. Is it possible that events are just happening too fast, so that the time elapsed keeps getting rounded down to zero, or something like that? In fact, does my demo work (i,e, do you see the Robot and Jaiqui move)? If so, can you have my robot and your animation in the same scene? What if you add your animation to my scene file? These kind of tests will help narrow down the problem.

Lastly, you can turn down the framerate in case it it simply too fast. Try calling Application::setUpdateInterval() with a value of 10 or so. You'll want to put back in the division by 1000 before you do this.
User avatar
iio
Gnoblar
Posts: 19
Joined: Wed Jul 30, 2008 3:28 pm

Re: QtOgre Application Framework - Now using Qt 4.5

Post by iio »

I've been trying something similar and have come to a point where I have to choose between Qt's namespace and Ogre's. I wanted to make Oge's namespace the dominant one as I think there will be far more Ogre code than Qt code. How did you solve this problem if you don't mind me asking?
User avatar
PolyVox
OGRE Contributor
OGRE Contributor
Posts: 1316
Joined: Tue Nov 21, 2006 11:28 am
Location: Groningen, The Netherlands
x 18
Contact:

Re: QtOgre Application Framework - Now using Qt 4.5

Post by PolyVox »

Well, in my case I have created a new namespace called QtOgre - all my classes are in there. I also tend to avoid 'using namespace' declarations, preferring to fully qualify the class name with the namespace when necessary.
User avatar
iio
Gnoblar
Posts: 19
Joined: Wed Jul 30, 2008 3:28 pm

Re: QtOgre Application Framework - Now using Qt 4.5

Post by iio »

Yeah I thought so and I'm starting to come to that conclusion myself. Thanks for the reply. I browsed your code and thought of doing something similar but I have a number of other packages I want to add so I think I'll just fully qualify everything.
Cha
Gnoblar
Posts: 14
Joined: Wed Apr 15, 2009 10:49 am
Location: France, Lille

Re: QtOgre Application Framework - Now using Qt 4.5

Post by Cha »

Well. First, thanks for your help.
Now, when you've said to try Application::setUpdateInterval(), I realized that I hadn't the svn code. So I take it and configure your code like I want : using the file "resources.cfg" and compiling under Visual Studio. Now, it works so I can test what you've said.

So, for the shadows in my own scene, I'm not using your .scene loader (hum... in fact I don't think so oO), because i use .osm, which is the format when you export with OFusion, and I use the oScene loader with TinyXML, given by OFusion too. That's why I don't understand why shadows don't work. I can access to my entities because I can set them invisible. But nothing for shadows, that's really strange...

For animations... yes, your demo works fine :)
I can add my scene in yours but it doesn't change nothing for animations. Your entities are walking, but as I said, my animations are moving only when I click or resize widget. And if I add the division by 1000, they don't move at all.

I will try Application::setUpdateInterval(), and look if some functions which must be called per frame are missing in paintEvent().
But I'm not using Ogre for a long time, only three months, so animations are a little confuse to me :roll:

Edit : OKKK ! I call Application::setUpdateInterval() just before calling my updateAnimations(float timeElapsedInSeconds) with a value of 122. And animations looks to be "normal" for the two scene I tested. But is it normal that I have a fps of 6-7 when I have more than 600 in Ogre without Qt ??
The problem of shadows is still here but maybe it will be better if I ask in the OFusion forum, don't you think ? Or did someone have already use Ogre shadows in this framework ?
Anyway, thanks again :D
User avatar
PolyVox
OGRE Contributor
OGRE Contributor
Posts: 1316
Joined: Tue Nov 21, 2006 11:28 am
Location: Groningen, The Netherlands
x 18
Contact:

Re: QtOgre Application Framework - Now using Qt 4.5

Post by PolyVox »

Cha wrote:So, for the shadows in my own scene, I'm not using your .scene loader (hum... in fact I don't think so oO), because i use .osm, which is the format when you export with OFusion, and I use the oScene loader with TinyXML, given by OFusion too. That's why I don't understand why shadows don't work. I can access to my entities because I can set them invisible. But nothing for shadows, that's really strange...
Ok, it sounds like you are not using my loading code. However, I don't know what the oFusion loading code does - how much of the shadows does it set up for you? There are various things you needs to do to get shadows working, as described here: http://www.ogre3d.org/docs/manual/manual_70.html#SEC304.

In order to track this down you need to do some more experiments... Do shadows work with oFusion if you use the 'normal' Ogre Example Application, rather than mine. Or, what if you use mine but create the shadows in code rather than through oFusion?

I do have shadows working in my application, which uses my framework. Just as an example, I had to use the following code. I don't know how much of this oFusion does for you...:

Code: Select all

if(qApp->settings()->value("Shadows/EnableShadows", false).toBool())
		{
			mSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);
			//m_pOgreSceneManager->setShadowFarDistance(1000.0f);
			mSceneManager->setShadowTextureSelfShadow(true);
			mSceneManager->setShadowTextureCasterMaterial("ShadowMapCasterMaterial");
			mSceneManager->setShadowTexturePixelFormat(Ogre::PF_FLOAT32_R);
			mSceneManager->setShadowCasterRenderBackFaces(true);
			mSceneManager->setShadowTextureSize(qApp->settings()->value("Shadows/ShadowMapSize", 1024).toInt());
		}
Along with a few other bits maybe. Maybe oFusion sets all this up for you, maybe it doesn't.
Cha wrote:For animations... yes, your demo works fine :)
I can add my scene in yours but it doesn't change nothing for animations. Your entities are walking, but as I said, my animations are moving only when I click or resize widget. And if I add the division by 1000, they don't move at all.

I will try Application::setUpdateInterval(), and look if some functions which must be called per frame are missing in paintEvent().
But I'm not using Ogre for a long time, only three months, so animations are a little confuse to me :roll:

Edit : OKKK ! I call Application::setUpdateInterval() just before calling my updateAnimations(float timeElapsedInSeconds) with a value of 122. And animations looks to be "normal" for the two scene I tested. But is it normal that I have a fps of 6-7 when I have more than 600 in Ogre without Qt ??
The problem of shadows is still here but maybe it will be better if I ask in the OFusion forum, don't you think ? Or did someone have already use Ogre shadows in this framework ?
Anyway, thanks again :D
Just to be clear, the Application::setUpdateInterval() function sets the number of milliseconds between frames. So if you set it to 122 then you will get 1000/122 = 8.2 frames per second. That's not what you want. An interval of 10-30 milliseconds would be more appropriate.
pra
Halfling
Posts: 55
Joined: Sat Jul 15, 2006 4:03 pm
Contact:

Re: QtOgre Application Framework - Now using Qt 4.5

Post by pra »

PolyVox wrote:
  • A log viewer:
    • Syntax highlighting and filtering
    • Qt's message handler are redirected to this system
    • Ogre's logs are also redirected
It's nice and all, but can you also disable this feature? The log manager seems to be extremely integrated into the framework. Or am I supposed to subclass pretty much everything if I do not want this log window?
User avatar
PolyVox
OGRE Contributor
OGRE Contributor
Posts: 1316
Joined: Tue Nov 21, 2006 11:28 am
Location: Groningen, The Netherlands
x 18
Contact:

Re: QtOgre Application Framework - Now using Qt 4.5

Post by PolyVox »

pra wrote:It's nice and all, but can you also disable this feature? The log manager seems to be extremely integrated into the framework. Or am I supposed to subclass pretty much everything if I do not want this log window?
To be honest I didn't give much thought to that. However, once the Application class is initialised it should be possible to call qInstallMsgHandler() from your own code to replace the one that QtOgre has installed. This gets you your Qt log back. As for Ogre, it allows multiple listeners so you can install your own in addition to the QtOgre one. Then just hide the LogManager window, and you should be good to go.

Of course, the Ogre messages are still secretly being logged in the background. If you have a lot and the QtOgre LogManager is causing performance problems then you need a different solution...
Cha
Gnoblar
Posts: 14
Joined: Wed Apr 15, 2009 10:49 am
Location: France, Lille

Re: QtOgre Application Framework - Now using Qt 4.5

Post by Cha »

OK. So, shadows work now.
I had to set the shadow technique on the scene manager manually but now it works. I don't understand, because in a "normal" Ogre application, shadows are displayed with the code given by OFusion, while in QtOgre I have to call setShadowTechnique in code.
However now it works, so thanks :)

And for animations, I still have little problems. I set the value to setUpdateInterval to 122 because that's where animations are running "normally". Under, they move too fast. And if I set it under 47, animations move only if I click or resize a widget.
I try by changing value in setUpdateInterval(), dividing (mCurrent-mLastFrameTime) with other values in DemoGameLogic::update() in your code, and the same for timeElapsedInSeconds in DemoGameLogic::updateAnimations(float timeElapsedInSeconds) in my code given by OFusion - which is in my first post, above. But as I said I don't exactly know how animations work so it's not easy lol
But I keep searching, I can do it :roll:
User avatar
PolyVox
OGRE Contributor
OGRE Contributor
Posts: 1316
Joined: Tue Nov 21, 2006 11:28 am
Location: Groningen, The Netherlands
x 18
Contact:

Re: QtOgre Application Framework - Now using Qt 4.5

Post by PolyVox »

Cha wrote:OK. So, shadows work now.
I had to set the shadow technique on the scene manager manually but now it works. I don't understand, because in a "normal" Ogre application, shadows are displayed with the code given by OFusion, while in QtOgre I have to call setShadowTechnique in code.
However now it works, so thanks :)
I wish I could tell you more... but I haven't done enough work with shadows or OFusion. But I'm glad it works now :-)
Cha wrote:And for animations, I still have little problems. I set the value to setUpdateInterval to 122 because that's where animations are running "normally". Under, they move too fast. And if I set it under 47, animations move only if I click or resize a widget.
I try by changing value in setUpdateInterval(), dividing (mCurrent-mLastFrameTime) with other values in DemoGameLogic::update() in your code, and the same for timeElapsedInSeconds in DemoGameLogic::updateAnimations(float timeElapsedInSeconds) in my code given by OFusion - which is in my first post, above. But as I said I don't exactly know how animations work so it's not easy lol
But I keep searching, I can do it :roll:
Ok, the values you are changing basically just boil down to a single value which gets passed to the addTime() function (at least in my demo code). What happens if you just replace the variable you are passing to addTime() with a constant value, say 0.1? I'm just trying to determine whether the animation code is at fault, or whether there is a problem with the timer.
Cha
Gnoblar
Posts: 14
Joined: Wed Apr 15, 2009 10:49 am
Location: France, Lille

Re: QtOgre Application Framework - Now using Qt 4.5

Post by Cha »

In fact, I'm not using addTime().
Lioric wrote:There is no need to call the getAnimation on the entity, as the entity is not animated at all in Ogre but the node that contains the entity is (an Ogre concept), you get the animation from the scene manager not from the entity (as a single animation can move several different nodes)
And here comes the code I've posted. It get an animation iterator on the scene manager and update each animation. For that, the function apply() is used.

I've already try to do like you, with addTime(), but it didn't work because entities are not animated. getAllAnimationStates() on an entity animated returns NULL.
I've tried to use addTime() on animation state too, but nothing move, even if I setUpdateInterval(10), and if I click or resize a widget, nothing too :

Code: Select all

		mApplication->setUpdateInterval(10);
		float speed = 1.0f;
		if (mSceneManager->hasAnimationState("Move"))
		{
			Ogre::AnimationState *sceneAnimState = mSceneManager->getAnimationState("Move");
			sceneAnimState->addTime( timeElapsedInSeconds * speed );
		}
hasAnimationState() returns true.

Edit : Well, I've try what you say. Instead of passing timeElapsedInSeconds to my function updateAnimations, I've passed it a constant value. And animations are running normally at 2.0 in my scene. I'm not calling setUpdateInterval and everything works fine. Frame per seconds are around 350 so everything is ok... For only one scene. Of course in another scene animations are too fast, and I have to go down to 1.5 for example... But it may be due to my animations. So do you think this is a timer problem, with timeElapsedInSeconds ?
It works for a particular scene but it's not really appropriate to give a constant value. I will be interested if you have an idea on how to resolve this "problem". Thanks again :)

Another question (yes, again lol). It seems that shaders are not working. Do you know if i have to modify something for them to work ?
User avatar
PolyVox
OGRE Contributor
OGRE Contributor
Posts: 1316
Joined: Tue Nov 21, 2006 11:28 am
Location: Groningen, The Netherlands
x 18
Contact:

Re: QtOgre Application Framework - Now using Qt 4.5

Post by PolyVox »

Cha wrote:So do you think this is a timer problem, with timeElapsedInSeconds ?
You could create your own timer (using either Qt or Ogre) and try using that to drive your animations? Just to see whether my timer is at fault. Mine still needs to be present (it drives the frame upates) but you could use your own for animation.
Cha wrote:Another question (yes, again lol). It seems that shaders are not working. Do you know if i have to modify something for them to work ?
Not that I'm aware of. Again, are you sure this is because of QtOgre? Is there anything in the ogre.html log file?
Cha
Gnoblar
Posts: 14
Joined: Wed Apr 15, 2009 10:49 am
Location: France, Lille

Re: QtOgre Application Framework - Now using Qt 4.5

Post by Cha »

I've done my own timer like in the Basic Ogre Framework.
In your initialise() function, I create a new Ogre timer and I reset it. Then, in your update() function, I call a method that I made, here is the code :

Code: Select all

	void DemoGameLogic::runDemo()
	{
		startTime = m_pTimer->getMillisecondsCPU();		
		updateAnimations(timeSinceLastFrame);
		Ogre::Root::getSingleton().renderOneFrame();
		timeSinceLastFrame = m_pTimer->getMillisecondsCPU() - startTime;
	}
I just had to change a value in my updateAnimations() method.

Code: Select all

			currentTime += timeSinceLastFrame/663;
			animation->apply(currentTime);
Before I was dividing timeSinceLastFrame by 1000, now by 663 for animations to run "normally". Don't know why but well, it works for all my animated scenes :)


And for shaders... They are working in Ogre without Qt so... I've added cg.dll in the directory where is the .exe. And that's all, isn't it ? I had nothing else to do for shaders ?



Edit : Ok. I've just added the Ogre Media directory in my resources.cfg and now I've got errors in the log file:

Code: Select all

[...]
	10:45:41 am - 	Parsing script GLSLSwizzle.material
	10:45:41 am - 	Cannot compile GLSL high-level shader : Ogre/GPTest/Swizzle_GP_GLSL opération non valideGeometry shader was successfully compiled to run on hardware.
	10:45:41 am - 	OGRE EXCEPTION(7:InternalErrorException): Cannot compile GLSL high-level shader : Ogre/GPTest/Swizzle_GP_GLSL opération non valideCannot compile GLSL high-level shader : Ogre/GPTest/Swizzle_GP_GLSL opération non valideGeometry shader was successfully compiled to run on hardware. in GLSLProgram::loadFromSource at ..\src\GLSL\src\OgreGLSLExtSupport.cpp (line 66)
	10:45:41 am - 	High-level program Ogre/GPTest/Swizzle_GP_GLSL encountered an error during loading and is thus not supported. OGRE EXCEPTION(7:InternalErrorException): Cannot compile GLSL high-level shader : Ogre/GPTest/Swizzle_GP_GLSL opération non valideCannot compile GLSL high-level shader : Ogre/GPTest/Swizzle_GP_GLSL opération non valideGeometry shader was successfully compiled to run on hardware. in GLSLProgram::loadFromSource at ..\src\GLSL\src\OgreGLSLExtSupport.cpp (line 66)
	10:45:41 am - 	OGRE EXCEPTION(2:InvalidParametersException): Named constants have not been initialised, perhaps a compile error. in GpuProgramParameters::_findNamedConstantDefinition at ..\src\OgreGpuProgram.cpp (line 1087)
	10:45:41 am - 	Compiler error: invalid parameters in GLSLSwizzle.material(15): setting of constant failed
	10:45:41 am - 	OGRE EXCEPTION(2:InvalidParametersException): Named constants have not been initialised, perhaps a compile error. in GpuProgramParameters::_findNamedConstantDefinition at ..\src\OgreGpuProgram.cpp (line 1087)
	10:45:41 am - 	Compiler error: invalid parameters in GLSLSwizzle.material(16): setting of constant failed
	10:45:41 am - 	GLSL compiled : Ogre/GPTest/Passthrough_VP_GLSLVertex shader was successfully compiled to run on hardware. 
[...]
	10:45:42 am - 	Parsing script emitted_emitter.particle
	10:45:42 am - 	OGRE EXCEPTION(2:InvalidParametersException): Cannot find requested emitter type. in ParticleSystemManager::_createEmitter at ..\src\OgreParticleSystemManager.cpp (line 337)
User avatar
PolyVox
OGRE Contributor
OGRE Contributor
Posts: 1316
Joined: Tue Nov 21, 2006 11:28 am
Location: Groningen, The Netherlands
x 18
Contact:

Re: QtOgre Application Framework - Now using Qt 4.5

Post by PolyVox »

Hi, sorry, I'm not getting to post much at the moment. I've been reinstalling my computer over the weekend, and currently don't have QtOgre, etc.

As I recall, QtOgre doesn't make use of 'resources.cfg' (or any of the other configuration files). I might be wrong though, and I don't have the source to hand to check. But it's probably ignoring all the paths you added. I'm not sure what is involved to make it use the 'resources.cfg' file, I've never had to do it. I just set up all my paths in code (I think that's how the QtOgre demo does it).

Same for 'plugins.cfg'. It's ignored, and so QtOgre is probably not loading the particle systems plugin. You'll need to load that yourself and initialise it. Unfortunatly I haven't needed these things myself so haven't added support for them yet...
Cha
Gnoblar
Posts: 14
Joined: Wed Apr 15, 2009 10:49 am
Location: France, Lille

Re: QtOgre Application Framework - Now using Qt 4.5

Post by Cha »

Good luck with your computer :)

So, yes, QtOgre uses resources.cfg. I modify it to use this file and I change my scene using it. Errors have just appeared after I added this in my resources.cfg:

Code: Select all

[Bootstrap]
Zip=./media/Ogre/packs/OgreCore.zip

[General]
FileSystem=./media/Ogre
FileSystem=./media/Ogre/fonts
FileSystem=./media/Ogre/materials/programs
FileSystem=./media/Ogre/materials/scripts
FileSystem=./media/Ogre/materials/textures
FileSystem=./media/Ogre/models
FileSystem=./media/Ogre/overlays
#FileSystem=./media/Ogre/particle
FileSystem=./media/Ogre/gui
FileSystem=./media/Ogre/DeferredShadingMedia
FileSystem=./media/Ogre/PCZAppMedia
Zip=./media/Ogre/packs/cubemap.zip
Zip=./media/Ogre/packs/cubemapsJS.zip
Zip=./media/Ogre/packs/dragon.zip
Zip=./media/Ogre/packs/fresneldemo.zip
Zip=./media/Ogre/packs/ogretestmap.zip
Zip=./media/Ogre/packs/skybox.zip
If I comment the particle line, and remove the CGSwizzle.material, everything compile fine.
For the particle plugin, I will try by adding it in code. And for the CGSwizzle, I searched in Ogre forums and it seems that the problem is coming from my graphic card. I have a ATI Radeon HD 4800 Series, and the driver is up to date.
What is strange is that I hadn't got those errors using Ogre without Qt, and shaders were working fine.
I will search more in forums but it's weird :roll:

Errors I posted before are if I use OpenGL. Here is what I have if I use DirectX:

Code: Select all

05:38:30 pm - 	OGRE EXCEPTION(2:InvalidParametersException): Parameter called lightFalloff does not exist. in GpuProgramParameters::_findNamedConstantDefinition at ..\src\OgreGpuProgram.cpp (line 1097)
05:38:30 pm - 	Compiler error: invalid parameters in deferred_post_minilight.hlsl.program(27): setting of constant failed
Anyway, thanks for your patience :D

Edit : Ok... In fact, even in Ogre without Qt, I got those errors but shaders are working fine. And I've tested on a NVidia card, shaders are not working either in QtOgre. I have to say that I don't understand :|
User avatar
PolyVox
OGRE Contributor
OGRE Contributor
Posts: 1316
Joined: Tue Nov 21, 2006 11:28 am
Location: Groningen, The Netherlands
x 18
Contact:

Re: QtOgre Application Framework - Now using Qt 4.5

Post by PolyVox »

Cha wrote:Edit : Ok... In fact, even in Ogre without Qt, I got those errors but shaders are working fine. And I've tested on a NVidia card, shaders are not working either in QtOgre. I have to say that I don't understand :|
If you can show that the problem is independant of QtOgre then it's probably worth mentioning this in the main forum, rather than just in this thread, as someone might have more idea what's going on.The best approach is always to make the simplest possible example which demonstrates the problem - the act of doing this simplification often helps you realise what is going on :-)
pra
Halfling
Posts: 55
Joined: Sat Jul 15, 2006 4:03 pm
Contact:

Re: QtOgre Application Framework - Now using Qt 4.5

Post by pra »

hm ok.
now I try to create a mainwindow with an mdiarea, with the ogre widged and the log manager being subwindows of it

Code: Select all

       mOgreWidget = new QtOgre::EventHandlingOgreWidget(0, 0);
        mOgreWidget->resize(500,500);
       //Logging should be initialised ASAP, and before Ogre::Root is created.
       initialiseLogging();

       mRoot = new Ogre::Root();
       loadRenderSystemsFromPlugins();

        mainWnd = new Ui::EditorMainWindow(this);
        mainWnd->setupUi();

        mainWnd->mdiArea->addSubWindow(mOgreWidget);  
        mainWnd->mdiArea->addSubWindow(mLogManager);     
and then, in initialize:

Code: Select all

mainWnd->show();
        mOgreWidget->show();
        mOgreWidget->resize(800,600);

	mLogManager->show();
        



	mLogManager->setForceProcessEvents(true);
	initialiseOgre();
first, i'm not able to set the ogre widget's size. it's always "minimized". resize and showNormal have no effect. only if i manually resize it (using the mouse)
second, at some point, the log manager window just loses it's content. it seems to re-appear,a s soon as something is logged, though:
Image
first one is the qtogre widget, second one is the log manager

(im very new to qt, yes :oops: )
PaddyWagon
Halfling
Posts: 94
Joined: Fri Jul 17, 2009 4:39 am
x 1

Re: QtOgre Application Framework - Now using Qt 4.5

Post by PaddyWagon »

I'm an experienced coder and have done some work Ogre already and also generally with frameworks in the past, but never with QT so I'm unfamiliar with QT too :cry:

I have a couple of questions that I hope are general enough to help others in the same situation.

Is it possible to build QtOgre as a DLL without the demo application and reference it that way from my main application? I may have missed seeing this because I'm unfamiliar with qmake/cmake and the conversion of the project into visual studio. And I'd really like to keep the projects separate to ease patches and all that.

This may really be a QT question but the process may be different because of your integration. Let's say I want to make a new window kind of like your FPS widget, it pops up when needed and updates from external data in real time. What's the round trip to creating the GUI piece (QTCreator? which seems to be the 4.5 way), adding all the backing code required to interface with program data and integrating all that within my main visual studio project? And would it be possible to re-edit the GUI (QTCreator, new components, layout etc...) and not lose all the code :D

If that last question is answerable with QT resources, please point the way!
User avatar
iio
Gnoblar
Posts: 19
Joined: Wed Jul 30, 2008 3:28 pm

Re: QtOgre Application Framework - Now using Qt 4.5

Post by iio »

PaddyWagon wrote:I'm an experienced coder and have done some work Ogre already and also generally with frameworks in the past, but never with QT so I'm unfamiliar with QT too :cry:

I have a couple of questions that I hope are general enough to help others in the same situation.

Is it possible to build QtOgre as a DLL without the demo application and reference it that way from my main application? I may have missed seeing this because I'm unfamiliar with qmake/cmake and the conversion of the project into visual studio. And I'd really like to keep the projects separate to ease patches and all that.

This may really be a QT question but the process may be different because of your integration. Let's say I want to make a new window kind of like your FPS widget, it pops up when needed and updates from external data in real time. What's the round trip to creating the GUI piece (QTCreator? which seems to be the 4.5 way), adding all the backing code required to interface with program data and integrating all that within my main visual studio project? And would it be possible to re-edit the GUI (QTCreator, new components, layout etc...) and not lose all the code :D

If that last question is answerable with QT resources, please point the way!
You have to integrate Qt into MSVS first. There are a couple of guides found through google that do this. The problem is that you need Qt's tools to create anything that Qt uses(moc,qmake,etc). I integrated 4.5 with MSVS2009 Express and use QtCreator to set up the cpp, header and moc files and then just cut'n'paste into VS. You could probably just use QtDesigner, create the .ui files and then create the C++ files though I don't know how. You will have to do some setting up of OGRE in QtC if you don't keep your project highly modular though and separate the signals/slots from your Ogre implementation.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: QtOgre Application Framework - Now using Qt 4.5

Post by jacmoe »

No need to mess around with QT Creator to use Qt with Visual Studio Express - just use this:
http://code.google.com/p/xr-qt-msvc/ :wink:

Or, use CMake - it also sets it up automatically.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
PaddyWagon
Halfling
Posts: 94
Joined: Fri Jul 17, 2009 4:39 am
x 1

Re: QtOgre Application Framework - Now using Qt 4.5

Post by PaddyWagon »

I feel a long night of experiments coming on :wink: Thank you both for pointing in the right direction.
User avatar
PolyVox
OGRE Contributor
OGRE Contributor
Posts: 1316
Joined: Tue Nov 21, 2006 11:28 am
Location: Groningen, The Netherlands
x 18
Contact:

Re: QtOgre Application Framework - Now using Qt 4.5

Post by PolyVox »

Hi all...

@pra - I don't a firm answer to either of your questions as I haven't used the components outside the scope of my own framework. But you should probably start by looking at the constructors of both the OgreWidget and the LogManager, as in both cases I am doing unusual things with the window flags. In the case of the LogManager I set the 'Qt::Tool' flag, and in the case of the OgreWidget I set the 'Qt::MSWindowsOwnDC'. Try removing/changing these to see if it makes a difference. I might change the framework at some point so these aren't automatically set. Also, not that the log manager drives from QDialog rather than QWidget. Again, I don't know if this is desirable for your situation.
PaddyWagon wrote:Is it possible to build QtOgre as a DLL without the demo application and reference it that way from my main application? I may have missed seeing this because I'm unfamiliar with qmake/cmake and the conversion of the project into visual studio. And I'd really like to keep the projects separate to ease patches and all that.
I'm a bit hazy on this, but if you look in the CMakeLists.txt you will see a comment where I removed this feature because it was giving some problem (and I didn't need it). You can try uncommenting those lines.
PaddyWagon wrote:This may really be a QT question but the process may be different because of your integration. Let's say I want to make a new window kind of like your FPS widget, it pops up when needed and updates from external data in real time. What's the round trip to creating the GUI piece (QTCreator? which seems to be the 4.5 way), adding all the backing code required to interface with program data and integrating all that within my main visual studio project? And would it be possible to re-edit the GUI (QTCreator, new components, layout etc...) and not lose all the code :D
Most of the widgets were designed in Qt Designer, which is Qt's GUI layout tool. I haven't used QtCreator but if it supports layout editing then I'm sure it will be compatible. Open one of the '.ui' files in 'QtOgre\ui' and see. They are basically .xml files which get converted to C++ by the UIC tool. You then subclass the resulting C++ class to implement behaviour. This should get you started: http://doc.qtsoftware.com/4.5/designer-manual.html
User avatar
bulkhead
Gnoblar
Posts: 20
Joined: Sat Feb 21, 2009 8:44 am

Re: QtOgre Application Framework - Now using Qt 4.5

Post by bulkhead »

Hi all QtOgre masters,

Need help here. I've finally ported my projects from windows SDK to Qt platform, and using QtOgre for the rendering part. I have also written my version of main app to load OgreWidget in a QMainWindow, instead of QApplication in the original example.

Haven't really compared the performace yet, but I have noticed one problem. I added one viewport in my OgreWidget. This is just a normal Ogre viewport created using Ogre::RenderTarget::addViewport(). The viewport was rendered properly previously when running on codes derived from ExampleApplication.h, but after ported to the Qt platform, the scene in the viewport seems to be corrupted.

I suspect it has something to do with the fact that we are now doing the refresh using paintEvent(), instead of through the Ogre::Root::startRendering() loop.

I have tried to set the camera aspectRatio, setOverlaysEnabled(false), and the Qt attributes (i.e. WA_PaintOnScreen, WA_NoSystemBackground, WA_OpaquePaintEvent), but no luck with these.
Additional notes: the viewport is created using Ogre::TexturePtr->getBuffer()->getRenderTarget()->addViewport().

Any ides what could be wrong?

Thanks in advanced.
PaddyWagon
Halfling
Posts: 94
Joined: Fri Jul 17, 2009 4:39 am
x 1

Re: QtOgre Application Framework - Now using Qt 4.5

Post by PaddyWagon »

Just wanted to follow up my work based on your suggestions :D

I decided to stick with the static library build, while the problem with building DLLs is not that severe I agree with your comment that stacking a lot of "qtogre," "ogrexxx" and "ogreyyy" DLLs will end up being more confusion than simply patching the EXE when QtOgre improves over time.

A note for VisualStudio (I use 2008 standard) users, QT4.5 has a very nice integration into the studio. You can create new QT apps, replace the main() it generates with a QtOgre Application class, add the appropriate libraries to the link and away you go. Plus you can create new UI files directly in VS that call up Designer and add all the pieces directly to your project, and this includes the ability to regenerate QT components during a regular VS build cycle. Basically it is the deeply studio integrated version of http://code.google.com/p/xr-qt-msvc/ with more automation.
Post Reply