Skip to main content
gamedev.net
🔒 Locked

Tools Programming C++ Wrapper in C#

Started by WBlacklidge 1 reply 600+ views
Original Post
WBlacklidge
WBlacklidge
Hello, I am new to these forums and I did a search looking for this topic, and I found similar topics but nothing that addressed what I wanted to accomplish. I am currently working to put together a series of tools. One of which is a Particle System. The Direct3D wrapper that I am using is C++. I want to shove the c++ wrapper into a DLL and use it in a windows forms c# application. My question is that, is this possible? Is this the best way to go about creating my tools? I traditionally have done all of my tools in MFC and C# forms are much easier to put together and produce better results. Thanks a lot!
circlesoft
circlesoft
Quote:
Original post by WBlacklidge
I want to shove the c++ wrapper into a DLL and use it in a windows forms c# application. My question is that, is this possible?


Yep - what you are looking for is called the pinvoke mechanism - it allows you to call native code from unmanaged code. There are lots and lots of resources out there on it, so just search for it. (Brief Intro)

Quote:
Is this the best way to go about creating my tools? I traditionally have done all of my tools in MFC and C# forms are much easier to put together and produce better results.

I'm sure this is up for debate, but I see it as pretty convienient. Of course, you are always going to have to juggle maintaining the managed->native links vs just converting it to C#. I guess it depends on how complicated your interfaces are and how much of them you have to expose.
WBlacklidge
WBlacklidge
Thanks a lot! I am going to look into it. I am going to use the tutorials to create my dll and then I have to figure out how to get a real time loop, something like the OnTimer() call in MFC. I hear that I am going to have to look into using the Timer class in C#. I just need to be able to loop as if it were a main game loop or something. I have only started working with C# in the last 2 weeks so I am still pretty unfamiliar with it. Thanks for the advice!

Topic Locked

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

Sign in to reply to this topic.