Integrating Ogre 1.7.4 with Qt 4.8.0

Problems building or running the engine, queries about how to use features etc.
Post Reply
vdrum
Gnoblar
Posts: 4
Joined: Tue Mar 20, 2012 11:41 pm

Integrating Ogre 1.7.4 with Qt 4.8.0

Post by vdrum » Wed Mar 21, 2012 12:41 am

Hi,

I'm experimenting the integration of Ogre within a QWidget.
A fairly simple task in view of the many threads one can find here and in other forums.
However, I have tried many of the advices I have found and still my QOgreWidget shows, after 2 days of digging in the forums, nothing else than a black background.

Technically, I'm trying to integrate Ogre 1.7.4 with Qt 4.8.0 compiling with Visual C++ 2010 Express on a Windows 7 64 bits.
I have no issue with compilation. At execution, the QWidget remains black.

As shown in the attached code extract, the viewport's got a red background which I can see subtly perceive when I rapidely resize back and forth the window.
It acts as if, immediately after Ogre::Root::update() had the chance to draw, Qt was redrawing the widget in black (or was wrongly swapping the buffers).
And of course the simple basic cube is not displayed :(

I have also added in the code extracts comments describing different behaviours occuring when some lines of code are uncommented.

Unless someone finds something wrong or missing in the code, I suspect an issue due to the version of Qt (4.8.0).
Anybody's got an idea ? Thx ;-)

QOWidget.h

Code: Select all

#ifndef QOWIDGET_H
#define QOWIDGET_H

#include <QtGui/QWidget>
#include <QtGui/QShowEvent>
#include <QtGui/QMoveEvent>
#include <QtGui/QResizeEvent>
#include <QtGui/QPaintEvent>
#include <Ogre.h>

class QOWidget : public QWidget
{
    // --- Constructors & Destructor ---
public:
    QOWidget(QWidget* parent = 0);
    ~QOWidget();

    // --- Getters & Setters ---
public:
    Ogre::RenderWindow* GetOgreRenderWindow() { return m_pOgreRenderWindow; }
    Ogre::Viewport* GetOgreViewport() { return m_pOgreViewport; }
    Ogre::Camera* GetOgreCamera() { return m_pOgreCamera; }

    // --- Virtual Methods Implementation ---
protected:
    virtual void showEvent(QShowEvent* event);
    virtual void moveEvent(QMoveEvent* event);
    virtual void resizeEvent(QResizeEvent* event);
    virtual void paintEvent(QPaintEvent* event);
    virtual QPaintEngine* paintEngine();

    // --- Private Operators ---
private:
    void initOgreSystem();
    void createRenderWindow();
    void createViewport();
    void createCamera();
    void createDefaultLight();
    void loadMeshFile();
    void loadResources();

private:
    Ogre::Root*         m_pOgreRoot;
    Ogre::SceneManager* m_pOgreSceneManager;
    Ogre::RenderWindow* m_pOgreRenderWindow;
    Ogre::Viewport*     m_pOgreViewport;
    Ogre::Camera*       m_pOgreCamera;

};

#endif QOWIDGET_H
QOWidget.cpp

Code: Select all

#include <QtCore/QDebug>

#include "QOWidget.h"


QOWidget::QOWidget(QWidget *parent)
    : QWidget(parent)
{
    m_pOgreRoot = 0;
    m_pOgreSceneManager = 0;
    m_pOgreRenderWindow = 0;
    m_pOgreViewport = 0;
    m_pOgreCamera = 0;

    // Here I have tried many combination of attribute settings
    setAttribute(Qt::WA_OpaquePaintEvent);
    setAttribute(Qt::WA_PaintOnScreen);
    //setAttribute(Qt::WA_NoSystemBackground);
    //setAutoFillBackground(false);
}

QOWidget::~QOWidget()
{
}

void QOWidget::initOgreSystem()
{
    if (m_pOgreRoot)
        return;

    // Create and store the root node
    m_pOgreRoot = new Ogre::Root();

    // Initialize the render system
    //Ogre::RenderSystem* pRenderer = m_pOgreRoot->getRenderSystemByName("Direct3D9 Rendering Subsystem");
    Ogre::RenderSystem* pRenderer = m_pOgreRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
    m_pOgreRoot->setRenderSystem(pRenderer);

    // Initialize the Ogre system without creating a window
    // which is delegated to Qt
    m_pOgreRoot->initialise(false);

    // Create the Scene Manager object
    m_pOgreSceneManager = m_pOgreRoot->createSceneManager(Ogre::ST_GENERIC);

    // Load resources based on config files
    loadResources();

    createRenderWindow();
    createCamera();
    createViewport();
    createDefaultLight();

    // Trying to push the init of Root later in the process
    // but it does not solve the issue
    //m_pOgreRoot->initialise(false);

    loadMeshFile();
}

void QOWidget::loadResources()
{
    Ogre::ConfigFile cf;
    cf.load("./resources.cfg");

    // Go through all sections & settings in the file
    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

    Ogre::String secName, typeName, archName;
    while (seci.hasMoreElements())
    {
        secName = seci.peekNextKey();
        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
        Ogre::ConfigFile::SettingsMultiMap::iterator i;
        for (i = settings->begin(); i != settings->end(); ++i)
        {
            typeName = i->first;
            archName = i->second;
            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
                archName, typeName, secName);
        }
    }
}


