so well, here you go:
1. load your windows forms project in VC++
2. create a panel where you want to draw irrlicht in. you can also draw irrlicht in the main panel (which is what i do) but it does not work if you create irrlicht on application start. you have to wait until the main window is created and the n use irrlicht with it. but this is not a problem since i do not load irrlicht on application startup, but when "File/New File..." is clicked.
3. for irrlicht you have to specify a HWND to draw in, which you dont have in windows.forms. so you must take a certain object where you want to draw irrlicht in and take its handle, like this:
Code: Select all
irr::SIrrlichtCreationParameters param;
param.WindowId = (s32)yourobject->Handle.ToPointer();
// for the main window this would be:
//param.WindowId = (s32)this->Handle.ToPointer();
4. then continiue loading irrlicht like in the win32 tutorial. here is an example of how to load it:
Code: Select all
// put this somewhere in the class
IrrlichtDevice* RenderDevice;
IVideoDriver* VideoDriver;
ISceneManager* SceneManager;
bool RenderingEnabled;
//put this somewhere in your class, too:
private: void initIrrlicht()
{
if(!RenderDevice)
{
irr::SIrrlichtCreationParameters param;
param.WindowId = (s32)this->Handle.ToPointer();
param.DriverType = video::EDT_OPENGL;
RenderDevice = createDeviceEx(param);
SceneManager = RenderDevice->getSceneManager();
VideoDriver = RenderDevice->getVideoDriver();
RenderingEnabled = true;
while (RenderDevice->run())
{
if(RenderingEnabled == true)
{
VideoDriver->beginScene(true, true, SColor(255, 255, 0, 0));
SceneManager->drawAll();
VideoDriver->endScene();
}
Sleep(1);
}
RenderDevice->closeDevice();
RenderDevice->drop();
}
}
i put a "Sleep(1);" in the while loop because then the editor takes only 1% cpu usage, which is good because you dont want an editor to run on 50% cpu usage all the time.
now make a button for example with the label "Start Irrlicht" and make it load "initIrrlicht();"
last note: when you do an editor its better for you to create a few classes because if you put everything in one .H file it will get messy pretty soon.
hope that helped you
![Smile :)](./images/smilies/icon_smile.gif)