I'm just new to Irrlicht. About a day old. So I started to code a small gui app using C++ windows form. Anyway here is a code to show 150+ windows of the same scene.
I have also test to have more than 250 windows showing the same scene from different view.
[img]
http://s2.postimg.org/u2yzyucax/Untitled.jpg
[/img]
Irrlicht is quite simple to use. Congratulation.
Here's the code:
Code: Select all
lstForm = gcnew List<RenderForm^>; //A list of render windows.
lstCamera = new irr::core::list<ICameraSceneNode*>(); //A list of cameras.
irr::SIrrlichtCreationParameters params;
params.WindowId = (void *)this->Handle; //I point this to the MDI windows.
params.DriverType = video::EDT_DIRECT3D9;
params.EventReceiver = 0;
params.AntiAlias = true;
device = createDeviceEx(params); //The device is create but it is hidden.
if (!device)
return;
driver = device->getVideoDriver();
smgr = device->getSceneManager();
//Get mesh from path.
//I'm using hardcode path since I'm not familiar with the relative path convention in irrlicht yet.
IAnimatedMesh* mesh = smgr->getMesh("D:\\ProjectCodes\\Irrlicht\\NVuDu\\Project1\\Debug\\media\\sydney.md2");
if (!mesh)
{
device->drop();
return;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("D:\\ProjectCodes\\Irrlicht\\NVuDu\\Project1\\Debug\\media\\sydney.bmp") );
}
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
//Rendering loop.
//Well since I use the interface thread to do the drawing so I use the DoEvent statement.
while (device->run())
{
if(lstForm->Count > 0) //Render if there a render form in the list of forms.
{
lstCamera->begin();
list<ICameraSceneNode *>::Iterator it;
it = lstCamera->begin();
for(int i = 0; i < lstForm->Count; i++)
{
if(!lstForm[i]->IsDisposed)
{
//Begin render to the window form handle.
driver->beginScene( true, true, SColor(255,100,101,140), SExposedVideoData((void*)lstForm[i]->Handle));
//Using the camera view
smgr->setActiveCamera(*it);
it++;
smgr->drawAll();
driver->endScene();
Threading::Thread::Sleep(1);
Application::DoEvents();
}
else
{
lstForm->RemoveAt(i);
if(i > 0) i--;
}
}
}
Threading::Thread::Sleep(1);
Application::DoEvents();
}
device->closeDevice();
device->drop();
Cheers,
vu