How put two RenderWindow in a windows form?

arturo02

09-03-2009 11:30:48

Hi everyone,

Im trying to put two RenderWindow in a windows form,I'm trying with this code but it don't work public partial class OgreForm : Form
{
Root mRoot;
RenderWindow mWindow;
RenderWindow mWindow2;

public OgreForm()
{
InitializeComponent();
this.Size = new Size(1600, 600);
Disposed += new EventHandler(OgreForm_Disposed);
Resize += new EventHandler(OgreForm_Resize);
}

void OgreForm_Disposed(object sender, EventArgs e)
{
mRoot.Dispose();
mRoot = null;
}

void OgreForm_Resize(object sender, EventArgs e)
{
mWindow.WindowMovedOrResized();
mWindow2.WindowMovedOrResized();
}


public void Go()
{
Show();
while (mRoot != null && mRoot.RenderOneFrame())
Application.DoEvents();

}

public void Init()
{
// Create root object
mRoot = new Root();

// Define Resources
ConfigFile cf = new ConfigFile();
cf.Load("resources.cfg", "\t:=", true);
ConfigFile.SectionIterator seci = cf.GetSectionIterator();
String secName, typeName, archName;

while (seci.MoveNext())
{
secName = seci.CurrentKey;
ConfigFile.SettingsMultiMap settings = seci.Current;
foreach (KeyValuePair<string, string> pair in settings)
{
typeName = pair.Key;
archName = pair.Value;
ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
}
}

// Setup RenderSystem
RenderSystem rs = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
// or use "OpenGL Rendering Subsystem"
mRoot.RenderSystem = rs;
rs.SetConfigOption("Full Screen", "No");
rs.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");

// Create Render Window
mRoot.Initialise(false, "Main Ogre Window");
NameValuePairList misc = new NameValuePairList();
misc["externalWindowHandle"] = Handle.ToString();
mWindow = mRoot.CreateRenderWindow("Right RenderWindow", 800, 600, false, misc);
mWindow2 = mRoot.CreateRenderWindow("Left RenderWindow", 800, 600, false, misc);



Ithink that the problems is that the two windows are in the same place, but I don't know how to move this in the windows form

thank you

Chulein

09-03-2009 13:53:19

Hey.

You need to add a splitcontainer and add panels, and then use each of the panels Handels to create the new renderwindow.


implement this function.

protected virtual void CreateRenderWindow(IntPtr handle,string name,out RenderWindow win)
{
mRoot.Initialise(false, name);
if (handle != IntPtr.Zero)
{
NameValuePairList misc = new NameValuePairList();
misc["externalWindowHandle"] = handle.ToString();
misc["Anti aliasing"] = "Level 4";
misc["border"] = "fixed";

win = mRoot.CreateRenderWindow(name, 1280, 800, false, misc);

}
else
{
win = mRoot.CreateRenderWindow(name, 1280, 800, false);
}
}


from there you only need to setup the panels for where the renderwindows is to be set. and call the function like this.


CreateRenderWindow(Form.splitContainer1.Panel1.Handle, "panel1", out mWindow);
CreateRenderWindow(Form.splitContainer1.Panel2.Handle, "panel2", out mWindow2);
//etc



Chulein.