Fill a Panel of a winform with Ogre3D content

mattm

14-05-2007 12:28:39

Hi!
I'm trying to display the content of an Ogre3Ds window in a winform panel.
I have this fonction which usually open a render window:
AppOgre1.mRenderWindow = AppOgre1.mRoot.Initialise(false, "Test1");
The first argument, when set FALSE doesn't display the window. I think this is OK....
I've put it in the Panels fonction in the winform.
But what do i have to do to make her fill the content of my Panel??....
thanx!!

GermanDZ

14-05-2007 19:13:02

You need to do this:

AppOgre1.mRenderWindow = AppOgre1.mRoot.Initialise(thePanel);

You must be some experienced on C# for work with it.

This will work fine, but you will have troubles with events, be sure that the panel is active. So, you must do the initialization after the form is loaded. I recomends to use a separated Thread (for your 3D logic) from logic for the form. But.... you will need to use "invoke" for events or any kind of updates to Form where is called from 3D Objects.


How I learn that 5 days ago? Read code of Ogre (c++), interfaces declared on SWIG, OgreDotnet (C#) and Direct3DInput (W32API).


Dont play with fire if you aren't a fireman o have a Asbesto's Gloves!!!

mattm

15-05-2007 07:50:07

hi!
Thanx for the answer! yes i'm a newbie with C# :P ...
so i don't know if i will carry on with it.
I've tried with the piece of code you gave me. Where should I put it? I've tried like this, but it doesn't work:
namespace TestWinForm
{
public partial class Form1 : Form
{
AppOgre AppOgre1;


public Form1()
{
InitializeComponent();
}

private void panel1_Paint(object sender, PaintEventArgs e)
{

AppOgre1 = new AppOgre();
AppOgre1.mRenderWindow = AppOgre1.mRoot.Initialise(panel1_Paint);
}
}
}

mattm

15-05-2007 08:29:46

ok I've just taken the DemoWinform from the OgreDotNet CVS and it works...
So no problem at all!

GermanDZ

16-05-2007 04:15:08

good for you...

The problem with your code is that Panel_paint is not a good place to put Initialization code!