Kerion
03-05-2007 21:23:12
I am starting work on the all important world editor for my game system, and I am running in to some issues embedding MOGRE via a custom control.
Basically I have a UserControl called OgreView. Right now it's an extremely simple control, but the meat is as such:
Pretty simple stuff. OGRE has been initialized elsewhere (the OgreManager singleton) like so:
The OgreManager initialize is called first, then when my MainForm (which embeds an OgreView control) does it's load event, I call InitializeView() on the OgreView.
No errors are thrown, but when I call Root.RenderOneFrame on a timer, nothing renders. The control should, in theory, turn black as soon as RenderOneFrame is called, but it never renders. No errors are written to the OGRE log (or mango.log in this case).
The timer callback looks like:
Is there anything particular that I am missing?
Oh, also, on the Resize and Move events of the OgreView, I am calling RenderWindow.WindowMovedOrResized(), so I am handle those events correctly (as far as I know them).
Do I need to invalidate the control or something to force it to paint?
UPDATE:
Tried invalidating the control with
No dice.
Basically I have a UserControl called OgreView. Right now it's an extremely simple control, but the meat is as such:
public void InitializeView() {
if (Singleton.HasRef<OgreManager> ()) {
Root root = Singleton.Ref<OgreManager> ().Root;
SceneManager mgr = Singleton.Ref<OgreManager> ().SceneManager;
NameValuePairList nvp = new NameValuePairList ();
nvp["parentWindowHandle"] = this.Handle.ToString ();
m_Window = root.CreateRenderWindow (GetOgreViewName (), (uint)this.ClientSize.Width, (uint)this.ClientSize.Height, false, nvp);
m_Camera = mgr.CreateCamera (GetOgreViewName () + "Camera");
m_Camera.AutoAspectRatio = true;
m_Window.AddViewport (m_Camera);
m_Camera.SetPosition (0.0f, 200.0f, -400.0f);
IncOgreViewCount ();
}
}
Pretty simple stuff. OGRE has been initialized elsewhere (the OgreManager singleton) like so:
public void Initialize() {
m_Root = new Root ("", "", "mango.log");
m_Root.LoadPlugin ("RenderSystem_Direct3D9");
m_Root.LoadPlugin ("RenderSystem_GL");
m_Root.LoadPlugin ("Plugin_ParticleFX");
RenderSystem rs = m_Root.GetRenderSystemByName ("Direct3D9 Rendering Subsystem");
m_Root.RenderSystem = rs;
rs.SetConfigOption ("Full Screen", "No");
rs.SetConfigOption ("Video Mode", "800 x 600 @ 32-bit colour");
m_SceneMgr = m_Root.CreateSceneManager (SceneType.ST_GENERIC);
m_Root.Initialise (false);
}
The OgreManager initialize is called first, then when my MainForm (which embeds an OgreView control) does it's load event, I call InitializeView() on the OgreView.
No errors are thrown, but when I call Root.RenderOneFrame on a timer, nothing renders. The control should, in theory, turn black as soon as RenderOneFrame is called, but it never renders. No errors are written to the OGRE log (or mango.log in this case).
The timer callback looks like:
private void timer1_Tick (object sender, EventArgs e) {
this.Invoke (
new MethodInvoker(delegate {
Singleton.Ref<OgreManager> ().Root.RenderOneFrame ();
})
);
}
Is there anything particular that I am missing?
Oh, also, on the Resize and Move events of the OgreView, I am calling RenderWindow.WindowMovedOrResized(), so I am handle those events correctly (as far as I know them).
Do I need to invalidate the control or something to force it to paint?
UPDATE:
Tried invalidating the control with
ogreView1.Invoke (
new MethodInvoker (delegate {
ogreView1.Invalidate ();
})
);
No dice.