How to integrate irrlicht with MFC tutorial

A forum to store posts deemed exceptionally wise and useful
Post Reply
Mancuso Raffaele
Posts: 70
Joined: Sat Dec 17, 2005 4:43 pm
Location: licata (AG) italy
Contact:

How to integrate irrlicht with MFC tutorial

Post by Mancuso Raffaele »

Hi all. I wrote a tutorial on how to integrate irrlicht with MFC. I spent 4 days to mix this two libraries correctly, in a way that both work. You can download tutorial and source from
here .
What do you think about this tutorial?
Bye all,
Mancuso Raffaele (Ares FPS game)
cymx2
Posts: 5
Joined: Tue Jul 04, 2006 7:56 am

Post by cymx2 »

thank you very much!!

i write windows with irrlicht is working ,but use mfc isn't working !!

I don't know why

I use createDeviceEx in CIrrMFCTestView::OnCreate(), use smgr->drawAll() in CIrrMFCTestView::OnDraw(CDC* pDC)

but it isn't working! why?? please tell me,thank you!
cymx2
Posts: 5
Joined: Tue Jul 04, 2006 7:56 am

Post by cymx2 »

I create irr device in CMyView:: OnInitialUpdate()

now it is working !! and I have know why not in OnCreate()

I render scene in CMyView:: OnDraw() not in CApp::Run() ,but working!

thank you again!!
Mancuso Raffaele
Posts: 70
Joined: Sat Dec 17, 2005 4:43 pm
Location: licata (AG) italy
Contact:

Post by Mancuso Raffaele »

I use createDeviceEx in CIrrMFCTestView::OnCreate(), use smgr->drawAll() in CIrrMFCTestView::OnDraw(CDC* pDC)
but it isn't working! why?? please tell me,thank you!
after 4 days of debug, I have discovered that OnDraw() function is called in 4 case:
-before the mainframe is created
-after the mainframe is created
-the first time the loop is execute
-when,according to the MFC, the scene is changed (when you click a menu element, when you move mouse,exc..)
but if none of the things above happens the OnDraw function is not called, so smgr->drawAll() is not called and the scene is not drawed. So you need create a "Irrlicht loop" in the function CApp::Run(). For default MFC use the function run of the class CWnd. Obviously this function don't call smgr->drawAll(), so you need to redefine it manually in your code (particularly in CApp derived from CWndApp), as I explain in the tutorial.
Thanks you for downloading my tut.
Bye all,
Mancuso Raffaele (Ares FPS game)
cymx2
Posts: 5
Joined: Tue Jul 04, 2006 7:56 am

Post by cymx2 »

Mancuso Raffaele wrote:
I use createDeviceEx in CIrrMFCTestView::OnCreate(), use smgr->drawAll() in CIrrMFCTestView::OnDraw(CDC* pDC)
but it isn't working! why?? please tell me,thank you!
after 4 days of debug, I have discovered that OnDraw() function is called in 4 case:
-before the mainframe is created
-after the mainframe is created
-the first time the loop is execute
-when,according to the MFC, the scene is changed (when you click a menu element, when you move mouse,exc..)
but if none of the things above happens the OnDraw function is not called, so smgr->drawAll() is not called and the scene is not drawed. So you need create a "Irrlicht loop" in the function CApp::Run(). For default MFC use the function run of the class CWnd. Obviously this function don't call smgr->drawAll(), so you need to redefine it manually in your code (particularly in CApp derived from CWndApp), as I explain in the tutorial.
Thanks you for downloading my tut.
I use SetTimer(1,1,0) in OnInitialUpdate() function,and in OnTimer(UINT nIDEvent) I use Invalidate(0),so, CIrrMFCTestView::OnDraw(CDC* pDC)
is update always

I want to build a particle editor and scene editor ,I now receive the keyboard and mouse message and pass them to the irrlicht engine's sceneManage,so I can control camera by mouse and keyboard
Hedonist
Posts: 1
Joined: Sat Sep 09, 2006 4:24 pm
Location: Vermont, USA

Post by Hedonist »

I tried this out (both the tutorial and the downloaded source code). In both cases, it compiles and runs, but the document window is just a black screen. The only change I made was to change the addTestSceneNode to addCubeSceneNode, which I understand was a change in version 1.1. Any ideas what I'm missing?
Post Reply