I'm aware the most users of the engine are creating games that are intended to run full screen. I'm in the camp that would like to use irrlicht to render a scene inside a gui. I'm also in the camp that targets linux. I'm aware the intersection of these two is actually quite small, but I haven't let that stop me.
I recently posted a solution for getting irrlicht to render inside a window in wxWidgets: http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=39719. However this solution is somewhat fragile and there are a couple of things bothering me about it. I've finally had time to dig through the source and figure out exactly what was going on. I'd like to describe to devs what I've found and ask them for some feedback. In particular, is it within the interest of the devs to support irrlicht from within a window manager? i.e. is the windows gui support incidental? Or is this something you really wish for the engine in general? Hoping that it is the latter, I've identified a few problems with the current implementation of CIrrlichtDeviceLinux that are preventing this from being reliable on linux. I'm not sure about on Mac, but since mac comes with x11 I assume the ideas will extend to that OS. Here is what I've found (line numbers are from today's svn trunk, rev 3402):
- Currently, when the library user passes in an X11 window ID through SDeviceCreationParameters, the implementation of CIrrlichtDeviceLinux makes a few assumptions:
- the X window does not have a glxWindow associated with it (CIrrDeviceLinux.cpp:694)
- the GL Context has not been created (CIrrDeviceLinux.cpp:698 & CirrDeviceLinux:719)
- irrlicht will be responsible for managing the X11 message pump (CIrrDeviceLinux.cpp:846)
- Despite these assumptions, the COpenGLDriver class (COpenGLDriver.cpp:533) does not recieve the context and the display created by CIrrlichtDeviceLinux, but rather picks up the current display and context, assuming the device has set it up (this is why it actually works on linux right now)
- The X11 message pump is handled by the window manager (Gnome, or presumably KDE, XFCE, etc)
- GTK exposes the underlying X11 data structures, so they can be retrieved and passed into irrlicht
- wxWidgets exposes the underlying GTK data structures, ...
- Despite my expectations, when passing an "ordinary" X-window in to irrlicht, it cannot create the glx window and the context on it's own (this could me something of my own fault, but this is kind of a small point)
- Both GTK and wxWidgets have OpenGL objects for managing openGL windows
- Either GTK or wxWidgets does not reliably size the windows prior to drawing them (I'll explain why this is significant)
- We can create an opengl window, and context from within wxWigets or GTK (wxCanvas or GtkGLExt), but we can't tell irrlicht that we've done so, so we get some error messages in the console and (what is a bigger concern) future versions of the engine may fail unnecessarily in the device construction
- The opengl driver can initialize correctly because the opengl context and related Drawable created by the window manager is still current
- Sometimes (isn't this cute) when the irrlicht device is created it will detect an X window size with the correct height but a width of 1px. This happens reliably on x86 Linux but infrequently on AMD64. I'm guessing it's the different versions of GTK or Gnome for the different platforms. And, since the window manager library is taking care of the X message loop, the irrlicht device never understands that the window size has changed. In fact, we have no way of passing messages from the window manager to irrlicht. In any case, we have IVideoDriver::onResize() but we don't have IrrlichtDevice::onResize(). As a result, the rendered scene is one pixel wide, stretched across the width of the actual window. Now, if a library user is also using a window manager, they should probably assume responsibility in their code integrating with the window manager to enable/disable rendering with irrlicht when the window is not visible, but I think we'll need a way to pass resize, minimize, restore, etc kinds of events from the window manager into irrlicht.