[SOLVED] QT Irrlicht Integration

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!

[SOLVED] QT Irrlicht Integration

Postby ritti » Tue Jul 03, 2012 1:41 pm

Hi,
as the title says I'm trying to integrate Irrlicht in QT.
I followed this tutorial: viewtopic.php?f=5&t=44658
It works great, but now I have a problem with all the stuff thats done during runtime (sending units around, collision detection...)
I started with the Irrlichts tutorial 07.Collision and built on it so that i can send units around and test for collision detection.
All this is done in a while loop in the main.cpp:
cpp Code: Select all
while(mainWindow.getIrrlichtWidget()->getIrrlichtDevice()->run())
    if (mainWindow.getIrrlichtWidget()->getIrrlichtDevice()->isWindowActive())
    {... //code to send units around and watch for collisions

But i have to
cpp Code: Select all
return app.exec();
otherwise the window wont be created.
Well if i return inside the loop the units are shown but i cant move anything because the while loop is over.
And if i return after the loop the Game wont never end the loop and the window wont be created.
Where do i have to place the loop or the app.exec?
I hope somebody can help me :)
Thx in advance
Ritti
Last edited by ritti on Tue Jul 03, 2012 7:52 pm, edited 1 time in total.
ritti
 
Posts: 54
Joined: Tue Apr 10, 2012 12:09 pm

Re: QT Irrlicht Integration

Postby smso » Tue Jul 03, 2012 5:06 pm

You should put the run loop in the paintEvent handler of the irr widget, e.g.


cpp Code: Select all
void QIrrlichtWidget::paintEvent(QPaintEvent *event)
{
    init(); // create device if not done
   
 
    if (device && device->run())
    {
        if (isVisible() && isEnabled())
        {
            driver->beginScene(true, true, video::SColor(255, 0, 0, 0));
            smgr->drawAll();
            driver->endScene();
        }
        else
        {
            device->yield();
        }
    }
   
    emit repainted();
}


Regards,
smso
smso
 
Posts: 217
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: QT Irrlicht Integration

Postby ritti » Tue Jul 03, 2012 7:52 pm

Yeah thank you very much, now it works perfectly.
ritti
 
Posts: 54
Joined: Tue Apr 10, 2012 12:09 pm


Return to Advanced Help

Who is online

Users browsing this forum: No registered users and 0 guests