void QOWidget::loadMeshFile()
{
    Ogre::Entity* pEntity = m_pOgreSceneManager->createEntity("Mesh", "cube.mesh");
    Ogre::SceneNode* pNode = m_pOgreSceneManager->getRootSceneNode()->createChildSceneNode();
    pNode->attachObject(pEntity);
}

/*
 * Virtual implementation
*/
void QOWidget::showEvent(QShowEvent* event)
{
    if (!m_pOgreRenderWindow)
    {
        initOgreSystem();
    }
    QWidget::showEvent(event);
}

void QOWidget::moveEvent(QMoveEvent* event)
{
    QWidget::moveEvent(event);
    if (event->isAccepted() && m_pOgreRenderWindow)
    {
        m_pOgreRenderWindow->windowMovedOrResized();
        update();
    }
}

void QOWidget::resizeEvent(QResizeEvent* event)
{
    QWidget::resizeEvent(event);
    if (event->isAccepted())
    {
        const QSize& newSize = event->size();
        if (m_pOgreCamera)
        {
            Ogre::Real aspectRatio = Ogre::Real(newSize.width()) / Ogre::Real(newSize.height());
            m_pOgreCamera->setAspectRatio(aspectRatio);
        }
        if (m_pOgreRenderWindow)
        {
            m_pOgreRenderWindow->resize(newSize.width(), newSize.height());
            m_pOgreRenderWindow->windowMovedOrResized();
        }
    }
}

void QOWidget::paintEvent(QPaintEvent* event)
{
    m_pOgreRoot->_fireFrameStarted();
    m_pOgreRenderWindow->update();
    m_pOgreRoot->_fireFrameEnded();
    
    event->accept();
}

QPaintEngine* QOWidget::paintEngine()
{
    return 0;
    //return QWidget::paintEngine();
}

/*
 * Private Operators
*/
void QOWidget::createRenderWindow()
{
    if (!m_pOgreRenderWindow)
    {
        Ogre::NameValuePairList windowParameters;

        size_t widgetHandle;
        widgetHandle = (size_t)((HWND)winId());
        windowParameters["externalWindowHandle"] = Ogre::StringConverter::toString(widgetHandle);
        // When the window handle is assigned to the parent parameter instead of the external one,
        // a quite big RED square is drawn on the widget area but starting at position (800,410) and
        // still no scene object (cube)
        //windowParameters["parentWindowHandle"] = Ogre::StringConverter::toString(widgetHandle);
        
        m_pOgreRenderWindow = m_pOgreRoot->createRenderWindow("Viewer",
		    width(), height(), false, &windowParameters);
        // Have tried to NOT pass the window handle : a separate window is well created,
        // shows the red background of the viewport, resizes in sync when I resize the 
        // QOWidget window but the scene (the cube) is not drawn.
        //m_pOgreRenderWindow = QOgreApplication::GetOgreRoot()->createRenderWindow("Viewer",
		//    width(), height(), false);
    }
}

