Sign in to follow this  
DoRsal

C++ to C# and vertexbuffer problem

Recommended Posts

I have developed a lib in C++ for a Particle System. I now need to use this particle system code in C# so I have created a DLL in c++ and a wrapper class in C# that uses the DLL. It works great for setting up a particle system with affectors and emitters etc. The problem is that I need to get the particle data into C# as well and this is not so easy. I belive some new design of the particle system for handeling the particle data should be good but I dont know how. Currently the particle data is stored in a list: list<Particle*> m_particles; and the Particle class have a bunch of variables like position, rotation, velocity etc. The update part of the particle system is quite fast but the rendering part is very slow since i just wrote some fast code to render it in DirectX9 by creating a quad that i transform and render for each particle using DrawPrimitiveUP(...) just to get the result. So what I want to do now is to create a vertexbuffer for the particle data and be able to send it over to C# through the DLL. My questions are: 1. How do I make a vertexbuffer in a good way for handeling particles and how do I update it? 2. How do I transfer the vertexbuffer data to C#? Some clarification on the DLL part: The c++ DLL looks something like:
extern "C"
{
	int PS_DECLSPEC test()
	{
		return 43;
	}
}
the C# code looks something like this:
class PSWrapper
{
    [DllImport("LasrodDLL.dll")]
    public static extern int test();
}
I need way to make a function that returns the data(probably the vertexbuffer) so that I can render the particles in C#.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this