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
User avatar
Jules Robichaud Gagnon
Goblin
Posts: 227
Joined: Thu Jan 18, 2007 2:13 pm
Location: Chicoutimi, Québec

Re: QtOgre Application Framework - Now using Qt 4.5

Post by Jules Robichaud Gagnon »

Hi Everyone,

I have a question about running QT 4.5 (built with -direct3d flag) with Ogre on direct3D with Windows Aero.

If i understand well, the GPU will not need to copy the frame buffers to the ram in order to handle the blending, everything will be done hardware. Is that right?

And should we use "native" or "raster" ?
The Windows version of Qt supports an additional command line option, if Direct3D support has been compiled into Qt:

* -direct3d will make the Direct3D paint engine the default widget paint engine in Qt. This functionality is experimental.
void QApplication::setGraphicsSystem ( const QString & system ) [static]

Sets the default graphics backend to system, which will be used for on-screen widgets and QPixmaps. The available systems are "native", "raster" and "opengl".

This function call overrides both the application commandline -graphicssystem switch and the configure -graphicssystem switch.

Warning: This function must be called before the QApplication constructor is called.

Note: The "opengl" option is currently experimental.

This function was introduced in Qt 4.5.
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 »

I don't have much information about this I'm afraid - I did look into it a year ago but that was on Vista and I can't really recall what I found. Also I think I couldn't get Qt to build with the -direct3d option. At any rate this framework just sets the widget opacity with the QWidget::setWindowOpacity() function. Also, even if you run both Qt and Ogre using their respective OpenGL render systems then they are still maintaining seperate OpenGL contexts. Sorry I can't be more help!
vectori
Gnoblar
Posts: 21
Joined: Tue Sep 15, 2009 12:11 pm

Re: QtOgre Application Framework - Now using Qt 4.5

Post by vectori »

Is there any way to include orgewidget into Qt ui form.

example:
in fullscreen mode there is navibar on the side and other area is filled by ogrewidget.

or
is it only possible to render qt stuff in the ogre window ?
I'm just really needing those qt widgets to work in the same window..

reason is that i only could use one window in my app. and i don't want to make other window for menu etc.. they should be on the side.