void QOWidget::createViewport()
{
    if (!m_pOgreViewport)
    {
        // Create the viewport and set the background color to RED
        // so that it is clearly visible (in vain ... :-/
        m_pOgreViewport = m_pOgreRenderWindow->addViewport(m_pOgreCamera);
        m_pOgreViewport->setBackgroundColour(Ogre::ColourValue(1.0f, 0.0f, 0.0f));
        // Have tried this as well
        //m_pOgreViewport->setAutoUpdated(true);
    }
}

void QOWidget::createCamera()
{
    if (!m_pOgreCamera)
    {
        // Create and adapt the aspect ratio
        m_pOgreCamera = m_pOgreSceneManager->createCamera("myCamera");
        m_pOgreCamera->setAspectRatio(Ogre::Real(width()) / Ogre::Real(height()));
        // Set the default location and orientation
        m_pOgreCamera->setPosition(Ogre::Vector3(0.0f, 10.0f, 50.0f));
        m_pOgreCamera->lookAt(Ogre::Vector3(0.0f, 0.0f, 0.0f));
    }
}

void QOWidget::createDefaultLight()
{
    m_pOgreSceneManager->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f));
}
main.cpp

Code: Select all

#include <QtGui/QApplication>

#include "QOWidget.h"

/*
 * MAIN ENTRY POINT
 */
int main(int argc, char* argv[])
{
	QApplication app(argc, argv);

    QOWidget window;
	window.setWindowTitle(QObject::tr("Ogre within Qt"));
	window.resize(300, 300);
	window.show();

    return app.exec();
}
0 x

Eldandir
Gnoblar
Posts: 22
Joined: Thu Mar 15, 2012 4:02 pm

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by Eldandir » Wed Mar 21, 2012 10:58 am

Quite the same problem here with QT 4.5.1 and Visual Studio 2005.
I will try on Qt 4.7.x.
If you want, I will tell you if it works.
Besides, in the section of the Cookbook Snippets, there is a link for an application using Qt 4.7.4 and Ogre 1.7.3 and Mac OSX 10.6.
So if it doesn't work between Ogre 1.7.4 and Qt 4.8.0, it could maybe work with the pair described above.
0 x

vdrum
Gnoblar
Posts: 4
Joined: Tue Mar 20, 2012 11:41 pm

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by vdrum » Wed Mar 21, 2012 12:42 pm

From the many threads on the net, we know it works with Qt 4.5.x
It will be interesting to know what happens with Qt 4.7.x but ultimately it should be working with the latest official release of Qt (i.e. 4.8.x)

The default color of a QWidget is grey. Here the widget area is desesparately black while nothing in the code says so (viewport background is RED).
And because resizing fast back and forth the window makes the RED background appear subtly, I start to think that the widget area is cleared after (or by) the renderWindow->update().

I'm going to trace Qt from that point on and see whether it does what I suspect ...
Thanks for considering my question :wink:
0 x

vdrum
Gnoblar
Posts: 4
Joined: Tue Mar 20, 2012 11:41 pm

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by vdrum » Wed Mar 21, 2012 2:59 pm

I have found the issue !

I wrongly thought that QWidget::paintEngine() is a virtual method and so I had declared in my QOWidget.h QOWidget::paintEngine() as virtual.
As a consequence, when QWidget is calling paintEngine() it is executing its own method and not mine.
However, QWidget::paintEngine() must be overloaded to return 0 which disables the backingstore management and allow direct painting to the screen.
The side effect was that the call to setAttribute(Qt::WA_PaintOnScreen) is not taken into acount.

Solution is then to declare :
public:
QPaintEngine* paintEngine() const;
instead of :
protected:
virtual QPaintEngine* paintEngine();
That was a quite vicious bug !
0 x

sewalg
Kobold
Posts: 31
Joined: Mon Aug 07, 2006 9:28 am
Location: Mississippi, USA

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by sewalg » Sun Jul 22, 2012 11:00 pm

