How to integrate Irrlicht in a wxWidgets application

Especially since Irrlicht 1.1 and irrEdit 0.3 are released, I'm getting tons of mails asking how to integrate Irrlicht in an application written using wxWidgets, just like I did it with irrEdit. Here is a short howto:

There are two possibilities to display Irrlicht in wxWidgets.

A) Take a look at the 14th tutorial, I am showing how to use Irrlicht in a Win32 window there. This is done by creating the IrrlichtDevice with a parameter set to the HWND handle of the Win32 window. If you are using wxWidgets in Windows, you can get that HWND and simply set it. The method in wxWidgets for this is named GetHandle().

B) There is a second way which is a bit more difficult, and I am using it in irrEdit. It only works in Windows and only with the Software and Direct3D devices, and not with OpenGL, currently. The advantage of this method is that you can render into multiple windows with variable sizes, but only need one IrrlichtDevice. The method IVideoDriver::endScene() takes a windowId as parameter. Just set this to the window your want Irrlicht to render everything into (use GetHandle() again), and that's it.

Hope this helped a bit.

seven comments, already:

Nice niko!
bicunisa - 08 08 06 - 19:54

The Complexity of it all proves that Niko is all-powerful… not really, but I am just to lazy to try.. ;-)
RustyNail - 08 08 06 - 20:51

Here is an expansion of the first method, which I am using that works in OpenGL :)

One problem with wxWidgets is it is a bit tricky to integrate. In Win32 the default window proc is not called in the message loop, so if you decide to update the display continuously you’ll need a way to send messages to Irrlicht.

Unfortunately not all messages can be sent to irrlicht via the proc postEventFromUser, for example the resize event. One way to get around that is to manually add some methods to force resize in Irrlicht itself.

In order to use wxWidgets, you’ll need to override the default message loop like this:

//overload this
int EditorApp::OnRun()

wxMainEventLoop eventLoop(this);

m_mainLoop = &eventLoop;

for ( ; ; ) {

while (!Pending() && ProcessIdle());

while (Pending())
if (!Dispatch())
mShouldLeave = true;

if (mShouldLeave)
while (Pending())

m_mainLoop = NULL;
return 0;

if (mFrame)

wxMilliSleep(10); // dont take up 100% of cpu as usual

m_mainLoop = NULL;
return 0;

Definition of new class:

class wxMainEventLoop : public wxEventLoop

wxMainEventLoop(EditorApp *editorApp);
virtual void OnExit();

EditorApp *mEditorApp;

add this:

wxMainEventLoop::wxMainEventLoop(EditorApp *editorApp) : wxEventLoop()
mEditorApp = editorApp;

void wxMainEventLoop::OnExit()

good luck!
Matthew (link) - 09 08 06 - 00:46

Jan_ - 09 08 06 - 08:07

Hello Niko!

I have one quastion.Maybe is a noob quastion,but i don’t know how i can load terrain in IrrEdit…

Here is the topic on forum:

thank you for irrlicht.
Ros - 09 08 06 - 10:00

Hey Niko,

some time time ago i figured out that you render to multiple windows by passing the handle via endScene (as seen in your first alpha of 1.1 via SVN)...In principle in OpenGL this is possible too, and i implemented this already myself in 1.1. But, and thats the reason why i am posting here, in OGL one has to at least bind the GL render context to the corresponding device handle (HDC). And that has to be done before any drawing (e.g. via glxMakeCurrent under win32). I am just saying that this endScene thingy will never work for OGL when you want to render to some secondary output windows…As i understand this, glxMakeCurrent always flushs the render context (HRC).

I understand that your solution is the most compatible way in terms of a stable Irrlicht API. But i suspect a generic solution will need an API change by introducing an extra Method to pass the window handle. Would be still compatible in a way if this method is not used…*

Just to let you know…*
mrcdrc - 09 08 06 - 12:56

Hey Niko,

Great work on the lightmapper! I’m amazed at how awesome it looks. No more need for Dele D for me :)

I am here to make a feature request: May you please add simple terrain display functionality into irrEdit as soon as possible? This would greatly help out any project using irrlicht that requires outdoor rendering of any type. .

I have started a thread and there seems to be a collective need for terrain in order for projects such as mine to be able to use irrEdit efficiently.

Please consider my request (and that of many others).

Thankyou very much,
Krama (link) - 31 08 06 - 08:16

Displayed name:  
Remember personal info?
Website (optional):
Enter "layered" (antispam):
Comment:Emoticons / Textile


Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Note: If you type in your email adress above, it will be visible to other visitors, although it will be hidden for bots using javaScript.