Using Python-Ogre as a glue layer


11-09-2007 02:38:27

I am writing my game engine in C++, but I am developing an entire extensibility layer using Python. Of course I will be exposing my own classes, but I would like to expose OGRE and CEGUI to the Python layer as well, so I can code as much non-speed critical logic in Python as possible. If I wanted to use Python-Ogre as my glue between my app and OGRE + CEGUI, would I need to statically compile Python-Ogre in to my app, or could I use the dynamic module provided in the SDK's? Specifically I need to be able to return OGRE and CEGUI objects from my classes, defined in my app and exposed using Boost.Python, and have Python know that the returned object be translated correctly to the Python-Ogre layer so it can be used from Python. For instance, I have a class that may return a const reference to a SceneManager object. This would be exposed through Boost.Python to return an internal reference.

Has anyone used Python-Ogre for this purposes? Do I need to statically compile Python-Ogre in to my app, or can I use the dynamic modules?


11-09-2007 07:56:39

I did something like that, by including the needed Ogre class in my Py++ script with something like that:

I don't know if this method is available on a namespace though...


11-09-2007 20:45:22

I am not using Py++ to generate my wrapper, so that may not work for me. What exactly does that switch do in Py++? Does it generate any special Boost.Python code in my wrapper?


12-09-2007 01:55:47

Perhaps you could turn things around -- simply take your C++ code and make it into a python module (you can use Py++ to wrap it which even makes that part easy)

This way you can take full advantage of all the current (and future) Python-Ogre functionality, pass objects around as much as you want, and your only need to add functions to your C++ module as you identify performance issues..



13-09-2007 15:42:46

To be quite honest, I could never get Py++ to work (or more specifically I could never get GCC-XML to parse my code), so I am hand wrapping my engine. It's really not that bad.

I may move things more to a Python centric view, but I am not sure if I like the loose design caused by that. We will have to see.


14-09-2007 13:41:10

If you send me your header files I'd be happy to take a look and see if a wrapper can be automatically created.