Hey vdrum, I'm just getting back into Ogre programming after a couple of years elsewhere. I'm attempting to do the same as you with Ogre 1.8 and I am experiencing a similar problem with drawing mesh objects. A Skybox renders fine and I can move the camera within the scene but the cube is non existent. Did you ever find out why you couldn't see the cube?
0 x
Bridge ahead. Pay troll. :-)

User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by Mind Calamity » Sun Jul 22, 2012 11:13 pm

Try my version of the QtWidget here and see if you can see the entity.

I'm currently working with Ogre 1.9 and Qt 4.8.1 without any problems.
0 x
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt

sewalg
Kobold
Posts: 31
Joined: Mon Aug 07, 2006 9:28 am
Location: Mississippi, USA

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by sewalg » Sun Jul 22, 2012 11:41 pm

Thanks for the quick reply. Your zip file appears to be missing "ui_mainwindow.h" so won't build for me. There's a few other Windows related bits and pieces that don't seem to work for me as I'm building in Linux. I will sift through your code and see what you're doing differently to me and hopefully my cube will appear!

EDIT: Update... I couldn't find anything obvious, so I implemented the CameraMan code from your example and it now I get my objects rendering! Must have been something to do with how my camera was placed in the scene but I haven't figured that out yet! Is that CameraMan.h all MIT licensed? Or have you made your own changes that you don't want to redistribute?
Last edited by sewalg on Sun Jul 22, 2012 11:58 pm, edited 1 time in total.
0 x
Bridge ahead. Pay troll. :-)

User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by Mind Calamity » Sun Jul 22, 2012 11:58 pm

The ui_mainwindow.h is generated by the Qt Designer/Creator. You should be able to get it by opening the mainwindow.ui into the said program and going Form -> Generate Code (I think).
0 x
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt

sewalg
Kobold
Posts: 31
Joined: Mon Aug 07, 2006 9:28 am
Location: Mississippi, USA

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by sewalg » Mon Jul 23, 2012 12:00 am

Got it working. Kudos to you!
0 x
Bridge ahead. Pay troll. :-)

User avatar
Miscreant
Greenskin
Posts: 126
Joined: Mon Jun 14, 2010 2:12 am
Location: Brisbane, Australia

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by Miscreant » Mon Jul 23, 2012 1:29 am

I can also confirm that QtOgre from the wiki works with Qt 4.8.0 (and of course the newer 4.8.1 and 4.8.2)
0 x

sewalg
Kobold
Posts: 31
Joined: Mon Aug 07, 2006 9:28 am
Location: Mississippi, USA

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by sewalg » Mon Jul 23, 2012 5:39 pm

Mind Calamity wrote:Try my version of the QtWidget here and see if you can see the entity.

I'm currently working with Ogre 1.9 and Qt 4.8.1 without any problems.
Hey Mind Calamity, thanks again for your help. In the interest of contributing something back to you and anyone else trying to build similar widgets in Linux, I have a couple of suggested additions. Your code will work fine on Windows (obviously!) but there will be problems with your Widget::configure(void) causing compilation problems, widget drawing corruption (and/or Segfaulting) in Linux. Firstly, X11 widgets do not have HWND handles. Consequently, you need to derive a handle in a different manner for Linux using the X11 screen, display and window handle of the parent window. Secondly, it seems that the widget geometry is not retained unless you explicitly reinforce it from the RenderWindow. I've pasted the code below...

I hope this can help someone too!

Code: Select all

    Ogre::NameValuePairList viewConfig;
    Ogre::String widgetHandle;

#ifdef Q_WS_WIN
    widgetHandle = Ogre::StringConverter::toString((size_t)((HWND)winId()));
#else
    QWidget *q_parent = dynamic_cast <QWidget *> (parent());
    QX11Info xInfo = x11Info();

    widgetHandle = Ogre::StringConverter::toString ((unsigned long)xInfo.display()) +
        ":" + Ogre::StringConverter::toString ((unsigned int)xInfo.screen()) +
        ":" + Ogre::StringConverter::toString ((unsigned long)q_parent->winId());