THANKS !
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, my application framework always creates a single main window with a OgreWidget as the main widget. However, if you copy the OgreWidgt.cpp and .h files into your own project you should just be able to use them as regular Qt widgets (maybe some tweaking is required as I haven't tried it). This means you should be able to add them as children of other widgets, etc. If you only need the OgreWidget (rather than the rest of my framework) then you might also look at the http://www.ogitor.org/ project which also uses their own version of an OgreWidget in a more full-featured GUI.
azzolini
Gnoblar
Posts: 16
Joined: Sun Oct 18, 2009 10:14 pm

Re: QtOgre Application Framework - Now using Qt 4.5

Post by azzolini »

Great work!

I installed your souce and compiled the demo.
Now i have a question about directx9

If i choose directx9 i get an error ogre exception failed to create direct3d9 device invalid call in ::3d9renderwindow

This happens in your prebuild release version and also in the one i compiled.

I tried to change option and resolution but no luck.

No problem with OpenGL.

Running Ogre samples i can use direct3d9 whitout any error

Is this a known issue?

Thanks
Lorenzo
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 »

Interesting, did you look at the log? It should be saved in logs/Ogre.html. Post it here and it might help work out what is going on.
azzolini
Gnoblar
Posts: 16
Joined: Sun Oct 18, 2009 10:14 pm

Re: QtOgre Application Framework - Now using Qt 4.5

Post by azzolini »

Sorry Polivox, i cannot see any logs/Ogre.html file neither in ogreSDK directories... neither in qtogre directories...
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 »

The 'logs' directory should be created in the working directory of the executable when you run it. Am I correct in thinking that you have got the QtOgre code from SVN, built it using CMake, and are running through the Visual Studio IDE? If so, I find the logs folder here:

C:\ogreaddons\QtOgreFramework\build\Demo\logs

Note that it is in the 'Demo' folder not the 'QtOgre' folder, because that is where the executable is. Otherwise, try going to the QtOgreFramework folder and making Windows do a search for all html files?
azzolini
Gnoblar
Posts: 16
Joined: Sun Oct 18, 2009 10:14 pm

Re: QtOgre Application Framework - Now using Qt 4.5

Post by azzolini »

Yes, i do things as you supposed.
MeanWhile, I had to use a particlesystem so i realized that i was missing something !
Infact I discovered that I missed to get the file plugin.cfg in build/demo/debug directory where i have my executable.
So i copied this file in the build/demo/debug directory and now in the realtime log I see the direct3d device loaded.

the contents of the plugin.cfg are the following
--------------
# Defines plugins to load
# Define plugin folder
PluginFolder=.

# Define plugins
Plugin=RenderSystem_Direct3D9_d.dll // here I supposed the direct3d device has now loaded
Plugin=RenderSystem_GL_d.dll
Plugin=Plugin_ParticleFX_d.dll // here the particlesystem
Plugin=Plugin_BSPSceneManager_d.dll
Plugin=Plugin_CgProgramManager_d.dll
Plugin=Plugin_PCZSceneManager_d.dll
Plugin=Plugin_OctreeZone_d.dll
Plugin=Plugin_OctreeSceneManager_d.dll
--------------

Now the direct3d device seems to be found but... now
when i close the qtogre executable ( after running in the visual studio 2005 IDE )
i get an error at

Application::~Application()
{
if (mRoot)
delete mRoot; // HERE THE ERROR
}

saing that....

First-chance exception at 0x01d5cb00 in demo.exe: 0xC0000005: Access violation reading location 0x000050f5.
Unhandled exception at 0x01d5cb00 in demo.exe: 0xC0000005: Access violation reading location 0x000050f5.

It seems like there is something loading from plugin.cfg that conflicts with something already loaded from qtogre ?

I think your work is a very exciting one and I would be very interested in making it fully working,
almost for who, like me, is trying to understand the path you made to wrap the Ogre !

Finally... I tried to search for log/ogre.html in all the drives but cannot find any.

Thanks for your gently replay
bye Lorenzo
azzolini
Gnoblar
Posts: 16
Joined: Sun Oct 18, 2009 10:14 pm

Re: QtOgre Application Framework - Now using Qt 4.5

Post by azzolini »

sorry, I tried now some debugging...

I see that if I put plugin.cfg in the directory where i have the executable
I got errors... loading the following plug-ins

Plugin=Plugin_BSPSceneManager_d.dll
Plugin=Plugin_CgProgramManager_d.dll
Plugin=Plugin_PCZSceneManager_d.dll
Plugin=Plugin_OctreeZone_d.dll
Plugin=Plugin_OctreeSceneManager_d.dll

while..
if I load

# Plugin=RenderSystem_Direct3D9_d.dll
# Plugin=RenderSystem_GL_d.dll

i got the error in application destructor, when closing the qtogre window
-------
Application::~Application()
{
if (mRoot)
delete mRoot; // HERE THE ERROR
}
-------

THE ONLY PLUGIN I was allowed to load is

Plugin=Plugin_ParticleFX_d.dll

this way I can declare a particlesystem like in the following code

Ogre::ParticleSystem *pSys2 = mSceneManager->createParticleSystem("fountain1", "PEExamples/stoneh2");
mFountainNode = mSceneManager->getRootSceneNode()->createChildSceneNode();

but if I try to attach the particlesystem with...

mFountainNode->attachObject(pSys2);

I get a compiler error:

error C2664: 'Ogre::SceneNode::attachObject' : cannot convert parameter 1 from 'Ogre::ParticleSystem *' to
'Ogre::MovableObject *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

THIS IS WHAT I WAS ABLE to TRY till now

Bye
Lorenzo
azzolini
Gnoblar
Posts: 16
Joined: Sun Oct 18, 2009 10:14 pm

Re: QtOgre Application Framework - Now using Qt 4.5

Post by azzolini »

Ok btw the problem with particlesystem was due to a stupid forgetting... not included ogreparticlesystem.h

Instead the reason why I cannot find the log/ogre.html was due to... the 4th variable passed to createlog
if set to false the log is not created.

// mInternalOgreLog = mInternalOgreLogManager->createLog("Ogre.log", false, true, true);
mInternalOgreLog = mInternalOgreLogManager->createLog("Ogre.log", false, true, false);

( and in the source, if created the file is named Ogre.log )

This is the final part of ogre.log

02:00:58: *-*-* OGRE Initialising
02:00:58: *-*-* Version 1.6.1 (Shoggoth)
02:00:58: Loading library RenderSystem_GL_d
02:00:58: Installing plugin: GL RenderSystem
02:00:58: OpenGL Rendering Subsystem created.
02:00:59: Plugin successfully installed
02:00:59: Loading library RenderSystem_Direct3D9_d
02:00:59: Installing plugin: D3D9 RenderSystem
02:00:59: D3D9 : Direct3D9 Rendering Subsystem created.
02:00:59: D3D9: Driver Detection Starts
02:00:59: D3D9: Driver Detection Ends
02:00:59: Plugin successfully installed
02:01:02: CPU Identifier & Features
02:01:02: -------------------------
02:01:02: * CPU ID: GenuineIntel: Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz
02:01:02: * SSE: yes
02:01:02: * SSE2: yes
02:01:02: * SSE3: yes
02:01:02: * MMX: yes
02:01:02: * MMXEXT: yes
02:01:02: * 3DNOW: no
02:01:02: * 3DNOWEXT: no
02:01:02: * CMOV: yes
02:01:02: * TSC: yes
02:01:02: * FPU: yes
02:01:02: * PRO: yes
02:01:02: * HT: no
02:01:02: -------------------------
02:01:02: D3D9 : Subsystem Initialising
02:01:02: ***************************************
02:01:02: *** D3D9 : Subsystem Initialised OK ***
02:01:02: ***************************************
02:01:03: D3D9RenderSystem::_createRenderWindow "OgreWindow", 800x600 windowed miscParams: FSAA=8
externalWindowHandle=4917842
02:01:03: D3D9 : Created D3D9 Rendering Window 'OgreWindow' : 800x600, 32bpp
02:01:03: D3D9 : WARNING - disabling VSync in windowed mode can cause timing issues at lower frame rates, turn VSync on
if you observe this problem.
02:01:03: OGRE EXCEPTION(3:RenderingAPIException): Failed to create Direct3D9 Device: Invalid call in
D3D9RenderWindow::createD3DResources at
f:\codingextra\ogre\shoggoth_vc8\ogre\rendersystems\direct3d9\src\ogred3d9renderwindow.cpp (line 597)



Resume:
1) in plugin.cfg I only loaded particlesystem.dll plugin
2) no problem with OpenGL
3) impossible to use direct3d for: Invalid call in D3D9RenderWindow::createD3DResources


