Problems with wxWidgets and Irrlicht

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
hindupower
Posts: 15
Joined: Thu Sep 27, 2007 7:49 pm

Problems with wxWidgets and Irrlicht

Post by hindupower »

Hi,

I'm working on a program that uses wxWidgets and I'm trying to port it to linux. I implemented the the "easy way" which uses a wxGlCanvas as explained in http://irrlicht.sourceforge.net/forum/v ... hp?t=39719 because I don't know how to map XID to SIrrlichtCreationParameters nor do I know how to make a new XWindow as a child of my wxWidget program which are talked about in the correct way.

After running my program with the easy implementation, I see the wxWidget window I expect with the irrlicht scene in it, but I also see two problems.
1. Another window is created with it and its just blank because its buffer is being swapped into the wxGlCanvas. (If this window can be hidden, then that would be a good start albeit not the best)
2. The gui enivornment text is not being shown and same with the 2DRectangles i draw using the driver. (If I don't use a gl context and swap buffers to show the Irrlicht scene in the wxGlCanvas, I see the scene in the other window WITH the guienv text and the 2D rectangles drawn.)

I think the other window is created because of XCreateWindow() in CIrrDeviceLinux.cpp line 629, because windowid is null when GDK_WINDOW_XDISPLAY() is used to get the XID. I think this is the case because I read somewhere that the GtkWindow stored in a wxWidget usually doesn't have its XWindow id stored. I have no clue about the text/rectangles not rendering, but I think this warning I get when I run the program might have to do with it : "Gdk-WARNING **: /build/buildd/gtk+2.0-2.24.4/gdk/x11/gdkdrawable-x11.c:952 drawable is not a pixmap or window"

Any help on figuring this out would be much appreciated. Also if anyone has the code for the correct way from cheshirekow's post at http://irrlicht.sourceforge.net/forum/v ... hp?t=39719, that would most likely be very helpful because I think this "easy way" is the culprit to my problems.
hindupower
Posts: 15
Joined: Thu Sep 27, 2007 7:49 pm

Re: Problems with wxWidgets and Irrlicht

Post by hindupower »

FINALLY, found out how to easily setup up irrlicht with wxWidgets in linux.

I checked in the wxWidgets forum to see if anyone had found out how to do this and I luckily found out how to get the XID/Window from a GtKWindow thanks to this useful post from the wxWidgets forum: http://forums.wxwidgets.org/viewtopic.php?f=1&t=29850.

It seems that gtk_widget_realize( GtkWidget* ) has to be called first before calling GDK_WINDOW_XWINDOW() to get the window, otherwise you will just get a 0/NULL.
It also seems that calling that before calling GDK_WINDOW_XDISPLAY() for getting the display, doesn't seg fault anymore.

Now when I run this irrlicht gets a good window id and so renders to it perfectly. I also tried it with just a plain wxWindow, but irrlicht could not find the opengl and so nothing gets displayed. So a wxGlCanvas has to still be used, but there is no more need for a context and swapping of buffers because now we can just let Irrlicht take care of everything. Also no more warnings!

If someone can try this on their computers and see if this is actually working well, that would be great.
Post Reply