#endif


    viewConfig["externalWindowHandle"] = widgetHandle;
    ogreRenderWindow = ogreRoot->createRenderWindow("View",
		width(), height(), false, &viewConfig);

    ogreRenderWindow->setActive(true);
    WId ogreWinId = 0x0;
    ogreRenderWindow->getCustomAttribute("WINDOW", &ogreWinId);
    QRect geo = this->frameGeometry();
    this->create(ogreWinId);
    this->setGeometry(geo);
0 x
Bridge ahead. Pay troll. :-)

adi
Gnoblar
Posts: 5
Joined: Mon Apr 30, 2012 7:19 pm

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by adi » Sat Aug 11, 2012 8:45 pm

Hello all,

I am new to QT and am trying to integrate Ogre 1.7.4 with Qt 4.8.1 ....... well I just read way too many threads and I just got confused

DOUBTS
1> Do I need Ogre 1.8.0 sdk for mingw () to work with Latest QT 4.8.1 ( I have installed QT sdk directly and havent built from source )
2> Ogre wiki also says 1.8.0 doesnt work with QT creator
3> Ogre 1.7.4 sdk doesnt even have mingw version (How did u guys integrate or did u guys build QT libraries from source????)
4> What should be my build and run settings under projects tab????
5> Which settings should i use under options>>>Build and Run for Qtversions and toolchains
6> Currently i have 1.7.4 pre-built sdk for visual studio 2010 and i set this as OGRE_HOME variable
7> In my toolchains options window i get two different microsoft vc++ compiler for x86...how do i decide which to choose?????[Posting Screenshot]
8> I have downloaded QtOgre widget that u guys have suggested but i it doesnt work for me as there are many dark corners for a noob like me to figure out and i am posting the screenshot that i get from application output.

I have worked with ogre for quite a bit with 1.7.4 and visual studio 2010 express and now coming into qt, i dont understand qmake, mingw and other related things to qt. With so many doubts it is hard to read any more threads and make sense out of it.

@ sewalg , @ Mind Calamity and others, Since u guys have got it to work can you please help with a little more detail how u guys got it working with directory structure that u guys follow for OGRE_HOME variable and corresponding .pro file for making use of that environment variable.....
Attachments
ToolChains.PNG
ToolChains.PNG (96.15 KiB) Viewed 4297 times
Build & Run.PNG
Build & Run.PNG (93.9 KiB) Viewed 4297 times
CompileOutput.PNG
CompileOutput.PNG (31.5 KiB) Viewed 4297 times
0 x

User avatar
saejox
Goblin
Posts: 260
Joined: Tue Oct 25, 2011 1:07 am

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by saejox » Sat Aug 11, 2012 10:22 pm

prebuilt mingw sdk will not work. because qt ships with 4.4 mingw which is quite old.

you gotta build ogre with mingw 4.4.
or build qt with what ogre is built with. (4.6.2 it seems)

i advice building ogre from source. building qt is a much much tougher job.
you will have to use older mingw 4.4.

after all this is done.
to use qtCreator you should learn writing qmake scripts.
copy/paste would only get you so far.
0 x
Nimet - Advanced Ogre3D Mesh/dotScene Viewer
asPEEK - Remote Angelscript debugger with html interface
ogreHTML - HTML5 user interfaces in Ogre

adi
Gnoblar
Posts: 5
Joined: Mon Apr 30, 2012 7:19 pm

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by adi » Sun Aug 12, 2012 2:30 pm

@ seajox,
Well i searched around a few more threads for a sticky or a tutorial how to build ogre 1.7.2 + mingw + qt but almost always found information regarding ogre + mingw + codeblocks.......Never dealt with codeblocks either...... Even the information found on Setting up an application using QT Creator (Found on wiki) is hardly of any help. Anyway I was looking at a powerful gui toolkit along with Ogre to build an editor for Ogre and hence was looking into getting this working. The new cookbook that has come out for Ogre contains the topic using MFC for UI , will have a look at that for now . Never the less, am still interested to see how to get a Basic Tutorial framework working with QT creator beacuse at my workplace , it is QT + Ogre as a part of the technical pipeline but that codebase has many more libraries and other stuff integrated that it is hard for me to understand Qt+ Ogre at a more fundamental or unit level and hence i was trying to do it this way around. I had previously got close to success when a messageboxW issue started showing up in QT and stopped there. Anyway, will wait furthur for some more help.....
0 x

