Comments on current SVN version


28-04-2007 13:03:41


I was using python-ogre module some 2 months ago. Now I tried
the latest version (built it myself).

After the statement:

from _ogre_ import *

I get a warning:

Scripting\Ogre\ RuntimeWarning: to-Python converter for struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > already registered; second conversion method ignored.

Should I pay attention to it?

And one more thing. I am missing Ogre StringConverter
class. In previous versions it was there, but now it is not!
I considered it quite handy.


28-04-2007 13:54:44

I get this too.

Also, I'm trying to create a new framework step by step for a new project but am running into an undefinable c++ exception, which isn't particularly helpful. Is there any way of catching this exception and actually having a look at what it is?

code and error:

self.renderWindow = self.root.initialise(True, "OGRE Render Window")
RuntimeError: unidentifiable C++ exception


28-04-2007 14:18:37

Yes there is, start your app in a similar way to this:

if __name__=='__main__':
app = myOgreApplication()
except ogre.OgreException, e:
print '## EXCEPTION ##'
print str(e)

you should be able to see any ogre exceptions that are thrown now.


28-04-2007 15:49:33

The warnings about multiple imports are going to remain for a while (just not a high priority to fix them) and they can be suppressed with Python's warning module (if you need to use Python-Ogre in a commerical environment as some have already)..

The Ogre Stringconverter was (and is) a pain to wrap as it has lots of ugly overloads, and considering that in all the demos I've been able to replace all calls to StringConverter with Python's 'str' it didn't seem like a class that I should spend much time on :)

As for the exception error I'd suggest looking at and taking note of the order that things are done as Ogre is sensitive to this..



30-04-2007 03:25:39

Ok, I didn't want to do a code dump as I thought I could work this out, but I'm just stumped, and can't really go anywhere with this project until I clear this up. I'm sure it's something really basic that I'm missing...

I'm following as a guideline on what to set up when, but I just can't work out what's going wrong, especially considering I can't seem to get any information out of this damn unidentifiable c++ exception...

Anyway, this is my code so far, note it's WIP, and I'm trying to build and test more or less line by line, so a lot of things aren't final yet.


import ogre.renderer.OGRE as ogre
import sys

class Viewer:
def __init__(self):
self.root = None
self.sceneManager = None
self.renderWindow = None
self.cameras = []
self.viewports = []

def setUp(self):

self.root = ogre.Root("../configs/plugins.cfg")

#set up resources
config = ogre.ConfigFile()
seci = config.getSectionIterator()
while seci.hasMoreElements():
SectionName = seci.peekNextKey()
Section = seci.getNext()
for item in Section:
addResourceLocation(item.value, item.key, SectionName)

# configure
carryOn = self.root.showConfigDialog()
if not carryOn:

try: ############## DIES HERE ##################
self.renderWindow = self.root.initialise(True, "OGRE Render Window")
except Exception, e: ###note ogre.OgreException doesn't catch anything
print '## EXCEPTION ##'
print str(e) ###prints "unidentifiable C++ exception"

self.sceneManager = self.root.createSceneManager(ogre.ST_GENERIC,"ExampleSMInstance") = PlayerCam(self.sceneManager, "player1")
self.viewport = PlayerViewport(self.renderWindow,


class PlayerViewport:
def __init__(self, renderWindow, camera):
self.viewport = renderWindow.addViewport(camera.getRealCamera())
self.viewport.BackgroundColour = ogre.ColourValue(0.0,1.0,1.0)

class PlayerCam:
def __init__(self, sceneManager, name): = name = sceneManager.createCamera(name)

# temp, 0, 500)), 0, -300)) = 5


#Testing code
v = Viewer()
print "done"

I had a quick look around and it seems there's a way of registering certain types of c++ exceptions and translating them into python ones, but without having a clue what I'm looking for (or really even how to do it), this seems like a rather difficult proposition... any ideas anyone?


30-04-2007 07:17:04

Do your demos work? And is the plugins.cfg and resources.cfg the same as those in the standard demos?

I ask as I tested your code on my machine (only with the GL driver) and didn't have any problems (apart from fixing a bug in the PlayerViewport class)...



30-04-2007 09:37:43

Yeah, the demos all work fine.

I'm pretty sure plugins.cfg is good, as without it set up right the config dialogue doesn't even display DirectX or OpenGL as options, so you can't get past that stage even.

resources.... maybe that's it. I tried to cut down on what was on the list, but maybe I took out something that was required. Will beef up my media folder, change the config and see what happens...

[UPDATE]: nope, still get the same error, even with an identical media folder/resources.cfg to the ogre section of the demos. just tried running it outside of the eclipse environment and still get the same problem, so it's not that either.

I really wish I could see what that c++ exception actually was saying. What kind of exceptions does root.initialise() normally throw?

Oh, and incidentally, what was the other small bug you mentioned?


30-04-2007 16:38:52

Guessing it was

self.viewport.BackgroundColour = ogre.ColourValue(0.0,1.0,1.0)

which won't do what you want. BackgroundColour doesn't exist, its backgroundColour or using a set function



self.viewport.backgroundColour = ogre.ColourValue(0.0,1.0,1.0)


01-05-2007 00:25:27

ok, got it to work, tried a few different .cfg files until it started working.

Don't really like the whole hit and miss style of programming though...


01-05-2007 00:49:54

Stuff doesn't happen randomly, maybe you can post both a working and non working cfg files and we can see why works and the other doesn't.


01-05-2007 07:46:00

sorry, yeah, that probably would have been the clever thing to do. I'm afraid I seem to have come home last night slightly drunk, debugged my app and destroyed the original error creating code, so no longer have anything to compare it to.

But suffice to say, it all seems to be working now! Guess you just need to be persistent in these cases... :?