amirabiri
31-01-2011 12:06:54
Hi again, my saga of learning how to wrap unmanaged code continues and I'm actually quite happy with my progress but now I've hit a brick wall.
I've managed to wrap all the basic necessary Hydrax code for the following C# snippet to compile:
This code snippet is copied from the Hydrax demo code:
I've checked and double checked and all the right calls are made, in other words the c# code produces the exact same C++ calls under the hood.
The problem I'm getting is in mHydrax->create(), it causes an access violation error in Mesh.cpp line 211 (of Hydrax) actually inside Ogre in HardwareBufferManager::createVertexBuffer() (OgreHardwareBufferManager.h line 399).
To test the problem I compiled the Hydrax demo code (pure C++) in two project configurations: one use s the Ogre SDK for headers, static lib and dlls, and the other one almost identical but using the Ogre headers, static lib and dlls from the Mogre SDK.
The results are that the exact same line is reached in Hydrax (Mesh.cpp line 211) with the exact same parameters, and when linked against the Ogre SDK it works perfectly and I can see the Hydrax demo and when I link against the mogre SDK I get an access violation.
Does this ring a bell to anyone? Is there something obvious here that I've missed? Can anyone maybe point me in the right direction?
I've managed to wrap all the basic necessary Hydrax code for the following C# snippet to compile:
var hydrax = new MHydrax(mSceneMgr, mCamera, mWindow.GetViewport(0));
hydrax.Module = new ProjectedGrid(
hydrax,
new Perlin(), // Noise module
new Plane(Vector3.UNIT_Y, Vector3.ZERO), // Base plane
NormalMode.VERTEX, // Normal mode
new ProjectedGridOptions() // Projected grid options
);
hydrax.LoadCfg("HydraxDemo.hdx");
hydrax.Create();
This code snippet is copied from the Hydrax demo code:
mHydrax = new Hydrax::Hydrax(mSceneMgr, mCamera, mWindow->getViewport(0));
Module = new Hydrax::Module::ProjectedGrid(
mHydrax,
new Hydrax::Noise::Perlin(/*Generic one*/),
Ogre::Plane(Ogre::Vector3(0,1,0), Ogre::Vector3(0,0,0)),
Hydrax::MaterialManager::NM_VERTEX,
Hydrax::Module::ProjectedGrid::Options(/*264 /*Generic one*/));
mHydrax->setModule(static_cast<Hydrax::Module::Module*>(mModule));
mHydrax->loadCfg("HydraxDemo.hdx");
mHydrax->create();
I've checked and double checked and all the right calls are made, in other words the c# code produces the exact same C++ calls under the hood.
The problem I'm getting is in mHydrax->create(), it causes an access violation error in Mesh.cpp line 211 (of Hydrax) actually inside Ogre in HardwareBufferManager::createVertexBuffer() (OgreHardwareBufferManager.h line 399).
To test the problem I compiled the Hydrax demo code (pure C++) in two project configurations: one use s the Ogre SDK for headers, static lib and dlls, and the other one almost identical but using the Ogre headers, static lib and dlls from the Mogre SDK.
The results are that the exact same line is reached in Hydrax (Mesh.cpp line 211) with the exact same parameters, and when linked against the Ogre SDK it works perfectly and I can see the Hydrax demo and when I link against the mogre SDK I get an access violation.
Does this ring a bell to anyone? Is there something obvious here that I've missed? Can anyone maybe point me in the right direction?