BTW I noted that text between
#if defined(Q_WS_WIN)
#endif
is always grayed out... and my system is windows xp, is this by design ?
May I have to #include some stuff for direct3d in windows xp ?

bye
lorenzo
azzolini
Gnoblar
Posts: 16
Joined: Sun Oct 18, 2009 10:14 pm

Re: QtOgre Application Framework - Now using Qt 4.5

Post by azzolini »

Ok I found the reason why direct3d gives the error

ogreWindowParams["FSAA"] = "8";

cannot be used directly from code on direct3d
Instead if the line is commented, then U can set FSAA to 8 in setting dialog

That's all



void Application::initialise(void)
{

mOgreWidget->show();

mOgreWidget->resize(800,600);
centerWidget(mOgreWidget);

//mLogManagerDockWidget = mMainWindow->addAsDockWidget(mLogManager, "Logs", Qt::AllDockWidgetAreas);
//mLogManager->setParent(mMainWindow);
centerWidget(mLogManager, mOgreWidget);

//mLogManager->show();
mLogManager->setForceProcessEvents(true);
initialiseOgre();
Ogre::NameValuePairList ogreWindowParams;
//ogreWindowParams["FSAA"] = "8"; problem is HERE comment this line


bye
Lorenzo
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 am too slow to answer your questions! But actually it seems like you are doing a great job of working it out :-)
azzolini wrote:Instead the reason why I cannot find the log/ogre.html was due to... the 4th variable passed to createlog
if set to false the log is not created.

// mInternalOgreLog = mInternalOgreLogManager->createLog("Ogre.log", false, true, true);
mInternalOgreLog = mInternalOgreLogManager->createLog("Ogre.log", false, true, false);

( and in the source, if created the file is named Ogre.log )
Actually, my framework deliberatly turns off the 'Ogre.log' file, because it is supposed to generate the 'Ogre.html' file instead. The advantage of the .html version is that is uses different colours for errors, warnings, etc. This should happen in Log.cpp with the following code:

//Create a file to write this log to disk.
QString filename;
QTextStream(&filename) << "logs/" << mName << ".html";
mFile = new QFile(filename, this);
mFile->open(QFile::WriteOnly | QFile::Truncate | QFile::Text | QIODevice::Unbuffered);
mTextStream.setDevice(mFile);

Maybe you can use the debuggger on the code to see what is happening?
azzolini wrote:Ok I found the reason why direct3d gives the error