DarkBoss
Halfling
Posts: 56
Joined: Tue Sep 08, 2009 6:37 pm

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by DarkBoss » Sat Apr 06, 2013 11:47 pm

Thanks a bunch Calamity !
Your code works perfectly here, MSVC2012 + Ogre3D 1.9 (the transformer) + QT5 !
I've been struggling for ages, since the switch to Qt5 and for some reason the wiki ones didn't work for me !
I had strange repositionning issues event when overriding resize and move events.

I think your code is the perfect code base for and editor system and would save people a lot of time not reinventing
the wheel with something that works,
i just added a little logging dock to the bottom as i usually do, and great choice of gradient color btw ! :)

[EDIT]
I'd like to point out for future reference that apparently it's not compatible with the OGL 3+ rendering system.
Everything was drawn correctly ( i mean the viewport but no mesh, and custom 2d rectangle background ), which was curious.
It felt like if ogre wasn't updated while you still had the paint events being fired and the window updated, i just switched to d3d9;
without any other modification i started to see the ogre rotate, the background and all.
I added a messagepump as the doc says that you should register external windows in the window event utilities class, dont know if really necessary.

So I dont know if i was the only one having the QT5 - MSVC2012 - Ogre3D fatal combo, but for others having difficulty this seems like the only thread that i found working ...

Yay :) now i can play with my little Ogre all day long ;)
Last edited by DarkBoss on Sun Apr 07, 2013 1:18 am, edited 2 times in total.
0 x

User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by Mind Calamity » Sun Apr 07, 2013 12:05 am

@DarkBoss: Thanks, and I'm glad I could help :)
0 x
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt

User avatar
AlexeyKnyshev
Goblin
Posts: 213
Joined: Sat May 26, 2012 10:37 am
Location: Russia

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by AlexeyKnyshev » Mon Apr 08, 2013 2:12 pm

It will be good if someone succeed in Qt + Ogre integration would make an public repository at github or bitbucket.
0 x
Voltage Engine - boost your ogre project with realtime physics and interactive scripting!
OgreBullet & CMake - easy to use bullet physics integration.

User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by Mind Calamity » Mon Apr 08, 2013 6:11 pm

AlexeyKnyshev wrote:It will be good if someone succeed in Qt + Ogre integration would make an public repository at github or bitbucket.
I'll check if my Qt is properly setup, test the code again and upload it to a repository soon.
0 x
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt

User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by Mind Calamity » Tue Apr 09, 2013 9:01 pm

Ok guys, I updated the code (fixed a crash and updated the include files to Qt5), I hosted it on BitBucket, you can find the repository here:

https://bitbucket.org/MindCalamity/qtogre

And a pre-compiled demo of OGRE 1.8.2 and Qt5 here: https://bitbucket.org/MindCalamity/qtogre/downloads

The instructions aren't that great, but they should be enough to get you started.

I haven't tested this with Qt4 and platforms other than Windows, so if anyone could do that, that'd be great.

Enjoy :)
0 x
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt

madmage
Gnoblar
Posts: 3
Joined: Thu Apr 11, 2013 4:09 pm

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by madmage » Thu Apr 11, 2013 4:24 pm

