Skip to main content
GameDev.net gamedev.net
🔒 Locked

Managed Wrapper

Started by Talyrond Oct 10, 2006 at 2:41 PM 0 replies 500+ views
Original Post
Talyrond
Talyrond
Hi, I am testing a managed wrapper for native C++ code, so I can access the assembly from C#. The C++ code will be creating the data for my Model in the form of an array of CustomVertex.PositionNormalColored. So in my C# assembly I will create the array and pass to the wrapper, that in turn will populate with data so: C# code:
Wrapper wrapper = new Wrapper();

int arraySize = wrapper.GetArraySize();

CustomVertex.PositionNormalColored[] verts = new CustomVertex.PositionNormalColored[arraySize];
       
wrapper.CreateVertices(verts);
This is the Wrapper Code, (this works, I have a CLI version running):
void CreateVertices (array<Microsoft::DirectX::Direct3D::CustomVertex::PositionNormalColored>^ verts);
In my native code I have the function so:
public: void CreateVertices (Microsoft::DirectX::Direct3D::CustomVertex::PositionNormalColored* verts);
I cannot get the code to even compile, this is the error: cannot convert parameter 1 from 'cli::array ^' to 'Microsoft::DirectX::Direct3D::CustomVertex::PositionNormalColored *' But I think I have a bigger problem, because at of the day the native code will need to know about the PositionNormalColored data structure, which it can’t because it does not exist in the unmanaged world. Am I right about this? I think that a wrapper will not work, unless I am passing intrinsic types to the native code. My C++ is limited, so any help would be gratefully appreciated Julian

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.