27-09-2006 12:58:00

I'm trying to load some data into an Image object. However, I get this:

>>> from pyogre import ogre
>>> s = file("_haven.ico").read()
>>> type(s)
<type 'str'>
>>> im = ogre.Image()
>>> im.loadRawData(s, 32, 32, ogre.PF_A8R8G8B8)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "c:\python24\lib\site-packages\pyogre\", line 7053, in loadRawData

return _ogre.Image_loadRawData(*args)
NotImplementedError: No matching function for overloaded 'Image_loadRawData'

I would have thought that the typemap that converts a Python string to a DataStreamPtr would have handled this.

Am I missing something?


27-09-2006 19:51:06

Did you compile pyogre with Multi-threaded DLL (/MD)?

Just ran one of the original tests to load an icon with pyogre and Ogre1.2.3 and it seems OK. I'll double check with 1.2.0 if it's still a problem.

from pyogre import ogre

#icon saved in RAW format
f = file("test.raw",'rb').read()
assert len(f) == 48*48*3
im = ogre.Image()
im.loadRawData(f, 48, 48, ogre.PF_BYTE_RGB)
print "Image Size is",im.getSize()

# and if testing in _createScene add the following to save the image"output.jpg")


27-09-2006 19:54:02

Actually, I'm just using the pre-built binaries at the moment.


29-09-2006 06:55:05

Ok I've been able to reproduce why it works for me and not with the prebuilt binaries. I've been swigging on Windows with the -O optimisation option:

swig -O -python -c++ .....

From swig documentation:

- Add the -O option to enable all the optimization options at once, initially equivalent to:

-modern -fastdispatch -dirvtable -nosafecstrings -fvirtual

The fastdispatch option is the one:

-fastdispatch option
enables the "fast dispatch" mechanism for overloaded methods. The resulting code is smaller and faster since less type checking is performed. However, the error messages you get when the overloading is not resolved could be different from what the traditional method returns. With the old method you always get an error such as:

"No matching function for overloaded ..."
with the new method you can also get errors such as
"Type error in argument 1 of type ..."

I suppose you could use something like this:

%feature("fastdispatch") Ogre::Image::loadRawData;

I'll take a look at this.


29-09-2006 20:00:38

Thanks for checking into it -- much appreciated.


30-09-2006 14:16:12

Sorry the only way I've been able to reproduce the above on windows/linux is swigging without -O optimisation. This is set by default on the Windows vc80 project so I was wrong about that.

Strangely enough opening the vc80 project file with VC 2005 Express the Pre-Build event only shows "swig -O" for the Release Py24 target even though opening the file file in WordPad shows it's there for the Py23 targets.

Perhaps you should Istari's comments on the pre-built binaries or try building yourself.


30-09-2006 15:52:12

Thanks, I may try that.

For now, I have a work-around (I write the image out to a file, and it from there).