well...
i was supposed to develop an MFC application with a 3D scene window in it. i wonder if i could using irrlicht to render the subwindow in my application. Since there is already a tutorial about how to integrate win32 application with irrlicht, i think it is possible to do the same thing in MFC.
but i really don't kown where to put the "device->run()" function.
if anybody did it, please tell me.
can i using irrlicht in MFC?
I didn't try this but I think you have to put the "device->run" function into the function OnTimer. Start your own timer with a specific id and duration and then run the function when the timer is triggered. I don't know if this works but I think it does.
With the timer you can also change the frame rate yourself.
Here is some peace of example code:
As I said before I have never tested this. But let's have a try.
With the timer you can also change the frame rate yourself.
Here is some peace of example code:
Code: Select all
void CMyApp::OnTimer(UINT nIDEvent)
{
if(nIDEvent == 1)
device->run();
CDialog::OnTimer(nIDEvent);
}
void CMyApp::StopDrawing()
{
KillTimer(1);
}
BOOL CMyApp::OnInitDialog()
{
...
SetTimer(1, 50); // 20 fps
return TRUE;
}
As I said before I have never tested this. But let's have a try.
-
- Posts: 395
- Joined: Fri Apr 08, 2005 8:46 pm
i put some code in "OnTimer()" and it really works.
but there comes another problem, the scene does't show at all.
here is some of my code.
C***View::OnCreate(){
...
HWND hWnd;
hWnd = GetSafeHwnd();
SIrrlichtCreationParameters p;
p.DriverType = EDT_OPENGL;
p.AntiAlias = true;
p.WindowId = (s32)hWnd;
device = createDeviceEx(p);
driver = device->getVideoDriver();
smgr = device->getSceneManager();
device->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");
mesh = smgr->getMesh("20kdm2.bsp");
node = 0;
if (mesh)
node = smgr->addOctTreeSceneNode(mesh->getMesh(0));
if (node)
node->setPosition(core::vector3df(-1300,-144,-1249));
smgr->addCameraSceneNodeFPS();
SetTimer(1, 100, NULL);
...
}
C***View::OnTimer(){
...
driver->beginScene(true, true, SColor(0,rand()%200,rand()%200,rand()%200));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
...
}
i make the backcolor change everytime OnTimer() is called, and it works. but i can't see the expected quake map at all.
but there comes another problem, the scene does't show at all.
here is some of my code.
C***View::OnCreate(){
...
HWND hWnd;
hWnd = GetSafeHwnd();
SIrrlichtCreationParameters p;
p.DriverType = EDT_OPENGL;
p.AntiAlias = true;
p.WindowId = (s32)hWnd;
device = createDeviceEx(p);
driver = device->getVideoDriver();
smgr = device->getSceneManager();
device->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");
mesh = smgr->getMesh("20kdm2.bsp");
node = 0;
if (mesh)
node = smgr->addOctTreeSceneNode(mesh->getMesh(0));
if (node)
node->setPosition(core::vector3df(-1300,-144,-1249));
smgr->addCameraSceneNodeFPS();
SetTimer(1, 100, NULL);
...
}
C***View::OnTimer(){
...
driver->beginScene(true, true, SColor(0,rand()%200,rand()%200,rand()%200));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
...
}
i make the backcolor change everytime OnTimer() is called, and it works. but i can't see the expected quake map at all.