[VB.NET] Irrlicht Device in a MDI Child

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
harukiblue
Posts: 49
Joined: Sun Dec 10, 2006 6:23 pm

[VB.NET] Irrlicht Device in a MDI Child

Post by harukiblue »

Hello all, I have a dificult one. how do I open an Irrlicht device inside of a Child window of a MDI application?I called this from a child form of a MDI application.

Code: Select all

Dim Device As New Irrlicht.IrrlichtDevice(
Irrlicht.Video.DriverType.DIRECT3D9, 'driver
New Irrlicht.Core.Dimension2D(800, 600), 'dimension
32, 'Bit depth
False, 'fullscreen
False, 'stencil buffer
False, 'vsync
True,  'antiAlias
Me.Handle() ' window handle
)
This is all the code of the child form.

Code: Select all

Public Class frmModeler
    Dim Device As New Irrlicht.IrrlichtDevice(Irrlicht.Video.DriverType.DIRECT3D9, New Irrlicht.Core.Dimension2D(800, 600), 32, False, False, False, True, Me.Handle())
    Private Sub frmModeler_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim Node As Irrlicht.Scene.ISceneNode
        '(SceneNode,Rotation Speed,MoveSpeed,Id)
        device.SceneManager.AddCameraSceneNodeFPS(Node, 1, 1, 2)

    End Sub
    Public Sub Render()
        '(BackBuffer, ZBuffer, Color)
        Device.VideoDriver.BeginScene(True, True, New Irrlicht.Video.Color(255, 150, 100, 150))
        Device.SceneManager.DrawAll()
        Device.GUIEnvironment.DrawAll()
        Device.VideoDriver.EndScene()
    End Sub

    Private Sub frmModeler_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        While (Device.Run())
            Render()
        End While
    End Sub
End Class
this code compiles as long as I have the LIB in the debug folder,and the DLL referenced. It does not actually open an irrlicht device inside the child window. If I use a different version of the overloaded constructor it does open an irrlicht device, but it is not a child of the MDI application.

Code: Select all

Dim device As New Irrlicht.IrrlichtDevice(Irrlicht.Video.DriverType.DIRECT3D9)
This is all the code of the child form.

Code: Select all

Public Class frmModeler
Dim device As New Irrlicht.IrrlichtDevice(Irrlicht.Video.DriverType.DIRECT3D9)
    Private Sub frmModeler_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim Node As Irrlicht.Scene.ISceneNode
        '(SceneNode,Rotation Speed,MoveSpeed,Id)
        device.SceneManager.AddCameraSceneNodeFPS(Node, 1, 1, 2)

    End Sub
    Public Sub Render()
        '(BackBuffer, ZBuffer, Color)
        Device.VideoDriver.BeginScene(True, True, New Irrlicht.Video.Color(255, 150, 100, 150))
        Device.SceneManager.DrawAll()
        Device.GUIEnvironment.DrawAll()
        Device.VideoDriver.EndScene()
    End Sub

    Private Sub frmModeler_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        While (Device.Run())
            Render()
        End While
    End Sub
End Class
My question is, how do I open an Irrlicht device inside of a Child window of a MDI application?
harukiblue
Posts: 49
Joined: Sun Dec 10, 2006 6:23 pm

anybody?

Post by harukiblue »

I have been working on this and still can not figure it out. Any one have any ideas about this?
harukiblue
Posts: 49
Joined: Sun Dec 10, 2006 6:23 pm

Further information

Post by harukiblue »

I am going to do some furthor investigation into the actual source. Where no noob has gone before ...
Last edited by harukiblue on Sun May 27, 2007 3:41 pm, edited 1 time in total.
harukiblue
Posts: 49
Joined: Sun Dec 10, 2006 6:23 pm

Further information

Post by harukiblue »

I did some further searching in hopes for some answers. I am still at a lost but this is what I came across. the following is a snipit from the .NET source where the irrlicht device prototype is implemented.

Code: Select all

IrrlichtDevice::IrrlichtDevice(Video::DriverType driverType, Core::Dimension2D windowSize, 
			int bits, bool fullScreen, bool stencilBuffer, bool vsync, bool antiAlias,
			System::IntPtr windowHandle)
: Device(0), ManagedVideoDriver(0), ManagedSceneManager(0), ManagedCursorControl(0)
{
	irr::SIrrlichtCreationParameters p;
	CreatedDriverType = (irr::video::E_DRIVER_TYPE)driverType;

	p.AntiAlias = antiAlias;
	p.Bits = bits;
	p.DriverType = CreatedDriverType;
	p.Fullscreen = fullScreen;
	p.Stencilbuffer = stencilBuffer;
	p.Vsync = vsync;
	p.WindowId = reinterpret_cast<irr::s32>((void*)windowHandle);
	p.WindowSize = irr::NativeConverter::getNativeDim(windowSize);

	Device = irr::createDeviceEx(p);
	createManagedStuff();
}
The following line is supposed to actually create the device, and probrally where the problem occurs. I cant find where this function is in the source code.

Code: Select all

Device = irr::createDeviceEx(p);
The following line converts the System::IntPtr window handel to a irr::s32 32 bit single.

Code: Select all

p.WindowId = reinterpret_cast<irr::s32>((void*)windowHandle);
harukiblue
Posts: 49
Joined: Sun Dec 10, 2006 6:23 pm

HELP

Post by harukiblue »

If I can't get Irrlicht to run inside a child form of a MDI application in VB.NET, I may have to start over in a different language. Maby C#, but more likely C++.

I am starting to thinking that Irrlicht and VB.NET is a hopeless combination. I doubt C# would be any different. I really just needed something fast. But I guess starting over in C++ is faster then waiting for a solution to arise in VB.NET. I really would like to hear some opinions about this, or in the odd chance I am not alone in this quest, some advice. Please guys, this would really save me a good bit of time.
Post Reply