Dear all,
I still have the issue of vdrum: Ogre 1.7.4 + Qt 4.8.3 on Linux (Kubuntu 12.10), tried the Qt Widget described on the wiki [http://www.ogre3d.org/tikiwiki/tiki-ind ... age=QtOgre], but got a black widget (but I put a red background color with setBackgroundColour( Ogre::ColourValue( 0.8,0.0,0.0 ) ))

Do you have any news about this issue?
Trying the code of vdrum/Mind Calamity results in a red rectangle (that is ok), but in the wrong position (my widget is not at (0,0), but the red rectangle is there). I initialize the render window with this parameter:

winHandle = "0:0:";
winHandle += Ogre::StringConverter::toString((unsigned long)(this->parentWidget()->winId()));
windowParameters["parentWindowHandle"] = winHandle;

Any ideas?
0 x

dermont
Orc Shaman
Posts: 780
Joined: Thu Dec 09, 2004 2:51 am
x 9

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by dermont » Thu Apr 11, 2013 6:08 pm

madmage wrote:Dear all,
I still have the issue of vdrum: Ogre 1.7.4 + Qt 4.8.3 on Linux (Kubuntu 12.10), tried the Qt Widget described on the wiki [http://www.ogre3d.org/tikiwiki/tiki-ind ... age=QtOgre], but got a black widget (but I put a red background color with setBackgroundColour( Ogre::ColourValue( 0.8,0.0,0.0 ) ))

Do you have any news about this issue?
Trying the code of vdrum/Mind Calamity results in a red rectangle (that is ok), but in the wrong position (my widget is not at (0,0), but the red rectangle is there). I initialize the render window with this parameter:

winHandle = "0:0:";
winHandle += Ogre::StringConverter::toString((unsigned long)(this->parentWidget()->winId()));
windowParameters["parentWindowHandle"] = winHandle;

Any ideas?
Try externalWindowHandle/widget's winId.

Code: Select all

windowParameters["externalWindowHandle"] = 
       Ogre::StringConverter::toString((unsigned long)winId());
Here are a simple examples(10 KB) QWidget/QGLWidget for Ubuntu 12.10/Ogre1.8.
https://docs.google.com/file/d/0B9FUpAq ... sp=sharing
0 x

madmage
Gnoblar
Posts: 3
Joined: Thu Apr 11, 2013 4:09 pm

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by madmage » Fri Apr 12, 2013 11:58 am

dermont wrote: Try externalWindowHandle/widget's winId.

Code: Select all

windowParameters["externalWindowHandle"] = 
       Ogre::StringConverter::toString((unsigned long)winId());
Here are a simple examples(10 KB) QWidget/QGLWidget for Ubuntu 12.10/Ogre1.8.
https://docs.google.com/file/d/0B9FUpAq ... sp=sharing
Using the externalWindowHandle parameter opens a new window, so I have my window with buttons and the empty Widget AND another window with the Ogre context.

I tried to download your QtDemos.tar.gz, but, after fighting with resources.cfg, it segfaults before the window appears.

Code: Select all

Finished parsing scripts for resource group Popular
Mesh: Loading ogrehead.mesh.
Texture: GreenSkin.jpg: Loading 1 faces(PF_R8G8B8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
Texture: spheremap.png: Loading 1 faces(PF_R8G8B8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
Texture: tusk.jpg: Loading 1 faces(PF_R8G8B8,96x96x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,96x96x1.
Mesh: Loading robot.mesh.
Skeleton: Loading robot.skeleton
Texture: r2skin.jpg: Loading 1 faces(PF_R8G8B8,512x512x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
Segmentation fault (core dumped)
0 x

dermont
Orc Shaman
Posts: 780
Joined: Thu Dec 09, 2004 2:51 am
x 9

Re: Integrating Ogre 1.7.4 with Qt 4.8.0

Post by dermont » Fri Apr 12, 2013 5:27 pm

madmage wrote:[
I tried to download your QtDemos.tar.gz, but, after fighting with resources.cfg, it segfaults before the window appears.

Code: Select all

Finished parsing scripts for resource group Popular
Mesh: Loading ogrehead.mesh.
Texture: GreenSkin.jpg: Loading 1 faces(PF_R8G8B8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
Texture: spheremap.png: Loading 1 faces(PF_R8G8B8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
Texture: tusk.jpg: Loading 1 faces(PF_R8G8B8,96x96x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,96x96x1.
Mesh: Loading robot.mesh.
Skeleton: Loading robot.skeleton
Texture: r2skin.jpg: Loading 1 faces(PF_R8G8B8,512x512x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
Segmentation fault (core dumped)
Probably just an issue with timing which my example didn't take into account, try this:
http://www.pasteall.org/41341

Otherwise can you upload your example somewhere and I'll try here. You could also search on the forum there are a number of examples that work for other Linux users.
0 x

Post Reply