How to use Wxpython with c++ Ogre? .....[SOLVED]


27-04-2007 14:14:44

Ok, I wanted to make an gui editor for my game. C# was the most desirable option but I didnt wanted to use .net version of ogre since I want to run my c++ game engine within the edtior.

WxWidgets is the 2nd best has lost of stuff but creating an gui editor in c++ requires a lot of time and effort. I already know wxpython which is very time savy.

So how can I use wxPython with my existing game. Im not interested in Ogre specific bindings at all. Can I do this without building PythonOgre? Any shortest way?


27-04-2007 15:11:57

If you want to access you C++ game engine in Python (or event C#) you must wrap you code so it can be used from that language. Your best bet is wrapping your own code with Py++ as we have done with Ogre.


27-04-2007 16:33:22

Actually my answer wasnt about binding.

Ok Im using python 2.4 and wxpython which is using wxWidgets (dlls).

So im downloading the 2.6.3 wxwidgets c++ sdk. Assuming they both use same dlls/lib vesrions. Im hoping that I can pass the wxFrame ref/pointer from wxpython to c++ to intialize wxOgre c++ class (the wiki one).

Will it work ?

binding the game engine is another issue which i think i can solve.


27-04-2007 18:19:23

Ogre doesn't need a wxWidgets pointer to anything to initialize properly. If you take a close look at the wxOgre C++ code an the Python-Ogre wxPython + Python-Ogre example you will see that all Ogre needs is the handle (as a string) of the window you want to place it in. To get this in wxPython its this simple: handle = str(myWxWindow.GetHandle())
Then when you create the Ogre render window, make sure you pass it a "externalWindowHandle" parameter mapped to the string you got above from wxPython.

Note: The behaviour is a little more complex in Linux and it won't work in Mac.


27-04-2007 19:25:56

:shock: oh, It means that I dont even have to deal with c++ wxwidgets library than you have solved my 80% problems. thanks, I will try it out.... 8)


29-04-2007 10:42:48

I created an ogre app with the wizard, and made it into a shared lib plus some python bindings. Im actually able to pass the window handle to c++.
class MyFrame(wx.Frame):
......, 640, 480)

The problem is that it only works with Main Window/Frame. If I send panel.GetHandle() the app crashes with unknown exception. How can I use a panel for my Ogre window instead of main frame to divide the space for other tools like property grid.

heres the panel, which crashes
panel = wx.Panel(self, size=wx.Size(640,480), pos=wx.Point(100,100)), 640, 480)


29-04-2007 15:02:03

Ahh Its solved. The crasing was because OIS only accepts the Top Level WindowHandle.