can i using irrlicht in MFC?

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
yjlchina
Posts: 9
Joined: Tue Nov 23, 2004 7:29 am
Location: China. west lake

can i using irrlicht in MFC?

Post by yjlchina »

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.
Bersi

Post by Bersi »

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:

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. ;)
Guest

Post by Guest »

But I thinks it's better when you create a second thread which draws the 3d scene. So you can work like you do with other irrlicht projects and use two threads. The base thread for the whole MFC stuff and the other for the irrlicht stuff. ;)
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

I've heard rumors (I could be wrong) that Irrlicht might snarf keyboard/mouse events or otherwise mess up event handling by MFC. I would love to get Irrlicht to work under MFC, what a great way to make gaming tools.
yjlchina
Posts: 9
Joined: Tue Nov 23, 2004 7:29 am
Location: China. west lake

Post by yjlchina »

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.
cpprules
Posts: 148
Joined: Wed Jul 27, 2005 8:37 pm
Location: on the Pedastal

Post by cpprules »

I hate MFC, is there any reason you must use it?
CRPG, FRPG, Oblivion Fan
Hater of Counter Strike (i hate it so much damn it)
yjlchina
Posts: 9
Joined: Tue Nov 23, 2004 7:29 am
Location: China. west lake

Post by yjlchina »

MFC is a powerful tool on windows platform. if you want to make some complex and standard window applications, MFC will be a good choice. if i want to make a level editor, what else can i use?
Post Reply