Linking ogre (C++) code from mogre (C#)?


07-06-2007 00:15:45

Has anyone tried to write some code in C# and link to C++ code?

In C#, i create a scene, control the camera, then want to call a C++ function to (for example) add overlay text.

As a simple example, i want to add overlay text from C++. I set things up in C# - everything works fine, then from C++ call:

// get the overlay manager
OverlayManager& overlayMgr = OverlayManager::getSingleton();

// Create a panel
Ogre::OverlayContainer* panel = static_cast<OverlayContainer*>(
overlayMgr.createOverlayElement("Panel", "PanelName"));

In ogre.log I get:

15:56:08: OGRE EXCEPTION(5:ItemIdentityException): Cannot locate factory for element type in OverlayManager::createOverlayElement at ..\src\OgreOverlayManager.cpp (line 568)

When I catch the exception from C#, OgreException.IsThrown is not true.

Any thoughts? My guess is that the C++ and C# aren't talking to the same ogre runtime (memory etc).

Has anyone tried this before? any pointers?