I just discovered Irrlicht a couple of days ago and decided to have a play around with it . However, I'm really a C# programmer, so I've just spent a few hours starting a managed C++ wrapper (enough to get half the "Hello World" app working in C# using it). I've got a couple of questions though if anyone can help?
Is anyone already doing this? I don't want to spend lots of time on it if it'a already being worked on? A google search hasn't come up with anything.
Assuming no-one is already doing it, would anyone (other than me!) find it useful for me to share my progress?
Geoff
Irrlicht and C#
-
Phreak
-
gjstockham
- Posts: 2
- Joined: Sun May 09, 2004 7:57 pm
No, P/Invoke is good for functions in a dll, but can't wrap C++ classes. I'm writing a wrapper in managed C++ to the dll, which can be referenced from C# (or other .NET language. It's slow progress, as I'm not a good C++ programmer! So far I have enough functionality for the first couple of demos. I'll release some code when I get the demos working and see what performance I get.IrateJoe wrote:I would find it interesting as well. I am certainly more at home with c# than c++. Would it be possible to reference the irrlicht.dll direcly from c#, kind of like you would reference the windows API??
For example, the first demo looks like this:
Code: Select all
using System;
using Irrlicht;
using Irrlicht.Core;
using Irrlicht.Scene;
using Irrlicht.Video;
using Irrlicht.Gui;
namespace HelloWorld
{
class Class1
{
static void Main(string[] args)
{
IrrlichtDevice device = IrrlichtDevice.CreateDevice
(DriverType.EDT_SOFTWARE,
new System.Drawing.Size(640, 480),
16,
false,
false,
0);
device.SetWindowCaption("Hello World! - Irrlicht Engine C# Demo");
VideoDriver driver = device.VideoDriver;
SceneManager smgr = device.SceneManager;
GuiEnvironment guienv = device.GuiEnvironment;
guienv.AddStaticText("Hello World! This is the Irrlicht Software engine!",
new Rect32(10,10,200,30),
true);
AnimatedMesh mesh = smgr.GetMesh("../../irrlicht-0.6/media/sydney.md2");
AnimatedMeshSceneNode node = smgr.AddAnimatedMeshSceneNode( mesh );
if (node != null)
{
node.SetMaterialFlag(MaterialFlags.EMF_LIGHTING, false);
node.SetFrameLoop(0, 310);
node.SetMaterialTexture( 0, driver.GetTexture("../../irrlicht-0.6/media/sydney.bmp") );
}
smgr.AddCameraSceneNode(null, new Vector3df(0,10,-40), new Vector3df(0,0,0));
while(device.Run())
{
driver.BeginScene(true, true, System.Drawing.Color.FromArgb(0,100,100,100));
smgr.DrawAll();
guienv.DrawAll();
driver.EndScene();
}
}
}
}