AccessViolation when trying to wrap Hydrax using Mogre SDK


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:
var hydrax = new MHydrax(mSceneMgr, mCamera, mWindow.GetViewport(0));
hydrax.Module = new ProjectedGrid(
new Perlin(), // Noise module
new Plane(Vector3.UNIT_Y, Vector3.ZERO), // Base plane
NormalMode.VERTEX, // Normal mode
new ProjectedGridOptions() // Projected grid options

This code snippet is copied from the Hydrax demo code:
mHydrax = new Hydrax::Hydrax(mSceneMgr, mCamera, mWindow->getViewport(0));
Module = new Hydrax::Module::ProjectedGrid(
new Hydrax::Noise::Perlin(/*Generic one*/),
Ogre::Plane(Ogre::Vector3(0,1,0), Ogre::Vector3(0,0,0)),
Hydrax::Module::ProjectedGrid::Options(/*264 /*Generic one*/));

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?


01-02-2011 20:44:52

mstoyke? GantZ? anyone...?


02-02-2011 11:54:20

which mogre dll do you use ? the vc9 or the vc10 one ? while doing the migration to 1.7 version, the hardware buffer manager cause trouble in the wrapping process, and there is mogre versions that have problem with it. But it have been corrected in the last versions. Otherwise, try to compare your code with the MHydrax one, since raygee have upload a working version for 1.7. If you can't find a solution, post your wrapper code, so someone could look into it.


03-02-2011 22:56:14

Thanks for the tips GantZ. Good to know about the buffer manager I'll keep an eye on that from now on.

Now that I've managed to compile Ogre I just compiled MHydrax against my fresh Mogre binaries and they run. I got half of the Hydrax demo working - sea and sky to the horizon! :-)

I noticed that with the compiled mogre boost isn't included. Perhaps that was the problem all along, or perhaps not. I think I will try later to compile Mogre with boost and see if my MHydrax wrapper still works.

I'm going to continue for now with my compiled version of Mogre and when I'm done I'll check to see that the new wrapper works against the Mogre SDK.


04-02-2011 07:40:49

good note about boost, I tried to modify SkyX but was having the same kind of problem, will try without boost