Irrlicht embedded in a wxWidgets control

A forum to store posts deemed exceptionally wise and useful
yablebab
Posts: 5
Joined: Wed Sep 20, 2006 9:20 pm
Location: Berkeley, CA

program crash

Post by yablebab »

I tried to use your class to make a simple test program, and it builds ok, but it crashes when i run it. I went through function by function and it seems there are a few things making it crash. First, in the OnPaint() function, declaring the wxPaintDC object causes the program to crash on termination. Also, in the OnMouse() function, calling m_pDevice->postEventFromUser(sevt) causes the program to crash as soon as I run it. I get the "test2.7.exe has encountered a problem and needs to close. We are sorry for the inconvenience." offering to send an error report and all that. It actually pops up 3 times.

Is anyone else having a similar problem? Any insight or tips on how to fix this?

Brian
kornerr
Posts: 245
Joined: Thu Jul 06, 2006 9:57 am
Location: Russia, Siberia, Kemerovo
Contact:

Post by kornerr »

Will we ever see a linux demo? It's been over a month or two since I was asking you...
Open Source all the way, baby ;)
OSRPG
AndyCR
Posts: 110
Joined: Tue Nov 08, 2005 2:51 pm
Location: Colorado, USA
Contact:

Post by AndyCR »

I'm having the same issue as Kornerr. Under Windows, it works perfectly after a bit of tweaking, but under GNU/Linux, it creates Irrlicht in a seperate window every time.

EDIT: Well, after a little investigation I do not see how it could possibly work, at least in irrlicht 1.2. This is relevant code from the createDeviceEx method on Windows:

Code: Select all

CIrrDeviceWin32* dev = new CIrrDeviceWin32(

		parameters.DriverType,

		parameters.WindowSize,

		parameters.Bits,

		parameters.Fullscreen,

		parameters.Stencilbuffer,

		parameters.Vsync,

		parameters.AntiAlias,

		parameters.HighPrecisionFPU,

		parameters.EventReceiver,

		[b]reinterpret_cast<HWND>(parameters.WindowId)[/b],

		parameters.SDK_version_do_not_use);
And the corresponding code for GNU/Linux:

Code: Select all

CIrrDeviceLinux* dev = new CIrrDeviceLinux(

		param.DriverType,

		param.WindowSize,

		param.Bits,

		param.Fullscreen,

		param.Stencilbuffer,

		param.Vsync,

		param.AntiAlias,

		param.EventReceiver,

		param.SDK_version_do_not_use);
And indeed, CIrrDeviceLinux does not know anything about window handles. Thus, the window handle parameter is simply ignored, and irrlicht happily creates its own window.
kornerr
Posts: 245
Joined: Thu Jul 06, 2006 9:57 am
Location: Russia, Siberia, Kemerovo
Contact:

Post by kornerr »

Shame on mandrav :?
Open Source all the way, baby ;)
OSRPG
AndyCR
Posts: 110
Joined: Tue Nov 08, 2005 2:51 pm
Location: Colorado, USA
Contact:

Post by AndyCR »

I think I have it figured out. Basically, in this post: http://irrlicht.sourceforge.net/phpBB2/ ... highlight= He created a patch to create Irrlicht in a GTK window. I imagine that that patch is required for this code to work under GNU/Linux. He emailed the patch to Hybrid, but I do not know if it became available to anyone else afterwards. If anyone has this patch, please send it to me, and if I get it working I will make a quick and dirty GNU/Linux demo of this control in return.

EDIT: Found it. http://parsys.informatik.uni-oldenburg. ... ndow.patch Give me a few days.
kornerr
Posts: 245
Joined: Thu Jul 06, 2006 9:57 am
Location: Russia, Siberia, Kemerovo
Contact:

Post by kornerr »

I tried to change things as they are in patch, but still, Irrlicht starts in its own window :(
I guess that's the reason why it wasn't included in Irrlicht, it simply doesn't work for all Linuxes... I may be wrong though...
We definetely need to know mandrav system specs ;)
Open Source all the way, baby ;)
OSRPG
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hmm, it might also be due changes in between. Some function calls have moved. The reason for not including everything (there had been even more in the patch, which is already part of Irrlicht now) was that I wanted to check the correct typing of the variables and a thorough cleanup to simplify the window creation.
But this patch is also on my list for addition to the core, so it should be in 1.3.
kornerr
Posts: 245
Joined: Thu Jul 06, 2006 9:57 am
Location: Russia, Siberia, Kemerovo
Contact:

Post by kornerr »

Then please please please make it work out of the box :D
Open Source all the way, baby ;)
OSRPG
AndyCR
Posts: 110
Joined: Tue Nov 08, 2005 2:51 pm
Location: Colorado, USA
Contact:

Post by AndyCR »

Indeed. That would be great! In the meantime, I plan to attempt to patch this into the version of Irrlicht it was written for, then port it up to 1.2. No garantees, but I need it as well for a level editor I am writing.
stef_
Posts: 53
Joined: Tue Apr 18, 2006 9:39 pm
Contact:

Post by stef_ »

I'm interested in using irrlicht(1.2) inside a gtk application (with debian/linux).

I know irrlicht & gtk "quite" well and I have used the method described by mandrav
and it works perfectly (tested with EDT_SOFTWARE, EDT_SOFTWARE2 and
EDT_OPENGL).

I have only changed the SIrrlichtCreationParameters a bit more, because by now
I want to take it easy, without any cast:

Code: Select all

struct SIrrlichtCreationParameters {
                ...
                s32 WindowId;
                void *display;
                long int xid;
                ...
}
And so I have modified mandrav patch to CIrrDeviceLinux.cpp accordingly.

Then in my gtk application I do:

Code: Select all

drawing_area = gtk_drawing_area_new();
...
params.display = GDK_WINDOW_XDISPLAY(drawing_area->window);
params.xid = GDK_WINDOW_XWINDOW (drawing_area->window);
...
device = createDeviceEx(params);
Have fun,
bye
kornerr
Posts: 245
Joined: Thu Jul 06, 2006 9:57 am
Location: Russia, Siberia, Kemerovo
Contact:

Post by kornerr »

Can you please show workable demo?
I *don't* believe it's that easy.
Give us an example app and modified irrlicht files. You can even post it all here, in the topic.
I hope to hear from you soon, thanks.

AND this is for all who want to prove they succeeded in it: PROVIDE US WITH APPLICATION SOURCES AND MODIFIED IRRLICHT FILES!

I'm really bothered with ppl who can only *claim* they did it, but can't say *how* they did it.
Open Source all the way, baby ;)
OSRPG
Eternl Knight
Posts: 313
Joined: Tue Nov 01, 2005 5:01 am

Post by Eternl Knight »

No offense, kornerr - but there is no requirement for people to provide you with source and/or modified Irrlicht files. If they do do it - that's great. If not, well, that's life. Remember that under the open source license used by Irrlicht, nobody is compelled to release code they don't want to (a Good Thing in my opinion).

This is from a member that would love to see a working wxWindows integration (that is, myself). wxWindows (or wxWidgets as I believe it is now called) is my favourite cross-platform GUI library and when I get around to making a more user-friendly editor - I hope to utilise code that enables me to embed the engine inside a wxWindows environment.

--EK
stef_
Posts: 53
Joined: Tue Apr 18, 2006 9:39 pm
Contact:

Post by stef_ »

@kornerr

The smallest (but incomplete) working patch It's something
like this (I have followed mandrav patch):

Code: Select all

diff -u SIrrCreationParameters.h.orig SIrrCreationParameters.h
@@ -24,6 +24,8 @@
                        HighPrecisionFPU = false;
                        EventReceiver = 0;
                        WindowId = 0;
+                       display = NULL;
+                       xid = 0;
                        SDK_version_do_not_use = IRRLICHT_SDK_VERSION;
                }

@@ -126,6 +128,8 @@
                However, there is no need to draw the picture this often. Just do it how you like.
                */
                s32 WindowId;
+                void *display;
+                long int xid;

                //! Don't use or change this parameter.
                /** Always set it to IRRLICHT_SDK_VERSION, which is done by default.
==============================================
diff -u CIrrDeviceLinux.cpp.orig CIrrDeviceLinux.cpp
@@ -19,6 +19,10 @@
 #include "CColorConverter.h"
 #include "SIrrCreationParameters.h"

+static Display *my_display;
+static long int my_xid;
+static bool isUserSuppliedWindow = false;
+
 namespace irr
 {
        namespace video
@@ -78,6 +82,9 @@
        if (driverType != video::EDT_NULL)
        {
                // create the window, only if we do not use the null device
+               display = my_display;
+               window = my_xid;
+               isUserSuppliedWindow = display && window;
                if (!createWindow(windowSize, bits))
                        return;
        }
@@ -166,8 +173,8 @@
        os::Printer::log("Creating X window...", ELL_INFORMATION);
        XSetErrorHandler(IrrPrintXError);
 #endif
-
-       display = XOpenDisplay(0);
+       if (!isUserSuppliedWindow)
+               display = XOpenDisplay(0);
        if (!display)
        {
                os::Printer::log("Error: Need running XServer to start Irrlicht Engine.", ELL_ERROR);
@@ -473,7 +480,7 @@
        // create color map
        Colormap colormap;
        colormap = XCreateColormap(display,
-                           RootWindow(display, visual->screen),
+                           isUserSuppliedWindow ? window : RootWindow(display, visual->screen),
                            visual->visual, AllocNone);

        attributes.colormap = colormap;
@@ -501,7 +508,7 @@
                XGrabPointer(display, window, True, ButtonPressMask,
                        GrabModeAsync, GrabModeAsync, window, None, CurrentTime);
        }
-       else
+       else if (!isUserSuppliedWindow)
        {
                // we want windowed mode
                attributes.event_mask |= ExposureMask;
@@ -655,6 +662,9 @@
                        switch (event.type)
                        {
                        case ConfigureNotify:
+                               if(event.xconfigure.display != display || event.xconfigure.window != window)
+                                       break;
+
                                // check for changed window size
                                if ((event.xconfigure.width != Width) ||
                                        (event.xconfigure.height != Height))
@@ -1114,6 +1124,9 @@

 IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& param)
 {
+       my_display = (Display *)param.display;
+       my_xid = param.xid;
+
        CIrrDeviceLinux* dev = new CIrrDeviceLinux(
                param.DriverType,
                param.WindowSize,
==============================================
I have only modified SIrrCreationParameters.h and CIrrDeviceLinux.cpp,
nothing else.

For the gtk application is exactly what I have already posted.

BTW: Mouse works instead I have problems with keyboard...
When I move arrow keys I change the selection of gtk buttons instead
of moving irrlicht camera (?).

Bye
kornerr
Posts: 245
Joined: Thu Jul 06, 2006 9:57 am
Location: Russia, Siberia, Kemerovo
Contact:

Post by kornerr »

Thanks. The only thing left are the demo application sources, so that everyone can test it out of the box.
Open Source all the way, baby ;)
OSRPG
Eternl Knight
Posts: 313
Joined: Tue Nov 01, 2005 5:01 am

Post by Eternl Knight »

Well, feel free to contribute then, Kornerr. All I am seeing here is your whinging that someone won't put in extra effort for your benefit.

--EK
Post Reply