Irrlicht in a WinForm!
-
- Posts: 101
- Joined: Wed Feb 15, 2006 4:22 pm
- Location: RO
Irrlicht in a WinForm!
How do I integrate Irrlicht in a WinForm Apllication like a control not a separat windows!
blog :] http://redcloud.no-ip.info/
-
- Posts: 30
- Joined: Wed Mar 15, 2006 7:42 pm
- Location: http://cube3.helpmy.net
Platform 3D Engine using Irrlicht.NET
http://cube3.helpmy.net
http://cube3.helpmy.net
-
- Posts: 101
- Joined: Wed Feb 15, 2006 4:22 pm
- Location: RO
No not working! VS Studio 2005 C# 2.0! Irrlicht 1.0!
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Irrlicht;
using Irrlicht.Video;
using Irrlicht.Core;
using Irrlicht.Scene;
namespace Program
{
public partial class FormProgram : Form
{
IrrlichtDevice device;
ITexture texLogo;
System.Threading.Thread irrThread;
public FormProgram()
{
InitializeComponent();
}
private void FormProgram_Load(object sender, EventArgs e)
{
device = new IrrlichtDevice(DriverType.OPENGL,
new Dimension2D(pictureBox1.Width, pictureBox.Height), 16,
false, false, false, true, pictureBox.Handle);
irrThread = new System.Threading.Thread(new System.Threading.ThreadStart(IrrlichtInit));
irrThread.Start();
}
private void FormProgram_FormClosing(object sender, FormClosingEventArgs e)
{
if (irrThread != null)
irrThread.Abort();
if (device != null)
device.CloseDevice();
}
private void IrrlichtInit()
{
IVideoDriver driver = device.VideoDriver;
ITexture tex = device.VideoDriver.GetTexture(@"C:\irrlicht-1.0\engine\Data\color.tga");
while (device.Run())
{
device.VideoDriver.BeginScene(true, true, new Irrlicht.Video.Color(128, 128, 0, 255));
driver.Draw2DImage(tex, new Position2D(10, 10));
device.SceneManager.DrawAll();
device.VideoDriver.EndScene();
}
}
}
}
blog :] http://redcloud.no-ip.info/
-
- Posts: 30
- Joined: Wed Mar 15, 2006 7:42 pm
- Location: http://cube3.helpmy.net
You are initializing the device on a different thread than the render loop. There are issues with that, OPENGL will then show a black screen. Try DirectX8 or 9 and it should work, or choose to run the control + irrlicht on the same thread.
Platform 3D Engine using Irrlicht.NET
http://cube3.helpmy.net
http://cube3.helpmy.net
-
- Posts: 101
- Joined: Wed Feb 15, 2006 4:22 pm
- Location: RO
Code: Select all
private void IrrlichtInit()
{
device = new IrrlichtDevice(DriverType.DIRECT3D9,
new Dimension2D(pictureBox1.Width, pictureBox.Height), 16,
false, false, false, true, pictureBox.Handle);
driver = device.VideoDriver;
tex = device.VideoDriver.GetTexture(@"C:\irrlicht-1.0\engine\Data\color.tga");
while (device.Run())
{
device.VideoDriver.BeginScene(true, true, new Irrlicht.Video.Color(128, 128, 0, 255));
// driver.Draw2DImage(tex, new Position2D(10, 10));
// device.SceneManager.DrawAll();
device.VideoDriver.EndScene();
}
}
ERROR Window:
Cross-thread operation not valid: Control 'pictureBox' accessed from a thread other than the thread it was created on."
blog :] http://redcloud.no-ip.info/
-
- Posts: 30
- Joined: Wed Mar 15, 2006 7:42 pm
- Location: http://cube3.helpmy.net
In the constructor of your form after
Use
Code: Select all
InitializeComponent();
Code: Select all
CheckForIllegalCrossThreadCalls = false;
Platform 3D Engine using Irrlicht.NET
http://cube3.helpmy.net
http://cube3.helpmy.net
-
- Posts: 101
- Joined: Wed Feb 15, 2006 4:22 pm
- Location: RO
It's seems to be working even with OpenGL! BIG TKS!
Code: Select all
private void IrrlichtInit()
{
device = new IrrlichtDevice(DriverType.OPENGL,
new Dimension2D(pictureBox1.Width, pictureBox.Height), 16,
false, false, false, true, pictureBox.Handle);
driver = device.VideoDriver;
tex = device.VideoDriver.GetTexture(@"C:\irrlicht-1.0\engine\Data\color.tga");
while (device.Run())
{
device.VideoDriver.BeginScene(true, true, new Irrlicht.Video.Color(128, 128, 0, 255));
driver.Draw2DImage(tex, new Position2D(10, 10));
device.SceneManager.DrawAll();
device.VideoDriver.EndScene();
}
}
blog :] http://redcloud.no-ip.info/
-
- Posts: 101
- Joined: Wed Feb 15, 2006 4:22 pm
- Location: RO
It is possible to use addCameraSceneNodeMaya() or addCameraSceneNodeFPS() in a WinForm? (If yes how?)
Code: Select all
cam = device.SceneManager.AddCameraSceneNodeMaya(null, -250, 100, 100, -1);
blog :] http://redcloud.no-ip.info/
Sure, they work as intended, but they do take over your control device. If you want to use a Window dialog or such with it, then you'd have to set the ActiveCamera's HasControl (sorry, don't have the exact method right now as my dev PC is not fully functional right now) property to false. Then when you leave the dialog you can set it back to true.chromdragon wrote:It is possible to use addCameraSceneNodeMaya() or addCameraSceneNodeFPS() in a WinForm? (If yes how?)
Code: Select all
cam = device.SceneManager.AddCameraSceneNodeMaya(null, -250, 100, 100, -1);
-
- Posts: 101
- Joined: Wed Feb 15, 2006 4:22 pm
- Location: RO
Here is the online documentation. I can't find anything in the ICameraSceneNode class.
Irrlicht Doc: http://irrlicht.sourceforge.net/docu/index.html
Irrlicht .Net Doc: http://irrlicht.sourceforge.net/docu.net/index.html
Irrlicht Doc: http://irrlicht.sourceforge.net/docu/index.html
Irrlicht .Net Doc: http://irrlicht.sourceforge.net/docu.net/index.html
blog :] http://redcloud.no-ip.info/
-
- Posts: 101
- Joined: Wed Feb 15, 2006 4:22 pm
- Location: RO
-
- Posts: 101
- Joined: Wed Feb 15, 2006 4:22 pm
- Location: RO