I am embedding an Irrlicht window inside a Qt widget for some 3D rendering. This works quite well if I only do this with one Irrlicht window. However, if I create two separate Irrlicht windows and put them in the same application under Linux while using OpenGL for rendering, only one of the Irrlicht windows actually renders something while the other remains empty. Also, if I use only 1 Irrlicht window and add a QGLWidget (basically a Qt widget with OpenGL acceleration) to the same application, the same thing happens to the Irrlicht window. However if I try two QGLWidgets, both of them work normally. Thus I suspect the problem lies somewhere with Irrlicht.
Does anyone have any suggestions on what could be wrong?
The complete code I am using to test this can be found here: http://www.box.net/shared/77cy2rlcv9
When I run it, I get the following output in the terminal:
- Code: Select all
kkrizka@sein:~/Projects/amelia/testbed/qtrr$ ./qtrr
Irrlicht Engine version 1.4.2
Linux 2.6.27-7-generic #1 SMP Thu Oct 30 04:18:38 UTC 2008 i686
Creating X window...
Visual chosen: : 33
Using renderer: OpenGL 1.4
Mesa DRI Intel(R) 965GM 20061102 x86/MMX/SSE2: Tungsten Graphics, Inc
OpenGL driver version is 1.2 or better.
GLSL version: 1.3
Found joystick 0, 2 axes, 0 buttons, 'ThinkPad HDAPS joystick emulation'
Found joystick 1, 2 axes, 0 buttons, 'ThinkPad HDAPS accelerometer data'
Irrlicht Engine version 1.4.2
Linux 2.6.27-7-generic #1 SMP Thu Oct 30 04:18:38 UTC 2008 i686
Creating X window...
Visual chosen: : 33
Using renderer: OpenGL 1.4
Mesa DRI Intel(R) 965GM 20061102 x86/MMX/SSE2: Tungsten Graphics, Inc
OpenGL driver version is 1.2 or better.
GLSL version: 1.3
Found joystick 0, 2 axes, 0 buttons, 'ThinkPad HDAPS joystick emulation'
Found joystick 1, 2 axes, 0 buttons, 'ThinkPad HDAPS accelerometer data'
Here is what is displayed:

Below is a snipplet of my QIrrWidget class, which basically is a Qt widget that contains and Irrlicht window. In my testcode, I inherit this class by another class called ABase, where I implement the load() function to create a white cube scene node. In my main() function, I create a base parent QWidget and to it add two instances of the fore mentioned ABase class.
- Code: Select all
QIrrWidget::QIrrWidget( QWidget *parent )
: QWidget(parent),Device(0)
{
// Wait for the init() call
Device = 0;
// Default to Open GL
#ifdef Q_WS_WIN
_driverType = irr::video::EDT_DIRECT3D9;
#else
_driverType = irr::video::EDT_OPENGL;
#endif
setAttribute( Qt::WA_OpaquePaintEvent );
//Tell Qt we will use something else for painting
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoBackground);
setAttribute(Qt::WA_NoSystemBackground);
setMouseTracking(true);
setFocusPolicy(Qt::StrongFocus);
setAutoFillBackground(false);
}
QIrrWidget::~QIrrWidget()
{
if ( Device != 0 )
{
Device->closeDevice();
Device->drop();
Device=0;
}
}
irr::IrrlichtDevice* QIrrWidget::GetDevice()
{
return Device;
}
video::IVideoDriver* QIrrWidget::GetDriver()
{
return Device->getVideoDriver();
}
ISceneManager* QIrrWidget::GetSceneManager()
{
return Device->getSceneManager();
}
irr::video::E_DRIVER_TYPE QIrrWidget::driverType()
{
return _driverType;
}
void QIrrWidget::execute() { }
bool QIrrWidget::OnEvent(const SEvent &event)
{
return false;
}
void QIrrWidget::load() { }
void QIrrWidget::Init()
{
// Don't initialize more than once!
if ( Device != 0 ) return;
irr::SIrrlichtCreationParameters params;
params.DriverType = driverType();
params.WindowId = (void*)winId();
params.WindowSize.Width = width();
params.WindowSize.Height = height();
params.AntiAlias = true;
params.IgnoreInput = true;
Device = irr::createDeviceEx( params );
timerId=startTimer(20);
load();
}
void QIrrWidget::timerEvent(QTimerEvent* event)
{
update();
}
void QIrrWidget::paintEvent( QPaintEvent* event )
{
if(!Device)
{
Init();
}
if (Device)
{
Device->getTimer()->tick();
execute();
irr::video::SColor color (0,0,0,0);
Device->getVideoDriver()->beginScene( isEnabled(), true, color);
Device->getSceneManager()->drawAll();
Device->getVideoDriver()->endScene();
}
QWidget::paintEvent(event);
}
QPaintEngine * QIrrWidget::paintEngine () const
{
return 0;
}
