I am trying to render to two windows panel (using irrlicht 1.8 ), and I don't understand why but it looks like the Z test is failing on the second panel.
I am using openGL driver (opengl is required because i want to use irrlicht inside an application that otherwise uses opengl), and I get window handles from the panels with
Code: Select all
panel1->Handle.ToPointer()
The whole code:
Code: Select all
void RenderThread() {
PIXELFORMATDESCRIPTOR pfd;
int pf;
struct SExposedVideoData irrdeviceVideoInfo;
struct SExposedVideoData nativeVideoInfo1;
struct SExposedVideoData nativeVideoInfo2;
irr::SIrrlichtCreationParameters params;
params.WindowId = _WinId1; //I point this to the MDI windows.
params.DriverType = video::EDT_OPENGL;
params.EventReceiver = 0;
params.AntiAlias = 0;
IrrlichtDevice* device = createDeviceEx(params); //The device is create but it is hidden.
_IrDevice = device;
// setup 2 windows
irrdeviceVideoInfo = _IrDevice->getVideoDriver()->getExposedVideoData();
memset( &pfd,0, sizeof(pfd) );
pfd.nSize = sizeof(pfd);
pf = GetPixelFormat((HDC)irrdeviceVideoInfo.OpenGLWin32.HDc);
DescribePixelFormat((HDC)irrdeviceVideoInfo.OpenGLWin32.HDc,pf, sizeof(pfd), &pfd);
pfd.dwFlags |= PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
pfd.cDepthBits=16;
nativeVideoInfo1.OpenGLWin32.HWnd = _WinId1;
nativeVideoInfo1.OpenGLWin32.HDc = GetDC((HWND)nativeVideoInfo1.OpenGLWin32.HWnd);
pf = ChoosePixelFormat( (HDC)nativeVideoInfo1.OpenGLWin32.HDc, &pfd );
SetPixelFormat( (HDC)nativeVideoInfo1.OpenGLWin32.HDc, pf, &pfd );
nativeVideoInfo1.OpenGLWin32.HRc = wglCreateContext( (HDC)nativeVideoInfo1.OpenGLWin32.HDc );
wglShareLists((HGLRC)irrdeviceVideoInfo.OpenGLWin32.HRc, (HGLRC)nativeVideoInfo1.OpenGLWin32.HRc);
memset( &pfd,0, sizeof(pfd) );
pfd.nSize = sizeof(pfd);
pf = GetPixelFormat((HDC)irrdeviceVideoInfo.OpenGLWin32.HDc);
DescribePixelFormat((HDC)irrdeviceVideoInfo.OpenGLWin32.HDc,pf, sizeof(pfd), &pfd);
pfd.dwFlags |= PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
pfd.cDepthBits=16;
nativeVideoInfo2.OpenGLWin32.HWnd = _WinId2;
nativeVideoInfo2.OpenGLWin32.HDc = GetDC((HWND)nativeVideoInfo2.OpenGLWin32.HWnd);
pf = ChoosePixelFormat( (HDC)nativeVideoInfo2.OpenGLWin32.HDc, &pfd );
SetPixelFormat( (HDC)nativeVideoInfo2.OpenGLWin32.HDc, pf, &pfd );
nativeVideoInfo2.OpenGLWin32.HRc = wglCreateContext( (HDC)nativeVideoInfo2.OpenGLWin32.HDc );
wglShareLists((HGLRC)irrdeviceVideoInfo.OpenGLWin32.HRc, (HGLRC)nativeVideoInfo2.OpenGLWin32.HRc);
// setup drawing
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
irr::core::vector3df position;
position.X = 0;
position.Y = 0;
position.Z = 0;
scene::IMeshSceneNode* node = smgr->addCubeSceneNode(3.0f, 0, -1, position);
scene::ISceneNodeAnimator* anim = smgr->createRotationAnimator(core::vector3df(0.0f, 0.3f,0));
node->setPosition(core::vector3df(0,0,0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialType(video::EMT_SOLID);
//node->setMaterialFlag(video::EMF_WIREFRAME, true);
node->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);
node->addAnimator(anim);
anim->drop();
IMeshBuffer* mb = node->getMesh()->getMeshBuffer(0);
u32 count = mb->getVertexCount();
video::S3DVertex* vertices = (video::S3DVertex*)mb->getVertices();
for( int i=0; i<count; i++ ) {
switch( i%6 )
{
case 0: vertices[i].Color = SColor(0xFF,0xFF,0,0); break;
case 1: vertices[i].Color = SColor(0xFF,0,0xFF,0); break;
case 2: vertices[i].Color = SColor(0xFF,0,0,0xFF); break;
case 3: vertices[i].Color = SColor(0xFF,0,0xFF,0xFF); break;
case 4: vertices[i].Color = SColor(0xFF,0xFF,0xFF,0xFF); break;
case 5: vertices[i].Color = SColor(0xFF,0xFF,0xFF,0); break;
}
}
scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
cam->setPosition(core::vector3df(0,0,10.0));
cam->setTarget(core::vector3df(0,0,0));
while(true)
{
device->run();
driver->beginScene(true, true, video::SColor(0,0,180,255), nativeVideoInfo2);
smgr->setActiveCamera(cam);
smgr->drawAll();
driver->endScene();
driver->beginScene(true, true, video::SColor(0,100,180,255), nativeVideoInfo1);
smgr->setActiveCamera(cam);
smgr->drawAll();
driver->endScene();
}
device->drop();
}
Then if I invert the nativeVideoInfo1 and 2 in the drawing loop, I will get inverted results (panel1=OK, panel2=NG).
Any ideas?
I have been struggling with this for hours now, I can't understand what can be the problem.
Is it a bug?
** If i find how to do it, I will post an image.