Irrlicht and C#

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
gjstockham
Posts: 2
Joined: Sun May 09, 2004 7:57 pm

Irrlicht and C#

Post by gjstockham »

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
Phreak

Post by Phreak »

I would find it interesting. Im mostly Visual Basic 6/.NET and C++, but I do use C# alot. So anything like that would be helpful...

Phreak
IrateJoe
Posts: 1
Joined: Wed May 12, 2004 12:42 pm
Location: Bristol, UK
Contact:

Post by IrateJoe »

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??
gjstockham
Posts: 2
Joined: Sun May 09, 2004 7:57 pm

Post by gjstockham »

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??
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.

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();
			}
		}
	}
}

niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Wow, nice. Looking forward to see your wrapper :)
Post Reply