How to use Wxpython with c++ Ogre? .....[SOLVED]
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?
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.
Actually my answer wasnt about binding.
Ok Im using python 2.4 and wxpython which is using wxWidgets 188.8.131.52 (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.
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.
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....
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++.
The problem is that it only works with Main Window/Frame.
testOgre.run(str(self.GetHandle()), 640, 480)
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))
testOgre.run(str(panel.GetHandle()), 640, 480)
Ahh Its solved. The crasing was because OIS only accepts the Top Level WindowHandle.