I'm trying to adapt tutorial #14 for MFC but am only getting a blank black window. I know the Irrlicht device is drawing something because it turns black. But there are no shapes. I basically made a new MFC project and added some of the code from tutorial 14 to the CMainFrame class in a separate thread that is launched from the OnCreate() method. Here is the code, though it's modified very little from the original found in tutorial 14. Any help would be much appreciated. Note that m_wndView is a member of the CMainFrame of type CChildView which is a derivative of CWnd. It is a class that is automatically generated by Visual Studio when the project is created. I did not modify that class.
Code: Select all
void CMainFrame::run()
{
//***** IRRLICHT CODE - COPIED FROM TUTORIAL 14 *****
irr::SIrrlichtCreationParameters param;
param.WindowId = reinterpret_cast<void*>(m_wndView.m_hWnd); // hColorButton
param.DriverType = irr::video::EDT_OPENGL;
irr::IrrlichtDevice* device = irr::createDeviceEx(param);
irr::scene::ISceneManager* smgr = device->getSceneManager();
video::IVideoDriver* driver = device->getVideoDriver();
scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
cam->setTarget(core::vector3df(0,0,0));
scene::ISceneNodeAnimator* anim =
smgr->createFlyCircleAnimator(core::vector3df(0,15,0), 30.0f);
cam->addAnimator(anim);
anim->drop();
scene::ISceneNode* cube = smgr->addCubeSceneNode(10);
device->getFileSystem()->addFolderFileArchive ("C://irr//irrlicht-1.5//media//");
cube->setMaterialTexture(0, driver->getTexture("wall.bmp"));
cube->setMaterialTexture(1, driver->getTexture("water.jpg"));
cube->setMaterialFlag( video::EMF_LIGHTING, false );
cube->setMaterialType( video::EMT_REFLECTION_2_LAYER );
smgr->addSkyBoxSceneNode(
driver->getTexture("irrlicht2_up.jpg"),
driver->getTexture("irrlicht2_dn.jpg"),
driver->getTexture("irrlicht2_lf.jpg"),
driver->getTexture("irrlicht2_rt.jpg"),
driver->getTexture("irrlicht2_ft.jpg"),
driver->getTexture("irrlicht2_bk.jpg"));
while (device->run())
{
driver->beginScene(true, true, 0);
smgr->drawAll();
driver->endScene();
Sleep(100);
}
device->closeDevice();
device->drop();
//***** IRRLICHT CODE - COPIED FROM TUTORIAL 14 ******
}