ogreWindowParams["FSAA"] = "8";

cannot be used directly from code on direct3d
Instead if the line is commented, then U can set FSAA to 8 in setting dialog
Well I'm glad you found it, but it is strange that I don't have that problem on my computer. However, the settings dialog cannot actually be used to control the FSAA value. Although the control exists, I have not written the code to use it yet :-)

I will try to investigate the problems with plugins.cfg when I have more time.
Netich
Halfling
Posts: 40
Joined: Tue Oct 06, 2009 8:52 am

Re: QtOgre Application Framework - Now using Qt 4.5

Post by Netich »

Hi, great work you have done with this framework.
I plan to use it for my degree project. I have designed some widgets, and hopefully some of them (the less specific ones) can be included in the framework:
- an entities and objects tree widget, where you can select them and perform some basic actions.
- a profiler, where some classes can suscribe and set timers between two points to see man/min/mean. Maybe several threads could suscribe too to test how they overlap and avoid race conditions.

I am testing the framework with ogre 1.6.5 and Qt 4.6 built with VS2008. I have two questions:
- in my laptop (which has an integrated Intel GPU) the ogre widget doesnt update if another widget overlap it, any help on this?
- this is a suggestion: to make the framework easier, the "onMousePress", "onMouseMove" and such could have a default behaviour in gameLogic class, so you dont have to override them for the basic usage.

Again, thanks for this great framework.
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, thanks for your comments! I am interested in your work but unfortunately I am traveling for a few weeks and so I won't be able to test or integrate anything until the end of the month. But I think it sounds very promising.
Netich wrote:- an entities and objects tree widget, where you can select them and perform some basic actions.
Yep, sounds useful. How does the synchronization work? If you modify the scene graph through code, or by responding to keyboard event for example, does the widget automatically update?
Netich wrote:- a profiler, where some classes can suscribe and set timers between two points to see man/min/mean. Maybe several threads could suscribe too to test how they overlap and avoid race conditions.
Also good. I don't make any explicit use of threads in the framework though applications built on the framework can of course use them (as my engine does).

I trust you are happy to contribute your code under the zlib license?
Netich wrote:I am testing the framework with ogre 1.6.5 and Qt 4.6 built with VS2008. I have two questions:
- in my laptop (which has an integrated Intel GPU) the ogre widget doesnt update if another widget overlap it, any help on this?
I don't recall seeing this problem... do you get it with both OpenGL and Direct3D render systems? Also, can you test on a system with a better graphics card (I have also seen differences between Win XP and Vista/Win7)? Also, I haven't tried Qt 4.6 yet but I will do so when I get a chance.
Netich wrote:- this is a suggestion: to make the framework easier, the "onMousePress", "onMouseMove" and such could have a default behavior in gameLogic class, so you don't have to override them for the basic usage.
Possibly, I will think about this when I have the code to hand :)
JonnyJP
Goblin
Posts: 231
Joined: Sun Nov 01, 2009 4:23 pm
x 2

Re: QtOgre Application Framework - Now using Qt 4.5

Post by JonnyJP »

Do you have a simple Visual Studio project or solution please?

All I need is an Ogre Widget (preferably dockable) that can handle keyboard / mouse input as well as doing stuff on a timer.

I've used the basic tutorial at

http://projectify.blogspot.com/2009/06/ ... press.html

but I could only get the OgreWidget added like this...

Code: Select all

MyClass::MyClass(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
ui.setupUi(this);

QtOgre::OgreWidget* m_pWidget = new QtOgre::OgreWidget(this);
//Add the widget to the QMainWindow
setCentralWidget(m_pWidget);

// this then goes on doing code that I would normally do in createScene of ExampleApplication
}
where MyClass was created using the New Project -> New Qt4 Application.

Any help appreciated, and preferably head-ache tablets and some general purpose wall filler.
JonnyJP
Goblin
Posts: 231
Joined: Sun Nov 01, 2009 4:23 pm
x 2

Re: QtOgre Application Framework - Now using Qt 4.5

Post by JonnyJP »

Just to clarify, if the mouse cursor is over the OgreWidget I want to be able to move the camera using WASD and clicking and dragging in here will rotate the camera. Once the mouse cursor leaves the OgreWidget, it should still carry on doing whatever timed animation it was doing before.

Cheers
JonnyJP
Goblin
Posts: 231
Joined: Sun Nov 01, 2009 4:23 pm
x 2

