Google

Fill a Panel of a winform with Ogre3D content

Discussion regarding OgreDotNet, located in CVS at ogreaddons/ogredotnet

Moderators: OGRE Team, OgreDotNet Moderators

Fill a Panel of a winform with Ogre3D content

Postby mattm » Mon May 14, 2007 12:28 pm

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:
Code: Select all
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!!
mattm
Gnoblar
 
Posts: 13
Kudos: 0
Joined: 14 May 2007

Postby GermanDZ » Mon May 14, 2007 7:13 pm

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!!!
GermanDZ
Halfling
 
Posts: 49
Kudos: 0
Joined: 10 May 2007

Postby mattm » Tue May 15, 2007 7:50 am

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
Gnoblar
 
Posts: 13
Kudos: 0
Joined: 14 May 2007

Postby mattm » Tue May 15, 2007 8:29 am

ok I've just taken the DemoWinform from the OgreDotNet CVS and it works...
So no problem at all!
mattm
Gnoblar
 
Posts: 13
Kudos: 0
Joined: 14 May 2007

Postby GermanDZ » Wed May 16, 2007 4:15 am

good for you...

The problem with your code is that Panel_paint is not a good place to put Initialization code!
GermanDZ
Halfling
 
Posts: 49
Kudos: 0
Joined: 10 May 2007


Return to OgreDotNet

Who is online

Users browsing this forum: No registered users and 0 guests