irrlicht + Qt4 integration

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
rookie
Posts: 16
Joined: Thu Dec 29, 2011 9:44 pm

irrlicht + Qt4 integration

Post by rookie »

I am trying to embed irrlicht into qt4. I have got the following code working. Can anyone please help me why the mesh doesn't show up when I call mainwindow->show after irrlich device is created??

Code: Select all

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
 
    // Create the main window
    QMainWindow *mainWindow = new QMainWindow();
 
    // Create the central widget to be put into the main window
    QWidget *centralWidget = new QWidget(mainWindow);
    centralWidget->setAttribute(Qt::WA_PaintOnScreen, true);
    mainWindow->setCentralWidget(centralWidget);
 
    // Resize and then show the main window
    mainWindow->resize(800,600);
    mainWindow->show();
 
    // Create the Irrlicht device
    SIrrlichtCreationParameters params;
 
    params.DriverType = video::EDT_OPENGL;
    params.WindowId = (void *)(QWidget *)centralWidget->winId();
    params.WindowSize.Width = centralWidget->width();
    params.WindowSize.Height = centralWidget->height();
    params.EventReceiver = 0;
    params.AntiAlias = true;
 
    IrrlichtDevice *device = createDeviceEx( params );
    ISceneManager *scene = device->getSceneManager();
    IVideoDriver *driver = device->getVideoDriver();
    IAnimatedMesh *cubeMesh =  scene->getMesh("Shirt_test.obj");
    IAnimatedMeshSceneNode *cubeNode =  scene->addAnimatedMeshSceneNode(cubeMesh, 0, -1, vector3df(0, 0, 0), vector3df(0,0,0), vector3df(10,10,10), false);
    cubeNode->setMaterialFlag(video::EMF_LIGHTING, false);
    cubeNode->setMaterialTexture(0, driver->getTexture("Billabong_guys_shirt3.bmp"));
    ICameraSceneNode *camera = scene->addCameraSceneNode(0);
    camera->setPosition(vector3df(0,0,-800));
    camera->setTarget(vector3df(0, 0, 0));
 
    device->getTimer()->tick();
    driver->beginScene(true, true, SColor(255,100,101,140));
    scene->drawAll();
    driver->endScene();
 
    return a.exec();
}
 
I have created a class MainWindow which inherits from QMainWindow & all my stuff is done in MainWindow. My main.cpp is as follows

Code: Select all

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;    
    w.show();
 
    return a.exec();
}
Hence I am calling w.show() after irrlicht initialization. So the mesh rendered by irrlicht doesn't show up. Can anyone please help me with this?? I need to everything related to irrlicht since all other stuff which precludes the rendered mesh is done in MainWindow.
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: irrlicht + Qt4 integration

Post by smso »

Please search the forum for:
qirrwidget

Regards
smso
rookie
Posts: 16
Joined: Thu Dec 29, 2011 9:44 pm

Re: irrlicht + Qt4 integration

Post by rookie »

thanks but I want it to be QMainWindow since I am embedding into another project which already has been implemented. If I use QWidget I would display over the stuff which I wanna display behind some QGraphicsItem
Post Reply