Re: QtOgre Application Framework - Now using Qt 4.5

Post by JonnyJP »

Pleeeeeeeeeeeeeeeeeeeeeeeeease help!
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 »

I think we have some confusion here. This forum thread describes my own framework to integrate Qt and Ogre. However, the basic tutorial which you link to describes someone elses attempt. That is, there is no link between the QtOgreFramework which you can read about in this thread, and the basic tutorial which you are reading on BlogSpot.

My own QtOgre Framework (which this thread discusses) is more advanced and also more complex than the one you see in that basic tutorial. However, there is naturally a lot of overlap so you might find it useful to download my framework and compare. You can get the latest version from Ogre Addons (http://www.ogre3d.org/developers/addons) or you can find an older version here: http://www.david-williams.info/linked_f ... Source.zip.

If you have questions about that blog post, you might want to try contacting the author directly.
JonnyJP
Goblin
Posts: 231
Joined: Sun Nov 01, 2009 4:23 pm
x 2

Re: QtOgre Application Framework - Now using Qt 4.5

Post by JonnyJP »

I know I'm talking about someone elses attempt, but I've had no luck with them. Since you've managed to create this framework you must have experience in what I'm trying to do, surely?

Thanks for the links, I'll have a play around and post if I get it working. Please offer any suggestions for things to try.
JonnyJP
Goblin
Posts: 231
Joined: Sun Nov 01, 2009 4:23 pm
x 2

Re: QtOgre Application Framework - Now using Qt 4.5

Post by JonnyJP »

Ok, another direction. How do I use your framework with Visual Studio 2005 pro?
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 »

JonnyJP wrote:Ok, another direction. How do I use your framework with Visual Studio 2005 pro?
In order to build the framework you have to download CMake from http://www.cmake.org/ and use it to generate the Visual Studio files. Install this, and then create a folder called 'build' in the QtOgreFramework folder. Open a DOS box, change into this build folder, and run 'cmake ..' to run CMake against the CMakeLists.txt file in the parent directory. This should then generate the Visual Studio files.

That said, it might not 'just work' and I've sometimes found I have to fiddle around with the CMake scripts to get it working the first time. You might be better off just copying the OgreWidget and EventHandlingOgreWidget classes, studying them, and trying to work out how to integrate them into your own project.
JonnyJP
Goblin
Posts: 231
Joined: Sun Nov 01, 2009 4:23 pm
x 2

Re: QtOgre Application Framework - Now using Qt 4.5

Post by JonnyJP »

No it didn't just work doing that (I found the instructions in the earlier part of the thread). I didn't even have the .exe or linker options in project preferences when I opened it up in Visual Studio which was strange.

Anyway, I've eventually got it compiled and running (I had to remove lots of bits here and there). So now I'm just trying to gradually reduce it piece by piece, module by module, until I've got the bare minimum.

Thanks everyone for the support.
JonnyJP
Goblin
Posts: 231
Joined: Sun Nov 01, 2009 4:23 pm
x 2

Re: QtOgre Application Framework - Now using Qt 4.5

Post by JonnyJP »

Right, I've stripped out all the stuff I don't need and now have an OgreWidget as the central widget on a form with a dockable widget. The mouse and keyboard events seem to be working fine. However, the Ogre view is flickering like crazy!

My main function looks like this...

Code: Select all

int main(int argc, char *argv[])
{
  // This is the same Application as the framework with stuff ripped out
  QtOgre::Application* w = new QtOgre::Application(argc, argv, 0);

  // Just a normal QMainWindow with the menu, toolbar and status bar (that I need).
  QMainWindow* mainWin = new QMainWindow();

  // This is a simple class that's created based on the .ui file I added
  ui::ApplicationClass ui;  
  ui.setupUi(mainWin);

  // Show the QMainWindow
  mainWin->show();

  // Add the ogre widget to the QMainWindow
  mainWin->setCentralWidget(w->mainWidget());

  return w->exec();
}
This seems like an arse about face way of doing things as I'd imagine it would be better to have the OgreWidget inside a custom QMainWindow, but its the closest I've got so far.

Any ideas on the flickering? Any help is appreciated.

Cheers

JP
User avatar
Lee04
Minaton
Posts: 945
Joined: Mon Jul 05, 2004 4:06 pm
Location: Sweden
x 1

Re: QtOgre Application Framework - Now using Qt 4.5

Post by Lee04 »

Does this framework and QT work as well if I have Ogre running in a browser?
Ph.D. student in game development
Post Reply